lusa 5 жил өмнө
parent
commit
09d90ca3ea
100 өөрчлөгдсөн 36283 нэмэгдсэн , 5460 устгасан
  1. 14 36
      app/Makefile
  2. 0 24
      app/bmc.sh
  3. 407 0
      app/bmc/Api.c
  4. 29 0
      app/bmc/Api.h
  5. 136 0
      app/bmc/BmcType.h
  6. 162 0
      app/bmc/ChassisTimer/ChassisTimerTask.c
  7. 14 0
      app/bmc/ChassisTimer/ChassisTimerTask.h
  8. 127 0
      app/bmc/Makefile
  9. 111 0
      app/bmc/OemFRU.c
  10. 1292 0
      app/bmc/Session.c
  11. 251 0
      app/bmc/Session.h
  12. 73 0
      app/bmc/SysTimer/TimerTask.c
  13. 6 0
      app/bmc/SysTimer/TimerTask.h
  14. BIN
      app/bmc/bmc_app
  15. BIN
      app/bmc/bmc_app.gdb
  16. 91 0
      app/bmc/encryption/AuthCode.c
  17. 15 0
      app/bmc/encryption/AuthCode.h
  18. 14 12
      app/bmc/encryption/MD.h
  19. 93 0
      app/bmc/encryption/MD2.c
  20. 70 0
      app/bmc/encryption/MD5.c
  21. 41 18
      app/bmc/encryption/MD5_128.c
  22. 23 24
      app/bmc/encryption/MD5_128.h
  23. 88 0
      app/bmc/encryption/md2.h
  24. 171 0
      app/bmc/encryption/md2_dgst.c
  25. 59 0
      app/bmc/encryption/md5.h
  26. 311 0
      app/bmc/encryption/md5c.c
  27. 270 0
      app/bmc/encryption/sha1.c
  28. 73 0
      app/bmc/encryption/sha1.h
  29. 824 0
      app/bmc/encryption/sha2.c
  30. 108 0
      app/bmc/encryption/sha2.h
  31. 427 0
      app/bmc/ipmb/IPMBIfc.c
  32. 7 0
      app/bmc/ipmb/IPMBIfc.h
  33. 0 0
      app/bmc/lan/Ciphertable.h
  34. 726 0
      app/bmc/lan/LANIfc.c
  35. 24 18
      app/bmc/lan/LANIfc.h
  36. 1224 0
      app/bmc/lan/RMCP+.c
  37. 14 14
      app/bmc/lan/RMCP+.h
  38. 1381 0
      app/bmc/lan/RMCP.c
  39. 103 0
      app/bmc/lan/RMCP.h
  40. 306 0
      app/bmc/libipmi_struct.h
  41. 126 0
      app/bmc/main.c
  42. 106 0
      app/bmc/main.h
  43. 133 0
      app/bmc/message.c
  44. 30 0
      app/bmc/message.h
  45. 27 48
      app/bmc/msghndlr/App/App.c
  46. 19 0
      app/bmc/msghndlr/App/App.h
  47. 14 14
      app/bmc/msghndlr/App/AppDevice+.h
  48. 95 0
      app/bmc/msghndlr/App/AppDevice.h
  49. 3768 4386
      app/bmc/msghndlr/App/AppDevice/AppDevice.c
  50. 417 0
      app/bmc/msghndlr/App/AppDevice/WDT.c
  51. 304 0
      app/bmc/msghndlr/App/IPMDevice/Firewall.c
  52. 53 0
      app/bmc/msghndlr/App/IPMDevice/Firewall.h
  53. 222 0
      app/bmc/msghndlr/App/IPMDevice/IPMDevice.c
  54. 13 13
      app/bmc/msghndlr/App/IPMDevice/IPMDevice.h
  55. 14 15
      app/bmc/msghndlr/App/WDT.h
  56. 73 0
      app/bmc/msghndlr/Bridge/Bridge.c
  57. 20 0
      app/bmc/msghndlr/Bridge/Bridge.h
  58. 51 0
      app/bmc/msghndlr/Chassis/Chassis.c
  59. 18 0
      app/bmc/msghndlr/Chassis/Chassis.h
  60. 1119 0
      app/bmc/msghndlr/Chassis/ChassisDevice.c
  61. 14 14
      app/bmc/msghndlr/Chassis/ChassisDevice.h
  62. 337 0
      app/bmc/msghndlr/MsgHndlr.h
  63. 743 0
      app/bmc/msghndlr/MsgHndlrTask.c
  64. 10 0
      app/bmc/msghndlr/MsgHndlrTask.h
  65. 1711 0
      app/bmc/msghndlr/OemSMMCmds/OemSMMCmds.c
  66. 541 0
      app/bmc/msghndlr/OemSMMCmds/OemSMMCmds.h
  67. 383 0
      app/bmc/msghndlr/PDKCmds.c
  68. 60 50
      app/bmc/msghndlr/PDKCmds.h
  69. 20 0
      app/bmc/msghndlr/PICMG/PICMG.h
  70. 63 0
      app/bmc/msghndlr/PICMG/PICMGDevice.c
  71. 874 0
      app/bmc/msghndlr/PMConfig.h
  72. 37 36
      app/bmc/msghndlr/SensorEvent/Sensor.h
  73. 2114 0
      app/bmc/msghndlr/SensorEvent/SensorDevice/Sensor.c
  74. 1031 0
      app/bmc/msghndlr/SensorEvent/SensorDevice/SensorMonitor.c
  75. 75 0
      app/bmc/msghndlr/SensorEvent/SensorEvent.c
  76. 132 0
      app/bmc/msghndlr/SensorEvent/SensorEvent.h
  77. 329 0
      app/bmc/msghndlr/SensorEvent/SensorMonitor.h
  78. 201 0
      app/bmc/msghndlr/Storage/FRUDevice/FRU.c
  79. 6 20
      app/bmc/msghndlr/Storage/FRUDevice/FRU.h
  80. 24 24
      app/bmc/msghndlr/Storage/SDR.h
  81. 1811 0
      app/bmc/msghndlr/Storage/SDRDevice/SDR.c
  82. 3 4
      app/bmc/msghndlr/Storage/SDRFunc.h
  83. 33 37
      app/bmc/msghndlr/Storage/SDRRecord.h
  84. 20 20
      app/bmc/msghndlr/Storage/SEL.h
  85. 2 2
      app/bmc/msghndlr/Storage/SELAPI.h
  86. 981 0
      app/bmc/msghndlr/Storage/SELDevice/SEL.c
  87. 172 0
      app/bmc/msghndlr/Storage/SELRecord.h
  88. 77 0
      app/bmc/msghndlr/Storage/Storage.c
  89. 18 0
      app/bmc/msghndlr/Storage/Storage.h
  90. 702 0
      app/bmc/msghndlr/Support.h
  91. 366 0
      app/bmc/msghndlr/Transport/Badpasswd.c
  92. 63 0
      app/bmc/msghndlr/Transport/DeviceConfig.c
  93. 3166 0
      app/bmc/msghndlr/Transport/LANConfig.c
  94. 619 0
      app/bmc/msghndlr/Transport/SOLConfig.c
  95. 1314 0
      app/bmc/msghndlr/Transport/SerialModem.c
  96. 901 631
      app/bmc/msghndlr/cmdselect.c
  97. 57 0
      app/bmc/msghndlr/cmdselect.h
  98. 7 0
      app/bmc/readme.txt
  99. 426 0
      app/bmc/sensor_driver.c
  100. 1133 0
      app/bmc/sensor_sdr.c

+ 14 - 36
app/Makefile

@@ -1,38 +1,16 @@
-all	: 
-	make -C ./test_app
-	make -C ./goahead-5.1.0
-#	apps modules test_apps
-clean	: clean_apps clean_modules clean_test_apps
+all	:
+	# make drivers
+	make -C ./driver/Platform
+	make -C ./driver/GPIO
+	make -C ./driver/FMC
+	make -C ./driver/ADC
+	make -C ./driver/I2C 
+	make -C ./driver/SPI
 	
-apps	: 
-	#make -C ./web
-	#make -C ./bmc_server
-
-#CFLAGS 	:= -Os -mcpu=cortex-m3 -mthumb
-#LDFLAGS	:= -mcpu=cortex-m3 -mthumb -L$(INSTALL_ROOT)/A2F/root/usr/lib
-#CC	= $(CROSS_COMPILE_APPS)gcc
-
-#SRC = stm32f429.c
-
-#CFLAGS	+= -I$(INSTALL_ROOT)/A2F/root/usr/include
-#CFLAGS	+= ./
-
-#OBJS = $(SRC:%.c=%.o)
-
-modules	:  
-#	make -C ./driver/FMC
-#	make -C ./driver/test
-#	make -C ./driver/Platform
-#	make -C ./driver/I2C
-
-test_apps:
+	# make apps
+	make -C ./bmc
+	make -C ./goahead-5.1.0
 	make -C ./test_app
-
-clean_apps:
-	rm -rf ./bmc_server/*.o
-
-clean_modules:
-	rm -rf ./driver/*.o
-
-clean_test_apps:
-	rm -rf ./test_app/*.o
+	#make -C ./ipmitool-1.8.18
+clean	: 
+	rm -rf *.o

+ 0 - 24
app/bmc.sh

@@ -1,24 +0,0 @@
-#!/bin/sh
-
-#install module
-insmod /usr/bin/test_module.ko
-#insmod /usr/bin/gpio.ko 
-insmod /usr/bin/i2c.ko 
-insmod /usr/bin/fmc.ko
-insmod /usr/bin/platform_STM32F429.ko
-
-#create node
-mknod /dev/test_module c 99 0
-#mknod /dev/gpio c 100 0 
-mknod /dev/platform c 100 0
-mknod /dev/i2c1 c 101 0 
-mknod /dev/i2c2 c 101 1 
-mknod /dev/i2c3 c 101 2
-mknod /dev/fmc_cpld c 102 0
-#mknod /dev/spi2 c 153 32
-#ifconfig eth0 192.168.0.15
-#run bmc_main in background
-#./usr/bin/bmc_main &	
-
-
-

+ 407 - 0
app/bmc/Api.c

@@ -0,0 +1,407 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "main.h"
+#include "Api.h"
+#include "SDRRecord.h"
+#include "SELRecord.h"
+#include "SEL.h"
+#include "MsgHndlr.h"
+
+
+int InitSdrConfig(void)
+{
+	printf("Init SDR Config...\r\n");
+	g_BMCInfo.SDRConfig.SDRError	=	0;
+	g_BMCInfo.SDRConfig.UpdatingSDR	=	FALSE;
+	g_BMCInfo.SDRConfig.UpdatingChannel	=	0;
+	g_BMCInfo.SDRConfig.TrackPOffset	=	0;
+	g_BMCInfo.SDRConfig.TrackRecID		=	0;
+	g_BMCInfo.SDRConfig.ReservationID	=	0;
+	g_BMCInfo.SDRConfig.IPMB_Seqnum		=	0;
+	g_BMCInfo.SDRConfig.PartAddbytes	=	0;
+	g_BMCInfo.SDRConfig.LatestRecordID	=	0;
+	g_BMCInfo.SDRConfig.NumMarkedRecords	=	0;
+	g_BMCInfo.SDRConfig.SDRRAM			=	(SDRRepository_T*)g_BMCInfo.pSDR;
+	
+	g_BMCInfo.SDRConfig.RepositoryInfo.Version	=	0x51;
+	g_BMCInfo.SDRConfig.RepositoryInfo.RecCt	=	((SDRRepository_T*)g_BMCInfo.SDRConfig.SDRRAM)->NumRecords;
+	g_BMCInfo.SDRConfig.RepositoryInfo.FreeSpace	=	0xffff;
+	g_BMCInfo.SDRConfig.RepositoryInfo.AddTimeStamp	=	0;
+	g_BMCInfo.SDRConfig.RepositoryInfo.EraseTimeStamp	=	0;
+	g_BMCInfo.SDRConfig.RepositoryInfo.OpSupport	=	0x23;
+	
+	//TODO:
+	g_BMCInfo.SDRConfig.RepositoryAllocInfo.NumAllocUnits	=	0;
+	g_BMCInfo.SDRConfig.RepositoryAllocInfo.AllocUnitSize	=	0;
+	g_BMCInfo.SDRConfig.RepositoryAllocInfo.NumFreeAllocUnits	=	0;
+	g_BMCInfo.SDRConfig.RepositoryAllocInfo.LargestFreeBlock	=	0;
+	g_BMCInfo.SDRConfig.RepositoryAllocInfo.MaxRecSize	=	0;
+
+	return 0;
+}
+
+int InitSelConfig(void)
+{
+	printf("InitSelConfig...\n");
+	g_BMCInfo.SELConfig.SelReservationID = 0;;
+    g_BMCInfo.SELConfig.LastEvtTS		=	0;
+    g_BMCInfo.SELConfig.PartialAddRecordID	=	0;
+    g_BMCInfo.SELConfig.PartialAddRecOffset	=	0;
+    g_BMCInfo.SELConfig.PartialAdd		=	0;
+    g_BMCInfo.SELConfig.SenMonSELFlag	=	0;
+    g_BMCInfo.SELConfig.MaxSELRecord	=	MAX_SEL_RECORD;
+//    g_BMCInfo.SELConfig.RsrvIDCancelled	=	FALSE;
+    g_BMCInfo.SELConfig.SELOverFlow		=	FALSE;
+    g_BMCInfo.SELConfig.selalmostfull	=	0;
+
+	
+//	SELEventRecord_T  SelPartialAddRecord;
+//    g_BMCInfo.SELConfig.SELEventMsg [16];
+	return 0;
+    
+}
+
+int PlatformInit(void)
+{
+	uint8_t PrimaryIPMBBusNum, SecondaryIPMBBusNum;
+	printf("Init Platform...\r\n");
+
+	//hardware init
+	GPIO_InitTypeDef GPIO_InitStruct;
+	GPIO_InitStruct.Pin = GA0_PIN | GA1_PIN | GA2_PIN | GA3_PIN | GA4_PIN | RACKID2_PIN;
+	GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+	GPIO_InitStruct.Pull = GPIO_NOPULL;
+	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+	stm32_gpio_init(GPIOH, &GPIO_InitStruct);
+
+	GPIO_InitStruct.Pin = GAP_PIN | RACKID1_PIN | RACKID3_PIN | RACKID4_PIN | RACKID5_PIN;
+	stm32_gpio_init(GPIOI, &GPIO_InitStruct);
+
+
+
+
+	g_BMCInfo.SelfTestByte 	=	0;
+	g_BMCInfo.SlotID		=	PDK_GetSlotID();
+	g_BMCInfo.ChassisID		=	PDK_GetChassisID();
+
+	g_BMCInfo.ChassisIdentify		=	FALSE;
+	
+	//init DevGUID
+	g_BMCInfo.DeviceGUID[0]	=	0x01;
+	g_BMCInfo.DeviceGUID[1]	=	0x01;
+	g_BMCInfo.DeviceGUID[2]	=	0x01;
+	g_BMCInfo.DeviceGUID[3]	=	0x01;
+	g_BMCInfo.DeviceGUID[4]	=	0x01;
+	g_BMCInfo.DeviceGUID[5]	=	0x01;
+	g_BMCInfo.DeviceGUID[6]	=	0x01;
+	g_BMCInfo.DeviceGUID[7]	=	0x01;
+	g_BMCInfo.DeviceGUID[8]	=	0x01;
+	g_BMCInfo.DeviceGUID[9]	=	0x01;
+	g_BMCInfo.DeviceGUID[10]	=	0x01;
+	g_BMCInfo.DeviceGUID[11]	=	0x01;
+	g_BMCInfo.DeviceGUID[12]	=	0x01;
+	g_BMCInfo.DeviceGUID[13]	=	0x01;
+	g_BMCInfo.DeviceGUID[14]	=	0x01;
+	g_BMCInfo.DeviceGUID[15]	=	0x01;
+	
+	g_BMCInfo.FwMajorVer		=	FW_VERSION_MAJOR;
+	g_BMCInfo.FwMinorVer		=	FW_VERSION_MINOR;
+	g_BMCInfo.SendMsgSeqNum				=	0;
+	
+	// g_BMCInfo.OemFlags.BladeWorkMode			=	BLADE_IPMC;
+	// g_BMCInfo.OemFlags.chassisManageFnEnable	=	0;
+	// g_BMCInfo.OemFlags.thisBladeIndex			=	0;
+	// g_BMCInfo.OemFlags.bladeStatus				=	1;	//0: not present, 1: normal, 2: error, others: reserved.
+	
+	g_BMCInfo.HealthLevel		=	SENSOR_STATUS_NORMAL;
+	g_BMCInfo.SensorSharedMem.SensorTick=	0;	
+	g_BMCInfo.SenConfig.PowerOnTick		=	0;
+	g_BMCInfo.SenConfig.SysResetTick	=	0;
+	g_BMCInfo.CurTimerTick				=	0;
+	g_BMCInfo.CurTimerSecond			=	0;
+	g_BMCInfo.BootValidMinutes			=	0;
+	
+	g_BMCInfo.pUserInfo					=	NULL;
+		
+	return 0;
+}
+
+int InitTimerTaskTbl(void)
+{
+	printf("InitTimerTaskTbl...\n");
+	g_BMCInfo.TimerTaskTblSize = 9;
+    memcpy(g_BMCInfo.TimerTaskTbl, m_TimerTaskTbl,sizeof(m_TimerTaskTbl));
+}
+
+int Init_SessionTbl(void)
+{
+	printf("Init_SessionTbl...\n");
+	g_BMCInfo.IpmiConfig.MaxSession				= 	10;
+	g_BMCInfo.IpmiConfig.SessionTimeOut			= 	10;	//10s
+	g_BMCInfo.IpmiConfig.SendMsgTimeout			=	10;	//10s
+	/*Allocating Memory to hold session Table informations */
+    g_BMCInfo.SessionTblInfo.SessionTbl = (SessionInfo_T *) malloc(sizeof(SessionInfo_T)*( g_BMCInfo.IpmiConfig.MaxSession + 1));
+    if(g_BMCInfo.SessionTblInfo.SessionTbl == NULL)
+    {
+        printf("Error in allocating memory for SessionTbl \n");
+        return 1;
+    }
+    /*Initialize the Session Table memory */
+    memset(g_BMCInfo.SessionTblInfo.SessionTbl,0,sizeof(SessionInfo_T)*(g_BMCInfo.IpmiConfig.MaxSession + 1));
+
+    /*Allocating Memory to hold UDS session Table informations */
+    g_BMCInfo.UDSSessionTblInfo.UDSSessionTbl = (UDSSessionTbl_T *) malloc(sizeof(UDSSessionTbl_T)*(g_BMCInfo.IpmiConfig.MaxSession + 1));
+    if(g_BMCInfo.UDSSessionTblInfo.UDSSessionTbl == NULL)
+    {
+        printf("Error in allocating memory for SessionTbl \n");
+        return 1;
+    }
+    /*Initialize the UDS Session Table memory */
+    memset(g_BMCInfo.UDSSessionTblInfo.UDSSessionTbl,0,sizeof(UDSSessionTbl_T)*(g_BMCInfo.IpmiConfig.MaxSession + 1));
+}
+
+const char FirstPowerOnStr[] = "First power on the bmc";
+int Init_IPMI_FRU_SDR_SEL(void)
+{
+	int i;
+	uint32_t	sdrSize =
+		sizeof(SDRRepository_T) + sizeof(HdrMgmtCtrlrDevLocator_T) + sizeof(HdrFullSensorRec_T)*SENSOR_NUMBERS;
+	uint32_t	selSize = sizeof(SELRepository_T) + sizeof(SELRec_T)*MAX_SEL_RECORD ;	
+	uint8_t*	pSDR = NULL;
+	uint8_t*	pSEL = NULL;
+	
+	
+	g_BMCInfo.pSDR = malloc(sdrSize);
+	if((g_BMCInfo.pSDR == NULL) && (sdrSize != 0))
+	{
+		printf("g_BMCInfo.pSDR Malloc failed!\r\n");
+	}
+	g_BMCInfo.pSEL = malloc(selSize);
+	if((g_BMCInfo.pSEL == NULL) && (selSize != 0))
+	{
+		printf("g_BMCInfo.pSEL Malloc failed!\r\n");
+	}
+	
+//	FLASH_GetIPMI(&g_BMCInfo.IpmiConfig);
+//	if(strncmp(g_BMCInfo.IpmiConfig.FirstPowerOnStr, FirstPowerOnStr, sizeof(FirstPowerOnStr)) != 0)
+	if(1)
+	{
+		//first power on
+		printf("BMC first power on!\r\n");
+		/************************** Init IPMI ******************************/
+		memcpy(g_BMCInfo.IpmiConfig.FirstPowerOnStr, FirstPowerOnStr, sizeof(FirstPowerOnStr));
+		
+		g_BMCInfo.IpmiConfig.SerialIfcSupport		=	SERIAL_IFC_SUPPORT;
+		g_BMCInfo.IpmiConfig.SerialTerminalSupport	=	SERIAL_TERMINAL_SUPPORT;
+		g_BMCInfo.IpmiConfig.LANIfcSupport			=	LAN_IFC_SUPPORT;
+		g_BMCInfo.IpmiConfig.SYSIfcSupport			=	SYS_IFC_SUPPORT;
+		g_BMCInfo.IpmiConfig.GrpExtnSupport 		= 	GROUP_EXTERN_SUPPORT;
+		g_BMCInfo.IpmiConfig.ChassisTimerInterval	=	CHASSIS_TIMER_INTERVAL;	
+		g_BMCInfo.IpmiConfig.PowerCycleInterval		=	PWR_CYCLE_INTERVAL;
+		g_BMCInfo.IpmiConfig.FanControlInterval		=	FAN_CONTROL_INTERVAL;		
+		g_BMCInfo.IpmiConfig.RearmSetSensorThreshold	=	REARM_SET_SENSOR_THRESHOLD;
+		g_BMCInfo.IpmiConfig.SELTimeUTCOffset		=	8*60;
+		
+		//IPMB
+		g_BMCInfo.IpmiConfig.PrimaryIPMBSupport		=	PRIMARY_IPMB_SUPPORT;
+		g_BMCInfo.IpmiConfig.SecondaryIPMBSupport	=	SECONDARY_IPMB_SUPPORT;
+		g_BMCInfo.IpmiConfig.PrimaryIPMBBus 		= 	PRIMARY_IPMB_BUS;
+		g_BMCInfo.IpmiConfig.SecondaryIPMBBus 		= 	SECONDARY_IPMB_BUS;
+		g_BMCInfo.IpmiConfig.PrimaryIPMBAddr 		= 	PRIMARY_IPMB_ADDR;
+		g_BMCInfo.IpmiConfig.SecondaryIPMBAddr 		= 	SECONDARY_IPMB_ADDR;
+		
+		// //set default user
+		// memset(g_BMCInfo.IpmiConfig.UserInfoTbl, 0, sizeof(UserInfo_T)*MAX_USER_NUM);
+		// g_BMCInfo.IpmiConfig.UserInfoTbl[0].ID		=	USER_ID;
+		// g_BMCInfo.IpmiConfig.UserInfoTbl[0].UserId	=	1;
+		// g_BMCInfo.IpmiConfig.UserInfoTbl[0].MaxPasswordSize	=	20;
+		// g_BMCInfo.IpmiConfig.UserInfoTbl[0].UserStatus	=	TRUE;
+		// g_BMCInfo.IpmiConfig.UserInfoTbl[0].ChannelAccess = 0x34;
+		// g_BMCInfo.IpmiConfig.UserInfoTbl[0].MaxPasswordSize = 20;
+		// memcpy(g_BMCInfo.IpmiConfig.UserInfoTbl[0].UserName, USER_NAME, sizeof(USER_NAME));
+		// memcpy(g_BMCInfo.IpmiConfig.UserInfoTbl[0].UserPassword, PASS_WORD, sizeof(PASS_WORD));
+		
+		// g_BMCInfo.IpmiConfig.CurrentNoUser			=	1;
+		
+		//Init FRU
+		memcpy(&g_BMCInfo.FRU, &Default_FRUData, sizeof(OemFRUData_T));
+		
+		/************************ Init SDR *************************************/
+		pSDR = g_BMCInfo.pSDR;
+		//init SDR repository header
+		((SDRRepository_T*)pSDR)->Signature[0]	=	0x00;
+		((SDRRepository_T*)pSDR)->Signature[1]	=	0x11;
+		((SDRRepository_T*)pSDR)->Signature[2]	=	0x22;
+		((SDRRepository_T*)pSDR)->Signature[3]	=	0x33;
+		
+		((SDRRepository_T*)pSDR)->NumRecords		=	SENSOR_NUMBERS + 1;
+		((SDRRepository_T*)pSDR)->Size			=	sdrSize;
+		((SDRRepository_T*)pSDR)->AddTimeStamp	=	0;
+		((SDRRepository_T*)pSDR)->EraseTimeStamp	=	0;
+		//init MgmtCtrlrDevLocator SDR
+		pSDR	+= sizeof(SDRRepository_T);
+		((HdrMgmtCtrlrDevLocator_T*)pSDR)->Valid	=	1;
+		((HdrMgmtCtrlrDevLocator_T*)pSDR)->Len	=	sizeof(HdrMgmtCtrlrDevLocator_T); 
+		memcpy(&(((HdrMgmtCtrlrDevLocator_T*)pSDR)->MgmtCtrlrDevLocator), &bmc_sdr, sizeof(MgmtCtrlrDevLocator_T));
+		//init FullSensorRec SDR
+		pSDR	+= sizeof(HdrMgmtCtrlrDevLocator_T);
+		for(i=0;i<SENSOR_NUMBERS;i++)
+		{
+			((HdrFullSensorRec_T*)pSDR)->Valid	=	1;
+			((HdrFullSensorRec_T*)pSDR)->Len	=	sizeof(HdrFullSensorRec_T); 
+			memcpy(&(((HdrFullSensorRec_T*)pSDR)->FullSensorRec), &full_sdr_tbl[i], sizeof(FullSensorRec_T));
+			pSDR	+= sizeof(HdrFullSensorRec_T);
+		}
+		
+		/******************************* Init SEL *************************************/
+		pSEL = g_BMCInfo.pSEL;
+		((SELRepository_T*)pSEL)->Signature[0] 	= 0x00;
+		((SELRepository_T*)pSEL)->Signature[1] 	= 0x11;
+		((SELRepository_T*)pSEL)->Signature[2] 	= 0x22;
+		((SELRepository_T*)pSEL)->Signature[3] 	= 0x33;
+		((SELRepository_T*)pSEL)->NumRecords	= 0;
+		((SELRepository_T*)pSEL)->Padding		= 0;
+		((SELRepository_T*)pSEL)->AddTimeStamp	= 0;
+		((SELRepository_T*)pSEL)->EraseTimeStamp = 0;
+		((SELRepository_T*)pSEL)->FirstRecID	= 0;
+		((SELRepository_T*)pSEL)->LastRecID		= 0;
+		((SELRepository_T*)pSEL)->SELIndex		= 0;
+		
+		((SELRepository_T*)pSEL)->SELRecord		= (SELRec_T*)(pSEL + sizeof(SELRepository_T));
+		
+		UpdateFlash();
+	}
+	else
+	{
+		// //Init FRU
+		// FLASH_GetFRU(&g_BMCInfo.FRU);
+		
+		// //Init SDR
+		// FLASH_GetSDR(g_BMCInfo.pSDR, sdrSize);
+		
+		// //Init SEL
+		// FLASH_GetSEL(g_BMCInfo.pSEL, selSize);
+	}
+	
+	return 0;
+}
+
+
+
+int UpdateFlash(void)
+{
+	//TODO:
+	return 0;
+}
+
+int SetSysTime(uint32_t *timeSecond)
+{
+	g_BMCInfo.SELTimeSecond = *timeSecond;
+	return 0;
+}
+
+int GetSysTime(void)
+{
+	return g_BMCInfo.SELTimeSecond;
+}
+
+int PostEventMessage (uint8_t *EventMsg,uint8_t size)
+{
+	uint8_t             SelReq [sizeof(SELEventRecord_T)];
+	uint8_t             SelRes [sizeof(AddSELRes_T)];
+	SELEventRecord_T*   SelRecord = ( SELEventRecord_T*) SelReq;
+
+	SelRecord->hdr.Type = 0x02;
+	SelRecord->hdr.TimeStamp = GetSysTime ();
+	memcpy (SelRecord->GenID, EventMsg, size);
+	
+	LockedAddSELEntry(SelReq, sizeof (SELEventRecord_T), SelRes);
+
+	return 0;
+}
+
+uint8_t PDK_GetSlotID(void)
+{
+	uint8_t SlotID = 0;
+	uint8_t check = 0;
+
+	if(stm32_gpio_read(GA0_PORT, GA0_PIN) == GPIO_PIN_RESET)
+		SlotID |= 0x01;
+	if(stm32_gpio_read(GA1_PORT, GA1_PIN) == GPIO_PIN_RESET)
+		SlotID |= 0x02;
+	if(stm32_gpio_read(GA2_PORT, GA2_PIN) == GPIO_PIN_RESET)
+		SlotID |= 0x04;
+	if(stm32_gpio_read(GA3_PORT, GA3_PIN) == GPIO_PIN_RESET)
+		SlotID |= 0x08;
+	if(stm32_gpio_read(GA4_PORT, GA4_PIN) == GPIO_PIN_RESET)
+		SlotID |= 0x10;
+
+	if(stm32_gpio_read(GAP_PORT, GAP_PIN) == GPIO_PIN_RESET)
+		SlotID |= 0x20;
+
+	int i;
+	for(i=0;i<6;i++)
+		check ^= (SlotID>>i)&0x01;
+
+	if(check == 0)
+		printf("Slot ID check error! GAP = %#x, GA[4:0] = %#x.\n", (SlotID>>5), (SlotID&0x1f));
+
+	return SlotID&0x1f;
+}
+
+uint8_t PDK_GetChassisID(void)
+{
+	uint8_t ChassisID = 0;
+	if(stm32_gpio_read(RACKID0_PORT, RACKID0_PIN) == GPIO_PIN_SET)
+		ChassisID |= 0x01;
+	if(stm32_gpio_read(RACKID1_PORT, RACKID1_PIN) == GPIO_PIN_SET)
+		ChassisID |= 0x02;
+	if(stm32_gpio_read(RACKID2_PORT, RACKID2_PIN) == GPIO_PIN_SET)
+		ChassisID |= 0x04;
+	if(stm32_gpio_read(RACKID3_PORT, RACKID3_PIN) == GPIO_PIN_SET)
+		ChassisID |= 0x08;
+	if(stm32_gpio_read(RACKID4_PORT, RACKID4_PIN) == GPIO_PIN_SET)
+		ChassisID |= 0x10;
+	if(stm32_gpio_read(RACKID5_PORT, RACKID5_PIN) == GPIO_PIN_SET)
+		ChassisID |= 0x20;
+
+	return ChassisID;
+}
+
+int PDK_PowerOffChassis(void)
+{
+	printf("power off chassis\n");
+}
+
+int PDK_PowerOnChassis(void)
+{
+	printf("power on chassis\n");
+}
+
+int PDK_SoftOffChassis(void)
+{
+	printf("soft off chassis\n");;
+}
+
+int PDK_PowerCycleChassis(void)
+{
+	printf("power cycle chassis\n");;
+}
+
+int PDK_ResetChassis(void)
+{
+	printf("power reset chassis\n");;
+}
+
+int PDK_DiagInterruptChassis(void)
+{
+	printf("power diag chassis\n");;
+}
+
+int PDK_FanControl(void)
+{
+	;
+}

+ 29 - 0
app/bmc/Api.h

@@ -0,0 +1,29 @@
+#ifndef __API_H__
+#define __API_H__
+
+int PlatformInit(void);
+int InitSelConfig(void);
+int InitSdrConfig(void);
+int Init_IPMI_FRU_SDR_SEL(void);
+int Init_SessionTbl(void);
+int InitTimerTaskTbl(void);
+
+int UpdateFlash(void);
+int SetSysTime(uint32_t *timeSecond);
+int GetSysTime(void);
+#define SET_SYSTEM_TIME_STAMP(time) SetSysTime(time)
+#define GET_SYSTEM_TIME_STAMP GetSysTime
+
+int PostEventMessage (uint8_t *EventMsg,uint8_t size);
+
+extern uint8_t PDK_GetSlotID(void);
+extern uint8_t PDK_GetChassisID(void);
+extern int PDK_PowerOffChassis(void);
+extern int PDK_PowerOnChassis(void);
+extern int PDK_SoftOffChassis(void);
+extern int PDK_PowerCycleChassis(void);
+extern int PDK_ResetChassis(void);
+extern int PDK_DiagInterruptChassis(void);
+extern int PDK_FanControl(void);
+
+#endif /* __API_H__ */

+ 136 - 0
app/bmc/BmcType.h

@@ -0,0 +1,136 @@
+#ifndef __BMC_TYPE_H__
+#define __BMC_TYPE_H__
+
+#include <stdint.h>
+#include <unistd.h>
+#include <pthread.h>
+#include "Session.h"
+#include "com_IPMI_ChassisDevice.h"
+#include "PMConfig.h"
+#include "SensorMonitor.h"
+#include "com_BmcType.h"
+#include "MsgHndlr.h"
+
+#pragma pack(1)
+
+/***************************************** IPMI ******************************************************/
+typedef struct
+{
+    pthread_key_t CurSessionID;
+    pthread_key_t CurPrivLevel;
+    pthread_key_t CurChannel;
+    pthread_key_t CurKCSIfcNum;
+    pthread_key_t CurSessionType;
+    pthread_key_t OwnerLUN;
+}TLS_T;
+
+typedef enum
+{
+  ORIGIN_UNSPECIFIED = 0,
+  ORIGIN_SENDMSG,
+  ORIGIN_CMDFWD,
+  ORIGIN_INT_REQ,
+  ORIGIN_NM,
+}BridgeOrigin;
+
+typedef struct
+{
+	char	FirstPowerOnStr[32];	//first power on the bmc 
+    uint8_t SendMsgTimeout;
+    uint8_t SessionTimeOut;
+    uint32_t ChassisTimerInterval;
+    	
+    uint8_t SerialIfcSupport ;
+    uint8_t SerialTerminalSupport;
+    uint8_t LANIfcSupport ;
+    uint8_t SYSIfcSupport;
+    uint8_t GrpExtnSupport ;
+
+	uint32_t FanControlInterval;
+
+ 	//IPMB
+ 	uint8_t 		PrimaryIPMBSupport ;
+    uint8_t 		SecondaryIPMBSupport ;
+	uint32_t 			PrimaryIPMBBus;
+    uint32_t 			SecondaryIPMBBus;
+    uint8_t             PrimaryIPMBAddr;	//8bit
+	uint8_t				SecondaryIPMBAddr;	//8bit
+
+	//chassis config
+	uint8_t                        SysRestartCause;
+	uint8_t                        PowerRestorePolicy;
+	ChassisPowerState_T          ChassisPowerState;
+	ChassisCapabilities_T        ChassisCapabilities;
+	uint8_t						PowerCycleInterval;
+	uint8_t                        SysPartitionScan;
+	
+	uint8_t				RearmSetSensorThreshold;
+	int16_t				SELTimeUTCOffset;
+	
+	uint8_t		MaxSession;
+	uint32_t	LogOutTimeout;
+} IPMIConfig_T;
+
+
+typedef struct
+{
+    IPMIConfig_T 		IpmiConfig;
+	OemFRUData_T		FRU;
+	uint8_t*			pSDR;
+	uint8_t*			pSEL;		
+
+	//time
+    uint32_t 			CurTimerTick;							//uint: 1ms
+	uint32_t			CurTimerSecond;
+	uint32_t			BootValidMinutes;						//This work time
+	uint32_t			TotalBootValidMinutes;					//Total work time
+	uint32_t			SELTimeSecond;							//seconds from 1970-1-1 00:00:00, UTC
+	
+	//chassis
+    uint8_t             SlotID;
+	uint8_t				ChassisID;
+
+	uint8_t				PowerGoodFlag;
+	uint8_t				FirstPowerOn;
+	uint8_t				SelfTestByte;
+	uint8_t				ChassisIdentifyForce;
+	uint8_t				ChassisIdentifyTimeout;
+	uint8_t				ChassisIdentify;
+	uint8_t				HealthLevel;
+	
+	SensorSharedMem_T	SensorSharedMem;
+	SENSOR_T 			SenConfig;
+	
+	//message handler
+	uint8_t    			SendMsgSeqNum;
+	
+	SDR_T				SDRConfig;
+	SEL_T				SELConfig;
+	
+	uint8_t				DeviceGUID[16];
+//	OEM_FLAGS_T			OemFlags;
+	
+	SessionInfo_T		LanSession;
+	SessionTblInfo_T 	SessionTblInfo;
+	UDSSessionTblInfo_T UDSSessionTblInfo;
+	uint8_t			 	TimerTaskTblSize;
+	TimerTaskTbl_T    	TimerTaskTbl[20];
+
+	//bool				loginOk;
+	//uint32_t			logOutCnt;
+	UserInfo_T			UserInfoTbl[MAX_USER_NUM];
+	UserInfo_T			*pUserInfo;
+	uint8_t				CurrentNoUser;
+	
+
+	
+	uint8_t				FwMajorVer;
+	uint8_t				FwMinorVer;
+
+} BMCInfo_t;
+
+
+
+
+#pragma pack()
+#endif /* __BMC_TYPE_H__ */

+ 162 - 0
app/bmc/ChassisTimer/ChassisTimerTask.c

@@ -0,0 +1,162 @@
+/*
+* Brief:	Handle all chassis function in this file. 
+			Such as: Fan control, update power_good status, update chassis health status.
+* Author:	Jimbo_Zhang@outlook.com
+* Date:		2019-9-18
+*/
+#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 "SensorMonitor.h"
+#include "time.h"
+
+#include "com_IPMI_App.h"
+
+
+int gFd_ChassisPwrHndlrQue;
+
+void *ChassisTimerTask(void* pArg)
+{
+	MsgPkt_T	MsgPkt;
+	uint32_t	preChassisSeconds;
+	uint32_t	preFanSeconds;
+	uint32_t	preIdentifySeconds = 0;
+	uint8_t		IdentifyTickCnt = 0;
+	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;
+    }
+
+	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);
+					//NVIC_SystemReset();
+					//TODO: reset stm32
+				}
+			}
+		}
+		
+		//Chassis timer interval
+		if((g_BMCInfo.CurTimerSecond != preChassisSeconds) 
+			&&((g_BMCInfo.CurTimerSecond - preChassisSeconds) >= g_BMCInfo.IpmiConfig.ChassisTimerInterval))
+		{
+			//log("Chassis interval\r\n");
+			preChassisSeconds	=	g_BMCInfo.CurTimerSecond;
+			//TODO:
+			g_BMCInfo.PowerGoodFlag = 1;
+			g_BMCInfo.IpmiConfig.ChassisPowerState.PowerState	=	g_BMCInfo.PowerGoodFlag;
+		}
+		
+		//Fan control
+		if((g_BMCInfo.CurTimerSecond != preFanSeconds)
+			&& (g_BMCInfo.CurTimerSecond % g_BMCInfo.IpmiConfig.FanControlInterval) == 0)
+		{
+			preFanSeconds	=	g_BMCInfo.CurTimerSecond;
+			PDK_FanControl();
+		}
+		
+		//Chassis Identify
+		if(g_BMCInfo.ChassisIdentify == TRUE)
+		{
+			if(IdentifyTickCnt == 5)	//0.5s
+			{
+				IdentifyTickCnt++;
+				printf("-> Turn on led!\r\n");
+			}
+			else if(IdentifyTickCnt == 10)
+			{
+				IdentifyTickCnt	=	0;
+				printf("-> Turn off led!\r\n");
+			}
+			else
+			{
+				IdentifyTickCnt++;
+			}
+			
+			//Identify finished
+			if(((g_BMCInfo.CurTimerSecond - preIdentifySeconds) >= g_BMCInfo.ChassisIdentifyTimeout) 
+				&& (g_BMCInfo.ChassisIdentifyForce != 1))
+			{
+				g_BMCInfo.ChassisIdentify	=	FALSE;
+			}
+		}
+		else
+		{
+			preIdentifySeconds	=	g_BMCInfo.CurTimerSecond;
+			IdentifyTickCnt	=	0;
+		}
+		
+		sleep(1);
+	}
+}
+
+
+

+ 14 - 0
app/bmc/ChassisTimer/ChassisTimerTask.h

@@ -0,0 +1,14 @@
+/*
+* Brief:	The header file of ChassisTimerTask.c
+* Author:	Jimbo_Zhang@outlook.com
+* Date:		2019-9-18
+*/
+
+#ifndef __CHASSIS_TIMER_TASK_H__
+#define __CHASSIS_TIMER_TASK_H__
+
+void *ChassisTimerTask(void* pArg);
+
+#endif /* __CHASSIS_TIMER_TASK_H__ */
+
+

+ 127 - 0
app/bmc/Makefile

@@ -0,0 +1,127 @@
+EXEC		= bmc_app
+
+CFLAGS		:= -Os -mcpu=cortex-m3 -mthumb
+LDFLAGS		:= -mcpu=cortex-m3 -mthumb -L$(INSTALL_ROOT)/A2F/root/usr/lib
+
+
+
+CC	= $(CROSS_COMPILE_APPS)gcc
+
+#source
+SRC	= ./main.c
+SRC += ./message.c
+SRC	+= ./Session.c
+SRC	+= ./Api.c
+SRC	+= ./sensor_driver.c
+SRC	+= ./sensor_sdr.c
+SRC	+= ./OemFRU.c
+
+SRC	+= ./SysTimer/TimerTask.c
+
+SRC	+= ./uds/UDSIfc.c
+SRC += ./lan/LANIfc.c
+SRC += ./lan/RMCP.c
+SRC += ./lan/RMCP+.c
+
+SRC += ./ipmb/IPMBIfc.c
+
+SRC += ./encryption/MD2.c
+SRC += ./encryption/md2_dgst.c
+SRC += ./encryption/MD5.c
+SRC += ./encryption/MD5_128.c
+SRC += ./encryption/md5c.c
+SRC += ./encryption/AuthCode.c
+
+SRC += ./ChassisTimer/ChassisTimerTask.c
+
+SRC += ./msghndlr/MsgHndlrTask.c
+SRC += ./msghndlr/cmdselect.c
+SRC += ./msghndlr/PDKCmds.c
+SRC += ./msghndlr/App/App.c
+SRC += ./msghndlr/App/AppDevice/AppDevice.c
+SRC += ./msghndlr/App/AppDevice/WDT.c
+#SRC += ./msghndlr/App/IPMDevice/Firewall.c
+SRC += ./msghndlr/App/IPMDevice/IPMDevice.c
+
+SRC += ./msghndlr/Bridge/Bridge.c
+SRC += ./msghndlr/Chassis/Chassis.c
+SRC += ./msghndlr/Chassis/ChassisDevice.c
+SRC += ./msghndlr/OemSMMCmds/OemSMMCmds.c
+SRC += ./msghndlr/PICMG/PICMGDevice.c
+
+SRC += ./msghndlr/SensorEvent/SensorEvent.c
+SRC += ./msghndlr/SensorEvent/SensorDevice/Sensor.c
+SRC += ./msghndlr/SensorEvent/SensorDevice/SensorMonitor.c
+
+SRC += ./msghndlr/Storage/Storage.c
+SRC += ./msghndlr/Storage/FRUDevice/FRU.c
+SRC += ./msghndlr/Storage/SDRDevice/SDR.c
+SRC += ./msghndlr/Storage/SELDevice/SEL.c
+
+# hal_api
+SRC += $(wildcard ../hal_api/*.c) 
+
+#incldue
+CFLAGS	+= -I$(INSTALL_ROOT)/A2F/root/usr/include
+CFLAGS	+= -I ../common_include
+CFLAGS	+= -I ../hal_api
+CFLAGS	+= -I ../driver
+CFLAGS	+= -I ../driver/STM32F4xx_HAL_Driver
+CFLAGS	+= -I ../driver/STM32F4xx_HAL_Driver/Inc 
+
+CFLAGS	+= -I ./
+CFLAGS	+= -I ./uds
+CFLAGS	+= -I ./lan
+CFLAGS	+= -I ./fru
+CFLAGS	+= -I ./sdr
+CFLAGS	+= -I ./sel
+CFLAGS	+= -I ./ipmb
+
+CFLAGS	+= -I ./SysTimer
+
+CFLAGS	+= -I ./ChassisTimer
+CFLAGS	+= -I ./encryption
+CFLAGS	+= -I ./ipmb
+CFLAGS	+= -I ./lan
+
+CFLAGS	+= -I ./msghndlr
+CFLAGS	+= -I ./msghndlr/App
+CFLAGS	+= -I ./msghndlr/App/AppDevice
+CFLAGS	+= -I ./msghndlr/App/IPMDevice
+CFLAGS	+= -I ./msghndlr/Bridge
+CFLAGS	+= -I ./msghndlr/Chassis
+CFLAGS	+= -I ./msghndlr/OemSMMCmds
+CFLAGS	+= -I ./msghndlr/PICMG
+CFLAGS	+= -I ./msghndlr/SensorEvent
+CFLAGS	+= -I ./msghndlr/SensorEvent/SensorDevice
+CFLAGS	+= -I ./msghndlr/Storage
+CFLAGS	+= -I ./msghndlr/Storage/FRUDevice
+CFLAGS	+= -I ./msghndlr/Storage/SDRDevice
+CFLAGS	+= -I ./msghndlr/Storage/SELDevice
+CFLAGS	+= -I ./msghndlr/Transport
+
+
+CFLAGS	+= -I ./encryption
+
+#CFLAGS	+= -I$(INSTALL_ROOT)/A2F/uclibc/include
+#library
+
+#sub-directory
+#SUBDIR 	= ./sensor
+
+
+
+
+
+#object
+OBJS	= $(SRC:%.o=%.c)
+
+$(EXEC): $(OBJS)
+	$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBS) -lpthread
+	rm -f *.o
+
+clean:
+	OBJS	= $(SRC:%.o=%.c)
+	rm -rf $(EXEC) $(OBJS)
+
+

+ 111 - 0
app/bmc/OemFRU.c

@@ -0,0 +1,111 @@
+/*
+* Brief:	Define default FRU data in here.
+*/
+
+#include "BmcType.h"
+#include "com_BmcType.h"
+#include "com_IPMI_FRU.h"
+
+
+/********************************** Flash *************************************/
+/*
+ * Common Header: 		offset = 0,		len = 8
+ * chassis info area	offset = 1,		len = 64
+ * Board info area:		offset = 9,		len = 96
+ * product info area:	offset = 21, 	len = 88
+ * ------------------------------------------------------------------
+ * 										total = 256 		
+ */
+const OemFRUData_T Default_FRUData = {
+		//common header
+		{
+			1,			//Format version
+			0,			//no internal use area 
+			1,			//chassis info area offset / 8 
+			9,			//board info area offset / 8
+			21,		//product info area offset / 8
+			0,			//MultiRecord area offset / 8
+			0x0,		//PAD
+			0xe0,		//checksum
+		},
+		
+		//chassis info area
+		{
+			1,			//version
+			FRU_CHASSIS_SIZE/8,		//length = 64/8
+			MainServerChassis,
+			//Data[58]
+			{
+					(0xc0 | 0x0a),	
+					'0', '0', '0', '0', '-', '0', '0', '0', '1', ' ',   		//Chassis Part Number
+					(0xc0 | 0x0a),	
+					'0', '0', '0', '0', '-', '0', '0', '0', '1', ' ',    		//Chassis Serial Number
+					(0xc0 | 0x0a),	
+					' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',    			//Extra info
+										
+			},
+			0xc1,	
+			0x0,		//Y
+			0x0,		//checksum
+		},
+		
+		//board info area
+		{
+			1,			//version
+			FRU_BOARD_SIZE/8,		//length = 96/8
+			English,
+			{34, 56, 78},			//Number of minutes from 0:00 hrs 1/1/96.	LSbyte first (little endian)
+			//Data[75]
+			{
+				(0xc0 | 0x0a),	
+				'S', 't', 'o', 'r', 'l', 'e', 'a', 'd', ' ', ' ',  		//board manufacturer
+				(0xc0 | 0x0b), 
+				'G', '_', 'C', 'A', 'L', 'C', 'U', 'L', 'A', 'T', 'E',   		//board product name
+				(0xc0 | 0x08),
+				'0', '0', '0', '1', ' ', ' ', ' ', ' ',	//board product serNum
+				(0xc0 | 0x08),
+				'0', '0', '0', '1', ' ', ' ', ' ', ' ',	//board product partNum
+				(0xc0 | 0x08),
+				' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',	//board fru file id
+				(0xc0 | 0x08),
+				' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',	//Extra info
+			},
+			{0,0,0,0},	//power on count
+			{0,0,0,0},	//Total work time
+			{0,0,0,0},	//This work time
+			0xc1,	
+			0x0,		//Y
+			0x0,		//checksum
+		},
+		
+		//product info area
+		{
+			1,			//version
+			FRU_PRODUCT_SIZE/8,		//length	=	88/8
+			English,	
+			//Data[82]
+			{
+				(0xc0 | 0x0a),
+				'S', 't', 'o', 'r',	'l', 'e', 'a', 'd', ' ', ' ', 	//manufacturer name
+				(0xc0 | 0x0b),
+				'G', '_', 'C', 'A', 'L', 'C', 'U', 'L', 'A', 'T', 'E',	//product name
+				(0xc0 | 0x08),
+				'0', '0', '0', '0', '0', '0', '0', '1',	//part number
+				(0xc0 | 0x08),
+				'1', '.', '0', '0', ' ', ' ', ' ', ' ',	//product version
+				(0xc0 | 0x08),
+				'0','0','0','0','0','0', '0', '1',	//product serNum
+				(0xc0 | 0x08), 	
+				' ',' ',' ',' ',' ',' ', ' ', ' ',	//Assert Tag
+				(0xc0 | 0x08), 		
+				' ',' ',' ',' ',' ',' ',' ',' ',	//FRU File ID
+				(0xc0 | 0x08), 		
+				' ',' ',' ',' ',' ',' ',' ',' ',	//Extra info
+			},
+			0xc1,	
+			0x0,		//Y
+			0x0,		//checksum
+		}
+};
+
+

+ 1292 - 0
app/bmc/Session.c

@@ -0,0 +1,1292 @@
+///****************************************************************
+// ****************************************************************
+// **                                                            **
+// **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+// **                                                            **
+// **            All Rights Reserved.                            **
+// **                                                            **
+// **        6145-F, Northbelt Parkway, Norcross,                **
+// **                                                            **
+// **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+// **                                                            **
+// ****************************************************************
+// ****************************************************************/
+///*****************************************************************
+// *
+// * Session.c
+// * Session related functions
+// *
+// * Author: Govind Kothandapani <govindk@ami.com>
+// * 		 : Rama Bisa <ramab@ami.com>
+// *       : Basavaraj Astekar <basavaraja@ami.com>
+// *       : Bakka Ravinder Reddy <bakkar@ami.com>
+// *
+// *****************************************************************/
+//#define ENABLE_DEBUG_MACROS    0
+#include "com_IPMIDefs.h"
+//#include "MsgHndlr.h"
+#include "PMConfig.h"
+//#include "SharedMem.h"
+//#include "NVRAccess.h"
+#include "Session.h"
+//#include "Debug.h"
+////#include "SerialRegs.h"
+//#include "SensorEvent.h"
+#include "com_IPMI_Sensor.h"
+#include "Support.h"
+//#include "Ethaddr.h"
+#include "AppDevice.h"
+#include "MsgHndlr.h"
+#include <stdio.h>
+#include "main.h"
+#include <string.h>
+#include <time.h>
+#include "com_IPMI_SensorEvent.h"
+
+//#define TOTAL_INFINITE_CMDS  sizeof(m_InfiniteCmdsTbl)/sizeof(IPMICmdsFilterTbl_T)
+
+//static IPMICmdsFilterTbl_T m_InfiniteCmdsTbl [] =
+//{     /* NetFn */       /*  Command#   */
+//	{   NETFN_AMI,  CMD_AMI_YAFU_COMMON_NAK             },
+//	{   NETFN_AMI,  CMD_AMI_YAFU_GET_FLASH_INFO         },	
+//	{   NETFN_AMI,	CMD_AMI_YAFU_GET_FIRMWARE_INFO	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_GET_FMH_INFO	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_GET_STATUS,	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_ACTIVATE_FLASH	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_ALLOCATE_MEMORY	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_FREE_MEMORY	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_READ_FLASH	            },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_WRITE_FLASH	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_ERASE_FLASH	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_PROTECT_FLASH	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_ERASE_COPY_FLASH	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_VERIFY_FLASH	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_READ_MEMORY	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_WRITE_MEMORY	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_COPY_MEMORY	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_COMPARE_MEMORY	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_CLEAR_MEMORY	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_GET_BOOT_CONFIG	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_SET_BOOT_CONFIG	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_GET_BOOT_VARS	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_DEACTIVATE_FLASH_MODE  },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_RESET_DEVICE	    },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_GET_ECF_STATUS         },
+//	{   NETFN_AMI,	CMD_AMI_YAFU_GET_VERIFY_STATUS	    },
+//	{   NETFN_AMI,	CMD_AMI_GET_CHANNEL_NUM	            },
+//	{   NETFN_AMI,	CMD_AMI_GET_ETH_INDEX	            },
+//	{   NETFN_AMI,	CMD_AMI_START_TFTP_FW_UPDATE    },
+//	{   NETFN_AMI,	CMD_AMI_GET_TFTP_FW_PROGRESS_STATUS },
+//	{   NETFN_AMI,	CMD_AMI_SET_FW_CONFIGURATION    },
+//       {   NETFN_AMI,       CMD_AMI_GET_FW_CONFIGURATION    },
+//       {   NETFN_AMI,       CMD_AMI_SET_FW_PROTOCOL},
+//       {   NETFN_AMI,       CMD_AMI_GET_FW_PROTOCOL},
+//       {   NETFN_AMI,       CMD_AMI_YAFU_FIRMWARE_SELECT_FLASH},
+
+//};
+
+/*********************************************************************************************
+   Name	:	SessionTimeOutTask
+   Input	:	void
+   Output	:	void
+       This program  checks for session timeout
+*********************************************************************************************/
+void SessionTimerTask (void)
+{
+   	SessionTblInfo_T*	pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
+   uint8_t				Index;
+//   char solsessionfile[MAXFILESIZE] = {0};
+   struct stat fp;
+
+   printf("-> SessionTimerTask\n");
+   for (Index=0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
+   {
+       if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
+       {
+           continue;
+       }
+
+       // if(g_BMCInfo.IpmiConfig.SerialIfcSupport == 1)
+       // {
+       //     if (g_BMCInfo.SERIALch == pSessionTblInfo->SessionTbl[Index].Channel)
+       //     {
+       //         continue;
+       //         if (!(g_BMCInfo.SMConfig.SessionTermination & 0x02)) /* If Session Inactivity timeout disabled */
+       //         {
+       //             continue;
+       //         }
+       //         else if (0 == g_BMCInfo.SMConfig.SessionInactivity) /* Never Time Out */
+       //         {
+       //             continue;
+       //         }
+       //     }
+       // }
+       
+       // if(pBMCInfo->IpmiConfig.SOLIfcSupport == 1)
+       // {
+       //     if(pSessionTblInfo->SessionTbl[Index].SessPyldInfo [PAYLOAD_SOL].Type == PAYLOAD_SOL)
+       //     {
+       //         if (pBMCInfo->IpmiConfig.SOLSessionTimeOut == 0 ) // Never Time Out 
+       //         {
+       //             continue;
+       //         }
+               
+       //         if(pSessionTblInfo->SessionTbl[Index].TimeOutValue == 0)
+       //         {
+       //             sprintf(solsessionfile,"%s%d",SOL_SESSION_FILE,BMCInst);
+               
+       //             if(stat(solsessionfile,&fp) == 0)
+       //             {
+       //                 unlink(solsessionfile);
+       //             }
+       //         }
+       //     }
+       // }
+
+    //   if(GetLinkStatus(pSessionTblInfo->SessionTbl[Index].Channel,BMCInst) !=0)
+    //   {
+           if (pSessionTblInfo->SessionTbl[Index].TimeOutValue > 0)
+           {
+               pSessionTblInfo->SessionTbl[Index].TimeOutValue--;
+               continue;
+           }
+       // }
+       // else
+       // {
+       //     pSessionTblInfo->SessionTbl[Index].Linkstat = TRUE;
+       //     continue;
+       // }
+
+       printf ("\nSessionTimerTask: Session Time Out Occured\n");
+       printf ("SessionID = 0x%lX  Num of Sessions = %X\n", pSessionTblInfo->SessionTbl[Index].SessionID,
+                       pSessionTblInfo->Count);
+
+       // if(pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
+       // {
+       //     if (pBMCInfo->SERIALch == pSessionTblInfo->SessionTbl[Index].Channel)
+       //     {
+       //         BMC_GET_SHARED_MEM (BMCInst)->SerialSessionActive = FALSE;
+       //     }
+       // }
+
+       /* Delete the Session from session table */
+       DeleteSession (&pSessionTblInfo->SessionTbl[Index]);
+   }
+}
+
+
+///*********************************************************************************************
+//    Name	:	getChannelInfo
+//    Input	:	ch	-	ChannelNumber
+//    Output	:	channelInformations
+//        This program  returns informations about the channel
+//*********************************************************************************************/
+// ChannelInfo_T* getChannelInfo (uint8_t ch )
+//{
+//    uint8_t Index;
+//    ChcfgInfo_T *pChannelInfo=NULL;
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    if(IsLANChannel(ch, BMCInst))
+//    {
+//        if(pBMCInfo->IpmiConfig.LANIfcSupport != 1)
+//        {
+//            return NULL;
+//        }
+//    }else
+//    {
+//        if( PRIMARY_IPMB_CHANNEL == ch && pBMCInfo->IpmiConfig.PrimaryIPMBSupport != 1 )
+//        {
+//            return NULL;
+//        }
+//        else if (pBMCInfo->IpmiConfig.SecondaryIPMBSupport != 1 && (pBMCInfo->SecondaryIPMBCh != CH_NOT_USED && ch == pBMCInfo->SecondaryIPMBCh))
+//        {
+//            return NULL;
+//        }
+//        else if (pBMCInfo->IpmiConfig.SerialIfcSupport != 1 && (pBMCInfo->SERIALch != CH_NOT_USED && ch == pBMCInfo->SERIALch))
+//        {
+//            return NULL;
+//        }
+//        else if (pBMCInfo->IpmiConfig.ICMBIfcSupport != 1 && (pBMCInfo->ICMBCh != CH_NOT_USED && ch == pBMCInfo->ICMBCh))
+//        {
+//            return NULL;
+//        }
+//        else if (pBMCInfo->IpmiConfig.SMBUSIfcSupport !=1 && (pBMCInfo->SMBUSCh != CH_NOT_USED && ch == pBMCInfo->SMBUSCh))
+//        {
+//            return NULL;
+//        }
+//        else if (pBMCInfo->IpmiConfig.USBIfcSupport != 1 && (ch == USB_CHANNEL))
+//        {
+//            return NULL;
+//        }
+//        else if (pBMCInfo->IpmiConfig.SMMIfcSupport != 1 && (pBMCInfo->SMMCh != CH_NOT_USED && ch == pBMCInfo->SMMCh))
+//        {
+//            return NULL;
+//        }
+//        else if(pBMCInfo->IpmiConfig.SYSIfcSupport !=1 && ch == SYS_IFC_CHANNEL)
+//        {
+//            return NULL;
+//        }
+//    }
+
+//    for(Index=0;Index<MAX_NUM_CHANNELS;Index++)
+//    {
+//        if(pBMCInfo->ChConfig[Index].ChType != 0xff)
+//        {
+//            pChannelInfo = &pBMCInfo->ChConfig[Index];
+//            //printf("Channel numb is %x %x \n",pChannelInfo->ChannelInfo.ChannelNumber,ch);
+//            if(pChannelInfo->ChannelInfo.ChannelNumber == ch)
+//            {
+//                return (ChannelInfo_T *)&pBMCInfo->ChConfig[Index].ChannelInfo;
+//            }
+//        }
+//    }
+
+//    return NULL;
+//}
+
+int UpdateUserInfoTable(void)
+{
+    uint8_t buf[1000];
+    uint8_t UserNameLen = 0;
+    uint8_t PassWordLen = 0;
+    uint8_t *pUserName;
+    uint8_t *pPassword;
+    uint8_t *pStr;
+    uint8_t usercnt = 0;
+    uint32_t len = 0;
+    uint8_t     namesize = 0;
+    FILE *fp = NULL;
+
+
+    printf("\n\nUpdateUserInfoTable\n");
+
+    fp = fopen(AUTH_FILE_PATH, "r");
+    if(fp == NULL)
+    {
+        printf("Open %s fail!\n", AUTH_FILE_PATH);
+        return -1;
+    }
+
+    while(fgets(buf, 1000, fp) != NULL){
+        pStr = buf;
+
+        //remove blank
+        while(*pStr == ' ')
+        {
+            pStr++;
+        }
+
+        if(strncmp(pStr, "user name=", 10) == 0)
+        {
+            pStr+=10;
+            //get name
+            pUserName = pStr;
+            UserNameLen = 0;
+            while(*pStr != ' ')
+            {
+                UserNameLen++;
+                pStr++;
+            }
+
+            memset(g_BMCInfo.UserInfoTbl[usercnt].UserName, 0, MAX_USERNAME_LEN);
+            memcpy(g_BMCInfo.UserInfoTbl[usercnt].UserName, pUserName, UserNameLen);
+            
+            //remove blank
+            while(*pStr == ' ')
+            {
+                pStr++;
+            }
+            if(strncmp(pStr, "password=", 9) == 0)
+            {
+                pStr += 9;
+                //get password
+                pPassword = pStr;
+                PassWordLen = 0;
+                while(*pStr != ' ')
+                {
+                    PassWordLen++;
+                    pStr++;
+                }
+
+                memset(g_BMCInfo.UserInfoTbl[usercnt].UserPassword, 0, MAX_PASSWORD_LEN);
+                memcpy(g_BMCInfo.UserInfoTbl[usercnt].UserPassword, pPassword, PassWordLen);
+            
+                g_BMCInfo.UserInfoTbl[usercnt].UserId = usercnt;
+
+                if(usercnt < 10)
+                    usercnt++;
+                else
+                    break;
+            }
+            else
+                continue;
+        }
+        else
+            continue;
+    }
+
+    g_BMCInfo.CurrentNoUser = usercnt;
+    fclose(fp);
+
+    return 0;
+}
+/*********************************************************************************************
+    Name	:	CheckForDuplicateUsers
+    Input	:	UserName - Name of the User
+    Output	:	returns 0 for success and -1 for failure
+        This program  returns Informations about the user
+*********************************************************************************************/
+uint8_t CheckForDuplicateUsers ( uint8_t* UserName)
+{
+	int i = 0;
+    
+    for(i=0; i<=MAX_USER_NUM; i++)
+    {
+        if(g_BMCInfo.UserInfoTbl[i].UserId != 0)
+        {
+            if (0 == memcmp(g_BMCInfo.UserInfoTbl[i].UserName, UserName, MAX_USERNAME_LEN))
+                return FALSE;
+        }
+    }	
+    return TRUE;    
+}
+
+/*********************************************************************************************
+    Name	:	getUserIdInfo
+    Input	:	UserID - User ID
+    Output	:	User information
+        This program  returns Informations about the user
+*********************************************************************************************/
+UserInfo_T*	getUserIdInfo (uint8_t UserId)
+{
+    UpdateUserInfoTable();
+    //if (UserId == 0) { return NULL; }
+
+    if (UserId < MAX_USER_NUM)
+    {
+        return &g_BMCInfo.UserInfoTbl[UserId];
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
+/*********************************************************************************************
+    Name	:	getUserNameInfo
+    Input	:	UserName - User name
+    Output	:	User information
+        This program  returns Informations about the user
+*********************************************************************************************/
+UserInfo_T*	getUserNameInfo (uint8_t *UserName)
+{
+   int i = 0;
+
+   UpdateUserInfoTable();
+   if (UserName[0] == 0) { return NULL; }
+   if( (UserName[0] >= '0') && (UserName[0] <= '9') ) {return NULL;}
+
+	for (i = 0; i < MAX_USERNAME_LEN; i++)
+	{
+		if(UserName[i] > 127)
+		{
+			return NULL;
+		}
+	}    
+	
+    for(i=0; i < MAX_USER_NUM; i++)
+    {
+        //if(g_BMCInfo.UserInfoTbl[i].UserId != 0)
+        {
+            if (0 == strcmp(g_BMCInfo.UserInfoTbl[i].UserName, UserName))
+            {
+                return &g_BMCInfo.UserInfoTbl[i];
+            }
+        }
+    }	
+
+	return NULL;
+}
+
+///*********************************************************************************************
+//    Name	:	getChUserPrivInfo
+//    Input	:	userName - user name
+//    			Role - requested role
+//                chIndex - channel's user index
+//                pChUserInfo - channel's user information
+//    Output	:	channel's matching user Information
+
+//This program returns information about the user for the given channel,
+//        & Index of the user in Channel User Array.
+//*********************************************************************************************/
+// ChannelUserInfo_T* getChUserPrivInfo ( char *userName,  uint8_t Role,  uint8_t* chIndex,  ChannelUserInfo_T *pChUserInfo, int BMCInst)
+//{
+//     UserInfo_T* pUserTable = (UserInfo_T *) GetNVRUsrCfgAddr (NVRH_USERCONFIG, BMCInst);
+//    int userIndex;
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    /* search the table */
+//    for(userIndex = 0; userIndex < pBMCInfo->IpmiConfig.MaxUsers; userIndex++)
+//    {
+//        for(*chIndex = 0; *chIndex < pBMCInfo->IpmiConfig.MaxChUsers; (*chIndex)++)
+//        {
+//            if ((Role <= pChUserInfo[*chIndex].AccessLimit) &&
+//                (1 == pUserTable[userIndex].UserStatus) &&
+//                (pUserTable[userIndex].UserId == pChUserInfo[*chIndex].UserId))
+//                {
+//                    /* if userName is not NULL then it is username/privilege
+//                    lookup else it is name_only lookup */
+//                    if (0 != *userName)
+//                    {
+//                        if (0 != _fmemcmp(pUserTable[userIndex].UserName, userName, MAX_USERNAME_LEN))
+//                        {
+//                            continue;
+//                        }
+//                    }
+//                    return (pChUserInfo + *chIndex);
+//                }
+//        }
+//    }
+//    return NULL;
+//}
+
+///*********************************************************************************************
+//    Name	:	getChUserInfo
+//    Input	:	userName - user name
+//                chIndex - to return Index of user in channelUser Array
+//                pChUserInfo - channel's user information
+//    Output	:	channel's matching user Information
+
+//This program returns information about the user for the given channel,
+//        & Index of the user in Channel User Array.
+//*********************************************************************************************/
+// ChannelUserInfo_T* getChUserInfo ( char *userName,   uint8_t* chIndex,  ChannelUserInfo_T *pChUserInfo )
+//{
+//     UserInfo_T* pUserTable = (UserInfo_T *) GetNVRUsrCfgAddr (NVRH_USERCONFIG, BMCInst);
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//    int userIndex;
+
+//    /* search the table */
+//    for(userIndex = 0; userIndex < pBMCInfo->IpmiConfig.MaxUsers; userIndex++)
+//    {
+//        for(*chIndex = 0; *chIndex < pBMCInfo->IpmiConfig.MaxChUsers; (*chIndex)++)
+//        {
+//            if ((0 == _fmemcmp(pUserTable[userIndex].UserName, userName, MAX_USERNAME_LEN)) &&
+//                /* Commented to return the pointer for disabled user */ 
+//                /* (1 == pUserTable[userIndex].UserStatus) && */
+//                (pUserTable[userIndex].UserId == pChUserInfo[*chIndex].UserId))
+//            return (pChUserInfo + *chIndex);
+//        }
+//    }
+//    return NULL;
+//}
+
+///*********************************************************************************************
+//    Name	:	getChUserIdInfo
+//    Input	:	userId - User ID
+//                Index - to return Index of user in channelUser Array.
+//                pChUserInfo - channel's user information
+//    Output	:	channel's matching user Information
+
+//This program returns information about the user for the given channel,
+//                & Index of the user inChannel User Array.
+
+//*********************************************************************************************/
+// ChannelUserInfo_T* getChUserIdInfo (uint8_t userId,  uint8_t *Index,  ChannelUserInfo_T*	pChUserInfo, int BMCInst)
+//{
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    if (userId == 0) { return NULL; }
+
+//    for(*Index=0; *Index < pBMCInfo->IpmiConfig.MaxChUsers; (*Index)++)
+//    {
+//        if ((pChUserInfo->UserId == userId) && ((pChUserInfo->ID == USER_ID )))
+//        {
+//            return pChUserInfo;
+//        }
+//        pChUserInfo++;
+//    }
+//    return NULL;
+//}
+
+///*********************************************************************************************
+//    Name	:	GetNVRChConfigs
+//    Input	:	pChannelInfo -Channel Information
+//                        Filename - Channel Name Information
+//    Output	:	Respective Channel's Information
+
+//This program returns information about the respective channel.
+
+//*********************************************************************************************/
+//ChannelInfo_T* GetNVRChConfigs(ChannelInfo_T *pChannelInfo, int BMCInst)
+//{
+//    int i=0;
+//    ChannelInfo_T *pNVRChInfo=NULL;
+
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//    for(i=0;i<MAX_NUM_CHANNELS;i++)
+//    {
+//        if( pBMCInfo->NVRChcfgInfo[i].ChType != 0xff)
+//        {
+//            pNVRChInfo = &pBMCInfo->NVRChcfgInfo[i].ChannelInfo;
+//            if(pChannelInfo->ChannelNumber == pNVRChInfo->ChannelNumber)
+//            {
+//                return (ChannelInfo_T *)&pBMCInfo->NVRChcfgInfo[i].ChannelInfo;
+//            }
+//        }
+//    }
+//    return NULL;
+//}
+
+///**
+//*@fn GetNVRChUserConfigs 
+//*@brief This function is invoked to get NVR User informations of the channel
+//*@param pChannelInfo - Channel Information
+//*@param Filename - Size of the SDR repository
+//*@return Returns Address of user information for the channel on success
+//*              Returns NULL on Failure
+//*/
+//ChannelUserInfo_T* GetNVRChUserConfigs(ChannelInfo_T *pChannelInfo, int BMCInst)
+//{
+//    int i=0;
+//    ChannelInfo_T *pNVRChInfo = NULL;
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    for(i=0;i<MAX_NUM_CHANNELS;i++)
+//    {
+//        if(pBMCInfo->NVRChcfgInfo [i].ChType != 0xff)
+//        {
+//            pNVRChInfo = &pBMCInfo->NVRChcfgInfo[i].ChannelInfo;
+//            if(pChannelInfo->ChannelNumber == pNVRChInfo->ChannelNumber)
+//            {
+//                return (ChannelUserInfo_T *)&pBMCInfo->NVRChcfgInfo[i].ChannelInfo.ChannelUserInfo[0];
+//            }
+//        }
+//    }
+//    return NULL;
+//}
+
+
+
+/*********************************************************************************************
+    Name	:	getSessionInfo
+    Input	:	Arg - Tells the type of data passed in Session
+                Session - Either one of these: session ID, session handle, session index or
+                channel number
+    Output	:	Session Information
+
+This program  returns the session information.
+*********************************************************************************************/
+SessionInfo_T* getSessionInfo (uint8_t Arg,  void *Session)
+{
+   uint8_t				Index;
+   uint8_t				ActiveSesIndex = 0;
+   SessionTblInfo_T*	pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
+
+   for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
+   {
+       if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
+       {
+           continue;
+       }
+       if (TRUE == pSessionTblInfo->SessionTbl[Index].Activated)
+       {
+           ActiveSesIndex++;
+       }
+
+       switch (Arg)
+       {
+       case SESSION_ID_INFO:
+           if(pSessionTblInfo->SessionTbl[Index].SessionID == *((uint32_t *)Session) )
+           {
+               return &pSessionTblInfo->SessionTbl[Index];
+           }
+           break;
+
+       // case SESSION_REMOTE_INFO:
+       //     if(pSessionTblInfo->SessionTbl[Index].RemConSessionID == *((uint32_t *)Session) )
+       //     {
+       //         return &pSessionTblInfo->SessionTbl[Index];
+       //     }
+       //     break;
+
+       case SESSION_HANDLE_INFO:
+           if (pSessionTblInfo->SessionTbl[Index].SessionHandle == *(( uint8_t*)Session) && pSessionTblInfo->SessionTbl[Index].Activated)
+           {
+           	//printf("---> SessionHandle = %#x\n",pSessionTblInfo->SessionTbl[Index].SessionHandle);
+               return &pSessionTblInfo->SessionTbl[Index];
+           }
+           break;
+
+       case SESSION_INDEX_INFO:
+           if (ActiveSesIndex == *(( uint8_t*)Session))
+           {
+               return &pSessionTblInfo->SessionTbl[Index];
+           }
+           break;
+
+       case SESSION_CHANNEL_INFO:
+           if (pSessionTblInfo->SessionTbl[Index].Channel == *(( uint8_t*)Session))
+           {
+               return &pSessionTblInfo->SessionTbl[Index];
+           }
+           break;
+
+       default:
+           return NULL;
+       }
+   }
+   return NULL;
+}
+
+///*********************************************************************************************
+//    Name	: AddChUser
+//    Input	: ChannelUserInfo
+//    Output	: Pointer to the free entry from the channel's user table.
+//This program returns the free entry from the channel's user table.
+//*********************************************************************************************/
+// ChannelUserInfo_T* AddChUser ( ChannelUserInfo_T* pChUserInfo,  uint8_t*	Index, int BMCInst)
+//{
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    *Index =0;
+//    while (*Index <pBMCInfo->IpmiConfig.MaxChUsers)
+//    {
+//        if(FALSE == pChUserInfo->IPMIMessaging )
+//        {
+//            if(pChUserInfo->ID != USER_ID )
+//                return pChUserInfo;
+//        }
+//        (*Index)++;
+//        pChUserInfo++;
+//    }
+//    return NULL;
+//}
+
+
+/*---------------------------------------
+* GetSelTimeStamp
+*---------------------------------------*/
+uint32_t
+GetTimeStamp(void)
+{
+   return (time(NULL));
+}
+
+/*********************************************************************************************
+   Name	:	GetNumOfActiveSessions
+   Input	:	Nothing
+   Output	:	Number of active Sessions
+
+This program returns the number of active session(s) from the session table
+*********************************************************************************************/
+uint8_t GetNumOfActiveSessions (void)
+{
+   uint8_t				Index, Count = 0;
+   SessionTblInfo_T*	pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
+
+   for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
+   {
+       if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
+       {
+           continue;
+       }
+       if (pSessionTblInfo->SessionTbl[Index].Activated)
+           Count++;
+   }
+
+   return Count;
+}
+
+/*********************************************************************************************
+   Name	:	GetNumOfUsedSessions
+   Input	:	Nothing
+   Output	:	Number of used Sessions
+
+This program returns the number of used session(s) from the session table
+*********************************************************************************************/
+uint8_t GetNumOfUsedSessions (void)
+{
+   uint8_t				Index, Count = 0;
+   	SessionTblInfo_T*	pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
+
+   for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
+   {
+       if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
+       {
+           continue;
+       }
+           Count++;
+   }
+
+   return Count;
+}
+
+
+/*********************************************************************************************
+   Name	:	CleanSession
+   Input	:	Nothing
+   Output	:	None
+
+This program delete the oldest session filled but not activate
+*********************************************************************************************/
+uint8_t  CleanSession(void)
+{
+   uint8_t			Index;
+   OldSessionInfo_T     OldSession;
+   SessionTblInfo_T*	pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
+
+   OldSession.Time=0xFFFFFFFF;
+   OldSession.Index= 0xFF;
+
+   for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
+   {
+       if (TRUE == pSessionTblInfo->SessionTbl[Index].Activated)
+       {
+           continue;
+       }
+
+       if(pSessionTblInfo->SessionTbl[Index].Time <OldSession.Time )
+       {
+           OldSession.Time=pSessionTblInfo->SessionTbl[Index].Time;
+           OldSession.Index=Index;
+       }
+   }
+
+   if(OldSession.Index !=0xFF)
+   {
+       pSessionTblInfo->SessionTbl[OldSession.Index].Used = FALSE;
+       pSessionTblInfo->Count--;
+       pSessionTblInfo->SessionTbl[OldSession.Index].Time=0xffffffff;
+   }else
+   {
+       return FALSE;
+   }
+
+   return TRUE;
+}
+
+
+/*********************************************************************************************
+   Name	:	DeleteSession
+   Input	:	pSessionInfo - session information
+   Output	:	Nothing
+
+This program deletes the session from the session table
+*********************************************************************************************/
+void DeleteSession( SessionInfo_T*	pSessionInfo)
+{
+   uint8_t			Index;		 
+   	SessionTblInfo_T*	pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
+   	UserInfo_T*		 pUserInfo;
+      ChannelInfo_T *      pChannelInfo;
+
+
+   for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
+   {
+       if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
+       {
+           continue;
+       }
+
+       if (0 == memcmp (&pSessionTblInfo->SessionTbl[Index], pSessionInfo , sizeof(SessionInfo_T)))
+       {
+           /* We have decrement  the Active session only .If session is activated */
+           if(TRUE ==pSessionTblInfo->SessionTbl[Index].Activated)
+           {
+               // if(!pSessionTblInfo->SessionTbl[Index].IsLoopBack)
+               // {
+               //     pChannelInfo= getChannelInfo(pSessionInfo->Channel);
+               //     if(NULL == pChannelInfo)
+               //     {
+               //         TDBG("Failed to get channel info while Deleting Session for Channel: %d\n",pSessionInfo->Channel);
+               //         return;
+               //     }
+
+               //     if(pChannelInfo!=NULL)
+               //     pChannelInfo->ActiveSession--;
+               //     pUserInfo = getUserIdInfo (pSessionInfo->UserId);
+               //     if (pUserInfo != NULL) { pUserInfo->CurrentSession--; }
+               // }
+               pSessionTblInfo->SessionTbl[Index].Activated=FALSE;
+               pSessionTblInfo->SessionTbl[Index].EventFlag = 0;
+           }
+
+           pSessionTblInfo->SessionTbl[Index].Used = FALSE;
+           pSessionTblInfo->Count--;
+           pSessionTblInfo->SessionTbl[Index].Time=0xFFFFFFFF;
+
+           printf("DeleteSession: SessionID = %lX	Num Session %X\t%x\n",
+           pSessionInfo->SessionID, pSessionTblInfo->Count,Index);
+           return;
+       }
+   }
+
+   return;
+}
+
+/*********************************************************************************************
+   Name	:	AddSession
+   Input	:	pSessionInfo - session information
+   Output	:	Nothing
+
+This program adds the session to the session table
+*********************************************************************************************/
+void AddSession ( SessionInfo_T* pSessionInfo)
+{
+   uint8_t Index;
+   	SessionTblInfo_T*	pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
+
+
+   for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
+   {
+       if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
+       {
+           memcpy (&pSessionTblInfo->SessionTbl[Index], ( uint8_t*)pSessionInfo, sizeof (SessionInfo_T));
+           pSessionTblInfo->SessionTbl[Index].Used = TRUE;
+           pSessionTblInfo->Count++;
+           pSessionTblInfo->SessionTbl[Index].Time= GetTimeStamp ();
+           pSessionTblInfo->SessionTbl[Index].TimeOutValue=g_BMCInfo.IpmiConfig.SessionTimeOut;
+           printf ("AddSession: SessionID   = %lX  Num Session %X\t%x\n",pSessionInfo->SessionID, pSessionTblInfo->Count,Index);
+           break;
+       }
+   }
+
+}
+
+// /*********************************************************************************************
+//    Name	:	getPayloadActiveInst
+//    Input	:	PayloadType
+//    Output	:	Activated Instance information of a given payload type.
+
+// This program returns the information about the activated instances of a given payload type.
+// *********************************************************************************************/
+// uint16_t getPayloadActiveInst (uint8_t PayloadType)
+// {
+//    uint8_t   PayloadIx;
+//    uint8_t   Index;
+//    uint16_t	ActivatedInst = 0;
+//    	SessionTblInfo_T*	pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
+
+
+//    for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
+//    {
+//        if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
+//        {
+//            continue;
+//        }
+//        if (FALSE == pSessionTblInfo->SessionTbl[Index].Activated)
+//        {
+//            continue;
+//        }
+
+//        for (PayloadIx = 0; PayloadIx < MAX_PYLDS_SUPPORT; PayloadIx++)
+//        {
+//            if (pSessionTblInfo->SessionTbl[Index].SessPyldInfo [PayloadIx].Type == PayloadType)
+//            {
+//                ActivatedInst |= pSessionTblInfo->SessionTbl[Index].SessPyldInfo [PayloadIx].ActivatedInst;
+//            }
+//        }
+//    }
+
+//    return ActivatedInst;
+// }
+
+///*********************************************************************************************
+//    Name	:	getPayloadInstInfo
+//    Input	:	Payloadtype, PayloadInst
+//    Output	:	sessionID
+
+//This program  returns the session ID of the session that was activated under the given payload 
+//type and payload instance.
+//*********************************************************************************************/
+// uint32_t getPayloadInstInfo (uint8_t PayloadType, uint16_t PayloadInst, int BMCInst)
+//{
+//    uint8_t   PayloadIx;
+//    uint8_t   Index;
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//    	SessionTblInfo_T*	pSessionTblInfo = &pBMCInfo->SessionTblInfo;
+
+
+//    for (Index = 0; Index < pBMCInfo->IpmiConfig.MaxSession; Index++)
+//    {
+//        if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
+//        {
+//            continue;
+//        }
+//        if (FALSE == pSessionTblInfo->SessionTbl[Index].Activated)
+//        {
+//            continue;
+//        }
+
+//        for (PayloadIx = 0; PayloadIx < MAX_PYLDS_SUPPORT; PayloadIx++)
+//        {
+//            if ((pSessionTblInfo->SessionTbl[Index].SessPyldInfo [PayloadIx].Type == PayloadType)
+//                && (pSessionTblInfo->SessionTbl[Index].SessPyldInfo [PayloadIx].ActivatedInst & (1 << (PayloadInst - 1))))
+//            {
+//                return pSessionTblInfo->SessionTbl[Index].SessionID;
+//            }
+//        }
+//    }
+
+//    return 0;
+//}
+
+static
+MsgPkt_T m_MsgPkt = {
+   PARAM_IFC,
+   0,                  /* Channel number not needed    */
+   0,                /* Source queue not needed      */
+   CMD_PLATFORM_EVENT, /* Cmd                          */
+   (NETFN_SENSOR << 2),/* Net Function                 */
+   PRIV_LOCAL,         /* Privilage                    */
+   0,                  /* Session ID not needed        */
+//   0,
+   WAIT_INFINITE,
+   0,
+   {0},                /* IP Addr not needed           */
+   0,                  /* UDPPort not needed           */
+   0,                  /* Socket  not needed           */
+   sizeof(SELEventRecord_T) + sizeof (IPMIMsgHdr_T) + 1,
+   {
+       0x20,               /* Generator ID             */
+       IPMI_EVM_REVISION,  /* IPMI Version             */
+       SENSOR_TYPE_SECUIRTY_VIOLATION,/*SensorType     */
+       SECUIRTY_VIOLATION_SENSOR_NUMBER,
+       SENSOR_SPECIFIC_READ_TYPE,
+       PW_VIOLATION_OFFSET,
+       0xff,
+       0xff
+   },
+};
+
+/*--------------------------------------------------------------------------*
+* PasswordViolation														*
+*--------------------------------------------------------------------------*/
+void
+PasswordViolation (void)
+{
+   /* Log the AC fail event to SEL	& send an alert */
+   /* Post to Message Hndlr Queue	*/
+   PostMsg ( gFd_MsgHndlrIfc, &m_MsgPkt);
+
+   return;
+}
+
+
+
+/*********************************************************************************************
+   Name	:	UDSSessionTimeOutTask
+   Input	:	void
+   Output	:	void
+       This program  checks for UDS session timeout
+*********************************************************************************************/
+void UDSSessionTimerTask (void)
+{
+   uint8_t Index=0;
+   UDSSessionTblInfo_T *pUDSSessionTblInfo = &g_BMCInfo.UDSSessionTblInfo;
+
+   printf("-> UDSSessionTimerTask\n");
+   for(Index=0;Index<g_BMCInfo.IpmiConfig.MaxSession;Index++)
+  {
+       if(FALSE == pUDSSessionTblInfo->UDSSessionTbl[Index].Activated)
+       {
+          /* Continue until we find the Next Slot which is being used to reduce the timeout */
+           continue;
+       }
+
+       if((pUDSSessionTblInfo->UDSSessionTbl[Index].SessionTimeoutValue <= g_BMCInfo.IpmiConfig.SessionTimeOut) && (pUDSSessionTblInfo->UDSSessionTbl[Index].SessionTimeoutValue != 0))
+       {
+          /* Reduce the Session Timeout Value if the session is not used */
+           pUDSSessionTblInfo->UDSSessionTbl[Index].SessionTimeoutValue--;
+       }
+       else if(pUDSSessionTblInfo->UDSSessionTbl[Index].SessionTimeoutValue <= 0)
+       {
+           DeleteUDSSession(&pUDSSessionTblInfo->UDSSessionTbl[Index]);
+       }
+  }
+}
+
+
+
+/*********************************************************************************************
+   Name	:	GetUDSSessionInfo
+   Input	:	Session - session ID
+   Output	:	Session Information
+
+This program  returns the session information.
+*********************************************************************************************/
+UDSSessionTbl_T* GetUDSSessionInfo (uint8_t Type,void* Data )
+{
+   uint8_t Index;
+    UDSSessionTblInfo_T*	pUDSSessionTblInfo = &g_BMCInfo.UDSSessionTblInfo;
+
+
+   for(Index=0;Index<g_BMCInfo.IpmiConfig.MaxSession;Index++)
+   {
+
+       if(FALSE == pUDSSessionTblInfo->UDSSessionTbl[Index].Activated)
+       {
+           continue;
+       }
+
+       switch(Type)
+       {
+           case UDS_SESSION_ID_INFO:
+               if(*((uint32_t *)Data) == pUDSSessionTblInfo->UDSSessionTbl[Index].SessionID)
+               {
+                    return &pUDSSessionTblInfo->UDSSessionTbl[Index];
+               }
+               break;
+            case UDS_SESSION_HANDLE_INFO:
+               if(*((uint8_t *)Data) == pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInSessionHandle)
+               {
+                    return &pUDSSessionTblInfo->UDSSessionTbl[Index];
+               }
+               break;
+            case UDS_SESSION_INDEX_INFO:
+               if((*((uint8_t *)Data) < g_BMCInfo.IpmiConfig.MaxSession) && ((Index) == *((uint8_t *)Data )))
+               {
+                   return &pUDSSessionTblInfo->UDSSessionTbl[Index];
+               }
+               break;
+            case UDS_SOCKET_ID_INFO:
+               if(*((int *)Data) == pUDSSessionTblInfo->UDSSessionTbl[Index].UDSSocket)
+               {
+                    return &pUDSSessionTblInfo->UDSSessionTbl[Index];
+               }
+               break;
+
+           default:
+               break;
+       }
+   }
+
+   return NULL;
+}
+
+/*********************************************************************************************
+   Name	:	AddUDSSession
+   Input	:	pUDSSessionInfo - session information
+   Output	:	return 0 on success ,-1 on failure
+
+This program adds the session to the UDS session table
+*********************************************************************************************/
+int AddUDSSession ( UDSSessionTbl_T* pUDSSessionInfo)
+{
+
+   uint8_t Index;
+    UDSSessionTblInfo_T*	pUDSSessionTblInfo = &g_BMCInfo.UDSSessionTblInfo;
+
+   for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
+   {
+           if(TRUE == pUDSSessionTblInfo->UDSSessionTbl[Index].Activated)
+           {
+                /* Continue Inorder to get the next Free Slot in UDS Session Table */
+                continue;
+           }
+
+           /* Copy the Session Information to Global BMC Info UDS Session Table */
+           memcpy (&pUDSSessionTblInfo->UDSSessionTbl[Index], ( uint8_t*)pUDSSessionInfo, sizeof (UDSSessionTbl_T));
+           pUDSSessionTblInfo->SessionCount++;
+           pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInTime = GetTimeStamp ();
+           pUDSSessionTblInfo->UDSSessionTbl[Index].SessionTimeoutValue = g_BMCInfo.IpmiConfig.SessionTimeOut;
+           break;
+   }
+
+   if(Index == g_BMCInfo.IpmiConfig.MaxSession)
+   {
+       printf("Add Session Failed for UDS\n");
+       return -1;
+   }
+
+   return 0;
+}
+
+/*********************************************************************************************
+   Name	:	DeleteUDSSession
+   Input	:	pUDSSessionInfo - session information
+   Output	:	return 0 on success,-1 on failure
+
+This program deletes the session from the UDS session table
+*********************************************************************************************/
+int DeleteUDSSession( UDSSessionTbl_T *pUDSSessionInfo )
+{
+   uint8_t Index;
+    UDSSessionTblInfo_T*	pUDSSessionTblInfo = &g_BMCInfo.UDSSessionTblInfo;
+
+   for(Index=0;Index<g_BMCInfo.IpmiConfig.MaxSession;Index++)
+   {
+       if(FALSE == pUDSSessionTblInfo->UDSSessionTbl[Index].Activated)
+       {
+           /* Continue to get the Next Occupied Session Slot in UDS Session Slot*/
+           continue;
+       }
+
+       if (0 == memcmp (&pUDSSessionTblInfo->UDSSessionTbl[Index], pUDSSessionInfo , sizeof(UDSSessionTbl_T)))
+       {
+            /* Resetting the UDS Session Table Slot as the session is no longer required */
+            pUDSSessionTblInfo->UDSSessionTbl[Index].Activated = FALSE;
+            pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInTime = 0xFFFFFFFF;
+            pUDSSessionTblInfo->UDSSessionTbl[Index].SessionTimeoutValue = 0;
+            pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInUserID =  0;
+            pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInChannel = 0xFF;
+            pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInPrivilege = 0xFF;
+            pUDSSessionTblInfo->SessionCount--;
+            break;
+       }
+   }
+
+   if(Index == g_BMCInfo.IpmiConfig.MaxSession)
+   {
+       printf("Delete Session Failed for UDS\n");
+       return -1;
+   }
+
+   return 0;
+}
+
+///*---------------------------------------------------
+// * @fn UpdateGetMsgTime
+// * @brief Updates the Current Uptime and timeout value
+// *        for an IPMI Message
+// * 
+// * @param pReq       : IPMI Message Packet
+// * @param ResTimeOut : Timeout Macro string
+// * @param BMCInst    : BMC Instance
+// * 
+// * @return none
+// *----------------------------------------------------*/
+//void UpdateGetMsgTime (MsgPkt_T* pReq,IfcType_T IfcType, int BMCInst)
+//{
+//    pReq->ReqTime    = 0;
+//    pReq->ResTimeOut = WAIT_INFINITE;
+
+//    if( g_corefeatures.ipmi_res_timeout == ENABLED )
+//    {
+//        int i;
+//        struct sysinfo sys_info;
+//        
+//        for( i = 0; i < TOTAL_INFINITE_CMDS; i++)
+//        {
+//            if( NET_FN(pReq->NetFnLUN) == m_InfiniteCmdsTbl[i].NetFn && pReq->Cmd == m_InfiniteCmdsTbl[i].Cmd )
+//            {
+//                return;
+//            }
+//        }
+//        
+//        if(g_PDKCmdsHandle[PDKCMDS_PDKISINFINITECOMMAND]  != NULL)
+//        {
+//            if( ((BOOL(*)(uint8_t,uint8_t))g_PDKCmdsHandle[PDKCMDS_PDKISINFINITECOMMAND])(NET_FN(pReq->NetFnLUN), pReq->Cmd))
+//            {
+//                return;
+//            }
+//        }
+//        
+//        /* Request UpTime */
+//        if(!sysinfo(&sys_info))
+//        {
+//            pReq->ReqTime    = sys_info.uptime;
+//            if(IfcType == IPMB_IFC)
+//            {
+//                pReq->ResTimeOut = g_coremacros.ipmb_res_timeout;
+//            }
+//            else if(IfcType == LAN_IFC)
+//            {
+//                pReq->ResTimeOut = g_coremacros.lan_res_timeout;
+//            }
+//            else if(IfcType == KCS_IFC)
+//            {
+//                pReq->ResTimeOut = g_coremacros.kcs_res_timeout;
+//            }
+//            else if(IfcType == SERIAL_IFC)
+//            {
+//                pReq->ResTimeOut = g_coremacros.serial_res_timeout;
+//            }
+//        }
+//    }
+//}
+
+///*---------------------------------------------------
+// * @fn IsMsgTimedOut
+// * @brief Checks if the time taken to process 
+// *        the IPMI Command expires
+// * 
+// * @param pReq     : IPMI Message Packet
+// * 
+// * @return 1 if timed out
+// *         0 if error or timeout not set 
+// *----------------------------------------------------*/
+//BOOL IsMsgTimedOut (MsgPkt_T* pReq)
+//{
+//    struct sysinfo sys_info;
+//    
+//    if( pReq->ReqTime && (!sysinfo(&sys_info)) )
+//    {
+//        return ( (sys_info.uptime - pReq->ReqTime) > pReq->ResTimeOut) ? TRUE : FALSE;
+//    }
+//    
+//    return FALSE;
+//}
+
+///*-----------------------------------------------------
+// * @fn IsResponseMatch
+// * @brief Checks if the Response Message corresponds to 
+// *        the Request Message
+// * 
+// * @param pReq    : IPMI Request Message Packet
+// * @param pRes    : IPMI Response Message Packet
+// * 
+// * @return  1 if match
+// *          0 if mismatch
+// *----------------------------------------------------*/
+//BOOL IsResponseMatch (MsgPkt_T* pReq, MsgPkt_T* pRes)
+//{
+
+//    if( ( ((((IPMIMsgHdr_T*)pRes->Data)->RqSeqLUN) >> 2) != ((((IPMIMsgHdr_T*)pReq->Data)->RqSeqLUN) >> 2) ) && 
+//        ( (pReq->NetFnLUN & 0x4) && (NO_RESPONSE != pRes->Param) ) )
+//    {
+//        return FALSE;
+//    }
+//  
+//    return TRUE;
+//}
+
+/*-------------------------------------------------------
+ * @fn FillIPMIResFailure
+ * @brief Frames the Response packet when the time taken 
+ *        to process an IPMI Command expires
+ * 
+ * @param pReq    : IPMI Request Message Packet
+ * @param pRes    : IPMI Response Message Packet
+ *        BMCInst : BMC Instance Number
+ * 
+ * @return  none
+ *------------------------------------------------------*/
+void FillIPMIResFailure ( MsgPkt_T* pReq,  MsgPkt_T* pRes)
+{  
+    /* Set the Cmd and Net function in response packet */
+    pRes->Cmd      = pReq->Cmd;
+    pRes->NetFnLUN = pReq->NetFnLUN & 0xFC;
+    
+    /* Normal IPMI Command response */
+    pRes->Param = PARAM_NORMAL_RESPONSE;
+  
+ 
+	pRes->Size  = sizeof (IPMIMsgHdr_T) + sizeof (uint8_t);
+	pRes->Data[sizeof (IPMIMsgHdr_T)] = CC_TIMEOUT;
+	
+	/* Check for Request Message */
+	if (0 == (pReq->NetFnLUN & 0x04))
+	{
+		/* Swap the header and copy in response */
+		SwapIPMIMsgHdr (( IPMIMsgHdr_T*)pReq->Data, ( IPMIMsgHdr_T*)pRes->Data);
+		
+		/* Calculate Checksum 2 */
+		pRes->Data[pRes->Size] = CalculateCheckSum2 (pRes->Data, pRes->Size);
+		pRes->Size++;
+	}
+}
+
+

+ 251 - 0
app/bmc/Session.h

@@ -0,0 +1,251 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************/
+/*****************************************************************
+ *
+ * Session.h
+ *
+ *
+ * Author: Govind Kothandapani <govindk@ami.com>
+ * 		 : Rama Bisa <ramab@ami.com>
+ *       : Basavaraj Astekar <basavaraja@ami.com>
+ *       : Bakka Ravinder Reddy <bakkar@ami.com>
+ *
+ *****************************************************************/
+#ifndef SESSION_H
+#define SESSION_H
+#include "com_BmcType.h"
+#include "com_IPMI_LANIfc.h"
+#include "com_IPMI_RMCP+.h"
+#include "com_IPMI_AppDevice.h"
+#include "com_IPMIDefs.h"
+#include "com_Message.h"
+#include "PMConfig.h"
+#pragma pack( 1 )
+
+/* Macros */
+#define		SESSION_ID_INFO							1
+#define		SESSION_HANDLE_INFO						2
+#define		SESSION_INDEX_INFO						3
+#define		SESSION_CHANNEL_INFO					4
+#define		MGD_SYS_SESSION_ID_INFO					5
+#define		SESSION_PAYLOAD_INFO					6
+#define		SESSION_REMOTE_INFO					7
+#define		MAX_INST_SUPPORTED						2
+#define		SESSIONLESS_CHANNEL						0x00
+#define		SINGLE_SESSION_CHANNEL					0x01
+#define		MULTI_SESSION_CHANNEL					0x02
+#define		SESSION_BASED_CHANNEL					0x03
+#define		HASH_DATA_LENGTH						16
+#define		NULL_USER_ID							1
+
+#define UDS_SESSION_COUNT_INFO                      0x00
+#define UDS_SESSION_ID_INFO                         0x01
+#define UDS_SESSION_HANDLE_INFO                     0x02
+#define UDS_SESSION_INDEX_INFO                      0x03
+#define UDS_SOCKET_ID_INFO                          0x04
+#define UDS_SESSION_PID_INFO                        0x05
+#define UDS_ACTIVE_SESSION_INDEX_LIST               0x06
+
+/* UDS Session Table Info */
+typedef struct
+{
+   uint32_t SessionID;
+   uint32_t LoggedInTime;
+   uint32_t SessionTimeoutValue;
+   int UDSSocket;
+   uint8_t LoggedInUsername[MAX_USERNAME_LEN];
+   uint8_t LoggedInPassword[MAX_PASSWORD_LEN];
+   uint8_t LoggedInUserID;
+   uint8_t Activated;
+   uint8_t LoggedInSessionHandle;
+   uint8_t UDSChannelNum;
+   uint8_t LoggedInChannel;
+   uint8_t LoggedInPrivilege;
+   uint8_t AuthenticationMechanism;
+   uint32_t ProcessID;
+   uint32_t ThreadID;
+   uint8_t IPAddr [IP6_ADDR_LEN];
+}  UDSSessionTbl_T;
+
+typedef struct
+{
+    uint16_t SessionCount;
+    UDSSessionTbl_T *UDSSessionTbl;
+}  UDSSessionTblInfo_T;
+
+/* SessPayloadInfo_T */
+typedef struct
+{
+    uint8_t    Type;
+    uint8_t    OemPldIANA [3];
+    uint8_t    OemPldID [2];
+    uint8_t    Version;
+    uint16_t    PortNum;
+    uint16_t    ActivatedInst;
+    uint8_t    AuxConfig [4];
+
+}    SessPayloadInfo_T;
+
+
+/*	structure to  keep track the information about a session.	*/
+/* SessionInfo_T */
+typedef struct
+{
+    uint8_t			Used; /* Flag to indicate the slot used or not */
+    uint32_t		SessionID;
+    uint8_t			Activated;
+    uint8_t			Channel;
+    uint8_t			AuthType;
+    uint8_t			Privilege;
+    uint8_t			MaxPrivilege;
+    uint32_t			InboundSeq;
+    uint32_t			OutboundSeq;
+    uint32_t			TimeOutValue;
+    uint8_t			Password[MAX_PASSWORD_LEN];
+    uint8_t			UserId;
+    uint8_t			SessionHandle;
+//     uint8_t			ChallengeString[CHALLENGE_STR_LEN];
+//     LANRMCPPkt_T	LANRMCPPkt;
+//     int			hSocket;
+//     BOOL			SerialModemMode;
+    uint32_t 			Time;
+// #if (IPMI20_SUPPORT == 1)
+//     uint8_t				Lookup;
+//     uint32_t				RemConSessionID;
+//     uint8_t				RemConRandomNo [16];
+//     uint8_t				MgdSysRandomNo [16];
+//     uint8_t				AuthAlgorithm;
+//     uint8_t				IntegrityAlgorithm;
+//     uint8_t				ConfidentialityAlgorithm;
+//     uint8_t				Key1 [MAX_HASH_KEY_SIZE];
+//     uint8_t				Key2 [MAX_HASH_KEY_SIZE];
+//     SessPayloadInfo_T	SessPyldInfo [MAX_PYLDS_SUPPORT];
+// #endif
+//     uint32_t                   InitialInboundSeq;
+//     uint32_t                   InboundTrac[SIXTEEN_COUNT_WINDOW_LEN];
+//     uint16_t                   InboundRecv;
+    uint8_t 			IsLoopBack;
+    uint8_t       Linkstat;
+    uint8_t 			EventFlag;
+    uint8_t                       UserName[MAX_USERNAME_LEN];
+} SessionInfo_T;
+
+/* SessionTblInfo_T */
+typedef	struct
+{
+    uint16_t			Count;
+    SessionInfo_T	*SessionTbl;
+}    SessionTblInfo_T;
+
+
+typedef struct
+{
+    uint32_t Time;
+    uint8_t  Index;
+}   OldSessionInfo_T;
+
+typedef enum
+{
+    KCS_IFC = 0x00,
+    IPMB_IFC,
+    LAN_IFC,
+    SERIAL_IFC,
+}IfcType_T;
+
+#pragma pack( )
+
+// /*--------------------------
+//  * Extern Declarations
+//  *--------------------------*/
+extern		 void				SessionTimerTask (void);
+// extern  ChannelInfo_T*  getChannelInfo (uint8_t ch );
+// extern _FAR_ ChannelUserInfo_T* getChUserIdInfo (uint8_t userId, _NEAR_ uint8_t *index, _FAR_ ChannelUserInfo_T* pChUserInfo, int BMCInst);
+extern SessionInfo_T*		getSessionInfo (uint8_t Arg, void *Session);
+// extern _FAR_ ChannelUserInfo_T* getChUserPrivInfo (_NEAR_ char *userName, _NEAR_ uint8_t Role, _NEAR_ uint8_t* chIndex, _FAR_ ChannelUserInfo_T *pChUserInfo, int BMCInst);
+// extern _FAR_ ChannelUserInfo_T*	getChUserInfo (_NEAR_ char *userName, _NEAR_ uint8_t* chIndex, _FAR_ ChannelUserInfo_T *pChUserInfo, int BMCInst);
+extern int UpdateUserInfoTable(void);
+extern UserInfo_T*		getUserIdInfo (uint8_t userId);
+extern  UserInfo_T* getUserNameInfo (uint8_t *UserName);
+extern uint8_t	CheckForDuplicateUsers (uint8_t* UserName);
+// extern _FAR_ ChannelUserInfo_T*	AddChUser (_FAR_ ChannelUserInfo_T*	pChUserInfo, _NEAR_ uint8_t*	Index );
+// extern _FAR_ ChannelInfo_T* GetNVRChConfigs(ChannelInfo_T *pChannelInfo, int BMCInst);
+// extern _FAR_ ChannelUserInfo_T* GetNVRChUserConfigs(ChannelInfo_T *pChannelInfo );
+// extern uint8_t disableUser (uint8_t UserId, int BMCInst);
+extern uint8_t GetNumOfActiveSessions (void);
+extern uint8_t GetNumOfUsedSessions (void);
+extern void  DeleteSession (SessionInfo_T*	pSessionInfo );
+extern void  AddSession (SessionInfo_T* pSessionInfo );
+extern uint8_t CleanSession(void);
+// extern _FAR_ uint16_t	getPayloadActiveInst (uint8_t PayloadType, int BMCInst);
+// extern _FAR_ uint32_t	getPayloadInstInfo (uint8_t PayloadType, uint16_t PayloadInst );
+extern void	PasswordViolation (void);
+extern void UDSSessionTimerTask (void);
+extern int AddUDSSession (UDSSessionTbl_T* pUDSSessionInfo);
+extern int DeleteUDSSession(UDSSessionTbl_T*  pUDSSessionInfo );
+extern UDSSessionTbl_T* GetUDSSessionInfo (uint8_t Type,void *Data );
+// /*---------------------------------------------------
+//  * @fn UpdateGetMsgTime
+//  * @brief Updates the Current Uptime and timeout value
+//  *        for an IPMI Message
+//  * 
+//  * @param pReq       : IPMI Message Packet
+//  * @param ResTimeOut : Timeout Macro string
+//  * @param BMCInst    : BMC Instance
+//  * 
+//  * @return none
+//  *----------------------------------------------------*/
+
+// extern void UpdateGetMsgTime (MsgPkt_T* pReq,IfcType_T IfcType, int BMCInst);
+
+// /*---------------------------------------------------
+//  * @fn IsMsgTimedOut
+//  * @brief Checks if the time taken to process 
+//  *        the IPMI Command expires
+//  * 
+//  * @param pReq     : IPMI Message Packet
+//  * 
+//  * @return 1 if timed out
+//  *         0 if error or timeout not set 
+//  *----------------------------------------------------*/
+
+// extern BOOL IsMsgTimedOut (MsgPkt_T* pReq);
+
+// /*-----------------------------------------------------
+//  * @fn IsResponseMatch
+//  * @brief Checks if the Response Message corresponds to 
+//  *        the Request Message
+//  * 
+//  * @param pReq    : IPMI Request Message Packet
+//  * @param pRes    : IPMI Response Message Packet
+//  * 
+//  * @return  1 if match
+//  *          0 if mismatch
+//  *----------------------------------------------------*/
+
+// extern BOOL IsResponseMatch (MsgPkt_T* pReq, MsgPkt_T* pRes);
+
+/*-------------------------------------------------------
+ * @fn FillIPMIResFailure
+ * @brief Frames the Response packet when the time taken 
+ *        to process an IPMI Command expires
+ * 
+ * @param pReq    : Request Message Packet
+ *        pRes    : Response Message Packet
+ *        BMCInst : BMC Instance Number
+ * 
+ * @return  none
+ *------------------------------------------------------*/
+extern void FillIPMIResFailure ( MsgPkt_T* pReq, MsgPkt_T* pRes);
+
+#endif	/* SESSION_H */

+ 73 - 0
app/bmc/SysTimer/TimerTask.c

@@ -0,0 +1,73 @@
+/*
+* Brief:	Micellaneous Ticks increment every 1 second.
+			Record system power on times.
+* Author:	Jimbo_Zhang@outlook.com
+* Date:		2019-9-16
+*/
+
+#include "TimerTask.h"
+#include "time.h"
+#include <stdint.h>
+#include "main.h"
+
+static void ProcessTimerReq (void);
+
+//g_BMCInfo.CurTimerTick increment in port.c/xPortSysTickHandler().
+void *TimerTask( void *pvParameters )
+{	
+	uint32_t preTimerTick = g_BMCInfo.CurTimerTick;
+	printf("TimerTask start...\n");
+	while(1)
+	{
+		preTimerTick = g_BMCInfo.CurTimerTick;
+		g_BMCInfo.SELTimeSecond++;
+	
+		if(g_BMCInfo.SensorSharedMem.SensorTick < 0xffffffff)	
+			g_BMCInfo.SensorSharedMem.SensorTick++;
+		
+		if(g_BMCInfo.SenConfig.PowerOnTick < 0xffffffff)
+			g_BMCInfo.SenConfig.PowerOnTick++;
+		
+		if(g_BMCInfo.SenConfig.SysResetTick < 0xffffffff)
+			g_BMCInfo.SenConfig.SysResetTick++;
+		
+		g_BMCInfo.CurTimerSecond++;
+		if(g_BMCInfo.PowerGoodFlag && (g_BMCInfo.CurTimerSecond%60 == 0))	// 1minute
+		{
+			g_BMCInfo.BootValidMinutes++;
+			g_BMCInfo.TotalBootValidMinutes++;
+		}
+
+		//ProcessTimerReq();
+
+		sleep(1);
+	}
+}
+
+
+/**
+*@fn ProcessTimerReq
+*@brief Executes Timer task function for every one second
+*@return none
+*/
+static void ProcessTimerReq (void)
+{
+	int i;
+	// if(g_corefeatures.delayed_lan_restart_support)
+	// {
+	// 	ElapsedTime++;
+	// }
+	for (i = 0; i < g_BMCInfo.TimerTaskTblSize; i++)
+	{
+		if (0 == (g_BMCInfo.CurTimerTick % g_BMCInfo.TimerTaskTbl [i].NumSecs))
+		{
+			g_BMCInfo.TimerTaskTbl [i].TimerFn ();
+		}
+	}
+	return;
+}
+
+
+
+
+

+ 6 - 0
app/bmc/SysTimer/TimerTask.h

@@ -0,0 +1,6 @@
+#ifndef __TIMER_TASK_H__
+#define __TIMER_TASK_H__
+
+void *TimerTask( void *pvParameters );
+
+#endif

BIN
app/bmc/bmc_app


BIN
app/bmc/bmc_app.gdb


+ 91 - 0
app/bmc/encryption/AuthCode.c

@@ -0,0 +1,91 @@
+/******************************************************************
+ ******************************************************************
+ ***                                                             **
+ ***    (C)Copyright 2008-2009, American Megatrends Inc.         **
+ ***                                                             **
+ ***    All Rights Reserved.                                     **
+ ***                                                             **
+ ***    5555 , Oakbrook Pkwy, Norcross,                          **
+ ***                                                             **
+ ***    Georgia - 30093, USA. Phone-(770)-246-8600.              **
+ ***                                                             **
+ ******************************************************************
+ ******************************************************************
+ ******************************************************************
+ *
+ * AuthCode.c
+ * Authentication Code Caluculation
+ *
+ *  Author: Winston <winstonv@amiindia.co.in>
+ ******************************************************************/
+#include "RMCP.h"
+#include "MD.h"
+#include <string.h>
+#include <stdint.h>
+#include "com_IPMIDefs.h"
+#include "com_IPMI_RMCP.h"
+#include "com_IPMI_AppDevice.h"
+#include "Session.h"
+
+/**
+ * @fn ComputeAuthCode
+ * @brief Compute authentication code.
+ * @param pPassword     - User password.
+ * @param pSessionHdr   - Session header RMCP message.
+ * @param pIPMIMsg      - IPMI message payload.
+ * @param pAuthCode     - Authentication Code being generated.
+ * @param ChannelType   - Channel Type.
+**/
+void
+ComputeAuthCode ( uint8_t* pPassword,  SessionHdr_T* pSessionHdr,
+                  IPMIMsgHdr_T* pIPMIMsg,  uint8_t* pAuthCode,
+                 uint8_t ChannelType)
+{
+    if (AUTH_TYPE_PASSWORD == pSessionHdr->AuthType)
+    {
+        memcpy (pAuthCode, pPassword, IPMI15_MAX_PASSWORD_LEN);
+    }
+    else
+    {
+        uint8_t   AuthBuf [MAX_AUTH_PARAM_SIZE];
+        uint16_t  AuthBufLen = 0;
+        uint8_t   IPMIMsgLen = *(( uint8_t*) pIPMIMsg - 1);
+
+        /* Password */
+        memcpy (AuthBuf, pPassword, IPMI15_MAX_PASSWORD_LEN);
+        AuthBufLen += IPMI15_MAX_PASSWORD_LEN;
+        /* Session ID */
+        memcpy ((uint8_t*)(AuthBuf + AuthBufLen), (uint8_t*)(&pSessionHdr->SessionID), sizeof (uint32_t));
+        AuthBufLen += sizeof (uint32_t);
+        /* IPMI Response Message */
+        memcpy (AuthBuf + AuthBufLen, pIPMIMsg, IPMIMsgLen);
+        AuthBufLen += IPMIMsgLen;
+
+        if (ChannelType == MULTI_SESSION_CHANNEL)
+        {
+            /* Session Sequence Number */
+            memcpy ((uint8_t*)(AuthBuf + AuthBufLen), (uint8_t*)(&pSessionHdr->SessionSeqNum), sizeof (uint32_t));
+            AuthBufLen += sizeof (uint32_t);
+        }
+        /* Password */
+        memcpy (AuthBuf + AuthBufLen, pPassword, IPMI15_MAX_PASSWORD_LEN);
+        AuthBufLen += IPMI15_MAX_PASSWORD_LEN;
+
+        switch (pSessionHdr->AuthType)
+        {
+        case AUTH_TYPE_MD2 :
+            AuthCodeCalMD2 (AuthBuf, pAuthCode, AuthBufLen);
+            break;
+
+        case AUTH_TYPE_MD5 :
+            AuthCodeCalMD5 (AuthBuf, pAuthCode, AuthBufLen);
+            break;
+
+        default  :
+            printf ("RMCP.c : Invalid Authentication Type \r\n");
+        }
+    }
+}
+
+
+

+ 15 - 0
app/bmc/encryption/AuthCode.h

@@ -0,0 +1,15 @@
+#ifndef __AUTH_CODE_H__
+#define __AUTH_CODE_H__
+
+#include <stdint.h>
+#include "com_IPMIDefs.h"
+#include "com_IPMI_RMCP.h"
+
+
+void
+ComputeAuthCode ( uint8_t* pPassword,  SessionHdr_T* pSessionHdr,
+                  IPMIMsgHdr_T* pIPMIMsg,  uint8_t* pAuthCode,
+                 uint8_t ChannelType);
+
+
+#endif                

+ 14 - 12
app/bmc_server/ipmi_dev/MD.h → app/bmc/encryption/MD.h

@@ -24,7 +24,9 @@
  *****************************************************************/
 #ifndef MD_H
 #define MD_H
-#include "Types.h"
+#include <stdint.h>
+#include "com_BmcType.h"
+#include "com_IPMIDefs.h"
 
 #pragma pack( 1 )
 
@@ -39,28 +41,28 @@
 /* MD2Context_T */
 typedef struct 
 {
-    INT8U		State[16];      /* state */
-    INT8U		Checksum[16];   /* checksum */
-    INT8U		Count;			/* number of bytes, modulo 16 */
-    INT8U		Buffer[16];     /* input buffer */
-} PACKED  MD2Context_T;
+    uint8_t		State[16];      /* state */
+    uint8_t		Checksum[16];   /* checksum */
+    uint8_t		Count;			/* number of bytes, modulo 16 */
+    uint8_t		Buffer[16];     /* input buffer */
+}    MD2Context_T;
 
 
 /* MD5Context_T */
 typedef struct 
 {
-    INT32U	state[4];		/* state (ABCD) */
-    INT32U	count[2];		/* number of bits, modulo 2^64 (lsb first) */
-    INT8U		buffer[64];		/* input buffer */
-} PACKED  MD5Context_T;
+    uint32_t	state[4];		/* state (ABCD) */
+    uint32_t	count[2];		/* number of bits, modulo 2^64 (lsb first) */
+    uint8_t		buffer[64];		/* input buffer */
+}    MD5Context_T;
 
 #pragma pack( )
 
 /*--------------------------
  * Extern Declarations
  *--------------------------*/
-extern void AuthCodeCalMD2 (_NEAR_ INT8U* String, _NEAR_ INT8U*	MD2Result, INT8U StrLen);
-extern void AuthCodeCalMD5 (_NEAR_ INT8U* Str, _NEAR_ INT8U* MD5Result, INT16U StrLen);
+extern void AuthCodeCalMD2 (  uint8_t* String,   uint8_t*	MD2Result, uint8_t StrLen);
+extern void AuthCodeCalMD5 (  uint8_t* Str,   uint8_t* MD5Result, uint16_t StrLen);
 
 #endif	/* MD_H */
 

+ 93 - 0
app/bmc/encryption/MD2.c

@@ -0,0 +1,93 @@
+/* MD2.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ * 
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to.  The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ * 
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *    "This product includes cryptographic software written by
+ *     Eric Young (eay@cryptsoft.com)"
+ *    The word 'cryptographic' can be left out if the rouines from the library
+ *    being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from 
+ *    the apps directory (application code) you must include an acknowledgement:
+ *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ * 
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * 
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed.  i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+
+#include "com_BmcType.h"
+#include "com_IPMIDefs.h"
+#include "md2.h"
+
+
+#define MD2Context_T    MD2_CTX
+#define MD2Init         MD2_Init
+#define MD2Update       MD2_Update
+#define MD2Final        MD2_Final
+
+/*********************************************************************************************
+    Name    :   AuthCodeCalMD2
+    Input   : Test string and a buffer of 16 bytes to store the digest.
+    Output  : Encrypted message in the buffer.
+    Return  : NONE
+     This program digests a string and prints the result.
+*********************************************************************************************/
+extern void AuthCodeCalMD2 (   uint8_t*  String,     /*test string*/
+                               uint8_t*  MD2Result,  /*result of MD2 digest*/
+                                    uint8_t   StrLen      /*Length of input string */
+                            )
+{
+  MD2Context_T  MD2Context;
+  uint8_t         Digest[16];
+
+  MD2Init (&MD2Context);
+  MD2Update (&MD2Context, String, StrLen);
+  MD2Final (Digest, &MD2Context);
+  memcpy(MD2Result, Digest, 16);
+}

+ 70 - 0
app/bmc/encryption/MD5.c

@@ -0,0 +1,70 @@
+/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
+ */
+
+/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+   rights reserved.
+
+   License to copy and use this software is granted provided that it
+   is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+   Algorithm" in all material mentioning or referencing this software
+   or this function.
+
+   License is also granted to make and use derivative works provided
+   that such works are identified as "derived from the RSA Data
+   Security, Inc. MD5 Message-Digest Algorithm" in all material
+   mentioning or referencing the derived work.  
+                                                                    
+   RSA Data Security, Inc. makes no representations concerning either
+   the merchantability of this software or the suitability of this
+   software for any particular purpose. It is provided "as is"
+   without express or implied warranty of any kind.  
+                                                                    
+   These notices must be retained in any copies of any part of this
+   documentation and/or software.  
+ */
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include "com_BmcType.h"
+#include "com_IPMIDefs.h"
+#include "md5.h"
+
+#define MD_CTX MD5_CTX
+#define MDInit MD5_Init
+#define MDUpdate MD5_Update
+#define MDFinal MD5_Final
+
+/*
+    INPUT  : Test string , buffer of 16 bytes to
+                store the digest,length of the string
+    OUTPUT	: Encrypted message in the buffer.
+    RETURN	: NONE
+    PROCESS	:Digests a string and prints the result.
+ */
+extern void AuthCodeCalMD5(
+          uint8_t  *string, 	/*test string */
+          uint8_t  *MD5Result,  /*result of MD5 digest*/
+          uint16_t LengthOfstring /*Length of input string */
+          )
+{
+    MD_CTX context;
+    uint8_t  digest[16];
+    MDInit (&context);
+    MDUpdate (&context, string, LengthOfstring);
+    MDFinal (digest, &context);
+    memcpy(MD5Result,digest,16);
+
+}
+unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md)
+{
+    MD5_CTX c;
+    static unsigned char m[16];
+
+    if (md == NULL) md=m;
+    MD5_Init(&c);
+    MD5_Update(&c,(unsigned char *)d,n);
+    MD5_Final(md,&c);
+//    OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */
+    return(md);
+}

+ 41 - 18
app/bmc_server/ipmi_dev/UDSIfc.h → app/bmc/encryption/MD5_128.c

@@ -10,31 +10,54 @@
  **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
  **                                                            **
  ****************************************************************
- ****************************************************************/
-/*****************************************************************
+ *****************************************************************
  *
- * UDSIfc.h
+ *   Md5_128.c   
+ *   This Code is taken from RFC 1321(RFC1321)
  *
- * Author: Suresh V <sureshv@amiindia.com>
  *
  *****************************************************************/
 
-#ifndef UDSIFC_H
-#define UDSIFC_H
 
-#define MAX_UDS_BUFFER_SIZE 1024*60
-#define UDS_SMB_PARAM 1
-#define UDS_TIMER_INTERVAL 10
+#include "md5.h"
 
-/* This Channel Number is decided based on the Reserved Channel Number List as per IPMI Specification 
-The Reserved Channel Numbers are 0x0C-0x0D*/
-#define UDS_CHANNEL 0x0D
 
-#define SOCKET_PATH_LEN 108
+/******************************************************************************      
+*
+*	Name
+*		MD5_128
+*	
+*	Abstract: 	
+*  		Function to compute the digest using MD5.
+*
+*	Context/Scope:	
+*   	Called from anywhere.
+*
+*	Side Effects:
+*
+*	Return Value:
+*		None
+* 
+*	Assumptions:
+*	   None
+*
+******************************************************************************/
+void MD5_128(char*    k,     /* secret key */
+		 int      lk,    /* length of the key in bytes */
+		 char*    d,     /* data */
+		 int      ld,    /* length of data in bytes */
+		 char*    out,   /* output buffer, at least "t" bytes */
+		 int      t )
+{
+      MD5_CTX ctx;
+      MD5_Init(&ctx) ;
+
+      MD5_Update(&ctx, (unsigned char *) k, lk) ;
+      MD5_Update(&ctx, (unsigned char *) d, ld) ;
+	// Added this to match the MD5 for user password integrity
+      MD5_Update(&ctx, (unsigned char *) k, lk) ;
+
+      MD5_Final((unsigned char *) out,&ctx ) ;
+}
 
-#define UDS_SUCCESS 0
-#define UDS_CMD_FAILURE 1
-#define UDS_FAILURE -1
-#define UDS_PARAM_FAILURE -2
 
-#endif /* UDSIFC_H */

+ 23 - 24
app/bmc_server/ipmi_dev/LEDMap.h → app/bmc/encryption/MD5_128.h

@@ -1,24 +1,23 @@
-/****************************************************************
- ****************************************************************
- **                                                            **
- **    (C)Copyright 2005-2006, American Megatrends Inc.        **
- **                                                            **
- **            All Rights Reserved.                            **
- **                                                            **
- **        6145-F, Northbelt Parkway, Norcross,                **
- **                                                            **
- **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
- **                                                            **
- ****************************************************************
- ****************************************************************/
-/*****************************************************************
- *
- * LEDMap.h
- * LED Control Functions
- *
- *
- *****************************************************************/
-#ifndef _LEDMAP_H
-#define _LEDMAP_H
-
-#endif
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ *****************************************************************
+ *
+ *   Md5_128.c   
+ *   This Code is taken from RFC 1321(RFC1321)
+ *
+ *
+ *****************************************************************/
+
+
+extern void MD5_128(char*    k,int      lk, char*    d,  int      ld, char*    out, int      t );
+

+ 88 - 0
app/bmc/encryption/md2.h

@@ -0,0 +1,88 @@
+/* crypto/md/md2.h */
+/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to.  The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *    "This product includes cryptographic software written by
+ *     Eric Young (eay@cryptsoft.com)"
+ *    The word 'cryptographic' can be left out if the rouines from the library
+ *    being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ *    the apps directory (application code) you must include an acknowledgement:
+ *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed.  i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef HEADER_MD2_H
+#define HEADER_MD2_H
+
+#define MD2_INT unsigned int
+
+#define MD2_DIGEST_LENGTH	16
+#define MD2_BLOCK       	16
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+typedef struct MD2state_st
+	{
+	unsigned int num;
+	unsigned char data[MD2_BLOCK];
+	MD2_INT cksm[MD2_BLOCK];
+	MD2_INT state[MD2_BLOCK];
+	} MD2_CTX;
+
+const char *MD2_options(void);
+int MD2_Init(MD2_CTX *c);
+int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len);
+int MD2_Final(unsigned char *md, MD2_CTX *c);
+unsigned char *MD2(const unsigned char *d, size_t n,unsigned char *md);
+#ifdef  __cplusplus
+}
+#endif
+
+#endif

+ 171 - 0
app/bmc/encryption/md2_dgst.c

@@ -0,0 +1,171 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+//#include <openssl/md2.h>
+//#include <openssl/opensslv.h>
+//#include <openssl/crypto.h>
+#include "md2.h"
+
+//const char *MD2_version="MD2" OPENSSL_VERSION_PTEXT;
+
+/* Implemented from RFC1319 The MD2 Message-Digest Algorithm
+ */
+
+#define UCHAR	unsigned char
+
+static void md2_block(MD2_CTX *c, const unsigned char *d);
+/* The magic S table - I have converted it to hex since it is
+ * basically just a random byte string. */
+static const MD2_INT S[256]={
+	0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01,
+	0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13,
+	0x62, 0xA7, 0x05, 0xF3, 0xC0, 0xC7, 0x73, 0x8C,
+	0x98, 0x93, 0x2B, 0xD9, 0xBC, 0x4C, 0x82, 0xCA,
+	0x1E, 0x9B, 0x57, 0x3C, 0xFD, 0xD4, 0xE0, 0x16,
+	0x67, 0x42, 0x6F, 0x18, 0x8A, 0x17, 0xE5, 0x12,
+	0xBE, 0x4E, 0xC4, 0xD6, 0xDA, 0x9E, 0xDE, 0x49,
+	0xA0, 0xFB, 0xF5, 0x8E, 0xBB, 0x2F, 0xEE, 0x7A,
+	0xA9, 0x68, 0x79, 0x91, 0x15, 0xB2, 0x07, 0x3F,
+	0x94, 0xC2, 0x10, 0x89, 0x0B, 0x22, 0x5F, 0x21,
+	0x80, 0x7F, 0x5D, 0x9A, 0x5A, 0x90, 0x32, 0x27,
+	0x35, 0x3E, 0xCC, 0xE7, 0xBF, 0xF7, 0x97, 0x03,
+	0xFF, 0x19, 0x30, 0xB3, 0x48, 0xA5, 0xB5, 0xD1,
+	0xD7, 0x5E, 0x92, 0x2A, 0xAC, 0x56, 0xAA, 0xC6,
+	0x4F, 0xB8, 0x38, 0xD2, 0x96, 0xA4, 0x7D, 0xB6,
+	0x76, 0xFC, 0x6B, 0xE2, 0x9C, 0x74, 0x04, 0xF1,
+	0x45, 0x9D, 0x70, 0x59, 0x64, 0x71, 0x87, 0x20,
+	0x86, 0x5B, 0xCF, 0x65, 0xE6, 0x2D, 0xA8, 0x02,
+	0x1B, 0x60, 0x25, 0xAD, 0xAE, 0xB0, 0xB9, 0xF6,
+	0x1C, 0x46, 0x61, 0x69, 0x34, 0x40, 0x7E, 0x0F,
+	0x55, 0x47, 0xA3, 0x23, 0xDD, 0x51, 0xAF, 0x3A,
+	0xC3, 0x5C, 0xF9, 0xCE, 0xBA, 0xC5, 0xEA, 0x26,
+	0x2C, 0x53, 0x0D, 0x6E, 0x85, 0x28, 0x84, 0x09,
+	0xD3, 0xDF, 0xCD, 0xF4, 0x41, 0x81, 0x4D, 0x52,
+	0x6A, 0xDC, 0x37, 0xC8, 0x6C, 0xC1, 0xAB, 0xFA,
+	0x24, 0xE1, 0x7B, 0x08, 0x0C, 0xBD, 0xB1, 0x4A,
+	0x78, 0x88, 0x95, 0x8B, 0xE3, 0x63, 0xE8, 0x6D,
+	0xE9, 0xCB, 0xD5, 0xFE, 0x3B, 0x00, 0x1D, 0x39,
+	0xF2, 0xEF, 0xB7, 0x0E, 0x66, 0x58, 0xD0, 0xE4,
+	0xA6, 0x77, 0x72, 0xF8, 0xEB, 0x75, 0x4B, 0x0A,
+	0x31, 0x44, 0x50, 0xB4, 0x8F, 0xED, 0x1F, 0x1A,
+	0xDB, 0x99, 0x8D, 0x33, 0x9F, 0x11, 0x83, 0x14,
+	};
+
+const char *MD2_options(void)
+	{
+	if (sizeof(MD2_INT) == 1)
+		return("md2(char)");
+	else
+		return("md2(int)");
+	}
+
+int MD2_Init(MD2_CTX *c)
+	{
+	c->num=0;
+	memset(c->state,0,sizeof c->state);
+	memset(c->cksm,0,sizeof c->cksm);
+	memset(c->data,0,sizeof c->data);
+	return 1;
+	}
+
+int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len)
+	{
+	register UCHAR *p;
+
+	if (len == 0) return 1;
+
+	p=c->data;
+	if (c->num != 0)
+		{
+		if ((c->num+len) >= MD2_BLOCK)
+			{
+			memcpy(&(p[c->num]),data,MD2_BLOCK-c->num);
+			md2_block(c,c->data);
+			data+=(MD2_BLOCK - c->num);
+			len-=(MD2_BLOCK - c->num);
+			c->num=0;
+			/* drop through and do the rest */
+			}
+		else
+			{
+			memcpy(&(p[c->num]),data,len);
+			/* data+=len; */
+			c->num+=(int)len;
+			return 1;
+			}
+		}
+	/* we now can process the input data in blocks of MD2_BLOCK
+	 * chars and save the leftovers to c->data. */
+	while (len >= MD2_BLOCK)
+		{
+		md2_block(c,data);
+		data+=MD2_BLOCK;
+		len-=MD2_BLOCK;
+		}
+	memcpy(p,data,len);
+	c->num=(int)len;
+	return 1;
+	}
+
+static void md2_block(MD2_CTX *c, const unsigned char *d)
+	{
+	register MD2_INT t,*sp1,*sp2;
+	register int i,j;
+	MD2_INT state[48];
+
+	sp1=c->state;
+	sp2=c->cksm;
+	j=sp2[MD2_BLOCK-1];
+	for (i=0; i<16; i++)
+		{
+		state[i]=sp1[i];
+		state[i+16]=t=d[i];
+		state[i+32]=(t^sp1[i]);
+		j=sp2[i]^=S[t^j];
+		}
+	t=0;
+	for (i=0; i<18; i++)
+		{
+		for (j=0; j<48; j+=8)
+			{
+			t= state[j+ 0]^=S[t];
+			t= state[j+ 1]^=S[t];
+			t= state[j+ 2]^=S[t];
+			t= state[j+ 3]^=S[t];
+			t= state[j+ 4]^=S[t];
+			t= state[j+ 5]^=S[t];
+			t= state[j+ 6]^=S[t];
+			t= state[j+ 7]^=S[t];
+			}
+		t=(t+i)&0xff;
+		}
+	memcpy(sp1,state,16*sizeof(MD2_INT));
+	//OPENSSL_cleanse(state,48*sizeof(MD2_INT));
+	}
+
+int MD2_Final(unsigned char *md, MD2_CTX *c)
+	{
+	int i,v;
+	register UCHAR *cp;
+	register MD2_INT *p1,*p2;
+
+	cp=c->data;
+	p1=c->state;
+	p2=c->cksm;
+	v=MD2_BLOCK-c->num;
+	for (i=c->num; i<MD2_BLOCK; i++)
+		cp[i]=(UCHAR)v;
+
+	md2_block(c,cp);
+
+	for (i=0; i<MD2_BLOCK; i++)
+		cp[i]=(UCHAR)p2[i];
+	md2_block(c,cp);
+
+	for (i=0; i<16; i++)
+		md[i]=(UCHAR)(p1[i]&0xff);
+	memset((char *)&c,0,sizeof(c));
+	return 1;
+	}
+

+ 59 - 0
app/bmc/encryption/md5.h

@@ -0,0 +1,59 @@
+/* MD5.H - header file for MD5C.C
+ */
+
+/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+   rights reserved.
+
+   License to copy and use this software is granted provided that it
+   is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+   Algorithm" in all material mentioning or referencing this software
+   or this function.
+
+   License is also granted to make and use derivative works provided
+   that such works are identified as "derived from the RSA Data
+   Security, Inc. MD5 Message-Digest Algorithm" in all material
+   mentioning or referencing the derived work.  
+                                                                    
+   RSA Data Security, Inc. makes no representations concerning either
+   the merchantability of this software or the suitability of this
+   software for any particular purpose. It is provided "as is"
+   without express or implied warranty of any kind.  
+                                                                    
+   These notices must be retained in any copies of any part of this
+   documentation and/or software.  
+ */
+
+#ifndef _MD5_H_
+#define _MD5_H_ 1
+
+#include <stdint.h>
+#include <unistd.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef UINT4
+#define UINT4 unsigned int
+#endif
+
+#ifndef POINTER
+#define POINTER unsigned char *
+#endif
+/* MD5 context. */
+typedef struct {
+  UINT4 state[4];                                   /* state (ABCD) */
+  UINT4 count[2];        /* number of bits, modulo 2^64 (lsb first) */
+  unsigned char buffer[64];                         /* input buffer */
+} MD5_CTX;
+
+void MD5_Init (MD5_CTX *context);
+void MD5_Update (MD5_CTX * context, unsigned char * input, unsigned int inputLen);
+void MD5_Final (unsigned char digest[16], MD5_CTX *context);
+unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /* _MD5_H_ */

+ 311 - 0
app/bmc/encryption/md5c.c

@@ -0,0 +1,311 @@
+/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
+ */
+
+/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+   rights reserved.
+
+   License to copy and use this software is granted provided that it
+   is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+   Algorithm" in all material mentioning or referencing this software
+   or this function.
+
+   License is also granted to make and use derivative works provided
+   that such works are identified as "derived from the RSA Data
+   Security, Inc. MD5 Message-Digest Algorithm" in all material
+   mentioning or referencing the derived work.  
+                                                                    
+   RSA Data Security, Inc. makes no representations concerning either
+   the merchantability of this software or the suitability of this
+   software for any particular purpose. It is provided "as is"
+   without express or implied warranty of any kind.  
+                                                                    
+   These notices must be retained in any copies of any part of this
+   documentation and/or software.  
+ */
+
+#include "md5.h"
+
+/* Constants for MD5Transform routine.
+ */
+#define S11 7
+#define S12 12
+#define S13 17
+#define S14 22
+#define S21 5
+#define S22 9
+#define S23 14
+#define S24 20
+#define S31 4
+#define S32 11
+#define S33 16
+#define S34 23
+#define S41 6
+#define S42 10
+#define S43 15
+#define S44 21
+
+static void MD5Transform (UINT4 state[4], unsigned char block[64]);
+static void Encode (unsigned char *output, UINT4 *input, unsigned int len);
+static void Decode (UINT4 *output, unsigned char *input, unsigned int len);
+static void MD5_memcpy (unsigned char *output, unsigned char *input, unsigned int len);
+static void MD5_memset (unsigned char *output, int value, unsigned int len);
+
+static unsigned char PADDING[64] = {
+  0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/* F, G, H and I are basic MD5 functions.
+ */
+#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
+#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define I(x, y, z) ((y) ^ ((x) | (~z)))
+
+/* ROTATE_LEFT rotates x left n bits.
+ */
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
+   Rotation is separate from addition to prevent recomputation.
+ */
+#define FF(a, b, c, d, x, s, ac) { \
+    (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
+    (a) = ROTATE_LEFT ((a), (s)); \
+    (a) += (b); \
+  }
+#define GG(a, b, c, d, x, s, ac) { \
+    (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
+    (a) = ROTATE_LEFT ((a), (s)); \
+    (a) += (b); \
+  }
+#define HH(a, b, c, d, x, s, ac) { \
+    (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
+    (a) = ROTATE_LEFT ((a), (s)); \
+    (a) += (b); \
+  }
+#define II(a, b, c, d, x, s, ac) { \
+    (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
+    (a) = ROTATE_LEFT ((a), (s)); \
+    (a) += (b); \
+  }
+
+/* MD5 initialization. Begins an MD5 operation, writing a new context.
+ */
+void MD5_Init (MD5_CTX *context)
+{
+  context->count[0] = context->count[1] = 0;
+
+  /* Load magic initialization constants.
+   */
+  context->state[0] = 0x67452301;
+  context->state[1] = 0xefcdab89;
+  context->state[2] = 0x98badcfe;
+  context->state[3] = 0x10325476;
+}
+
+/* MD5 block update operation. Continues an MD5 message-digest
+     operation, processing another message block, and updating the
+     context.
+ */
+void MD5_Update (MD5_CTX * context, unsigned char * input, unsigned int inputLen)
+{
+  unsigned int i, index, partLen;
+
+  /* Compute number of bytes mod 64 */
+  index = (unsigned int)((context->count[0] >> 3) & 0x3F);
+
+  /* Update number of bits */
+  if ((context->count[0] += ((UINT4)inputLen << 3))
+      < ((UINT4)inputLen << 3))
+    context->count[1]++;
+  context->count[1] += ((UINT4)inputLen >> 29);
+  
+  partLen = 64 - index;
+  
+  /* Transform as many times as possible.
+   */
+  if (inputLen >= partLen) {
+    MD5_memcpy
+      ((POINTER)&context->buffer[index], (POINTER)input, partLen);
+    MD5Transform (context->state, context->buffer);
+  
+    for (i = partLen; i + 63 < inputLen; i += 64)
+      MD5Transform (context->state, &input[i]);
+    
+    index = 0;
+  }
+  else
+    i = 0;
+  
+  /* Buffer remaining input */
+  MD5_memcpy 
+    ((POINTER)&context->buffer[index], (POINTER)&input[i],
+     inputLen-i);
+}
+
+/* MD5 finalization. Ends an MD5 message-digest operation, writing the
+     the message digest and zeroizing the context.
+ */
+void MD5_Final (unsigned char digest[16], MD5_CTX *context)
+{
+  unsigned char bits[8];
+  unsigned int index, padLen;
+
+  /* Save number of bits */
+  Encode (bits, context->count, 8);
+
+  /* Pad out to 56 mod 64.
+   */
+  index = (unsigned int)((context->count[0] >> 3) & 0x3f);
+  padLen = (index < 56) ? (56 - index) : (120 - index);
+  MD5_Update (context, PADDING, padLen);
+  
+  /* Append length (before padding) */
+  MD5_Update (context, bits, 8);
+
+  /* Store state in digest */
+  Encode (digest, context->state, 16);
+  
+  /* Zeroize sensitive information.
+   */
+  MD5_memset ((POINTER)context, 0, sizeof (*context));
+}
+
+/* MD5 basic transformation. Transforms state based on block.
+ */
+static void MD5Transform (UINT4 state[4], unsigned char block[64])
+{
+  UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
+  
+  Decode (x, block, 64);
+
+  /* Round 1 */
+  FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
+  FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
+  FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
+  FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
+  FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
+  FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
+  FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
+  FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
+  FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
+  FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
+  FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
+  FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
+  FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
+  FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
+  FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
+  FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
+
+  /* Round 2 */
+  GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
+  GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
+  GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
+  GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
+  GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
+  GG (d, a, b, c, x[10], S22,  0x2441453); /* 22 */
+  GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
+  GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
+  GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
+  GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
+  GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
+  GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
+  GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
+  GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
+  GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
+  GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
+
+  /* Round 3 */
+  HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
+  HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
+  HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
+  HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
+  HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
+  HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
+  HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
+  HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
+  HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
+  HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
+  HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
+  HH (b, c, d, a, x[ 6], S34,  0x4881d05); /* 44 */
+  HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
+  HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
+  HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
+  HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
+
+  /* Round 4 */
+  II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
+  II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
+  II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
+  II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
+  II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
+  II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
+  II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
+  II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
+  II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
+  II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
+  II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
+  II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
+  II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
+  II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
+  II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
+  II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
+
+  state[0] += a;
+  state[1] += b;
+  state[2] += c;
+  state[3] += d;
+  
+  /* Zeroize sensitive information.
+   */
+  MD5_memset ((POINTER)x, 0, sizeof (x));
+}
+
+/* Encodes input (UINT4) into output (unsigned char). Assumes len is
+     a multiple of 4.
+ */
+static void Encode (unsigned char *output, UINT4 *input, unsigned int len)
+{
+  unsigned int i, j;
+
+  for (i = 0, j = 0; j < len; i++, j += 4) {
+    output[j] = (unsigned char)(input[i] & 0xff);
+    output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
+    output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
+    output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
+  }
+}
+
+/* Decodes input (unsigned char) into output (UINT4). Assumes len is
+     a multiple of 4.
+ */
+static void Decode (UINT4 *output, unsigned char *input, unsigned int len)
+{
+  unsigned int i, j;
+
+  for (i = 0, j = 0; j < len; i++, j += 4)
+    output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
+      (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
+}
+
+/* Note: Replace "for loop" with standard memcpy if possible.
+ */
+static void MD5_memcpy (unsigned char *output, unsigned char *input, unsigned int len)
+{
+  unsigned int i;
+  
+  for (i = 0; i < len; i++)
+    output[i] = input[i];
+}
+
+/* Note: Replace "for loop" with standard memset if possible.
+ */
+static void MD5_memset (unsigned char *output, int value, unsigned int len)
+{
+  unsigned int i;
+  
+  for (i = 0; i < len; i++)
+    ((char *)output)[i] = (char)value;
+}

+ 270 - 0
app/bmc/encryption/sha1.c

@@ -0,0 +1,270 @@
+// /*
+//  ---------------------------------------------------------------------------
+//  Copyright (c) 2002, Dr Brian Gladman <brg@gladman.me.uk>, Worcester, UK.
+//  All rights reserved.
+
+//  LICENSE TERMS
+
+//  The free distribution and use of this software in both source and binary
+//  form is allowed (with or without changes) provided that:
+
+//    1. distributions of this source code include the above copyright
+//       notice, this list of conditions and the following disclaimer;
+
+//    2. distributions in binary form include the above copyright
+//       notice, this list of conditions and the following disclaimer
+//       in the documentation and/or other associated materials;
+
+//    3. the copyright holder's name is not used to endorse products
+//       built using this software without specific written permission.
+
+//  ALTERNATIVELY, provided that this notice is retained in full, this product
+//  may be distributed under the terms of the GNU General Public License (GPL),
+//  in which case the provisions of the GPL apply INSTEAD OF those given above.
+
+//  DISCLAIMER
+
+//  This software is provided 'as is' with no explicit or implied warranties
+//  in respect of its properties, including, but not limited to, correctness
+//  and/or fitness for purpose.
+//  ---------------------------------------------------------------------------
+//  Issue Date: 24/01/2003
+
+//  This is a byte oriented version of SHA1 that operates on arrays of bytes
+//  stored in memory.
+// */
+// #include "com_BmcType.h"
+// #include "sha1.h"
+// #include "memory.h"
+// #include "Platform.h"
+// #include "coreTypes.h"
+// /*
+//     To obtain the highest speed on processors with 32-bit words, this code
+//     needs to determine the order in which bytes are packed into such words.
+//     The following block of code is an attempt to capture the most obvious
+//     ways in which various environemnts specify their endian definitions.
+//     It may well fail, in which case the definitions will need to be set by
+//     editing at the points marked **** EDIT HERE IF NECESSARY **** below.
+// */
+
+// #define SHA_LITTLE_ENDIAN	1
+// #define SHA_BIG_ENDIAN		2
+
+// #if IS_PLATFORM_X86() || IS_PLATFORM_ARM() || IS_PLATFORM_SH()
+// #define PLATFORM_BYTE_ORDER		SHA_LITTLE_ENDIAN	
+// #else
+// #define PLATFORM_BYTE_ORDER		SHA_BIG_ENDIAN	
+// #endif
+
+// #define rotl32(x,n) (((x) << n) | ((x) >> (32 - n)))
+
+// #if (PLATFORM_BYTE_ORDER == SHA_BIG_ENDIAN)
+// #define swap_b32(x) (x)
+// #elif defined(bswap_32)
+// #define swap_b32(x) bswap_32(x)
+// #else
+// #define swap_b32(x) ((rotl32((x), 8) & 0x00ff00ff) | (rotl32((x), 24) & 0xff00ff00))
+// #endif
+
+// #define SHA1_MASK   (SHA1_BLOCK_SIZE - 1)
+
+// /* reverse byte order in 32-bit words       */
+
+// #define ch(x,y,z)       (((x) & (y)) ^ (~(x) & (z)))
+// #define parity(x,y,z)   ((x) ^ (y) ^ (z))
+// #define maj(x,y,z)      (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
+
+// /* A normal version as set out in the FIPS  */
+
+// #define rnd(f,k)    \
+//     t = a; a = rotl32(a,5) + f(b,c,d) + e + k + w[i]; \
+//     e = d; d = c; c = rotl32(b, 30); b = t
+
+// #if (PLATFORM_BYTE_ORDER == SHA_LITTLE_ENDIAN)
+// static  uint32  mask[4] =
+//     {   0x00000000, 0x000000ff, 0x0000ffff, 0x00ffffff };
+// static  uint32  bits[4] =
+//     {   0x00000080, 0x00008000, 0x00800000, 0x80000000 };
+// #else
+// static  uint32  mask[4] =
+//     {   0x00000000, 0xff000000, 0xffff0000, 0xffffff00 };
+// static  uint32  bits[4] =
+//     {   0x80000000, 0x00800000, 0x00008000, 0x00000080 };
+// #endif
+
+
+// /*----------------------------------------
+//  * sha1_compile
+//  *----------------------------------------*/
+// void 
+// sha1_compile ( Sha1_Ctx_T* pctx)
+// {   
+// 	int i;
+// 	uint32    w [80], a, b, c, d, e, t;
+
+//     /* note that words are compiled from the buffer into 32-bit */
+//     /* words in big-endian order so an order reversal is needed */
+//     /* here on little endian machines                           */
+//     for (i = 0; i < SHA1_BLOCK_SIZE / 4; ++i)
+// 	{
+//         w [i] = swap_b32 (pctx->wbuf [i]);
+// 	}
+
+//     for (i = SHA1_BLOCK_SIZE / 4; i < 80; ++i)
+// 	{
+//         w[i] = rotl32(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
+// 	}
+
+//     a = pctx->hash [0];
+//     b = pctx->hash [1];
+//     c = pctx->hash [2];
+//     d = pctx->hash [3];
+//     e = pctx->hash [4];
+
+//     for (i = 0; i < 20; ++i)
+//     {
+//         rnd (ch, 0x5a827999);
+//     }
+
+//     for (i = 20; i < 40; ++i)
+//     {
+//         rnd (parity, 0x6ed9eba1);
+//     }
+
+//     for (i = 40; i < 60; ++i)
+//     {
+//         rnd (maj, 0x8f1bbcdc);
+//     }
+
+//     for (i = 60; i < 80; ++i)
+//     {
+//         rnd (parity, 0xca62c1d6);
+//     }
+
+//     pctx->hash [0] += a;
+//     pctx->hash [1] += b;
+//     pctx->hash [2] += c;
+//     pctx->hash [3] += d;
+//     pctx->hash [4] += e;
+// }
+
+// /*----------------------------------------
+//  * sha1_begin
+//  *----------------------------------------*/
+// void 
+// sha1_begin ( Sha1_Ctx_T* pctx)
+// {
+//     pctx->count [0] = pctx->count [1] = 0;
+//     pctx->hash [0]  = 0x67452301;
+//     pctx->hash [1]  = 0xefcdab89;
+//     pctx->hash [2]  = 0x98badcfe;
+//     pctx->hash [3]  = 0x10325476;
+//     pctx->hash [4]  = 0xc3d2e1f0;
+// }
+
+// /*----------------------------------------
+//  * sha1_hash
+//  *----------------------------------------*/
+// void 
+// sha1_hash ( INT8U* pdata, INT16U len,  Sha1_Ctx_T* pctx)
+// {
+// 	/* SHA1 hash data in an array of bytes into hash buffer and */
+// 	/* call the hash_compile function as required.              */
+// 	uint32 pos = (uint32)(pctx->count[0] & SHA1_MASK),
+//              space = SHA1_BLOCK_SIZE - pos;
+//      INT8U *sp = pdata;
+ 
+//     if ((pctx->count[0] += len) < len)  { ++(pctx->count[1]); }
+
+//     while (len >= space)     /* tranfer whole blocks if possible  */
+//     {
+//         memcpy ((( INT8U*)pctx->wbuf) + pos, sp, space);
+//         sp += space; len -= (INT16U)space; space = SHA1_BLOCK_SIZE; pos = 0;
+//         sha1_compile (pctx);
+
+//     }
+
+// 	//dispscont (pctx);
+
+//     /*lint -e{803} conceivable data overrun */
+//     /* there are two cases: the above while loop entered or not */
+//     /* entered. If not entered, 'space = SHA1_BLOCK_SIZE - pos' */
+//     /* and 'len < space' so that 'len + pos < SHA1_BLOCK_SIZE'. */
+//     /* If entered, 'pos = 0', 'space = SHA1_BLOCK_SIZE' and     */
+//     /* 'len < space' so that 'pos + len < SHA1_BLOCK_SIZE'. In  */
+//     /* both cases, therefore, the memory copy is in the buffer  */
+
+//     memcpy ((( INT8U*)pctx->wbuf) + pos, sp, len);
+
+// }
+
+
+// /*----------------------------------------
+//  * sha1_end
+//  *----------------------------------------*/
+// void 
+// sha1_end ( INT8U* phval,  Sha1_Ctx_T* pctx)
+// {
+// 	uint32    i = (uint32)(pctx->count [0] & SHA1_MASK);
+
+// 	/* SHA1 final padding and digest calculation  */
+
+//     /* mask out the rest of any partial 32-bit word and then set    */
+//     /* the next byte to 0x80. On big-endian machines any bytes in   */
+//     /* the buffer will be at the top end of 32 bit words, on little */
+//     /* endian machines they will be at the bottom. Hence the AND    */
+//     /* and OR masks above are reversed for little endian systems    */
+//     /* Note that we can always add the first padding byte at this   */
+//     /* point because the buffer always has at least one empty slot  */
+//     pctx->wbuf [(INT16U)(i >> 2)] = (pctx->wbuf [(INT16U)(i >> 2)] & mask [(INT16U)(i & 3)]) | bits [(INT16U)(i & 3)];
+
+
+//     /* we need 9 or more empty positions, one for the padding byte  */
+//     /* (above) and eight for the length count.  If there is not     */
+//     /* enough space pad and empty the buffer                        */
+//     if (i > SHA1_BLOCK_SIZE - 9)
+//     {
+//         if (i < 60) { pctx->wbuf [15] = 0; }
+//         sha1_compile (pctx);
+//         i = 0;
+//     }
+//     else    /* compute a word index for the empty buffer positions  */
+// 	{
+//         i = (i >> 2) + 1;
+// 	}
+
+// 	/* and zero pad all but last two positions        */
+//     while (i < 14)  {  pctx->wbuf[(INT16U)(i++)] = 0; }
+
+
+//     /* assemble the eight byte counter in in big-endian format      */
+//     pctx->wbuf [14] = swap_b32 ((pctx->count[1] << 3) | (pctx->count[0] >> 29));
+//     pctx->wbuf [15] = swap_b32 (pctx->count[0] << 3);
+
+//     sha1_compile (pctx);
+
+
+//     /* extract the hash value as bytes in case the hash buffer is   */
+//     /* misaligned for 32-bit words                                  */
+//     /*lint -e{504} unusual shift operation (unusually formed right argument) */
+//     for (i = 0; i < SHA1_DIGEST_SIZE; ++i)
+// 	{
+//         phval [(INT16U)(i)] = (INT8U)(pctx->hash [(INT16U)(i >> 2)] >> (8 * (~i & 3)));
+// 	}
+
+// }
+
+// /*----------------------------------------
+//  * sha1
+//  *----------------------------------------*/
+// void 
+// sha1 ( INT8U* phval,  INT8U* pdata, INT16U len)
+// {
+// 	Sha1_Ctx_T    cx;
+
+//     sha1_begin (&cx); 
+// 	sha1_hash (pdata, len, &cx); 
+// 	sha1_end (phval, &cx);
+// }
+
+

+ 73 - 0
app/bmc/encryption/sha1.h

@@ -0,0 +1,73 @@
+
+//  ---------------------------------------------------------------------------
+//  Copyright (c) 2002, Dr Brian Gladman <brg@gladman.me.uk>, Worcester, UK.
+//  All rights reserved.
+
+//  LICENSE TERMS
+
+//  The free distribution and use of this software in both source and binary
+//  form is allowed (with or without changes) provided that:
+
+//    1. distributions of this source code include the above copyright
+//       notice, this list of conditions and the following disclaimer;
+
+//    2. distributions in binary form include the above copyright
+//       notice, this list of conditions and the following disclaimer
+//       in the documentation and/or other associated materials;
+
+//    3. the copyright holder's name is not used to endorse products
+//       built using this software without specific written permission.
+
+//  ALTERNATIVELY, provided that this notice is retained in full, this product
+//  may be distributed under the terms of the GNU General Public License (GPL),
+//  in which case the provisions of the GPL apply INSTEAD OF those given above.
+
+//  DISCLAIMER
+
+//  This software is provided 'as is' with no explicit or implied warranties
+//  in respect of its properties, including, but not limited to, correctness
+//  and/or fitness for purpose.
+//  ---------------------------------------------------------------------------
+//  Issue Date: 24/01/2003
+
+//  This file contains the definitions needed for SHA1
+
+
+// #ifndef _SHA1_H
+// #define _SHA1_H
+// #include "Types.h"
+// #include "coreTypes.h"
+
+
+// #define SHA1_BLOCK_SIZE  64
+// #define SHA1_DIGEST_SIZE 20
+
+// /* type to hold the SHA256 context  */
+
+// #ifdef __GNUC__
+// #define PACK __attribute__ ((packed))
+// #else
+// #define PACK
+// #pragma pack( 1 )
+// #endif
+
+// typedef struct
+// {
+// 	uint32 count [2];
+//     uint32 hash [5];
+//     uint32 wbuf [16];
+
+// } PACK Sha1_Ctx_T;
+
+// void sha1_compile ( Sha1_Ctx_T* pctx);
+// void sha1_begin ( Sha1_Ctx_T* pctx);
+// void sha1_hash ( INT8U* pdata, INT16U len, Sha1_Ctx_T* pctx);
+// void sha1_end ( INT8U* phval, Sha1_Ctx_T* pctx);
+// void sha1 ( INT8U* phval, INT8U* pdata, INT16U len);
+
+// #undef PACK
+// #ifndef __GNUC__
+// #pragma pack()
+// #endif
+
+// #endif

+ 824 - 0
app/bmc/encryption/sha2.c

@@ -0,0 +1,824 @@
+// /*
+//  * FIPS 180-2 SHA-224/256/384/512 implementation
+//  * Last update: 02/02/2007
+//  * Issue date:  04/30/2005
+//  *
+//  * Copyright (C) 2005, 2007 Olivier Gay <olivier.gay@a3.epfl.ch>
+//  * All rights reserved.
+//  *
+//  * Redistribution and use in source and binary forms, with or without
+//  * modification, are permitted provided that the following conditions
+//  * are met:
+//  * 1. Redistributions of source code must retain the above copyright
+//  *    notice, this list of conditions and the following disclaimer.
+//  * 2. Redistributions in binary form must reproduce the above copyright
+//  *    notice, this list of conditions and the following disclaimer in the
+//  *    documentation and/or other materials provided with the distribution.
+//  * 3. Neither the name of the project nor the names of its contributors
+//  *    may be used to endorse or promote products derived from this software
+//  *    without specific prior written permission.
+//  *
+//  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+//  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+//  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+//  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+//  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+//  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+//  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+//  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+//  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+//  * SUCH DAMAGE.
+//  */
+
+// #if 0
+// #define UNROLL_LOOPS /* Enable loops unrolling */
+// #endif
+
+// #include <string.h>
+
+// #include "sha2.h"
+
+// #define SHFR(x, n)    (x >> n)
+// #define ROTR(x, n)   ((x >> n) | (x << ((sizeof(x) << 3) - n)))
+// #define ROTL(x, n)   ((x << n) | (x >> ((sizeof(x) << 3) - n)))
+// #define CH(x, y, z)  ((x & y) ^ (~x & z))
+// #define MAJ(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
+
+// #define SHA256_F1(x) (ROTR(x,  2) ^ ROTR(x, 13) ^ ROTR(x, 22))
+// #define SHA256_F2(x) (ROTR(x,  6) ^ ROTR(x, 11) ^ ROTR(x, 25))
+// #define SHA256_F3(x) (ROTR(x,  7) ^ ROTR(x, 18) ^ SHFR(x,  3))
+// #define SHA256_F4(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHFR(x, 10))
+
+// #define SHA512_F1(x) (ROTR(x, 28) ^ ROTR(x, 34) ^ ROTR(x, 39))
+// #define SHA512_F2(x) (ROTR(x, 14) ^ ROTR(x, 18) ^ ROTR(x, 41))
+// #define SHA512_F3(x) (ROTR(x,  1) ^ ROTR(x,  8) ^ SHFR(x,  7))
+// #define SHA512_F4(x) (ROTR(x, 19) ^ ROTR(x, 61) ^ SHFR(x,  6))
+
+// #define UNPACK32(x, str)                      \
+// {                                             \
+//     *((str) + 3) = (uint8) ((x)      );       \
+//     *((str) + 2) = (uint8) ((x) >>  8);       \
+//     *((str) + 1) = (uint8) ((x) >> 16);       \
+//     *((str) + 0) = (uint8) ((x) >> 24);       \
+// }
+
+// #define PACK32(str, x)                        \
+// {                                             \
+//     *(x) =   ((uint32) *((str) + 3)      )    \
+//            | ((uint32) *((str) + 2) <<  8)    \
+//            | ((uint32) *((str) + 1) << 16)    \
+//            | ((uint32) *((str) + 0) << 24);   \
+// }
+
+// #define UNPACK64(x, str)                      \
+// {                                             \
+//     *((str) + 7) = (uint8) ((x)      );       \
+//     *((str) + 6) = (uint8) ((x) >>  8);       \
+//     *((str) + 5) = (uint8) ((x) >> 16);       \
+//     *((str) + 4) = (uint8) ((x) >> 24);       \
+//     *((str) + 3) = (uint8) ((x) >> 32);       \
+//     *((str) + 2) = (uint8) ((x) >> 40);       \
+//     *((str) + 1) = (uint8) ((x) >> 48);       \
+//     *((str) + 0) = (uint8) ((x) >> 56);       \
+// }
+
+// #define PACK64(str, x)                        \
+// {                                             \
+//     *(x) =   ((uint64) *((str) + 7)      )    \
+//            | ((uint64) *((str) + 6) <<  8)    \
+//            | ((uint64) *((str) + 5) << 16)    \
+//            | ((uint64) *((str) + 4) << 24)    \
+//            | ((uint64) *((str) + 3) << 32)    \
+//            | ((uint64) *((str) + 2) << 40)    \
+//            | ((uint64) *((str) + 1) << 48)    \
+//            | ((uint64) *((str) + 0) << 56);   \
+// }
+
+// /* Macros used for loops unrolling */
+
+// #define SHA256_SCR(i)                         \
+// {                                             \
+//     w[i] =  SHA256_F4(w[i -  2]) + w[i -  7]  \
+//           + SHA256_F3(w[i - 15]) + w[i - 16]; \
+// }
+
+// #define SHA512_SCR(i)                         \
+// {                                             \
+//     w[i] =  SHA512_F4(w[i -  2]) + w[i -  7]  \
+//           + SHA512_F3(w[i - 15]) + w[i - 16]; \
+// }
+
+// #define SHA256_EXP(a, b, c, d, e, f, g, h, j)               \
+// {                                                           \
+//     t1 = wv[h] + SHA256_F2(wv[e]) + CH(wv[e], wv[f], wv[g]) \
+//          + sha256_k[j] + w[j];                              \
+//     t2 = SHA256_F1(wv[a]) + MAJ(wv[a], wv[b], wv[c]);       \
+//     wv[d] += t1;                                            \
+//     wv[h] = t1 + t2;                                        \
+// }
+
+// #define SHA512_EXP(a, b, c, d, e, f, g ,h, j)               \
+// {                                                           \
+//     t1 = wv[h] + SHA512_F2(wv[e]) + CH(wv[e], wv[f], wv[g]) \
+//          + sha512_k[j] + w[j];                              \
+//     t2 = SHA512_F1(wv[a]) + MAJ(wv[a], wv[b], wv[c]);       \
+//     wv[d] += t1;                                            \
+//     wv[h] = t1 + t2;                                        \
+// }
+
+// uint32 sha224_h0[8] =
+//             {0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
+//              0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4};
+
+// uint32 sha256_h0[8] =
+//             {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
+//              0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
+
+// uint64 sha384_h0[8] =
+//             {0xcbbb9d5dc1059ed8ULL, 0x629a292a367cd507ULL,
+//              0x9159015a3070dd17ULL, 0x152fecd8f70e5939ULL,
+//              0x67332667ffc00b31ULL, 0x8eb44a8768581511ULL,
+//              0xdb0c2e0d64f98fa7ULL, 0x47b5481dbefa4fa4ULL};
+
+// uint64 sha512_h0[8] =
+//             {0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL,
+//              0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL,
+//              0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL,
+//              0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL};
+
+// uint32 sha256_k[64] =
+//             {0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
+//              0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
+//              0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
+//              0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
+//              0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
+//              0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+//              0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
+//              0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
+//              0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
+//              0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+//              0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
+//              0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+//              0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
+//              0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+//              0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+//              0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
+
+// uint64 sha512_k[80] =
+//             {0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL,
+//              0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL,
+//              0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL,
+//              0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL,
+//              0xd807aa98a3030242ULL, 0x12835b0145706fbeULL,
+//              0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL,
+//              0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL,
+//              0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL,
+//              0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL,
+//              0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL,
+//              0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL,
+//              0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL,
+//              0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL,
+//              0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL,
+//              0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL,
+//              0x06ca6351e003826fULL, 0x142929670a0e6e70ULL,
+//              0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL,
+//              0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL,
+//              0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL,
+//              0x81c2c92e47edaee6ULL, 0x92722c851482353bULL,
+//              0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL,
+//              0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL,
+//              0xd192e819d6ef5218ULL, 0xd69906245565a910ULL,
+//              0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL,
+//              0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL,
+//              0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL,
+//              0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL,
+//              0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL,
+//              0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL,
+//              0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL,
+//              0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL,
+//              0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL,
+//              0xca273eceea26619cULL, 0xd186b8c721c0c207ULL,
+//              0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL,
+//              0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL,
+//              0x113f9804bef90daeULL, 0x1b710b35131c471bULL,
+//              0x28db77f523047d84ULL, 0x32caab7b40c72493ULL,
+//              0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL,
+//              0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL,
+//              0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL};
+
+// /* SHA-256 functions */
+
+// void sha256_transf(sha256_ctx *ctx, const unsigned char *message,
+//                    unsigned int block_nb)
+// {
+//     uint32 w[64];
+//     uint32 wv[8];
+//     uint32 t1, t2;
+//     const unsigned char *sub_block;
+//     int i;
+
+// #ifndef UNROLL_LOOPS
+//     int j;
+// #endif
+
+//     for (i = 0; i < (int) block_nb; i++) {
+//         sub_block = message + (i << 6);
+
+// #ifndef UNROLL_LOOPS
+//         for (j = 0; j < 16; j++) {
+//             PACK32(&sub_block[j << 2], &w[j]);
+//         }
+
+//         for (j = 16; j < 64; j++) {
+//             SHA256_SCR(j);
+//         }
+
+//         for (j = 0; j < 8; j++) {
+//             wv[j] = ctx->h[j];
+//         }
+
+//         for (j = 0; j < 64; j++) {
+//             t1 = wv[7] + SHA256_F2(wv[4]) + CH(wv[4], wv[5], wv[6])
+//                 + sha256_k[j] + w[j];
+//             t2 = SHA256_F1(wv[0]) + MAJ(wv[0], wv[1], wv[2]);
+//             wv[7] = wv[6];
+//             wv[6] = wv[5];
+//             wv[5] = wv[4];
+//             wv[4] = wv[3] + t1;
+//             wv[3] = wv[2];
+//             wv[2] = wv[1];
+//             wv[1] = wv[0];
+//             wv[0] = t1 + t2;
+//         }
+
+//         for (j = 0; j < 8; j++) {
+//             ctx->h[j] += wv[j];
+//         }
+// #else
+//         PACK32(&sub_block[ 0], &w[ 0]); PACK32(&sub_block[ 4], &w[ 1]);
+//         PACK32(&sub_block[ 8], &w[ 2]); PACK32(&sub_block[12], &w[ 3]);
+//         PACK32(&sub_block[16], &w[ 4]); PACK32(&sub_block[20], &w[ 5]);
+//         PACK32(&sub_block[24], &w[ 6]); PACK32(&sub_block[28], &w[ 7]);
+//         PACK32(&sub_block[32], &w[ 8]); PACK32(&sub_block[36], &w[ 9]);
+//         PACK32(&sub_block[40], &w[10]); PACK32(&sub_block[44], &w[11]);
+//         PACK32(&sub_block[48], &w[12]); PACK32(&sub_block[52], &w[13]);
+//         PACK32(&sub_block[56], &w[14]); PACK32(&sub_block[60], &w[15]);
+
+//         SHA256_SCR(16); SHA256_SCR(17); SHA256_SCR(18); SHA256_SCR(19);
+//         SHA256_SCR(20); SHA256_SCR(21); SHA256_SCR(22); SHA256_SCR(23);
+//         SHA256_SCR(24); SHA256_SCR(25); SHA256_SCR(26); SHA256_SCR(27);
+//         SHA256_SCR(28); SHA256_SCR(29); SHA256_SCR(30); SHA256_SCR(31);
+//         SHA256_SCR(32); SHA256_SCR(33); SHA256_SCR(34); SHA256_SCR(35);
+//         SHA256_SCR(36); SHA256_SCR(37); SHA256_SCR(38); SHA256_SCR(39);
+//         SHA256_SCR(40); SHA256_SCR(41); SHA256_SCR(42); SHA256_SCR(43);
+//         SHA256_SCR(44); SHA256_SCR(45); SHA256_SCR(46); SHA256_SCR(47);
+//         SHA256_SCR(48); SHA256_SCR(49); SHA256_SCR(50); SHA256_SCR(51);
+//         SHA256_SCR(52); SHA256_SCR(53); SHA256_SCR(54); SHA256_SCR(55);
+//         SHA256_SCR(56); SHA256_SCR(57); SHA256_SCR(58); SHA256_SCR(59);
+//         SHA256_SCR(60); SHA256_SCR(61); SHA256_SCR(62); SHA256_SCR(63);
+
+//         wv[0] = ctx->h[0]; wv[1] = ctx->h[1];
+//         wv[2] = ctx->h[2]; wv[3] = ctx->h[3];
+//         wv[4] = ctx->h[4]; wv[5] = ctx->h[5];
+//         wv[6] = ctx->h[6]; wv[7] = ctx->h[7];
+
+//         SHA256_EXP(0,1,2,3,4,5,6,7, 0); SHA256_EXP(7,0,1,2,3,4,5,6, 1);
+//         SHA256_EXP(6,7,0,1,2,3,4,5, 2); SHA256_EXP(5,6,7,0,1,2,3,4, 3);
+//         SHA256_EXP(4,5,6,7,0,1,2,3, 4); SHA256_EXP(3,4,5,6,7,0,1,2, 5);
+//         SHA256_EXP(2,3,4,5,6,7,0,1, 6); SHA256_EXP(1,2,3,4,5,6,7,0, 7);
+//         SHA256_EXP(0,1,2,3,4,5,6,7, 8); SHA256_EXP(7,0,1,2,3,4,5,6, 9);
+//         SHA256_EXP(6,7,0,1,2,3,4,5,10); SHA256_EXP(5,6,7,0,1,2,3,4,11);
+//         SHA256_EXP(4,5,6,7,0,1,2,3,12); SHA256_EXP(3,4,5,6,7,0,1,2,13);
+//         SHA256_EXP(2,3,4,5,6,7,0,1,14); SHA256_EXP(1,2,3,4,5,6,7,0,15);
+//         SHA256_EXP(0,1,2,3,4,5,6,7,16); SHA256_EXP(7,0,1,2,3,4,5,6,17);
+//         SHA256_EXP(6,7,0,1,2,3,4,5,18); SHA256_EXP(5,6,7,0,1,2,3,4,19);
+//         SHA256_EXP(4,5,6,7,0,1,2,3,20); SHA256_EXP(3,4,5,6,7,0,1,2,21);
+//         SHA256_EXP(2,3,4,5,6,7,0,1,22); SHA256_EXP(1,2,3,4,5,6,7,0,23);
+//         SHA256_EXP(0,1,2,3,4,5,6,7,24); SHA256_EXP(7,0,1,2,3,4,5,6,25);
+//         SHA256_EXP(6,7,0,1,2,3,4,5,26); SHA256_EXP(5,6,7,0,1,2,3,4,27);
+//         SHA256_EXP(4,5,6,7,0,1,2,3,28); SHA256_EXP(3,4,5,6,7,0,1,2,29);
+//         SHA256_EXP(2,3,4,5,6,7,0,1,30); SHA256_EXP(1,2,3,4,5,6,7,0,31);
+//         SHA256_EXP(0,1,2,3,4,5,6,7,32); SHA256_EXP(7,0,1,2,3,4,5,6,33);
+//         SHA256_EXP(6,7,0,1,2,3,4,5,34); SHA256_EXP(5,6,7,0,1,2,3,4,35);
+//         SHA256_EXP(4,5,6,7,0,1,2,3,36); SHA256_EXP(3,4,5,6,7,0,1,2,37);
+//         SHA256_EXP(2,3,4,5,6,7,0,1,38); SHA256_EXP(1,2,3,4,5,6,7,0,39);
+//         SHA256_EXP(0,1,2,3,4,5,6,7,40); SHA256_EXP(7,0,1,2,3,4,5,6,41);
+//         SHA256_EXP(6,7,0,1,2,3,4,5,42); SHA256_EXP(5,6,7,0,1,2,3,4,43);
+//         SHA256_EXP(4,5,6,7,0,1,2,3,44); SHA256_EXP(3,4,5,6,7,0,1,2,45);
+//         SHA256_EXP(2,3,4,5,6,7,0,1,46); SHA256_EXP(1,2,3,4,5,6,7,0,47);
+//         SHA256_EXP(0,1,2,3,4,5,6,7,48); SHA256_EXP(7,0,1,2,3,4,5,6,49);
+//         SHA256_EXP(6,7,0,1,2,3,4,5,50); SHA256_EXP(5,6,7,0,1,2,3,4,51);
+//         SHA256_EXP(4,5,6,7,0,1,2,3,52); SHA256_EXP(3,4,5,6,7,0,1,2,53);
+//         SHA256_EXP(2,3,4,5,6,7,0,1,54); SHA256_EXP(1,2,3,4,5,6,7,0,55);
+//         SHA256_EXP(0,1,2,3,4,5,6,7,56); SHA256_EXP(7,0,1,2,3,4,5,6,57);
+//         SHA256_EXP(6,7,0,1,2,3,4,5,58); SHA256_EXP(5,6,7,0,1,2,3,4,59);
+//         SHA256_EXP(4,5,6,7,0,1,2,3,60); SHA256_EXP(3,4,5,6,7,0,1,2,61);
+//         SHA256_EXP(2,3,4,5,6,7,0,1,62); SHA256_EXP(1,2,3,4,5,6,7,0,63);
+
+//         ctx->h[0] += wv[0]; ctx->h[1] += wv[1];
+//         ctx->h[2] += wv[2]; ctx->h[3] += wv[3];
+//         ctx->h[4] += wv[4]; ctx->h[5] += wv[5];
+//         ctx->h[6] += wv[6]; ctx->h[7] += wv[7];
+// #endif /* !UNROLL_LOOPS */
+//     }
+// }
+
+// void sha256(const unsigned char *message, unsigned int len, unsigned char *digest)
+// {
+//     sha256_ctx ctx;
+
+//     sha256_init(&ctx);
+//     sha256_update(&ctx, message, len);
+//     sha256_final(&ctx, digest);
+// }
+
+// void sha256_init(sha256_ctx *ctx)
+// {
+// #ifndef UNROLL_LOOPS
+//     int i;
+//     for (i = 0; i < 8; i++) {
+//         ctx->h[i] = sha256_h0[i];
+//     }
+// #else
+//     ctx->h[0] = sha256_h0[0]; ctx->h[1] = sha256_h0[1];
+//     ctx->h[2] = sha256_h0[2]; ctx->h[3] = sha256_h0[3];
+//     ctx->h[4] = sha256_h0[4]; ctx->h[5] = sha256_h0[5];
+//     ctx->h[6] = sha256_h0[6]; ctx->h[7] = sha256_h0[7];
+// #endif /* !UNROLL_LOOPS */
+
+//     ctx->len = 0;
+//     ctx->tot_len = 0;
+// }
+
+// void sha256_update(sha256_ctx *ctx, const unsigned char *message,
+//                    unsigned int len)
+// {
+//     unsigned int block_nb;
+//     unsigned int new_len, rem_len, tmp_len;
+//     const unsigned char *shifted_message;
+
+//     tmp_len = SHA256_BLOCK_SIZE - ctx->len;
+//     rem_len = len < tmp_len ? len : tmp_len;
+
+//     memcpy(&ctx->block[ctx->len], message, rem_len);
+
+//     if (ctx->len + len < SHA256_BLOCK_SIZE) {
+//         ctx->len += len;
+//         return;
+//     }
+
+//     new_len = len - rem_len;
+//     block_nb = new_len / SHA256_BLOCK_SIZE;
+
+//     shifted_message = message + rem_len;
+
+//     sha256_transf(ctx, ctx->block, 1);
+//     sha256_transf(ctx, shifted_message, block_nb);
+
+//     rem_len = new_len % SHA256_BLOCK_SIZE;
+
+//     memcpy(ctx->block, &shifted_message[block_nb << 6],
+//            rem_len);
+
+//     ctx->len = rem_len;
+//     ctx->tot_len += (block_nb + 1) << 6;
+// }
+
+// void sha256_final(sha256_ctx *ctx, unsigned char *digest)
+// {
+//     unsigned int block_nb;
+//     unsigned int pm_len;
+//     unsigned int len_b;
+
+// #ifndef UNROLL_LOOPS
+//     int i;
+// #endif
+
+//     block_nb = (1 + ((SHA256_BLOCK_SIZE - 9)
+//                      < (ctx->len % SHA256_BLOCK_SIZE)));
+
+//     len_b = (ctx->tot_len + ctx->len) << 3;
+//     pm_len = block_nb << 6;
+
+//     memset(ctx->block + ctx->len, 0, pm_len - ctx->len);
+//     ctx->block[ctx->len] = 0x80;
+//     UNPACK32(len_b, ctx->block + pm_len - 4);
+
+//     sha256_transf(ctx, ctx->block, block_nb);
+
+// #ifndef UNROLL_LOOPS
+//     for (i = 0 ; i < 8; i++) {
+//         UNPACK32(ctx->h[i], &digest[i << 2]);
+//     }
+// #else
+//    UNPACK32(ctx->h[0], &digest[ 0]);
+//    UNPACK32(ctx->h[1], &digest[ 4]);
+//    UNPACK32(ctx->h[2], &digest[ 8]);
+//    UNPACK32(ctx->h[3], &digest[12]);
+//    UNPACK32(ctx->h[4], &digest[16]);
+//    UNPACK32(ctx->h[5], &digest[20]);
+//    UNPACK32(ctx->h[6], &digest[24]);
+//    UNPACK32(ctx->h[7], &digest[28]);
+// #endif /* !UNROLL_LOOPS */
+// }
+
+// /* SHA-512 functions */
+
+// void sha512_transf(sha512_ctx *ctx, const unsigned char *message,
+//                    unsigned int block_nb)
+// {
+//     uint64 w[80];
+//     uint64 wv[8];
+//     uint64 t1, t2;
+//     const unsigned char *sub_block;
+//     int i, j;
+
+//     for (i = 0; i < (int) block_nb; i++) {
+//         sub_block = message + (i << 7);
+
+// #ifndef UNROLL_LOOPS
+//         for (j = 0; j < 16; j++) {
+//             PACK64(&sub_block[j << 3], &w[j]);
+//         }
+
+//         for (j = 16; j < 80; j++) {
+//             SHA512_SCR(j);
+//         }
+
+//         for (j = 0; j < 8; j++) {
+//             wv[j] = ctx->h[j];
+//         }
+
+//         for (j = 0; j < 80; j++) {
+//             t1 = wv[7] + SHA512_F2(wv[4]) + CH(wv[4], wv[5], wv[6])
+//                 + sha512_k[j] + w[j];
+//             t2 = SHA512_F1(wv[0]) + MAJ(wv[0], wv[1], wv[2]);
+//             wv[7] = wv[6];
+//             wv[6] = wv[5];
+//             wv[5] = wv[4];
+//             wv[4] = wv[3] + t1;
+//             wv[3] = wv[2];
+//             wv[2] = wv[1];
+//             wv[1] = wv[0];
+//             wv[0] = t1 + t2;
+//         }
+
+//         for (j = 0; j < 8; j++) {
+//             ctx->h[j] += wv[j];
+//         }
+// #else
+//         PACK64(&sub_block[  0], &w[ 0]); PACK64(&sub_block[  8], &w[ 1]);
+//         PACK64(&sub_block[ 16], &w[ 2]); PACK64(&sub_block[ 24], &w[ 3]);
+//         PACK64(&sub_block[ 32], &w[ 4]); PACK64(&sub_block[ 40], &w[ 5]);
+//         PACK64(&sub_block[ 48], &w[ 6]); PACK64(&sub_block[ 56], &w[ 7]);
+//         PACK64(&sub_block[ 64], &w[ 8]); PACK64(&sub_block[ 72], &w[ 9]);
+//         PACK64(&sub_block[ 80], &w[10]); PACK64(&sub_block[ 88], &w[11]);
+//         PACK64(&sub_block[ 96], &w[12]); PACK64(&sub_block[104], &w[13]);
+//         PACK64(&sub_block[112], &w[14]); PACK64(&sub_block[120], &w[15]);
+
+//         SHA512_SCR(16); SHA512_SCR(17); SHA512_SCR(18); SHA512_SCR(19);
+//         SHA512_SCR(20); SHA512_SCR(21); SHA512_SCR(22); SHA512_SCR(23);
+//         SHA512_SCR(24); SHA512_SCR(25); SHA512_SCR(26); SHA512_SCR(27);
+//         SHA512_SCR(28); SHA512_SCR(29); SHA512_SCR(30); SHA512_SCR(31);
+//         SHA512_SCR(32); SHA512_SCR(33); SHA512_SCR(34); SHA512_SCR(35);
+//         SHA512_SCR(36); SHA512_SCR(37); SHA512_SCR(38); SHA512_SCR(39);
+//         SHA512_SCR(40); SHA512_SCR(41); SHA512_SCR(42); SHA512_SCR(43);
+//         SHA512_SCR(44); SHA512_SCR(45); SHA512_SCR(46); SHA512_SCR(47);
+//         SHA512_SCR(48); SHA512_SCR(49); SHA512_SCR(50); SHA512_SCR(51);
+//         SHA512_SCR(52); SHA512_SCR(53); SHA512_SCR(54); SHA512_SCR(55);
+//         SHA512_SCR(56); SHA512_SCR(57); SHA512_SCR(58); SHA512_SCR(59);
+//         SHA512_SCR(60); SHA512_SCR(61); SHA512_SCR(62); SHA512_SCR(63);
+//         SHA512_SCR(64); SHA512_SCR(65); SHA512_SCR(66); SHA512_SCR(67);
+//         SHA512_SCR(68); SHA512_SCR(69); SHA512_SCR(70); SHA512_SCR(71);
+//         SHA512_SCR(72); SHA512_SCR(73); SHA512_SCR(74); SHA512_SCR(75);
+//         SHA512_SCR(76); SHA512_SCR(77); SHA512_SCR(78); SHA512_SCR(79);
+
+//         wv[0] = ctx->h[0]; wv[1] = ctx->h[1];
+//         wv[2] = ctx->h[2]; wv[3] = ctx->h[3];
+//         wv[4] = ctx->h[4]; wv[5] = ctx->h[5];
+//         wv[6] = ctx->h[6]; wv[7] = ctx->h[7];
+
+//         j = 0;
+
+//         do {
+//             SHA512_EXP(0,1,2,3,4,5,6,7,j); j++;
+//             SHA512_EXP(7,0,1,2,3,4,5,6,j); j++;
+//             SHA512_EXP(6,7,0,1,2,3,4,5,j); j++;
+//             SHA512_EXP(5,6,7,0,1,2,3,4,j); j++;
+//             SHA512_EXP(4,5,6,7,0,1,2,3,j); j++;
+//             SHA512_EXP(3,4,5,6,7,0,1,2,j); j++;
+//             SHA512_EXP(2,3,4,5,6,7,0,1,j); j++;
+//             SHA512_EXP(1,2,3,4,5,6,7,0,j); j++;
+//         } while (j < 80);
+
+//         ctx->h[0] += wv[0]; ctx->h[1] += wv[1];
+//         ctx->h[2] += wv[2]; ctx->h[3] += wv[3];
+//         ctx->h[4] += wv[4]; ctx->h[5] += wv[5];
+//         ctx->h[6] += wv[6]; ctx->h[7] += wv[7];
+// #endif /* !UNROLL_LOOPS */
+//     }
+// }
+
+// void sha512(const unsigned char *message, unsigned int len,
+//             unsigned char *digest)
+// {
+//     sha512_ctx ctx;
+
+//     sha512_init(&ctx);
+//     sha512_update(&ctx, message, len);
+//     sha512_final(&ctx, digest);
+// }
+
+// void sha512_init(sha512_ctx *ctx)
+// {
+// #ifndef UNROLL_LOOPS
+//     int i;
+//     for (i = 0; i < 8; i++) {
+//         ctx->h[i] = sha512_h0[i];
+//     }
+// #else
+//     ctx->h[0] = sha512_h0[0]; ctx->h[1] = sha512_h0[1];
+//     ctx->h[2] = sha512_h0[2]; ctx->h[3] = sha512_h0[3];
+//     ctx->h[4] = sha512_h0[4]; ctx->h[5] = sha512_h0[5];
+//     ctx->h[6] = sha512_h0[6]; ctx->h[7] = sha512_h0[7];
+// #endif /* !UNROLL_LOOPS */
+
+//     ctx->len = 0;
+//     ctx->tot_len = 0;
+// }
+
+// void sha512_update(sha512_ctx *ctx, const unsigned char *message,
+//                    unsigned int len)
+// {
+//     unsigned int block_nb;
+//     unsigned int new_len, rem_len, tmp_len;
+//     const unsigned char *shifted_message;
+
+//     tmp_len = SHA512_BLOCK_SIZE - ctx->len;
+//     rem_len = len < tmp_len ? len : tmp_len;
+
+//     memcpy(&ctx->block[ctx->len], message, rem_len);
+
+//     if (ctx->len + len < SHA512_BLOCK_SIZE) {
+//         ctx->len += len;
+//         return;
+//     }
+
+//     new_len = len - rem_len;
+//     block_nb = new_len / SHA512_BLOCK_SIZE;
+
+//     shifted_message = message + rem_len;
+
+//     sha512_transf(ctx, ctx->block, 1);
+//     sha512_transf(ctx, shifted_message, block_nb);
+
+//     rem_len = new_len % SHA512_BLOCK_SIZE;
+
+//     memcpy(ctx->block, &shifted_message[block_nb << 7],
+//            rem_len);
+
+//     ctx->len = rem_len;
+//     ctx->tot_len += (block_nb + 1) << 7;
+// }
+
+// void sha512_final(sha512_ctx *ctx, unsigned char *digest)
+// {
+//     unsigned int block_nb;
+//     unsigned int pm_len;
+//     unsigned int len_b;
+
+// #ifndef UNROLL_LOOPS
+//     int i;
+// #endif
+
+//     block_nb = 1 + ((SHA512_BLOCK_SIZE - 17)
+//                      < (ctx->len % SHA512_BLOCK_SIZE));
+
+//     len_b = (ctx->tot_len + ctx->len) << 3;
+//     pm_len = block_nb << 7;
+
+//     memset(ctx->block + ctx->len, 0, pm_len - ctx->len);
+//     ctx->block[ctx->len] = 0x80;
+//     UNPACK32(len_b, ctx->block + pm_len - 4);
+
+//     sha512_transf(ctx, ctx->block, block_nb);
+
+// #ifndef UNROLL_LOOPS
+//     for (i = 0 ; i < 8; i++) {
+//         UNPACK64(ctx->h[i], &digest[i << 3]);
+//     }
+// #else
+//     UNPACK64(ctx->h[0], &digest[ 0]);
+//     UNPACK64(ctx->h[1], &digest[ 8]);
+//     UNPACK64(ctx->h[2], &digest[16]);
+//     UNPACK64(ctx->h[3], &digest[24]);
+//     UNPACK64(ctx->h[4], &digest[32]);
+//     UNPACK64(ctx->h[5], &digest[40]);
+//     UNPACK64(ctx->h[6], &digest[48]);
+//     UNPACK64(ctx->h[7], &digest[56]);
+// #endif /* !UNROLL_LOOPS */
+// }
+
+// /* SHA-384 functions */
+
+// void sha384(const unsigned char *message, unsigned int len,
+//             unsigned char *digest)
+// {
+//     sha384_ctx ctx;
+
+//     sha384_init(&ctx);
+//     sha384_update(&ctx, message, len);
+//     sha384_final(&ctx, digest);
+// }
+
+// void sha384_init(sha384_ctx *ctx)
+// {
+// #ifndef UNROLL_LOOPS
+//     int i;
+//     for (i = 0; i < 8; i++) {
+//         ctx->h[i] = sha384_h0[i];
+//     }
+// #else
+//     ctx->h[0] = sha384_h0[0]; ctx->h[1] = sha384_h0[1];
+//     ctx->h[2] = sha384_h0[2]; ctx->h[3] = sha384_h0[3];
+//     ctx->h[4] = sha384_h0[4]; ctx->h[5] = sha384_h0[5];
+//     ctx->h[6] = sha384_h0[6]; ctx->h[7] = sha384_h0[7];
+// #endif /* !UNROLL_LOOPS */
+
+//     ctx->len = 0;
+//     ctx->tot_len = 0;
+// }
+
+// void sha384_update(sha384_ctx *ctx, const unsigned char *message,
+//                    unsigned int len)
+// {
+//     unsigned int block_nb;
+//     unsigned int new_len, rem_len, tmp_len;
+//     const unsigned char *shifted_message;
+
+//     tmp_len = SHA384_BLOCK_SIZE - ctx->len;
+//     rem_len = len < tmp_len ? len : tmp_len;
+
+//     memcpy(&ctx->block[ctx->len], message, rem_len);
+
+//     if (ctx->len + len < SHA384_BLOCK_SIZE) {
+//         ctx->len += len;
+//         return;
+//     }
+
+//     new_len = len - rem_len;
+//     block_nb = new_len / SHA384_BLOCK_SIZE;
+
+//     shifted_message = message + rem_len;
+
+//     sha512_transf(ctx, ctx->block, 1);
+//     sha512_transf(ctx, shifted_message, block_nb);
+
+//     rem_len = new_len % SHA384_BLOCK_SIZE;
+
+//     memcpy(ctx->block, &shifted_message[block_nb << 7],
+//            rem_len);
+
+//     ctx->len = rem_len;
+//     ctx->tot_len += (block_nb + 1) << 7;
+// }
+
+// void sha384_final(sha384_ctx *ctx, unsigned char *digest)
+// {
+//     unsigned int block_nb;
+//     unsigned int pm_len;
+//     unsigned int len_b;
+
+// #ifndef UNROLL_LOOPS
+//     int i;
+// #endif
+
+//     block_nb = (1 + ((SHA384_BLOCK_SIZE - 17)
+//                      < (ctx->len % SHA384_BLOCK_SIZE)));
+
+//     len_b = (ctx->tot_len + ctx->len) << 3;
+//     pm_len = block_nb << 7;
+
+//     memset(ctx->block + ctx->len, 0, pm_len - ctx->len);
+//     ctx->block[ctx->len] = 0x80;
+//     UNPACK32(len_b, ctx->block + pm_len - 4);
+
+//     sha512_transf(ctx, ctx->block, block_nb);
+
+// #ifndef UNROLL_LOOPS
+//     for (i = 0 ; i < 6; i++) {
+//         UNPACK64(ctx->h[i], &digest[i << 3]);
+//     }
+// #else
+//     UNPACK64(ctx->h[0], &digest[ 0]);
+//     UNPACK64(ctx->h[1], &digest[ 8]);
+//     UNPACK64(ctx->h[2], &digest[16]);
+//     UNPACK64(ctx->h[3], &digest[24]);
+//     UNPACK64(ctx->h[4], &digest[32]);
+//     UNPACK64(ctx->h[5], &digest[40]);
+// #endif /* !UNROLL_LOOPS */
+// }
+
+// /* SHA-224 functions */
+
+// void sha224(const unsigned char *message, unsigned int len,
+//             unsigned char *digest)
+// {
+//     sha224_ctx ctx;
+
+//     sha224_init(&ctx);
+//     sha224_update(&ctx, message, len);
+//     sha224_final(&ctx, digest);
+// }
+
+// void sha224_init(sha224_ctx *ctx)
+// {
+// #ifndef UNROLL_LOOPS
+//     int i;
+//     for (i = 0; i < 8; i++) {
+//         ctx->h[i] = sha224_h0[i];
+//     }
+// #else
+//     ctx->h[0] = sha224_h0[0]; ctx->h[1] = sha224_h0[1];
+//     ctx->h[2] = sha224_h0[2]; ctx->h[3] = sha224_h0[3];
+//     ctx->h[4] = sha224_h0[4]; ctx->h[5] = sha224_h0[5];
+//     ctx->h[6] = sha224_h0[6]; ctx->h[7] = sha224_h0[7];
+// #endif /* !UNROLL_LOOPS */
+
+//     ctx->len = 0;
+//     ctx->tot_len = 0;
+// }
+
+// void sha224_update(sha224_ctx *ctx, const unsigned char *message,
+//                    unsigned int len)
+// {
+//     unsigned int block_nb;
+//     unsigned int new_len, rem_len, tmp_len;
+//     const unsigned char *shifted_message;
+
+//     tmp_len = SHA224_BLOCK_SIZE - ctx->len;
+//     rem_len = len < tmp_len ? len : tmp_len;
+
+//     memcpy(&ctx->block[ctx->len], message, rem_len);
+
+//     if (ctx->len + len < SHA224_BLOCK_SIZE) {
+//         ctx->len += len;
+//         return;
+//     }
+
+//     new_len = len - rem_len;
+//     block_nb = new_len / SHA224_BLOCK_SIZE;
+
+//     shifted_message = message + rem_len;
+
+//     sha256_transf(ctx, ctx->block, 1);
+//     sha256_transf(ctx, shifted_message, block_nb);
+
+//     rem_len = new_len % SHA224_BLOCK_SIZE;
+
+//     memcpy(ctx->block, &shifted_message[block_nb << 6],
+//            rem_len);
+
+//     ctx->len = rem_len;
+//     ctx->tot_len += (block_nb + 1) << 6;
+// }
+
+// void sha224_final(sha224_ctx *ctx, unsigned char *digest)
+// {
+//     unsigned int block_nb;
+//     unsigned int pm_len;
+//     unsigned int len_b;
+
+// #ifndef UNROLL_LOOPS
+//     int i;
+// #endif
+
+//     block_nb = (1 + ((SHA224_BLOCK_SIZE - 9)
+//                      < (ctx->len % SHA224_BLOCK_SIZE)));
+
+//     len_b = (ctx->tot_len + ctx->len) << 3;
+//     pm_len = block_nb << 6;
+
+//     memset(ctx->block + ctx->len, 0, pm_len - ctx->len);
+//     ctx->block[ctx->len] = 0x80;
+//     UNPACK32(len_b, ctx->block + pm_len - 4);
+
+//     sha256_transf(ctx, ctx->block, block_nb);
+
+// #ifndef UNROLL_LOOPS
+//     for (i = 0 ; i < 7; i++) {
+//         UNPACK32(ctx->h[i], &digest[i << 2]);
+//     }
+// #else
+//    UNPACK32(ctx->h[0], &digest[ 0]);
+//    UNPACK32(ctx->h[1], &digest[ 4]);
+//    UNPACK32(ctx->h[2], &digest[ 8]);
+//    UNPACK32(ctx->h[3], &digest[12]);
+//    UNPACK32(ctx->h[4], &digest[16]);
+//    UNPACK32(ctx->h[5], &digest[20]);
+//    UNPACK32(ctx->h[6], &digest[24]);
+// #endif /* !UNROLL_LOOPS */
+// }
+
+

+ 108 - 0
app/bmc/encryption/sha2.h

@@ -0,0 +1,108 @@
+// /*
+//  * FIPS 180-2 SHA-224/256/384/512 implementation
+//  * Last update: 02/02/2007
+//  * Issue date:  04/30/2005
+//  *
+//  * Copyright (C) 2005, 2007 Olivier Gay <olivier.gay@a3.epfl.ch>
+//  * All rights reserved.
+//  *
+//  * Redistribution and use in source and binary forms, with or without
+//  * modification, are permitted provided that the following conditions
+//  * are met:
+//  * 1. Redistributions of source code must retain the above copyright
+//  *    notice, this list of conditions and the following disclaimer.
+//  * 2. Redistributions in binary form must reproduce the above copyright
+//  *    notice, this list of conditions and the following disclaimer in the
+//  *    documentation and/or other materials provided with the distribution.
+//  * 3. Neither the name of the project nor the names of its contributors
+//  *    may be used to endorse or promote products derived from this software
+//  *    without specific prior written permission.
+//  *
+//  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+//  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+//  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+//  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+//  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+//  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+//  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+//  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+//  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+//  * SUCH DAMAGE.
+//  */
+
+// #ifndef SHA2_H
+// #define SHA2_H
+
+// #define SHA224_DIGEST_SIZE ( 224 / 8)
+// #define SHA256_DIGEST_SIZE ( 256 / 8)
+// #define SHA384_DIGEST_SIZE ( 384 / 8)
+// #define SHA512_DIGEST_SIZE ( 512 / 8)
+
+// #define SHA256_BLOCK_SIZE  ( 512 / 8)
+// #define SHA512_BLOCK_SIZE  (1024 / 8)
+// #define SHA384_BLOCK_SIZE  SHA512_BLOCK_SIZE
+// #define SHA224_BLOCK_SIZE  SHA256_BLOCK_SIZE
+
+// #ifndef SHA2_TYPES
+// #define SHA2_TYPES
+// typedef unsigned char uint8;
+// typedef unsigned long uint32;
+// typedef unsigned long long uint64;
+// #endif
+
+// #ifdef __cplusplus
+// extern "C" {
+// #endif
+
+// typedef struct {
+//     unsigned int tot_len;
+//     unsigned int len;
+//     unsigned char block[2 * SHA256_BLOCK_SIZE];
+//     uint32 h[8];
+// } sha256_ctx;
+
+// typedef struct {
+//     unsigned int tot_len;
+//     unsigned int len;
+//     unsigned char block[2 * SHA512_BLOCK_SIZE];
+//     uint64 h[8];
+// } sha512_ctx;
+
+// typedef sha512_ctx sha384_ctx;
+// typedef sha256_ctx sha224_ctx;
+
+// void sha224_init(sha224_ctx *ctx);
+// void sha224_update(sha224_ctx *ctx, const unsigned char *message,
+//                    unsigned int len);
+// void sha224_final(sha224_ctx *ctx, unsigned char *digest);
+// void sha224(const unsigned char *message, unsigned int len,
+//             unsigned char *digest);
+
+// void sha256_init(sha256_ctx * ctx);
+// void sha256_update(sha256_ctx *ctx, const unsigned char *message,
+//                    unsigned int len);
+// void sha256_final(sha256_ctx *ctx, unsigned char *digest);
+// void sha256(const unsigned char *message, unsigned int len,
+//             unsigned char *digest);
+
+// void sha384_init(sha384_ctx *ctx);
+// void sha384_update(sha384_ctx *ctx, const unsigned char *message,
+//                    unsigned int len);
+// void sha384_final(sha384_ctx *ctx, unsigned char *digest);
+// void sha384(const unsigned char *message, unsigned int len,
+//             unsigned char *digest);
+
+// void sha512_init(sha512_ctx *ctx);
+// void sha512_update(sha512_ctx *ctx, const unsigned char *message,
+//                    unsigned int len);
+// void sha512_final(sha512_ctx *ctx, unsigned char *digest);
+// void sha512(const unsigned char *message, unsigned int len,
+//             unsigned char *digest);
+
+// #ifdef __cplusplus
+// }
+// #endif
+
+// #endif /* !SHA2_H */
+

+ 427 - 0
app/bmc/ipmb/IPMBIfc.c

@@ -0,0 +1,427 @@
+/*
+*	Brief:	Implement IPMB send and receive function in this file, include primary IPMB and secondary IPMB.
+*	Author:	Jimbo_Zhang@outlook.com
+*	Date:	2019-9-9
+*/
+
+/* Standard includes. */
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+
+#include "com_IPMI_LANIfc.h"
+#include "com_IPMI_RMCP.h"
+#include "RMCP.h"
+#include "LANIfc.h"
+#include "com_IPMIDefs.h"
+#include "RMCP.h"
+#include "MD.h"
+#include <netdb.h>        /* getaddrinfo(3) et al.                       */
+#include <netinet/in.h>   /* sockaddr_in & sockaddr_in6 definition.      */
+#include  <net/if.h>
+#include <sys/prctl.h>
+#include "main.h"
+#include "Session.h"
+#include "com_IPMI_SDR.h"
+#include "com_IPMI_Storage.h"
+#include "SDR.h"
+
+//static int sendIPMBPkt(uint32_t ipmb_bus, uint8_t* i2c_send_buf, uint8_t size);
+static uint8_t ValidateIPMBChkSums ( uint8_t* Data, uint8_t Size);
+static void ProcessIPMBReq ( MsgPkt_T* pReq);
+uint8_t IsResponseMatch (MsgPkt_T* pReq, MsgPkt_T* pRes);
+static void* RecvIPMBPkt (void *pArg);
+
+int gFd_PrimaryIpmbIfcQ, gFd_PrimaryIpmbResQ;
+int gFd_SecondaryIpmbIfcQ, gFd_SecondaryIpmbResQ;
+int gFd_Primary,  gFd_Secondary;
+
+/*!
+    \brief      IPMB Task. Generating primary_IPMB task and secondary_IPMB task in this task.
+    \param:		0: primary ipmb, 1: secondary ipmb
+    \retval     none
+*/
+void *IPMBIfcTask(void *Param)
+{
+//	int i;
+	MsgPkt_T RcvMsgPkt;
+    uint8_t dev_name[10] = {0};
+    uint8_t IPMB_IFC_Q[32] = {0};
+    uint8_t IPMB_RES_Q[32] = {0};
+    uint8_t OwnerAddr;
+    int 	fd_IpmbDev;
+    int 	fd_IpmbIfcQ, fd_IpmbResQ;
+    uint8_t ipmbSelect = *(uint8_t*)Param;
+    int RetVal;
+    
+    //printf("ipmbSelect: %d\n", ipmbSelect);
+    //Primary IPMB
+    if((ipmbSelect == 0) && g_BMCInfo.IpmiConfig.PrimaryIPMBSupport)
+    {
+		printf("Primary IPMBIfcTask start...\n");
+		strcpy(IPMB_IFC_Q, PRIMARY_IPMB_IFC_Q);	
+		strcpy(IPMB_RES_Q, PRIMARY_IPMB_RES_Q);	
+		sprintf(dev_name, "/dev/i2c%d", g_BMCInfo.IpmiConfig.PrimaryIPMBBus);
+		OwnerAddr	=	g_BMCInfo.IpmiConfig.PrimaryIPMBAddr;
+	}
+	//Secondary IPMB
+	else if((ipmbSelect == 1) && g_BMCInfo.IpmiConfig.SecondaryIPMBSupport)
+	{
+		printf("Secondary IPMBIfcTask start...\n");
+		strcpy(IPMB_IFC_Q, SECONDARY_IPMB_IFC_Q);	
+		strcpy(IPMB_RES_Q, SECONDARY_IPMB_RES_Q);
+		sprintf(dev_name, "/dev/i2c%d", g_BMCInfo.IpmiConfig.SecondaryIPMBBus);
+		OwnerAddr	=	g_BMCInfo.IpmiConfig.SecondaryIPMBAddr;
+	}
+	else
+	{
+		printf("Invalid param! %d\n", ipmbSelect);
+		return (void *)-1;
+	}
+
+	//create IPMB_IFC_Q
+    if(-1 != access(IPMB_IFC_Q, F_OK))
+    {
+        remove(IPMB_IFC_Q);
+    }
+    if(0 != mkfifo (IPMB_IFC_Q, 0777))
+    {
+        printf("%s: Create %s fifo failed! %s\n", __FUNCTION__, IPMB_IFC_Q, strerror(errno));
+        return (void*)-1;
+    }
+    fd_IpmbIfcQ = open (IPMB_IFC_Q, O_RDWR);
+    if(-1 == fd_IpmbIfcQ)
+    {
+        printf("%s: Open %s fifo failed! %s\n", __FUNCTION__, IPMB_IFC_Q, strerror(errno));
+        return (void*)-1;
+    }
+
+	//create IPMB_RES_Q
+    if(-1 != access(IPMB_RES_Q, F_OK))
+    {
+        remove(IPMB_RES_Q);
+    }
+    if(0 != mkfifo (IPMB_RES_Q, 0777))
+    {
+        printf("%s: Create %s fifo failed! %s\n", __FUNCTION__, IPMB_RES_Q, strerror(errno));
+        return (void*)-1;
+    }
+    fd_IpmbResQ = open (IPMB_RES_Q, O_RDWR);
+    if(-1 == fd_IpmbResQ)
+    {
+        printf("%s: Open %s fifo failed! %s\n", __FUNCTION__, IPMB_RES_Q, strerror(errno));
+        return (void*)-1;
+    }
+
+    fd_IpmbDev = open (dev_name, O_RDWR);
+    if(-1 == fd_IpmbDev)
+    {
+        printf("%s: Open IPMB failed! %s\n", __FUNCTION__, strerror(errno));
+        return (void*)-1;
+    }
+    //set IPMB address
+    if(0 != stm32_i2c_set_addr(fd_IpmbDev, OwnerAddr))
+    	printf("Set ipmb address fail.\n");
+
+	if(ipmbSelect == 0)
+    {
+    	gFd_PrimaryIpmbIfcQ = fd_IpmbIfcQ;
+    	gFd_PrimaryIpmbResQ = fd_IpmbResQ;
+    	gFd_Primary 	=	fd_IpmbDev;
+    }
+    else if(ipmbSelect == 1)
+    {
+    	gFd_SecondaryIpmbIfcQ = fd_IpmbIfcQ;
+    	gFd_SecondaryIpmbResQ = fd_IpmbResQ;
+    	gFd_Secondary 	=	fd_IpmbDev;
+    }
+
+    /*Create a thread to recv IPMB Pkt */
+	gThreadIndex++;	
+    if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,RecvIPMBPkt,Param))
+    {
+        printf("%s: Create RecvIPMBPkt thread failed! %s\n", __FUNCTION__, strerror(errno));
+        return (void *)-1; 
+    }
+
+	while(1)
+	{		
+		while(GetMsg(fd_IpmbIfcQ, &RcvMsgPkt, WAIT_INFINITE) != 0);
+		
+		switch(RcvMsgPkt.Param)
+		{
+			case PARAM_REQUEST:
+				ProcessIPMBReq (&RcvMsgPkt);
+				break;
+			case PARAM_BRIDGE:
+                /* Send the response */
+                if(RcvMsgPkt.Channel == PRIMARY_IPMB_CHANNEL)
+                {
+                    RetVal = stm32_i2c_master_write(gFd_Primary, RcvMsgPkt.Data[0], &RcvMsgPkt.Data[1], RcvMsgPkt.Size);
+                }
+                else if(RcvMsgPkt.Channel == SECONDARY_IPMB_CHANNEL)
+                {
+                    RetVal = stm32_i2c_master_write(gFd_Secondary, RcvMsgPkt.Data[0], &RcvMsgPkt.Data[1], RcvMsgPkt.Size);
+                }
+                else
+                {
+                    printf("IPMBIfc.c: IPMB channel error. %#x\r\n", RcvMsgPkt.Channel);
+                }
+
+                if (RetVal < 0)
+                {
+                    printf ("IPMBIfc.c : Unable to send a IPMI Bridge Message\n");
+                    RespondSendMessage (&RcvMsgPkt, STATUS_FAIL);
+                }
+                else
+                {
+                    RespondSendMessage (&RcvMsgPkt, STATUS_OK);
+                }
+                printf("---> IPMBIfcTask/BRIDGING_REQUEST\n");
+                break;
+            default:
+				printf("Unknow message param %#x\r\n", RcvMsgPkt.Param);
+				break;
+		}
+		
+	}
+}
+
+
+
+/**
+ * @brief Process the request posted by IPMB driver.
+ * @param pReq - Request message pointer.
+**/
+static void
+ProcessIPMBReq ( MsgPkt_T* pReq)
+{
+    MsgPkt_T             	ResPkt;
+    uint8_t              	ReqLen;
+    IPMIMsgHdr_T* 			pIPMIMsgReq = (IPMIMsgHdr_T*) pReq->Data;
+   
+    int RetVal = 0;
+    ReqLen = pReq->Size;
+	
+    /* Validate Checksums */
+    if (TRUE != ValidateIPMBChkSums ((uint8_t*)pIPMIMsgReq, ReqLen))
+    {
+        printf ("IPMBIfc.c : IPMB Checksum validation failed\r\n");
+        return;
+    }
+
+    pReq->Param			= PARAM_IFC;
+    pReq->Cmd			= pIPMIMsgReq->Cmd;
+    pReq->NetFnLUN		= pIPMIMsgReq->NetFnLUN;
+
+    if(pReq->Channel == PRIMARY_IPMB_CHANNEL)
+    	pReq->SrcQ 			= gFd_PrimaryIpmbResQ;
+    else
+    	pReq->SrcQ 			= gFd_SecondaryIpmbResQ;
+	
+    /* Post the message to message handler Task */
+    PostMsg (gFd_MsgHndlrIfc, pReq);
+       
+    if(pReq->ResTimeOut < 1)	pReq->ResTimeOut = 10;
+    do
+    {
+    	if(pReq->Channel == PRIMARY_IPMB_CHANNEL)
+      		RetVal = GetMsg (gFd_PrimaryIpmbResQ, &ResPkt, pReq->ResTimeOut);  
+      	else
+      		RetVal = GetMsg (gFd_SecondaryIpmbResQ, &ResPkt, pReq->ResTimeOut);  
+
+    }while(!RetVal && !IsResponseMatch(pReq, &ResPkt) );
+	
+	if (0 != RetVal)
+    {
+		printf("Warning: Process IPMB request fail, return timeout.\r\n");
+		ResPkt.Param	=	PARAM_NORMAL_RESPONSE;
+		ResPkt.Size		=	sizeof(IPMIMsgHdr_T)+2;
+		
+		SwapIPMIMsgHdr(((IPMIMsgHdr_T*)pReq->Data), ((IPMIMsgHdr_T*)ResPkt.Data));
+		ResPkt.Data[sizeof(IPMIMsgHdr_T)]	=	CC_TIMEOUT;
+		ResPkt.Data[sizeof(IPMIMsgHdr_T)+1]	=	CalculateCheckSum2(ResPkt.Data, sizeof(IPMIMsgHdr_T)+1);
+    }   
+
+    /* If its not normal IPMI Response just return */
+    if (PARAM_NO_RESPONSE == ResPkt.Param)
+    {
+        printf ("IPMBIfc.c : IPMB request packet dropped, not processed\n");
+        return;
+    }
+
+    /* Send the response */
+	if(pReq->Channel == PRIMARY_IPMB_CHANNEL)
+	{
+		RetVal = stm32_i2c_master_write(gFd_Primary, ResPkt.Data[0], &ResPkt.Data[1], ResPkt.Size);
+	}
+	else if(pReq->Channel == SECONDARY_IPMB_CHANNEL)
+	{
+		RetVal = stm32_i2c_master_write(gFd_Secondary, ResPkt.Data[0], &ResPkt.Data[1], ResPkt.Size);
+	}
+	else
+	{
+		printf("IPMBIfc.c: IPMB channel error. %#x\r\n", pReq->Channel);
+	}
+	
+    if (0 != RetVal)
+    {
+        printf ("IPMBIfc.c : Unable to send a IPMI Response\n");
+    }
+    return;
+}
+
+/**
+ * @brief Validate IPMB Checksums.
+ * @param Data - Buffer to be validated.
+ * @param Size - Size of the buffer.
+ * @return TRUE if valid, FALSE if error.
+**/
+static uint8_t ValidateIPMBChkSums ( uint8_t* Data, uint8_t Size)
+{
+    uint8_t i;
+    uint8_t chksum;
+
+    /* Check IPMB message min size */
+    if (Size < MIN_IPMB_MSG_LENGTH)
+    {
+        printf("IPMBIfc.c: Invalid IPMB Message Length\r\n");
+        return FALSE;
+    }
+
+    /* Validate the checksum1 */
+    chksum = 0;
+    for (i = 0; i < 3; i++)
+    {
+        chksum += *(Data + i);
+    }
+
+    if (chksum != 0)
+    {
+       
+		printf ("IPMBIfc.c: Invalid checksum 1, size = %d\n",Size);
+		for(i = 0; i < Size;i++)
+			printf("%x ",Data[i]);
+		printf("\n");
+        return FALSE;
+    }
+    /* Validate the checksum2 */
+    chksum = 0;
+    for (i = 3; i < Size; i++)
+    {
+        chksum += *(Data + i);
+    }
+
+    if (chksum != 0)
+    {
+       
+		printf("IPMBIfc.c: Invalid checksum 2, size = %d\n",Size);
+		for(i = 0; i < Size;i++)
+			printf("%x ",Data[i]);
+		printf("\n");
+        
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
+
+/*-----------------------------------------------------
+ * @fn IsResponseMatch
+ * @brief Checks if the Response Message corresponds to 
+ *        the Request Message
+ * 
+ * @param pReq    : IPMI Request Message Packet
+ * @param pRes    : IPMI Response Message Packet
+ * 
+ * @return  1 if match
+ *          0 if mismatch
+ *----------------------------------------------------*/
+uint8_t IsResponseMatch (MsgPkt_T* pReq, MsgPkt_T* pRes)
+{
+
+    if( ( ((((IPMIMsgHdr_T*)pRes->Data)->RqSeqLUN) >> 2) != ((((IPMIMsgHdr_T*)pReq->Data)->RqSeqLUN) >> 2) ) && 
+        ( (pReq->NetFnLUN & 0x4) && (PARAM_NO_RESPONSE != pRes->Param) ) )
+    {
+        return FALSE;
+    }
+  
+    return TRUE;
+}
+
+
+
+/**
+ * @fn RecvIPMBPkt
+ * @brief This function receives IPMB request packet and post the message to
+ *        IPMB interface queue
+**/
+static void* RecvIPMBPkt (void *Param)
+{
+    MsgPkt_T    IPMBReqPkt;
+    int IPMBSlaveFd;
+    int retval;
+    uint8_t ipmbSelect = *(uint8_t*)Param;
+
+    prctl(PR_SET_NAME, __FUNCTION__, 0, 0, 0);
+    int curThreadIndex = 0;
+
+    memset(&IPMBReqPkt,0,sizeof(MsgPkt_T));
+    if(0 == ipmbSelect)
+    {
+    	printf ("Primary IPMB Receiver Started...\n");
+        IPMBReqPkt.Data [0] = g_BMCInfo.IpmiConfig.PrimaryIPMBAddr;
+        IPMBReqPkt.Channel = PRIMARY_IPMB_CHANNEL;
+        IPMBSlaveFd = gFd_Primary;
+    }
+    else if(1 == ipmbSelect)
+    {
+    	printf ("Secondary IPMB Receiver Started...\n");
+        IPMBReqPkt.Data [0] = g_BMCInfo.IpmiConfig.SecondaryIPMBAddr;
+        IPMBReqPkt.Channel = SECONDARY_IPMB_CHANNEL;
+        IPMBSlaveFd = gFd_Secondary;
+    }
+
+    /* Loop forever */
+    while (1)
+    {
+        retval = stm32_i2c_slave_recv(IPMBSlaveFd, &IPMBReqPkt.Data[1]);
+        if( retval > 5)
+        {
+            IPMBReqPkt.Param    = PARAM_REQUEST;
+            IPMBReqPkt.Size     = retval + 1;       /* +1 to include BMC Slave address */
+
+            /* Post the IPMB Request message to IPMBIfc Queue */
+            if(ipmbSelect == 0)
+            {
+                if (0 != PostMsg (gFd_PrimaryIpmbIfcQ, &IPMBReqPkt))
+                {
+                    printf ("IPMBIfc.c : Error posting message to IPMBIfc_Q\n");
+                }
+            }
+            else
+            {
+                if (0 != PostMsg (gFd_SecondaryIpmbIfcQ, &IPMBReqPkt))
+                {
+                    printf ("IPMBIfc.c : Error posting message to IPMBIfc_Q\n");
+                }
+            }
+        }
+
+        int cnt;
+        if(0 == ipmbSelect)
+        	printf("---> Primary IPMB Recv: ");
+        else
+        	printf("---> Secondary IPMB Recv: ");
+
+    	for(cnt=0;cnt < IPMBReqPkt.Size; cnt++)
+        	printf("%#x ", IPMBReqPkt.Data[cnt]);
+        printf("\n");
+	}
+    return (void*)-1;
+}

+ 7 - 0
app/bmc/ipmb/IPMBIfc.h

@@ -0,0 +1,7 @@
+#ifndef __IPMB_IFC_H__
+#define __IPMB_IFC_H__
+
+
+void *IPMBIfcTask( void *Param);
+
+#endif /* __IPMB_IFC_H__ */

+ 0 - 0
app/bmc_server/ipmi_dev/Ciphertable.h → app/bmc/lan/Ciphertable.h


+ 726 - 0
app/bmc/lan/LANIfc.c

@@ -0,0 +1,726 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************/
+/*****************************************************************
+ *
+ * LANIfc.c
+ * LAN Interface Handler
+ *
+ * Author: Govind Kothandapani <govindk@ami.com>
+ *       : Bakka Ravinder Reddy <bakkar@ami.com>
+ *
+ *****************************************************************/
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+
+#include "com_IPMI_LANIfc.h"
+#include "com_IPMI_RMCP.h"
+#include "RMCP.h"
+#include "LANIfc.h"
+#include "com_IPMIDefs.h"
+#include "RMCP.h"
+#include "MD.h"
+#include <netdb.h>        /* getaddrinfo(3) et al.                       */
+#include <netinet/in.h>   /* sockaddr_in & sockaddr_in6 definition.      */
+#include  <net/if.h>
+#include <sys/prctl.h>
+#include "main.h"
+#include "Session.h"
+
+#define NO_OF_RETRY                     3
+#define MAX_POSSIBLE_IPMI_DATA_SIZE     1000
+#define MAX_LAN_BUFFER_SIZE             1024
+#define LAN_TIMER_INTERVAL              10
+
+#define RMCP_CLASS_MSG_OFFSET           3
+#define IPMI_MSG_AUTH_TYPE_OFFSET       4
+#define RMCP_ASF_PING_MESSAGE_LENGTH    12
+#define IPMI_MSG_LEN_OFFSET             13
+#define IPMI20_MSG_LEN_OFFSET           14
+#define RMCP_CLASS_MSG_ASF              0x06
+#define RMCP_CLASS_MSG_IPMI             0x07
+
+//static void*    LANTimer (void*);
+static void*    RecvLANPkt (void*);
+static int      SendLANPkt (MsgPkt_T *pRes );
+static void     ProcessLANReq (  MsgPkt_T* pReq);
+static void		ProcessBridgeMsg (  MsgPkt_T* pReq );
+
+static int 		InitUDPSocket(void);
+static int SetIPv4Header(int socketID);
+
+
+/****************************Our additions for timing out connections****************************/
+/*We need a way to timeout connect calls faster in case of wrong email server ip entered
+so I created a connect_tmout function that gives this granularity
+we don't want to spend too much time in test alert etc waiting for connection timeouts*/
+
+// static void SetSocketNonBlocking(int s)
+// {
+// 	int flags;
+
+// 	flags = fcntl(s, F_GETFL, 0);
+// 	if(flags == -1)
+// 	{
+// 		flags = 0;
+// 	}
+
+// 	flags |= O_NONBLOCK;
+
+// 	flags = fcntl(s, F_SETFL, flags);
+// 	if(flags == -1)
+// 	{
+// 		printf("Could not set socket to non blocking!!\n");
+// 	}
+
+// 	return;
+// }
+
+int gSocket_LAN = -1;
+int gFd_LanIfcQ, gFd_LanResQ;
+
+/**
+ * @brief LAN Interface Task.
+**/
+void *LANIfcTask (void *param)
+{
+	MsgPkt_T    Req;
+	int i,BMC,Buffer = 0;
+	uint8_t ethindex=0;
+	
+	prctl(PR_SET_NAME,__FUNCTION__,0,0,0);
+	int curThreadIndex = 0;
+
+	/* Init LAN SMB */
+	printf("LANIfc Task Started... \n");
+
+	//create LAN_IFC_Q
+    if(-1 != access(LAN_IFC_Q, F_OK))
+    {
+        remove(LAN_IFC_Q);
+    }
+    if(0 != mkfifo (LAN_IFC_Q, 0777))
+    {
+        printf("%s: Create %s fifo failed! %s\n", __FUNCTION__, LAN_IFC_Q, strerror(errno));
+        return (void*)-1;
+    }
+    gFd_LanIfcQ = open (LAN_IFC_Q, O_RDWR);
+    if(-1 == gFd_LanIfcQ)
+    {
+        printf("%s: Open %s fifo failed! %s\n", __FUNCTION__, LAN_IFC_Q, strerror(errno));
+        return (void*)-1;
+    }
+
+	//create LAN_RES_Q
+    if(-1 != access(LAN_RES_Q, F_OK))
+    {
+        remove(LAN_RES_Q);
+    }
+    if(0 != mkfifo (LAN_RES_Q, 0777))
+    {
+        printf("%s: Create %s fifo failed! %s\n", __FUNCTION__, LAN_RES_Q, strerror(errno));
+        return (void*)-1;
+    }
+    gFd_LanResQ = open (LAN_RES_Q, O_RDWR);
+    if(-1 == gFd_LanResQ)
+    {
+        printf("%s: Open %s fifo failed! %s\n", __FUNCTION__, LAN_RES_Q, strerror(errno));
+        return (void*)-1;
+    }
+
+    /* Create LAN socket */
+    if(0 != InitUDPSocket())
+    {
+    	printf("%s: Create UDP socket failed! %s\n", __FUNCTION__, strerror(errno));
+    	return (void *)-1; 
+    }
+
+	/*Create a thread to recv UDS Pkt */
+	gThreadIndex++;	
+    if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,RecvLANPkt,NULL))
+    {
+        printf("%s: Create RecvLANPkt thread failed! %s\n", __FUNCTION__, strerror(errno));
+        return (void *)-1; 
+    }
+
+	while (1)
+	{		
+		/* Wait for a message in LANIfc interface Queue */
+		if (0 != GetMsg (gFd_LanIfcQ, &Req, WAIT_INFINITE))
+		{
+			printf("LANIfc.c : Error fetching message from hLANIfc_Q\n");
+			continue;
+		}
+
+		switch (Req.Param)
+		{
+		case LAN_SMB_REQUEST :
+			ProcessLANReq (&Req);
+			break;
+
+		case BRIDGING_REQUEST :
+			ProcessBridgeMsg (&Req );
+			break;
+
+		default :
+			printf ("LANIfc.c : Invalid request\n");
+			break;
+		}
+	}
+}
+
+/**
+ * @fn InitUnixDomainSocket
+ * @brief This function is used to create the Socket for each BMC
+ * @param BMCInst
+**/
+static int InitUDPSocket(void)
+{
+  	struct  sockaddr_in local;
+  	char    UDPIfcName [MAX_STR_LENGTH];
+  	int 	reuseaddr = 1;
+
+  	memset(UDPIfcName,0,sizeof(UDPIfcName));
+
+  	if(gSocket_LAN != -1)
+  	{
+  		close(gSocket_LAN);
+  		gSocket_LAN = -1;
+  	}
+
+	memset(&local, 0, sizeof(struct sockaddr_in));
+	local.sin_family = AF_INET;
+	local.sin_port = htons(623);
+	local.sin_addr.s_addr = htonl(INADDR_ANY);  
+
+    gSocket_LAN = socket(AF_INET,SOCK_DGRAM,0);
+    if(-1 == gSocket_LAN)
+    {
+        printf("LANIfc.c : Unable to create the UDP Socket\n");
+        return -1;
+    }
+
+    //printf("UDP Socket %d\n", gSocket_LAN);
+
+    strcpy(UDPIfcName,"eth0");
+	
+	if (0 != setsockopt (gSocket_LAN, SOL_SOCKET,SO_BINDTODEVICE, UDPIfcName, sizeof (UDPIfcName)+1))
+	{
+		printf("LANIfc.c: SetSockOpt(SO_BINDTODEVICE) Failed for UDP Socket\n");
+		return -1;
+	}
+	if (0 != setsockopt(gSocket_LAN, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(int)))
+	{
+		printf("LANIfc.c: Setsockopt(SO_REUSEADDR) Failed for UDP socket\n");
+	}
+	SetIPv4Header(gSocket_LAN);
+  
+    /* Bind */
+    if (-1 == bind(gSocket_LAN,(struct sockaddr *)&local,sizeof(local)))
+    {
+        printf("LANIfc.c : Error binding  UDP Socket, %d, %s\n", errno, strerror(errno));
+        return -1;
+    }
+
+    //printf("Create UDP socket successfully, socket %d, port: %d\n", gSocket_LAN, local.sin_port);
+
+    return 0;
+}
+
+/**
+ * @fn  ReadData
+ * @brief This function receives the IPMI LAN request packets
+ *
+ * @param pMsgPkt - pointer to message packet
+ * @param Socket  - Socket handle
+**/
+static
+int  ReadData (MsgPkt_T *pMsgPkt, int Socket )
+{
+	unsigned int    SourceLen = 0,Index,SocktIndex=0,addrlen=0;
+	int 			Channel = 0;
+	uint8_t   *pData      = pMsgPkt->Data;
+	int16_t   Len         = 0;
+	uint16_t  RecvdLen    = 0;
+	uint16_t  IPMIMsgLen  = 0;
+	uint16_t  IPMIMsgOffset   = 0;
+	struct  sockaddr_in Sourcev4;
+	struct  sockaddr_in server_v4addr;
+	void *Source = NULL ;
+	void *server_addr = NULL ;
+	uint8_t  WaitCount;
+	int i;
+			
+	
+	Source = &Sourcev4;
+	SourceLen = sizeof (Sourcev4);
+	
+	//printf("ReadData:\n");
+	 //SourceLen = sizeof (Source);
+	/* Read minimum bytes to find class of message */
+	while (RecvdLen < RMCP_CLASS_MSG_OFFSET)
+	{
+		Len = recvfrom (Socket, &pData[RecvdLen], MAX_LAN_BUFFER_SIZE, 0, (struct sockaddr *)Source, &SourceLen);
+		// printf("Recv1 %d: ", Len);
+		// for(i=0;i<Len;i++)
+		// 	printf("%#x ", pData[RecvdLen+i]);
+		// printf("\n");
+
+		if ((Len >= -1) && (Len <= 0))
+		{
+			return -1;
+		}
+		RecvdLen += (uint16_t)Len;
+	}
+
+
+	/*  if RMCP Presence Ping Requested */
+	if (RMCP_CLASS_MSG_ASF == pData[RMCP_CLASS_MSG_OFFSET])
+	{
+		/* Read remaining RMCP ASF ping message */
+		while (RecvdLen < RMCP_ASF_PING_MESSAGE_LENGTH)
+		{
+			Len = recvfrom (Socket, &pData[RecvdLen], MAX_LAN_BUFFER_SIZE, 0, (struct sockaddr *)Source, &SourceLen);
+			// printf("Recv2 %d: ", Len);
+			// for(i=0;i<Len;i++)
+			// 	printf("%#x ", pData[RecvdLen+i]);
+			// printf("\n");
+			if ((Len >= -1) && (Len <= 0))
+			{
+				return -1;
+			}
+			RecvdLen += (uint16_t)Len;
+		}
+	}
+			/*else if IPMI RMCP request */
+	else if (RMCP_CLASS_MSG_IPMI == pData[RMCP_CLASS_MSG_OFFSET])
+	{
+		/* Read minimum no of bytes for IPMI Auth type offset*/
+		while (RecvdLen < IPMI_MSG_AUTH_TYPE_OFFSET)
+		{
+			Len = recvfrom (Socket, &pData[RecvdLen], MAX_LAN_BUFFER_SIZE, 0,(struct sockaddr *)Source, &SourceLen);
+			// printf("Recv3 %d: ", Len);
+			// for(i=0;i<Len;i++)
+			// 	printf("%#x ", pData[RecvdLen+i]);
+			// printf("\n");
+			if ((Len >= -1) && (Len <= 0))
+			{
+				return -1;
+			}
+			RecvdLen += (uint16_t)Len;
+		}
+		/* Get the IPMI message length offset based on format/authentication type */
+		if (pData [IPMI_MSG_AUTH_TYPE_OFFSET] == RMCP_PLUS_FORMAT)
+		{
+			IPMIMsgOffset = IPMI20_MSG_LEN_OFFSET + 1;
+		}
+		else if (pData [IPMI_MSG_AUTH_TYPE_OFFSET] == AUTH_TYPE_NONE)
+		{
+			IPMIMsgOffset = IPMI_MSG_LEN_OFFSET;
+		}
+		else
+		{
+			IPMIMsgOffset = IPMI_MSG_LEN_OFFSET + AUTH_CODE_LEN;
+		}
+
+		/* Read minimum no of bytes for IPMI message length offset*/
+		while (RecvdLen < IPMIMsgOffset)
+		{
+			Len = recvfrom (Socket, &pData[RecvdLen], MAX_LAN_BUFFER_SIZE, 0,(struct sockaddr *)Source, &SourceLen);
+			// printf("Recv4 %d: ", Len);
+			// for(i=0;i<Len;i++)
+			// 	printf("%#x ", pData[RecvdLen+i]);
+			// printf("\n");
+			if ((Len >= -1) && (Len <= 0))
+			{
+				return -1;
+			}
+			RecvdLen += (uint16_t)Len;
+		}
+
+		/* Get the IPMI message length based on RMCP format type */
+		if (pData [IPMI_MSG_AUTH_TYPE_OFFSET] == RMCP_PLUS_FORMAT)
+		{
+			IPMIMsgLen = *((uint16_t*)&pData [IPMI20_MSG_LEN_OFFSET]);
+		}
+		else
+		{
+			IPMIMsgLen = pData [IPMIMsgOffset];
+		}
+		/* We are assuming that we cannot get more than 17 K data in IPMI Msg */
+		/* This work around for fix the malformed IPMI Msg length */
+
+		if(IPMIMsgOffset > MAX_POSSIBLE_IPMI_DATA_SIZE )
+		{
+			return -1;
+		}
+		/* Read the remaining IPMI message packets */
+		WaitCount = 3;
+		while (RecvdLen < IPMIMsgLen)
+		{
+			Len = recvfrom (Socket, &pData[RecvdLen], MAX_LAN_BUFFER_SIZE, 0,(struct sockaddr *)Source, &SourceLen);
+			// printf("Recv5 %d: ", Len);
+			// for(i=0;i<Len;i++)
+			// 	printf("%#x ", pData[RecvdLen+i]);
+			// printf("\n");
+			if ((Len >= -1) && (Len <= 0))
+			{
+				if(Len == -1)
+				{
+					if(errno == EAGAIN)
+					{
+					   WaitCount--;
+					}
+					else
+					   return -1;
+				}
+				else
+					return -1;
+			}
+			if(WaitCount == 0)
+			{
+				return -1;
+			}
+			RecvdLen += (uint16_t)Len;
+		}
+	}/* else other RMCP class are not supported. */
+	else
+	{
+		printf ("Unknown RMCP class\n");
+	}
+
+	pMsgPkt->Size     = RecvdLen;
+	pMsgPkt->UDPPort  = ((struct sockaddr_in *)Source)->sin_port;
+	pMsgPkt->Socket   = Socket;
+	pMsgPkt->Channel  = LAN_RMCP_CHANNEL;
+	
+	// printf("\nLan received %d: ",RecvdLen);
+	// for(i=0;i<RecvdLen;i++)
+	// {
+	// 	printf("%#x ", pData[i]);
+	// }
+	// printf("\n");
+
+	if(SourceLen!=0) 
+	{
+		memcpy (pMsgPkt->IPAddr, &((struct sockaddr_in *)Source)->sin_addr.s_addr, sizeof (struct in_addr));
+	}
+
+	pMsgPkt->Param    = LAN_SMB_REQUEST;
+	
+	return 0;
+}
+
+void *RecvLANPkt(void *pArg)
+{
+    MsgPkt_T            MsgPkt;
+    struct timeval Timeout;
+    struct sockaddr_in local;
+    int RetVal,max,Index = 0;
+    unsigned int locallen;
+    prctl(PR_SET_NAME,__FUNCTION__,0,0,0);
+    fd_set  fds;
+
+    memset(&local,0,sizeof(local));
+
+    locallen=sizeof(local);
+
+    printf("RecvLANPkt start...\n");
+    while(1)
+    {
+        Timeout.tv_sec  =   SESSION_TIMEOUT; 
+        Timeout.tv_usec  =   0; 
+
+        FD_ZERO(&fds);
+        if(gSocket_LAN != -1)
+            FD_SET(gSocket_LAN,&fds);
+        
+        max = gSocket_LAN+1;
+
+        /*Waits for an event to occur on socket*/
+        RetVal = select (max, &fds, NULL, NULL, &Timeout);
+        if (-1 == RetVal)
+        {
+            continue;
+        }
+        if (0 == RetVal)
+        {
+            /* Its due to timeout - continue */
+            continue;
+        }
+        
+        /*Accepting Connection*/
+        if(FD_ISSET(gSocket_LAN,&fds))
+        {
+            if(0 ==  ReadData( &MsgPkt,gSocket_LAN))
+            {
+                /* Post the request packet to LAN Interface Queue */
+				if (0 != PostMsg (gFd_LanIfcQ, &MsgPkt))
+				{
+					printf ("LANIfc.c : Error posting message to LANIfc Q\n");
+				}               
+            }       
+            else
+            {
+                close(gSocket_LAN);
+                gSocket_LAN = -1;
+            }      
+        }
+   }
+}
+
+/**
+ * @fn SendLANPkt
+ * @brief This function sends the IPMI LAN Response to the requester
+ * @param pRes - Response message.
+**/
+int SendLANPkt (MsgPkt_T *pRes )
+{
+	struct  sockaddr_in Dest;
+	//struct stat Stat;
+	int ret = 0;
+	
+	/* Set the destination UDP port and IP Address */
+	Dest.sin_family     =   AF_INET;
+	Dest.sin_port       =   pRes->UDPPort;
+	memcpy (&Dest.sin_addr.s_addr, pRes->IPAddr, sizeof (struct in_addr));
+	
+	/* Send the LAN response packet */
+	// int i;
+	// printf("\nLan send socket: %d, byte: %d: ", pRes->Socket, pRes->Size);
+	// for (i = 0; i < pRes->Size; ++i)
+	// {
+	// 	printf("%#x ", pRes->Data[i]);
+	// }
+	// printf("\n");
+
+	//Check the socket before send a message on a socket
+	//if (fstat(pRes->Socket, &Stat) != -1) 
+	{
+		
+		ret = sendto (pRes->Socket, pRes->Data, pRes->Size, 0, (struct sockaddr*)&Dest, sizeof (Dest));
+		if (ret == -1)
+		{
+			printf ("LANIfc.c : Error sending response packets to LAN, %s\n",strerror(errno));
+		}
+		// else
+		// {
+		// 	printf ("LANIfc.c : LAN packet sent successfully\n");
+		// }
+	}
+
+	return 1;
+}
+
+
+/**
+ * @brief Process SMB Request.
+ * @param pReq - Request message.
+**/
+static void
+ProcessLANReq (  MsgPkt_T* pReq )
+{
+	MsgPkt_T        Res;
+	SessionInfo_T*  pSessionInfo;
+	SessionHdr_T*   pSessionHdr;
+	SessionHdr2_T*  pSessionHdr2;
+	uint32_t          SessionID =0;
+
+	/* Copy the request to response */
+	Res = *pReq;
+
+	// /* Save the LAN header inofmation */
+	// pSessionHdr  = (SessionHdr_T*) (((RMCPHdr_T*)pReq->Data) + 1);
+	// pSessionHdr2 = (SessionHdr2_T*)(((RMCPHdr_T*)pReq->Data) + 1);
+	// if (RMCP_PLUS_FORMAT == pSessionHdr->AuthType)
+	// {
+	// 	SessionID = pSessionHdr2->SessionID;
+	// 	pSessionInfo = getSessionInfo (SESSION_ID_INFO, &SessionID);
+	// }
+	// else
+	// {
+	// 	SessionID = pSessionHdr->SessionID;
+	// 	pSessionInfo = getSessionInfo (SESSION_ID_INFO, &SessionID );
+	// }
+	// if (NULL != pSessionInfo)
+	// {
+	// 	pSessionInfo->LANRMCPPkt.UDPHdr.SrcPort = Res.UDPPort;
+	// 	pSessionInfo->hSocket                   = Res.Socket;
+	// 	SocktIndex=GetSocketInfoIndex(pSessionInfo->hSocket );
+		
+	// 	memcpy (pSessionInfo->LANRMCPPkt.IPHdr.Srcv4Addr, Res.IPAddr, sizeof (struct in_addr));
+	// 	memcpy (&pSessionInfo->LANRMCPPkt.RMCPHdr, Res.Data, sizeof (RMCPHdr_T));
+	// }
+
+	/* Process the RMCP Request */
+	Res.Size = ProcessRMCPReq ((RMCPHdr_T*)pReq->Data, (RMCPHdr_T*)Res.Data);
+
+	/* ResLen is 0, don't send the packet */
+	if (0 == Res.Size )
+	{
+        printf ("LANIfc.c : LAN request packet dropped, not processed\n");
+	 	return;
+	}
+
+	/* Sent the response packet */
+	SendLANPkt (&Res);
+
+	return;
+}
+
+/*--------------------------------------------
+ * ProcessBridgeMsg
+ *--------------------------------------------*/
+static void
+ProcessBridgeMsg (  MsgPkt_T* pReq )
+{
+// 	MsgPkt_T        ResPkt;
+// 	uint16_t          PayLoadLen   = 0;
+// 	uint8_t           PayLoadType  = 0;
+// 	//SessionInfo_T   *pSessionInfo = getSessionInfo (SESSION_HANDLE_INFO, pReq->Data);
+
+ 	printf ("LANIfc: Bridge Request\n");
+
+// 	if (NULL == pSessionInfo)
+// 	{
+// 		printf ("LANIfc: ProcessBridgeMsg - No Session with the LAN\n");
+// 		return;
+// 	}
+
+// 	/* Copy Lan RMCP headers from Session Record */
+// 	ResPkt.UDPPort  = pSessionInfo->LANRMCPPkt.UDPHdr.SrcPort;
+// 	ResPkt.Socket   = pSessionInfo->hSocket;
+	
+// 	memcpy (ResPkt.IPAddr, pSessionInfo->LANRMCPPkt.IPHdr.Srcv4Addr, sizeof (struct in_addr));
+// 	memcpy (ResPkt.Data, &pSessionInfo->LANRMCPPkt.RMCPHdr, sizeof (RMCPHdr_T));
+
+// #if IPMI20_SUPPORT == 1
+// 	if (RMCP_PLUS_FORMAT == pSessionInfo->AuthType)
+// 	{
+// 		/* Fill Session Header */
+// 		pSessionInfo->OutboundSeq++;
+// 		PayLoadLen      = pReq->Size - 1;
+// 		PayLoadType     = pReq->Cmd;
+// 		PayLoadType    |= (pSessionInfo->SessPyldInfo[PayLoadType].AuxConfig[0] & 0xC0);
+// 		PayLoadLen      = Frame20Payload (PayLoadType, (  RMCPHdr_T*)&ResPkt.Data [0],
+// 									 &pReq->Data[1], PayLoadLen, pSessionInfo );
+// 	}
+// 	else
+// #endif /*IPMI20_SUPPORT == 1*/
+// 	{
+// 		/* Fill Session Header */
+// 		  SessionHdr_T* pSessionHdr = (  SessionHdr_T*)(&ResPkt.Data [sizeof(RMCPHdr_T)]);
+// 		  uint8_t*        pPayLoad    = (  uint8_t*)(pSessionHdr + 1);
+
+	// 	pSessionHdr->AuthType       = pSessionInfo->AuthType;
+	// 	pSessionHdr->SessionSeqNum  = pSessionInfo->OutboundSeq++;
+	// 	pSessionHdr->SessionID      = pSessionInfo->SessionID;
+
+	// 	/* If AuthType is not 0 - Compute AuthCode */
+	// 	if (0 != pSessionInfo->AuthType)
+	// 	{
+	// 		IPMI_DBG_PRINT ("Compute Authcode\n");
+	// 		PayLoadLen = AUTH_CODE_LEN;
+	// 		pPayLoad [PayLoadLen++] = pReq->Size - 1;
+	// 		_fmemcpy (&pPayLoad [PayLoadLen], (pReq->Data + 1), (pReq->Size - 1));
+	// 		PayLoadLen += pReq->Size;
+	// 		PayLoadLen--;
+	// 		PayLoadLen += sizeof (SessionHdr_T) + sizeof (RMCPHdr_T);
+	// 		ComputeAuthCode (pSessionInfo->Password, pSessionHdr,
+	// 						 (  IPMIMsgHdr_T*) &pPayLoad [AUTH_CODE_LEN+1],
+	// 						 pPayLoad, MULTI_SESSION_CHANNEL);
+	// 	}
+	// 	else
+	// 	{
+	// 	   pPayLoad [PayLoadLen++] = pReq->Size - 1;
+	// 		/*  Fill the ipmi message */
+	// 	   _fmemcpy (&pPayLoad [PayLoadLen], (pReq->Data + 1), (pReq->Size - 1));
+	// 	   PayLoadLen += pReq->Size;
+	// 	   PayLoadLen--;
+	// 	   PayLoadLen += sizeof (SessionHdr_T) + sizeof (RMCPHdr_T);
+	// 	}
+
+	// }
+
+	// OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+
+	// ResPkt.Size = PayLoadLen;
+
+	// if(pSessionInfo->Activated)
+	// {
+	// 	/* Sent the response packet */
+	// 	SendLANPkt (&ResPkt,BMCInst);
+	// }
+
+	return;
+}
+
+
+// /**
+//  * @fn  LANTimer
+//  * @brief This function handles the time out for lan connections.
+//  * @param None
+// **/
+// static
+// void*  LANTimer (void *pArg)
+// {
+// 	int *inst = (int*)pArg;
+// 	int BMCInst= *inst;
+// 	prctl(PR_SET_NAME,__FUNCTION__,0,0,0);
+
+// 	while (1)
+// 	{
+// 		UpdateTimeout (BMCInst);
+// 		sleep (LAN_TIMER_INTERVAL);
+// 	}
+
+// 	return 0;
+// }
+
+
+static int SetIPv4Header(int socketID)
+{
+	uint8_t   	flag = 0;
+	uint8_t 	TimeToLive = 64;
+	//uint8_t		TypeOfService = 0;
+
+	if (setsockopt(socketID, IPPROTO_IP, IP_TTL,
+			&TimeToLive, sizeof(uint8_t)) == -1)
+	{
+		printf("LANIfc.c: Setsockopt(IP_TTL) Failed for UDP socket:");
+		return -1;
+	}
+
+	flag = 0;	/* Never send DF frames.  */
+	if (setsockopt(socketID, IPPROTO_IP, IP_MTU_DISCOVER,
+			&(flag), sizeof(uint8_t)) == -1)
+	{
+		printf("LANIfc.c: Setsockopt(IP_MTU_DISCOVER) Failed for UDP socket\n");
+		return -1;
+	}
+
+	// if (setsockopt(socketID, IPPROTO_IP, IP_TOS,
+	// 		&(pBMCInfo->LANCfs[ethIndex].Ipv4HdrParam.TypeOfService), sizeof(INT8U)) == -1)
+	// {
+	// 	printf("LANIfc.c: Setsockopt(IP_TOS) Failed for UDP socket\n");
+	// 	return -1;
+	// }
+
+	return 0;
+}
+

+ 24 - 18
app/bmc_server/ipmi_dev/LANIfc.h → app/bmc/lan/LANIfc.h

@@ -22,16 +22,14 @@
  *****************************************************************/
 #ifndef LANIFC_H
 #define LANIFC_H
-#include "Types.h"
-#include "Message.h"
-#include "IPMI_LANIfc.h"
+#include <stdio.h>
+#include <stdint.h>
+#include "com_BmcType.h"
+#include "com_Message.h"
+#include "com_IPMI_LANIfc.h"
 
 
 /*** External Definitions ***/
-#define LAN_SMB_REQUEST				1
-#define LAN_SNMP_REQUEST			2
-#define LAN_SM_REQUEST				3
-#define LAN_ARP_REQUEST				4
 #define GRATUITOUS_ARP_REQUEST		5
 #define PCI_RST_INTR				6
 #define LAN_SMB_ALERT				6
@@ -48,33 +46,41 @@
 #define FLAG_SET 1
 #define FLAG_UNSET 0
 
+#pragma pack(1)
+
 typedef struct
 {
-    SOCKET  Socket;
-    INT8U   Valid;
+    int 	Socket;
+    uint8_t   Valid;
     time_t  Time;
-    INT8U  IsLoopBackSocket;
-    INT8U  IsFixedSocket;
-}PACKED SocketTbl_T;
+    uint8_t  IsLoopBackSocket;
+    uint8_t  IsFixedSocket;
+}  SocketTbl_T;
+
+#pragma pack()
+
+
+void *LANIfcTask (void *param);
+
 
 
 /**
  * This variable is used to define if the packet
  * is from VLAN channel or not 
  */
-//extern INT8U	g_IsPktFromVLAN;
+//extern uint8_t	g_IsPktFromVLAN;
 
 /**
  * @defgroup lanifc LAN Interface Module
  * LAN interface functions.
  * @{
 **/
-extern BOOL	ValidateUDPChkSum	(_NEAR_ UDPPseudoHdr_T* pUDPPseudoHdr, _FAR_ UDPHdr_T* pUDPHdr);
-extern BOOL	ValidateIPChkSum	(_FAR_ IPHdr_T* pIPHdr);
-extern INT16U CalculateUDPChkSum (_NEAR_ UDPPseudoHdr_T* pUDPPseudoHdr, _FAR_ UDPHdr_T* pUDPHdr);
-extern INT16U CalculateIPChkSum	(_FAR_ IPHdr_T* pIPHdr);
+// extern BOOL	ValidateUDPChkSum	(  UDPPseudoHdr_T* pUDPPseudoHdr,   UDPHdr_T* pUDPHdr);
+// extern BOOL	ValidateIPChkSum	(  IPHdr_T* pIPHdr);
+// extern uint16_t CalculateUDPChkSum (  UDPPseudoHdr_T* pUDPPseudoHdr,   UDPHdr_T* pUDPHdr);
+// extern uint16_t CalculateIPChkSum	(  IPHdr_T* pIPHdr);
 
-//extern int SendSOLPkt  (INT8U* pSOLPkt, INT16U Len);
+//extern int SendSOLPkt  (uint8_t* pSOLPkt, uint16_t Len);
 /** @} */
 
 #endif /* LANIFC_H */

+ 1224 - 0
app/bmc/lan/RMCP+.c

@@ -0,0 +1,1224 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************/
+/*****************************************************************
+ *
+ * RMCP.c
+ * RMCP Message Handler
+ *
+ * Author: Govind Kothandapani <govindk@ami.com>
+ *       : Bakka Ravinder Reddy <bakkar@ami.com>
+ *
+ *****************************************************************/
+#include <stdio.h>
+#include <stdint.h>
+
+#include "com_Message.h"
+#include "com_IPMIDefs.h"
+#include "RMCP.h"
+#include "RMCP+.h"
+#include "Session.h"
+#include "LANIfc.h"
+#include "MD.h"
+#include "MD5_128.h"
+#include "main.h"
+
+#if IPMI20_SUPPORT == 1
+
+/*** Local definitions ***/
+#define AUTH_ALGORITHM                      00
+#define INTEGRITY_ALGORITHM                 01
+#define CONFIDENTIALITY_ALGORITHM           02
+
+#define MAX_ROLE_SUPPORTED                  0x05
+#define MAX_REM_CON_RAND_NO_LEN             0x10
+#define MAX_MGD_SYS_RAND_NO_LEN             0x10
+#define MAX_MGD_SYS_GUID_LEN                0x10
+#define MAX_HMAC_BUF_SIZE                   128
+#define RAKP1_HASH_SIZE                     20
+#define RAKP1_HASH_HMAC_MD5_SIZE            16
+#define RAKP1_HASH_HMAC_SHA256_SIZE  		32
+
+/* RSSP and RAKP Message Status Codes */
+#define SC_NO_ERROR                         0
+#define SC_INSUFFICIENT_RESOURCE            1
+#define SC_INV_SESSION_ID                   2
+#define SC_INV_PAYLOAD_TYPE                 3
+#define SC_INV_AUTH_ALGORITHM               4
+#define SC_INV_INTEGRITY_ALGORITHM          5
+#define SC_NO_MATCHED_AUTH_PAYLOAD          6
+#define SC_NO_MATCHED_INTEGRITY_PAYLOAD     7
+#define SC_INACTIVE_SESSION_ID              8
+#define SC_INV_ROLE                         9
+#define SC_UNAUTHORISED_ROLE                10
+#define SC_INSUFFICIENT_RESOURCE_AT_ROLE    11
+#define SC_INV_NAME_LEN                     12
+#define SC_UNAUTHORISED_NAME                13
+#define SC_UNAUTHORISED_GUID                14
+#define SC_INV_INTEGRITY_CHECK              15
+#define SC_INV_CONFIDENTIALITY_ALGORTHM     16
+#define SC_NO_CIPHER_SUITE_MATCH            17
+#define SC_ILLEGAL_OR_UNRECOGNIZED_PARAM    18
+
+/* Authentication Algorithm Numbers */
+#define RAKP_NONE                   0
+#define RAKP_HMAC_SHA1              1
+#define RAKP_HMAC_MD5	            2
+#define RAKP_HMAC_SHA256            3
+
+#define HASH_KEY1_CONST_SIZE                20
+#define HASH_KEY2_CONST_SIZE                20
+
+/**
+ * @var m_SIK
+ * @brief Session Key.
+**/
+static  _FAR_ INT8U m_SIK [SHA2_HASH_KEY_SIZE];
+
+
+/*----------------------------------------
+ * RSSPOpenSessionReq
+ *----------------------------------------*/
+int
+RSSPOpenSessionReq (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes, MiscParams_T *pParams, INT8U Channel, int BMCInst)
+{
+    _NEAR_  RSSPOpenSessionReq_T    *Req        =
+                                      (_NEAR_ RSSPOpenSessionReq_T*)pReq;
+    _NEAR_  RSSPOpenSessionRes_T    *Res        =
+                                      (_NEAR_ RSSPOpenSessionRes_T*)pRes;
+    _NEAR_  RSSPOpenSessionErrRes_T *ErrRes     =
+                                      (_NEAR_ RSSPOpenSessionErrRes_T*)pRes;
+    _FAR_   BMCInfo_t               *pBMCInfo   = 
+                                    &g_BMCInfo[BMCInst];
+    _FAR_   ChannelInfo_T           *pChannelInfo;
+    INT8U                           Role, i, id;
+    BOOL                            IsMatchReq      = FALSE;
+    BOOL                            TrackRollOver   = FALSE;
+    SessionInfo_T                   SessionInfo;
+    INT32U                          TempSessId;
+    INT8U                           CipherSuitePrivilage = 0;
+    INT8U                           EthIndex;
+    INT32U                          TrackRollOverSeq = SEQNUM_ROLLOVER;
+    unsigned int                    seed = 1; 
+
+
+    if(Channel == 0xFF)
+    {
+        Channel=GetLANChannel(Req->Reserved[0], BMCInst);
+    }
+    EthIndex= GetEthIndex(Channel, BMCInst);
+
+    if(0xff == EthIndex)
+    {
+        IPMI_WARNING("\n Invalid Channel number :%x",Channel);
+        *pRes = CC_INV_DATA_FIELD;
+        return sizeof (INT8U);
+    }
+
+    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
+    /* Get information abt this channel */
+    pChannelInfo = getChannelInfo (Channel, BMCInst);
+    if (NULL == pChannelInfo)
+    {
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+        Res->StatusCode = SC_INSUFFICIENT_RESOURCE;
+        return sizeof (RSSPOpenSessionErrRes_T);
+    }
+
+    if(pChannelInfo->ActiveSession >= pChannelInfo->SessionLimit)
+    {
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+        /* Session limit reached*/
+        IPMI_WARNING ("RMCP+.c : OpenSessionReq - Session limit exceeded :%x\t%x BMCInst %x\n ",pChannelInfo->ActiveSession,pChannelInfo->SessionLimit,BMCInst);
+        Res->StatusCode = SC_INSUFFICIENT_RESOURCE;
+        return sizeof (RSSPOpenSessionErrRes_T);
+    }
+    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+
+    /* Get Role */
+    Role = Req->Role & 0x0F;
+
+    /* Fill Err Response to return, in case any error occurred */
+    ErrRes->Reserved = 0;
+    ErrRes->RemConSessionID = Req->RemConSessionID;
+
+    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SessionTblMutex,WAIT_INFINITE);
+    if (GetNumOfUsedSessions(BMCInst) >= pBMCInfo->IpmiConfig.MaxSession)
+    {
+        if(FALSE == CleanSession(BMCInst))
+        {
+            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+            /* Session limit reached*/
+            IPMI_WARNING ("RMCP+.c : OpenSessionReq - Session limit exceeded\n");
+            Res->StatusCode = SC_INSUFFICIENT_RESOURCE;
+            return sizeof (RSSPOpenSessionErrRes_T);
+        }
+    }
+
+    /* Check Role  */
+    if (Role > MAX_ROLE_SUPPORTED)
+    {
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+        /* Invalid Payload Type */
+        IPMI_WARNING ("RMCP+.c : OpenSessionReq - Invalid role\n");
+        Res->StatusCode = SC_INV_ROLE;
+        return sizeof (RSSPOpenSessionErrRes_T);
+    }
+
+    /*Check Payload Type */
+    if ((AUTH_ALGORITHM             != Req->Auth.PayloadType) ||
+        (INTEGRITY_ALGORITHM        != Req->Integrity.PayloadType) ||
+        (CONFIDENTIALITY_ALGORITHM  != Req->Confidentiality.PayloadType))
+    {
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+        /* Invalid Payload Type */
+        IPMI_WARNING ("RMCP+.c : OpenSessionReq - Invalid Payload\n");
+        Res->StatusCode = SC_INV_PAYLOAD_TYPE;
+        return sizeof (RSSPOpenSessionErrRes_T);
+    }
+
+    /* Search for the matching cipher suite id from Cipher suite record. if matching id found
+           check for for requested role/privilege is allowed for privilege level for the cipher suite */
+    for (i = 0, id = 0; i < MAX_CIPHER_SUITES_BYTES; i++, id++)
+    {
+        if (i * 5 + 1 > MAX_CIPHER_SUITES_BYTES)
+        {
+            break;
+        }
+
+        if (
+            (((Req->Auth.PayloadType 	     << 6) | (Req->Auth.Algorithm & 0x3F))     	 	== g_CipherRec [(i * 5) + 2]) &&
+            (((Req->Integrity.PayloadType    << 6) | (Req->Integrity.Algorithm & 0x3F))     == g_CipherRec [(i * 5) + 3]) &&
+            (((Req->Confidentiality.PayloadType<< 6) | (Req->Confidentiality.Algorithm & 0x3F))== g_CipherRec [(i * 5) + 4])
+           )
+        {
+            id = g_CipherRec[(i * 5) + 1];
+            /* The Cipher Suite ID is matched */
+            /* get the privilege level for the given cipher suite id, if id is even its lower nibble else upper nibble */
+            CipherSuitePrivilage = pBMCInfo->LANCfs[EthIndex].CipherSuitePrivLevels [(id/2)+1];
+            CipherSuitePrivilage = ((id % 2) == 0) ? (CipherSuitePrivilage & 0x0f) : ((CipherSuitePrivilage >> 4) & 0x0f) ;
+
+            if(CipherSuitePrivilage == 0)
+            {
+                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+                Res->StatusCode = SC_NO_CIPHER_SUITE_MATCH;
+                return sizeof (RSSPOpenSessionErrRes_T);
+            }
+
+            /*if requested privilege level is greater than cipher suite id privilege level return errror*/
+            if ((CipherSuitePrivilage != 0) && (Role > CipherSuitePrivilage))
+            {
+                /* Invalid Payload Type */
+                //Res->StatusCode = SC_UNAUTHORISED_ROLE;
+                //return sizeof (RSSPOpenSessionErrRes_T);
+                Role = CipherSuitePrivilage;
+            }
+            break;
+        }
+    }
+    /* Role 0 indicates to find possible match */
+    if (0 == Role)
+    {
+        IsMatchReq  = TRUE;
+        Role        = MAX_ROLE_SUPPORTED;
+    }
+
+    /* Find Match */
+    do
+    {
+        Res->StatusCode = SC_NO_ERROR;
+
+        /*Check if requested authentication Algorithm supported **/
+        if (0 != Req->Auth.PayloadLen)
+        {
+            if ((sizeof (RSSPPayloadInfo_T) != Req->Auth.PayloadLen) ||
+                (0 == (pBMCInfo->RMCPPlus[EthIndex].Algorithm [Req->Auth.PayloadType] [Role] &
+                         (1 << Req->Auth.Algorithm))))
+            {
+                /* AuthAlgorithm not supported */
+                IPMI_DBG_PRINT ("RMCP+.c : OpenSessionReq - Authentication not supported \n");
+                Res->StatusCode = SC_NO_CIPHER_SUITE_MATCH;
+            }
+        }
+
+        /*Check if requested Integrity Algorithm supported  **/
+        if (0 != Req->Integrity.PayloadLen)
+        {
+            if ((sizeof (RSSPPayloadInfo_T) != Req->Integrity.PayloadLen) ||
+                (0 == (pBMCInfo->RMCPPlus[EthIndex].Algorithm [Req->Integrity.PayloadType] [Role] &
+                         (1 << Req->Integrity.Algorithm))))
+            {
+                /* Integrity Algorithm not supported */
+                IPMI_DBG_PRINT ("RMCP+.c : OpenSessionReq - Integrity not supported\n");
+                Res->StatusCode = SC_NO_CIPHER_SUITE_MATCH;
+            }
+        }
+
+        /*Check if requested Confidentiality Algorithm supported    **/
+        if (0 != Req->Confidentiality.PayloadLen)
+        {
+            if ((sizeof (RSSPPayloadInfo_T) != Req->Confidentiality.PayloadLen) ||
+                (0 == (pBMCInfo->RMCPPlus[EthIndex].Algorithm [Req->Confidentiality.PayloadType] [Role] &
+                         (1 << Req->Confidentiality.Algorithm))))
+            {
+                /* Confidentiality Algorithm not supported */
+                IPMI_DBG_PRINT ("RMCP+.c : OpenSessionReq - Confidentiality not supported \n");
+                Res->StatusCode = SC_NO_CIPHER_SUITE_MATCH;
+            }
+        }
+
+        if ((SC_NO_ERROR  == Res->StatusCode) &&
+            ((CipherSuitePrivilage == 0) || (Role <= CipherSuitePrivilage)))
+        {
+            /* Found Match */
+            break;
+        }
+
+    } while (IsMatchReq && Role--);
+
+    /* Return Err response */
+    if (Res->StatusCode != SC_NO_ERROR)
+    {
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+        IPMI_WARNING ("RMCP+.c : OpenSessionReq - Error Response\n");
+        return sizeof (RSSPOpenSessionErrRes_T);
+    }
+
+    if (GetNumOfActiveSessions (BMCInst) >= pBMCInfo->IpmiConfig.MaxSession)
+    {
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+        /* No slot available */
+        Res->StatusCode = SC_INSUFFICIENT_RESOURCE;
+        return sizeof (RSSPOpenSessionErrRes_T);
+    }
+    /* Add Session Info */
+    _fmemset (&SessionInfo, 0, sizeof (SessionInfo_T));
+    /* Activated in ActivateSession Command */
+    SessionInfo.Activated       = FALSE;
+    SessionInfo.RemConSessionID = Req->RemConSessionID;
+    SessionInfo.MaxPrivilege = Role;
+
+    do{
+        /*generate 32 bit temp session Id*/
+        TempSessId = ((INT32U)rand_r(&seed) << 16) | rand_r (&seed); 
+    } while ((NULL != getSessionInfo (SESSION_ID_INFO, &TempSessId, BMCInst)) ||
+             (0 == TempSessId));
+
+    SessionInfo.SessionID               = TempSessId;
+    SessionInfo.Channel                 = Channel;
+    SessionInfo.AuthAlgorithm           = Req->Auth.Algorithm;
+    SessionInfo.IntegrityAlgorithm      = Req->Integrity.Algorithm;
+    SessionInfo.ConfidentialityAlgorithm = Req->Confidentiality.Algorithm;
+    if(pParams->IsPktFromLoopBack)
+    {
+        if(IPMITimeout > 0)
+        {
+            SessionInfo.TimeOutValue = (IPMITimeout+10);
+        }
+        else
+        {
+            /*If it is not defined the timeout values for loop back session should be 
+                    SESSION_TIMEOUT defined in config.make.ipmi (60 seconds) */
+            SessionInfo.TimeOutValue =  pBMCInfo->IpmiConfig.SessionTimeOut;
+        }
+        SessionInfo.IsLoopBack              = TRUE;
+    }
+    else
+        SessionInfo.TimeOutValue          = pBMCInfo->IpmiConfig.SessionTimeOut;
+    
+    if(pBMCInfo->IpmiConfig.SOLIfcSupport == 1)
+    {
+        if(SessionInfo.SessPyldInfo [PAYLOAD_SOL].Type == PAYLOAD_SOL)
+        {
+            SessionInfo.TimeOutValue = pBMCInfo->IpmiConfig.SOLSessionTimeOut;
+        }
+    }
+    
+    SessionInfo.UserId  = 0xff;
+    SessionInfo.SessPyldInfo [0].AuxConfig [0] =
+        ((0 != Req->Integrity.Algorithm) ? 0x40: 0x00) |
+        ((0 != Req->Confidentiality.Algorithm) ? 0x80: 0x00);
+    SessionInfo.InitialInboundSeq   = SEQNUM_ROLLOVER;
+    SessionInfo.InboundSeq  = 0x00;
+
+    for(i=0; i < RMCPPLUS_SEQLOWLIMIT; i++)
+    {
+        if(((SessionInfo.InitialInboundSeq - (i+1)) != 0) &&(TrackRollOver == FALSE))
+            SessionInfo.InboundTrac[i] = SessionInfo.InitialInboundSeq - (i+1);
+        else if(((SessionInfo.InitialInboundSeq - (i+1)) == 0) &&(TrackRollOver == FALSE))
+        {
+            SessionInfo.InboundTrac[i] = SessionInfo.InitialInboundSeq - (i+1);
+            TrackRollOver = TRUE;
+        }
+        else if(TrackRollOver == TRUE)
+        {
+            SessionInfo.InboundTrac[i] = TrackRollOverSeq;
+            TrackRollOverSeq--;
+        }
+    }
+
+    SessionInfo.InboundRecv = 0xFF; 
+    AddSession (&SessionInfo, BMCInst);
+
+    /* Load RSSP Open session Response */
+    Res->Role = Role;
+    Res->Reserved = 0x00;
+    Res->RemConSessionID    = Req->RemConSessionID;
+    Res->MgdSysSessionID    = SessionInfo.SessionID;
+
+    /* Auth Algorithm Details */
+    Res->Auth.PayloadType   = AUTH_ALGORITHM;
+    Res->Auth.Reserved1 = 0;
+    Res->Auth.PayloadLen    = sizeof (RSSPPayloadInfo_T);
+    Res->Auth.Algorithm     = Req->Auth.Algorithm;
+    memset(Res->Auth.Reserved2, 0x0, 3);
+
+    /* Integrity Algorithm Details */
+    Res->Integrity.PayloadType  = INTEGRITY_ALGORITHM;
+    Res->Integrity.Reserved1 = 0;
+    Res->Integrity.PayloadLen   = sizeof (RSSPPayloadInfo_T);
+    Res->Integrity.Algorithm    = Req->Integrity.Algorithm;
+    memset(Res->Integrity.Reserved2, 0x0, 3);
+
+    /* Confidentiality Algorithm Details */
+    Res->Confidentiality.PayloadType = CONFIDENTIALITY_ALGORITHM;
+    Res->Confidentiality.Reserved1 = 0;
+    Res->Confidentiality.PayloadLen  = sizeof (RSSPPayloadInfo_T);
+    Res->Confidentiality.Algorithm   = Req->Confidentiality.Algorithm;
+    memset(Res->Confidentiality.Reserved2, 0x0, 3);
+    
+    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+
+    return sizeof (RSSPOpenSessionRes_T);
+}
+
+
+/*----------------------------------------
+ * RAKPMsg1
+ *----------------------------------------*/
+int
+RAKPMsg1 (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes, MiscParams_T *pParams, INT8U Channel, int BMCInst)
+{
+    _NEAR_  RAKPMsg1Req_T       *Req     = (_NEAR_ RAKPMsg1Req_T*) pReq;
+    _NEAR_  RAKPMsg2Res_T       *Res     = (_NEAR_ RAKPMsg2Res_T*) pRes;
+    _NEAR_  RAKPMsg2ErrRes_T    *ErrRes  = (_NEAR_ RAKPMsg2ErrRes_T*) pRes;
+    _FAR_   SessionInfo_T       *pSessInfo;
+    _FAR_   ChannelUserInfo_T   *pChUserInfo;
+    _FAR_   ChannelInfo_T       *pChannelInfo;
+    _FAR_   UserInfo_T          *pUserInfo;
+    _FAR_   RAKPMsg1HMAC_T      *pMsghmac;
+    _FAR_   BMCInfo_t           *pBMCInfo = &g_BMCInfo[BMCInst];
+    INT8U   Index;
+    INT8U   AuthCodeLen = 0;
+    INT8U   Role;
+    INT32U  ManSysSessionID;
+    int     i;
+    unsigned int seed = 1;
+    INT8U PwdEncKey[MAX_SIZE_KEY + 1] = {0};
+
+    /*Validate Mgd session ID*/
+    Role                    = Req->Role & 0x0f;
+    ManSysSessionID         = Req->ManSysSessionID;
+    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SessionTblMutex,WAIT_INFINITE);
+    pSessInfo               = getSessionInfo (SESSION_ID_INFO, (_FAR_ void*)&ManSysSessionID, BMCInst);
+    if (NULL == pSessInfo)
+    {
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+        IPMI_WARNING ("RMCP+.c : RAKPMsg1 - Invalid Session ID\n");
+        ErrRes->StatusCode  = SC_INV_SESSION_ID;
+        return sizeof (RAKPMsg2ErrRes_T);
+    }
+    /* In case of error, delete this session info */
+    pBMCInfo->LANConfig.DeleteThisLANSessionID = ManSysSessionID;
+
+    if(Channel == 0xFF)
+    {
+        Channel= pSessInfo->Channel;
+    }
+
+    ErrRes->RemConSessionID = pSessInfo->RemConSessionID;
+
+    /* Check Role  */
+    if (Role >  MAX_ROLE_SUPPORTED)
+    {
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+        /* Invalid Role */
+        IPMI_WARNING ("RMCP+.c : RAKPMsg1 - Invalid Role\n");
+        Res->StatusCode = SC_INV_ROLE;
+        return sizeof (RAKPMsg2ErrRes_T);
+    }
+
+    /* Check User Name Length */
+    if (Req->UsrNameLen > MAX_USERNAME_LEN)
+    {
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+        /* Invalid Name Len */
+        IPMI_WARNING ("RMCP+.c : RAKPMsg1 - Username len exceeded\n");
+        Res->StatusCode = SC_INV_NAME_LEN;
+        return sizeof (RAKPMsg2ErrRes_T);
+    }
+
+    /* Privilege for the session has to be assigned in RAKP1 only */
+    pSessInfo->Privilege = Role & 0xF;
+
+    /* Pad with NULL characters */
+    _fmemset (&Req->UsrName [Req->UsrNameLen], 0, MAX_USERNAME_LEN - Req->UsrNameLen);
+
+    pChannelInfo = getChannelInfo (Channel, BMCInst);
+    if (NULL == pChannelInfo)
+    {
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+        /* InSufficient resources */
+        IPMI_WARNING ("RMCP+.c : RAKPMsg1 - Insufficient resource\n");
+        Res->StatusCode = SC_INSUFFICIENT_RESOURCE;
+        return sizeof (RAKPMsg2ErrRes_T);
+    }
+
+
+    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
+    pSessInfo->Lookup = ((Req->Role & 0x10) >> 0x04);
+
+    if( pParams->IsPktFromLoopBack == TRUE  &&  Req->UsrName[0] == 0 )
+    {
+        pUserInfo = getUserIdInfo (NULL_USER, BMCInst);
+        pSessInfo->UserId = NULL_USER;
+        memset (pSessInfo->Password, 0, MAX_PASSWORD_LEN);
+    }
+    else
+    {
+        if (USER_ROLE_LOOKUP == pSessInfo->Lookup)
+        {
+        /* Get userInfo for the given userName and privilege */
+        pChUserInfo = getChUserPrivInfo ((_NEAR_ char *)Req->UsrName, Role, &Index,
+        pChannelInfo->ChannelUserInfo, BMCInst);
+
+        /* If user not found  */
+        if (NULL == pChUserInfo)
+        {
+            /* Invalid user     */
+            IPMI_WARNING ("RMCP+.c : RAKPMsg1 - user_priv - User not found : %s\n", (_NEAR_ char *)Req->UsrName);
+
+            if ( 0 != AddLoginEvent( 0xFF, Req->UsrName, EVENT_LOGIN_FAILURE, BMCInst ) )
+            {
+                    TCRIT("Problem while adding Log record \n");
+            }
+            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+            Res->StatusCode = SC_UNAUTHORISED_NAME;
+            return sizeof (RAKPMsg2ErrRes_T);
+        }
+
+        /* Check Role  */
+        if (pChUserInfo->AccessLimit == 0xF )
+        {
+            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+            /* Invalid Role */
+            IPMI_WARNING ("RMCP+.c : RAKPMsg1 - user_priv - Invalid Role\n");
+            Res->StatusCode = SC_INV_ROLE;
+            return sizeof (RAKPMsg2ErrRes_T);
+        }
+
+        //we cannot assign the pSessInfo->privilege here..this will cause RAKP3 integrity check to fail
+        //this is because the client will do integrity with the requested role rather than the max permissible role
+        // which we set here. client has no way of knowing at that time
+        //pSessInfo->Privilege = Role;
+        }
+        else /* if (NAME_ONLY_LOOKUP == pSessInfo->Lookup) */
+        {
+            /* Get userInfo for the given userName*/
+            pChUserInfo = getChUserInfo ((_NEAR_ char *)Req->UsrName, &Index,
+            pChannelInfo->ChannelUserInfo, BMCInst);
+            /* If user not found  */
+            if (NULL == pChUserInfo)
+            {
+                /* Invalid user     */
+                IPMI_WARNING ("RMCP+.c : RAKPMsg1 - name_only - User not found\n");
+
+                if ( 0 != AddLoginEvent( 0xFF, Req->UsrName, EVENT_LOGIN_FAILURE, BMCInst ))
+                {
+                    TCRIT("Problem while adding Log record \n");
+                }
+
+                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+                Res->StatusCode = SC_UNAUTHORISED_NAME;
+                return sizeof (RAKPMsg2ErrRes_T);
+            }
+
+            /* Check Role  */
+            if (pChUserInfo->AccessLimit == 0xF )
+            {
+                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+                /* Invalid Role */
+                IPMI_WARNING ("RMCP+.c : RAKPMsg1 - name_only - Invalid Role\n");
+                Res->StatusCode = SC_INV_ROLE;
+                return sizeof (RAKPMsg2ErrRes_T);
+            }
+        }
+
+        pUserInfo = getUserIdInfo (pChUserInfo->UserId, BMCInst);
+        if (pUserInfo == NULL || FALSE == pUserInfo->UserStatus)
+        {
+            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+            /*user name not enabled*/
+            IPMI_WARNING ("RMCP+.c : RAKPMsg1 - User not found in database\n");
+            Res->StatusCode = SC_UNAUTHORISED_NAME;
+            return sizeof (RAKPMsg2ErrRes_T);
+        }
+
+        /* Load UserId Session Info */
+        pSessInfo->UserId = (INT8U)pChUserInfo->UserId;
+        if (g_corefeatures.userpswd_encryption == ENABLED)
+        {
+            /* Get Encryption Key from the MBMCInfo_t structure */
+            memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
+
+            if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[pChUserInfo->UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, (INT8S*)pSessInfo->Password, MAX_PASSWORD_LEN, PwdEncKey))
+            {
+                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+                TCRIT("Error in decrypting the user password for user ID:%d. .\n", pChUserInfo->UserId);
+                Res->StatusCode  = SC_INSUFFICIENT_RESOURCE;
+                return sizeof(RAKPMsg2ErrRes_T);
+            }
+        }
+        else
+        {
+        	_fmemcpy (pSessInfo->Password, pUserInfo->UserPassword, MAX_PASSWORD_LEN);
+        }
+    }
+
+    /* Check for Empty password login */
+    if ( ENABLED == g_corefeatures.disable_empty_passwd_login && NULL_USER != pSessInfo->UserId && 0 == pSessInfo->Password[0])
+    {
+        IPMI_WARNING("RMCP+c : RAKPMsg1 - Empty Password Login is not allowed \n");
+
+        if ( 0 != AddLoginEvent(pSessInfo->UserId, NULL, EVENT_LOGIN_FAILURE, BMCInst))
+        {
+             TCRIT("Problem while adding Log record \n");
+        }
+
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+        Res->StatusCode = SC_ILLEGAL_OR_UNRECOGNIZED_PARAM;
+        return sizeof(RAKPMsg2ErrRes_T);
+    }
+
+    /* Check for Default Empty password login */
+    if(ENABLED != g_corefeatures.allow_default_empty_passwd_login && NULL_USER != pSessInfo->UserId && 0 == pSessInfo->Password[0] && pUserInfo->UserPasswdConfigured == 0)
+    {
+        TDBG("RMCP+c : RAKPMsg1 - User Password is not yet configured; Default Empty Password Login is not allowed \n");
+        if ( 0 != AddLoginEvent(pSessInfo->UserId, NULL, EVENT_LOGIN_FAILURE, BMCInst))
+        {
+             TCRIT("Problem while adding Log record \n");
+        }
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+        Res->StatusCode = SC_ILLEGAL_OR_UNRECOGNIZED_PARAM;
+        return sizeof(RAKPMsg2ErrRes_T);
+    }
+
+    if(FindUserLockStatus(pSessInfo->UserId, Channel, BMCInst) != 0)
+    {
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+        IPMI_WARNING("RMCP+c : RAKPMsg1 - User is Locked \n");
+        /* As of now sending Invalid Role for bad password*/
+        Res->StatusCode = SC_INV_ROLE;
+        return sizeof(RAKPMsg2ErrRes_T);
+    }
+
+    /* Check the number of active sessions */
+    if (pUserInfo->CurrentSession >= pUserInfo->MaxSession)
+    {
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+        /*can't accept any more session for this user*/
+        Res->StatusCode = SC_INSUFFICIENT_RESOURCE;
+        return  sizeof (RAKPMsg2ErrRes_T);
+    }
+    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+
+    /* Load Response */
+    Res->StatusCode = SC_NO_ERROR;
+    /* Store the Remote Console Random number in SessionInfo */
+    _fmemcpy (pSessInfo->RemConRandomNo, Req->RemConRandomNo,
+              MAX_REM_CON_RAND_NO_LEN);
+
+    for (i = 0 ; i < MAX_MGD_SYS_RAND_NO_LEN; i++)
+    {
+        Res->ManSysRandomNo [i] = rand_r (&seed);
+    }
+
+    /* Store the Managed System Random number in SessionInfo */
+    _fmemcpy (pSessInfo->MgdSysRandomNo, Res->ManSysRandomNo,
+              MAX_MGD_SYS_RAND_NO_LEN);
+
+    /* Copy the System GUID */
+    _fmemcpy (Res->ManSysGUID, BMC_GET_SHARED_MEM (BMCInst)->SystemGUID, 16);
+
+    /* Key Exchange Auth Code  */
+    switch (pSessInfo->AuthAlgorithm)
+    {
+        case RAKP_NONE:
+            AuthCodeLen = 0;
+            break;
+
+        case RAKP_HMAC_SHA1:
+            {
+                INT8U PasswdLen = 0;
+
+                pMsghmac                    = (_FAR_ RAKPMsg1HMAC_T*)pBMCInfo->LANConfig.HmacInBuf;
+                pMsghmac->RemConSessionID   = pSessInfo->RemConSessionID;
+                pMsghmac->MgdSysSessionID   = pSessInfo->SessionID;
+                /* Copy Random no.s  and GUID */
+                _fmemcpy (pMsghmac->RemConRandNo, pSessInfo->RemConRandomNo, 16);
+                _fmemcpy (pMsghmac->MgdSysRandNo, pSessInfo->MgdSysRandomNo, 16);
+                _fmemcpy (pMsghmac->MgdSysGUID, Res->ManSysGUID, MAX_MGD_SYS_GUID_LEN);
+
+                pMsghmac->Role          = Req->Role;
+                pMsghmac->UsrNameLen    = Req->UsrNameLen;
+                _fmemcpy (pMsghmac->UsrName, Req->UsrName, Req->UsrNameLen);
+
+                PasswdLen = _fstrlen ((_FAR_ char*)pSessInfo->Password);
+                PasswdLen = (PasswdLen > MAX_PASSWORD_LEN) ?
+                            MAX_PASSWORD_LEN : PasswdLen;
+                hmac_sha1 ((INT8U *)pSessInfo->Password, PasswdLen, (INT8U *)pBMCInfo->LANConfig.HmacInBuf,
+                           (sizeof (RAKPMsg1HMAC_T) - MAX_USERNAME_LEN + Req->UsrNameLen),
+                           (INT8U *)&pRes [sizeof (RAKPMsg2Res_T)], RAKP1_HASH_SIZE);
+                AuthCodeLen = RAKP1_HASH_SIZE;
+                break;
+            }
+
+        case RAKP_HMAC_MD5:
+            {
+                INT8U PasswdLen = 0;
+
+                pMsghmac                    = (_FAR_ RAKPMsg1HMAC_T*)pBMCInfo->LANConfig.HmacInBuf;
+                pMsghmac->RemConSessionID   = pSessInfo->RemConSessionID;
+                pMsghmac->MgdSysSessionID   = pSessInfo->SessionID;
+                /* Copy Random no.s  and GUID */
+                _fmemcpy (pMsghmac->RemConRandNo, pSessInfo->RemConRandomNo, 16);
+                _fmemcpy (pMsghmac->MgdSysRandNo, pSessInfo->MgdSysRandomNo, 16);
+                _fmemcpy (pMsghmac->MgdSysGUID, Res->ManSysGUID, MAX_MGD_SYS_GUID_LEN);
+
+                pMsghmac->Role          = Req->Role;
+                pMsghmac->UsrNameLen    = Req->UsrNameLen;
+                _fmemcpy (pMsghmac->UsrName, Req->UsrName, Req->UsrNameLen);
+
+                PasswdLen = _fstrlen ((_FAR_ char*)pSessInfo->Password);
+                PasswdLen = (PasswdLen > MAX_PASSWORD_LEN) ?
+                            MAX_PASSWORD_LEN : PasswdLen;
+                hmac_md5(pSessInfo->Password, PasswdLen, pBMCInfo->LANConfig.HmacInBuf,
+                           (sizeof (RAKPMsg1HMAC_T) - MAX_USERNAME_LEN + Req->UsrNameLen),
+                           &pRes [sizeof (RAKPMsg2Res_T)], RAKP1_HASH_HMAC_MD5_SIZE);
+                AuthCodeLen = RAKP1_HASH_HMAC_MD5_SIZE;
+                break;
+            }
+
+        case RAKP_HMAC_SHA256:
+			{
+        		INT8U PasswdLen = 0;
+
+         		pMsghmac                    = (_FAR_ RAKPMsg1HMAC_T*)pBMCInfo->LANConfig.HmacInBuf;
+                pMsghmac->RemConSessionID   = pSessInfo->RemConSessionID;
+                pMsghmac->MgdSysSessionID   = pSessInfo->SessionID;
+                /* Copy Random nos  and GUID */
+				_fmemcpy (pMsghmac->RemConRandNo, pSessInfo->RemConRandomNo, 16);
+				_fmemcpy (pMsghmac->MgdSysRandNo, pSessInfo->MgdSysRandomNo, 16);
+				_fmemcpy (pMsghmac->MgdSysGUID, Res->ManSysGUID, MAX_MGD_SYS_GUID_LEN);
+
+				pMsghmac->Role          = Req->Role;
+				pMsghmac->UsrNameLen    = Req->UsrNameLen;
+				_fmemcpy (pMsghmac->UsrName, Req->UsrName, Req->UsrNameLen);
+
+				PasswdLen = _fstrlen ((_FAR_ char*)pSessInfo->Password);
+				PasswdLen = (PasswdLen > MAX_PASSWORD_LEN) ?
+								MAX_PASSWORD_LEN : PasswdLen;
+
+        		hmac_sha256(pSessInfo->Password, PasswdLen, pBMCInfo->LANConfig.HmacInBuf,
+        			 (sizeof (RAKPMsg1HMAC_T) - MAX_USERNAME_LEN + Req->UsrNameLen),
+        	               &pRes [ sizeof (RAKPMsg2Res_T)], RAKP1_HASH_HMAC_SHA256_SIZE);
+				AuthCodeLen = RAKP1_HASH_HMAC_SHA256_SIZE;
+                break;
+           	}        	
+			
+        default:
+            IPMI_WARNING ("RMCP+.c : RAKPMsg1 - Invalid Authentication\n");
+            AuthCodeLen = 0;
+    }
+
+    pBMCInfo->LANConfig.DeleteThisLANSessionID = 0;
+    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+
+    return sizeof (RAKPMsg2Res_T) + AuthCodeLen;
+}
+
+
+/*----------------------------------------
+ * RAKPMsg3
+ *----------------------------------------*/
+int
+RAKPMsg3 (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes, MiscParams_T *pParams,INT8U Channel, int BMCInst)
+{
+    _NEAR_  RAKPMsg3Req_T       *Req     = (_NEAR_ RAKPMsg3Req_T*)pReq;
+    _NEAR_  RAKPMsg4Res_T       *Res     = (_NEAR_ RAKPMsg4Res_T*)pRes;
+    _FAR_   SessionInfo_T       *pSessInfo;
+    _NEAR_  INT8U               *pKeyXchgCode;
+    _NEAR_  SIKhmac_T           *pSIKhmac;
+    _FAR_   Msg3hmac_T          *pMsg3hmac;
+    _FAR_   UserInfo_T          *pUserInfo;
+    _FAR_   RAKPMsg4hmac_T      *pMsg4hmac;
+    _FAR_   ChannelInfo_T       *pChannelInfo;
+    _FAR_   ChannelUserInfo_T   *pChUserInfo;
+    _FAR_   BMCInfo_t           *pBMCInfo = &g_BMCInfo[BMCInst];
+            INT8U               TempKey [HASH_KEY1_CONST_SIZE];
+            INT8U               TempKey2 [HASH_KEY2_CONST_SIZE];
+            INT8U               UserPasswdLen=0;
+            int                 i;
+            INT8U               ResIntigrityKeyLen=0;
+            INT8U               Index;
+            INT8U               EthIndex;
+            INT8U               UserPswd [MAX_PASSWORD_LEN];
+            INT32U              SessionID;
+            INT8U PwdEncKey[MAX_SIZE_KEY + 1] = {0};
+
+    SessionID = Req->ManSysSessionID;
+    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SessionTblMutex,WAIT_INFINITE);
+    pSessInfo = getSessionInfo (SESSION_ID_INFO, &SessionID, BMCInst);
+    /* In case of error, delete this session info */
+    pBMCInfo->LANConfig.DeleteThisLANSessionID = Req->ManSysSessionID;
+
+    /* Check if Management System SessionID */
+    if (NULL == pSessInfo)
+    {
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+        IPMI_WARNING ("RMCP+.c : RAKPMsg3 - Invalid Session ID\n");
+        Res->StatusCode = SC_INV_SESSION_ID;
+        return sizeof (RAKPMsg4Res_T);
+    }
+
+    /* Check if previous transactions caused an error */
+    if (Req->StatusCode !=  SC_NO_ERROR)
+    {
+        if(Req->StatusCode == SC_INV_INTEGRITY_CHECK)
+        {
+            OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
+            LockUser(pSessInfo->UserId,Channel, BMCInst);
+            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+        }
+        IPMI_WARNING ("RMCP+.c : RAKPMsg3 - Invalid Status\n");
+
+        if ( 0 != AddLoginEvent( pSessInfo->UserId, NULL, EVENT_LOGIN_FAILURE, BMCInst ))
+        {
+            IPMI_WARNING("Problem while adding Log record \n");
+        }
+
+        Res->StatusCode = Req->StatusCode;
+        DeleteSession(pSessInfo,BMCInst);
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+        return 0;
+    }
+
+    UnlockUser(pSessInfo->UserId,Channel,BMCInst);
+
+    if(Channel == 0xFF)
+    {
+        Channel= pSessInfo->Channel;
+    }
+
+    EthIndex= GetEthIndex(Channel, BMCInst);
+
+    if(0xff == EthIndex)
+    {
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+        *pRes = CC_INV_DATA_FIELD;
+        return sizeof (INT8U);
+    }
+
+    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
+    /* Get User Info */
+    pUserInfo = getUserIdInfo((INT8U)pSessInfo->UserId, BMCInst);
+    if (NULL == pUserInfo)
+    {
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+        IPMI_WARNING ("RMCP+.c : RAKPMsg3 - User not found\n");
+        Res->StatusCode = SC_UNAUTHORISED_NAME;
+        return sizeof (RAKPMsg4Res_T);
+    }
+
+    if (g_corefeatures.userpswd_encryption == ENABLED)
+    {
+        /* Get Encryption Key from the MBMCInfo_t structure */
+            memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
+
+        if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[pSessInfo->UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, (char *)UserPswd, MAX_PASSWORD_LEN, PwdEncKey))
+        {
+            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+            IPMI_ERROR("Error in decrypting the user password for user ID:%d. .\n", pSessInfo->UserId);
+            Res->StatusCode = CC_UNSPECIFIED_ERR;
+            return sizeof(RAKPMsg4Res_T);
+        }
+    }
+    else
+    {
+    	_fmemcpy (UserPswd, pUserInfo->UserPassword, MAX_PASSWORD_LEN);
+    }
+
+    UserPasswdLen = _fstrlen ((_FAR_ char*)UserPswd);
+    UserPasswdLen = (UserPasswdLen > MAX_PASSWORD_LEN) ?
+                    MAX_PASSWORD_LEN : UserPasswdLen;
+
+    /* Check for Key Exchange Auth Code */
+    pKeyXchgCode = (_FAR_ INT8U*)(pReq + sizeof (RAKPMsg3Req_T));
+
+    /*Construct hmac to check Auth code */
+    pMsg3hmac = (_FAR_	Msg3hmac_T*) &pBMCInfo->LANConfig.HmacInBuf;
+    _fmemcpy (pMsg3hmac->MgdSysRandNo, pSessInfo->MgdSysRandomNo, 16);
+    pMsg3hmac->RemConSessionID  = pSessInfo->RemConSessionID;
+    pMsg3hmac->Role             = pSessInfo->Privilege | (pSessInfo->Lookup << 4);
+    pMsg3hmac->UsrNameLen       = _fstrlen ((_FAR_ char*)pUserInfo->UserName);
+    pMsg3hmac->UsrNameLen        = (pMsg3hmac->UsrNameLen > MAX_USERNAME_LEN) ?
+                                        MAX_USERNAME_LEN : pMsg3hmac->UsrNameLen;
+
+    _fmemcpy ((_FAR_ char*)pMsg3hmac->UsrName,
+          (_FAR_ char*)pUserInfo->UserName, pMsg3hmac->UsrNameLen);
+
+    /* Key Exchange Auth Code  */
+    switch (pSessInfo->AuthAlgorithm)
+    {
+        case RAKP_NONE:
+            break;
+
+        case RAKP_HMAC_SHA1:
+            hmac_sha1 ((INT8U *)UserPswd, UserPasswdLen, (INT8U *)pBMCInfo->LANConfig.HmacInBuf,
+                       sizeof (Msg3hmac_T) - (16 - pMsg3hmac->UsrNameLen),
+                       (INT8U *)&pRes [ sizeof (RAKPMsg4Res_T)], RAKP1_HASH_SIZE);
+
+            if (0 != _fmemcmp (pKeyXchgCode, &pRes [sizeof (RAKPMsg4Res_T)], RAKP1_HASH_SIZE))
+            {
+                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+                IPMI_WARNING ("RMCP+.c : RAKPMsg3 - Invalid integrity check\n");
+                Res->StatusCode = SC_INV_INTEGRITY_CHECK;
+                return sizeof (RAKPMsg4Res_T);
+            }
+            break;
+
+        case RAKP_HMAC_MD5:
+            hmac_md5(UserPswd, UserPasswdLen, pBMCInfo->LANConfig.HmacInBuf,
+                       sizeof (Msg3hmac_T) - (MAX_USERNAME_LEN - pMsg3hmac->UsrNameLen),
+                       &pRes [ sizeof (RAKPMsg4Res_T)], RAKP1_HASH_HMAC_MD5_SIZE);
+
+            if (0 != _fmemcmp (pKeyXchgCode, &pRes [sizeof (RAKPMsg4Res_T)], RAKP1_HASH_HMAC_MD5_SIZE))
+            {
+                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+                IPMI_WARNING ("RMCP+.c : RAKPMsg3 - Invalid integrity check\n");
+                Res->StatusCode = SC_INV_INTEGRITY_CHECK;
+                return sizeof (RAKPMsg4Res_T);
+            }
+            break;
+
+        case RAKP_HMAC_SHA256:
+        	hmac_sha256(pSessInfo->Password, UserPasswdLen, pBMCInfo->LANConfig.HmacInBuf,
+        		 sizeof (Msg3hmac_T) - (MAX_USERNAME_LEN - pMsg3hmac->UsrNameLen),
+                       &pRes [ sizeof (RAKPMsg4Res_T)], RAKP1_HASH_HMAC_SHA256_SIZE);
+        	 if (0 != _fmemcmp (pKeyXchgCode, &pRes [sizeof (RAKPMsg4Res_T)], RAKP1_HASH_HMAC_SHA256_SIZE))
+                {
+                    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+                    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+                    IPMI_WARNING ("RMCP+.c : RAKPMsg3 - Invalid integrity check\n");
+                    Res->StatusCode = SC_INV_INTEGRITY_CHECK;
+                    return sizeof (RAKPMsg4Res_T);
+                }
+                break;        
+
+        default:
+            IPMI_WARNING ("RMCP+.c : RAKPMsg3 - Invalid Authentication\n");
+    }
+
+    /*Construct SIK to send the Integrity check */
+    memset(pBMCInfo->LANConfig.HmacInBuf,0,sizeof(pBMCInfo->LANConfig.HmacInBuf));
+    memset(pBMCInfo->LANConfig.SIK,0,sizeof(pBMCInfo->LANConfig.SIK));
+
+    pSIKhmac = (_FAR_  SIKhmac_T*) &pBMCInfo->LANConfig.HmacInBuf;
+
+    _fmemcpy (pSIKhmac->RemConRandNo, pSessInfo->RemConRandomNo, 16);
+    _fmemcpy (pSIKhmac->MgdSysRandNo, pSessInfo->MgdSysRandomNo, 16);
+    pSIKhmac->Role = pSessInfo->Privilege | (pSessInfo->Lookup << 4) ;
+    pSIKhmac->UsrNameLen = _fstrlen ((_FAR_ char*)pUserInfo->UserName);
+    pSIKhmac->UsrNameLen = (pSIKhmac->UsrNameLen > MAX_USERNAME_LEN) ?
+                           MAX_USERNAME_LEN : pSIKhmac->UsrNameLen;
+    _fmemcpy ((_FAR_ char*)pSIKhmac->UsrName,
+              (_FAR_ char*)pUserInfo->UserName, pSIKhmac->UsrNameLen);
+
+    for (i = 0; i < HASH_KEY_LEN; i++)
+    {
+        if (pBMCInfo->RMCPPlus[EthIndex].KGHashKey [i] != 0)
+        {
+            break;
+        }
+    }
+
+    switch(pSessInfo->AuthAlgorithm)
+    {
+        case RAKP_NONE:
+             break;
+
+        case RAKP_HMAC_SHA1: 
+        {
+            // Encryption key must not be used for packets from VLAN or Loopback.
+        #ifdef  LAN_RESTRICTIONS_BYPASS_FOR_LOOPBACK_AND_VLAN
+            if ((i < HASH_KEY_LEN) && !(pParams->IsPktFromVLAN || pParams->IsPktFromLoopBack) )
+        #else
+            if ((i < HASH_KEY_LEN))
+        #endif
+            {
+                /* Use the KG (BMC Key set through SetChSecurityKeys command) Key */
+                hmac_sha1 ((INT8U *)pBMCInfo->RMCPPlus[EthIndex].KGHashKey, HASH_KEY_LEN, (INT8U *)pBMCInfo->LANConfig.HmacInBuf,
+                                    (sizeof (SIKhmac_T) - 16 + pSIKhmac->UsrNameLen),
+                                    (INT8U *)pBMCInfo->LANConfig.SIK, SESSION_INTEGRITY_KEY_SIZE);
+            }
+            else
+            {
+                /* Use the KUID (User Password) Key */
+                hmac_sha1 ((INT8U *)UserPswd, UserPasswdLen, (INT8U *)pBMCInfo->LANConfig.HmacInBuf,
+                                    (sizeof (SIKhmac_T) - 16 + pSIKhmac->UsrNameLen),
+                                    (INT8U *)pBMCInfo->LANConfig.SIK, SESSION_INTEGRITY_KEY_SIZE);
+            }
+
+            /* Create Key1 & Key2 for Rest of packet Integrity & Encryption */
+            _fmemset (TempKey, 1, HASH_KEY1_CONST_SIZE);
+            hmac_sha1 ((INT8U *)pBMCInfo->LANConfig.SIK, SESSION_INTEGRITY_KEY_SIZE, (INT8U *)TempKey, HASH_KEY1_CONST_SIZE,
+                                    (INT8U *)pSessInfo->Key1, HASH_KEY1_SIZE);
+            _fmemset (TempKey2, 2, HASH_KEY2_CONST_SIZE);
+            hmac_sha1 ((INT8U *)pBMCInfo->LANConfig.SIK, SESSION_INTEGRITY_KEY_SIZE, (INT8U *)TempKey2, HASH_KEY2_CONST_SIZE,
+                                    (INT8U *)pSessInfo->Key2, HASH_KEY2_SIZE);
+
+            /* Construct HMAC to send the Integrity check value using SIK got from prev hmac*/
+            pMsg4hmac = (_FAR_ RAKPMsg4hmac_T*) &pBMCInfo->LANConfig.HmacInBuf;
+            _fmemcpy (pMsg4hmac->RemConRandNo, pSessInfo->RemConRandomNo, 16);
+            pMsg4hmac->MgdSysSessionID = pSessInfo->SessionID;
+            /*Get System GUID */
+            _fmemcpy (pMsg4hmac->MgdSysGUID, BMC_GET_SHARED_MEM (BMCInst)->SystemGUID, 16);
+            hmac_sha1 ((INT8U *)pBMCInfo->LANConfig.SIK, SESSION_INTEGRITY_KEY_SIZE, (INT8U *)pBMCInfo->LANConfig.HmacInBuf, sizeof (RAKPMsg4hmac_T),
+                                    (INT8U *)&pRes [sizeof (RAKPMsg4Res_T)], HASH_KEY1_CONST_SIZE);
+            ResIntigrityKeyLen = HMAC_SHA1_96_LEN;
+            break;
+        }
+
+        case RAKP_HMAC_MD5:
+            {
+            #ifdef  LAN_RESTRICTIONS_BYPASS_FOR_LOOPBACK_AND_VLAN
+                if ((i < HASH_KEY_LEN) && !(pParams->IsPktFromVLAN || pParams->IsPktFromLoopBack) )
+            #else
+                if ((i < HASH_KEY_LEN))
+            #endif
+                {
+                    /* Use the KG (BMC Key set through SetChSecurityKeys command) Key */
+                    hmac_md5 (pBMCInfo->RMCPPlus[EthIndex].KGHashKey, HASH_KEY_LEN, pBMCInfo->LANConfig.HmacInBuf,
+                                            (sizeof (SIKhmac_T) - 16 + pSIKhmac->UsrNameLen),
+                                            pBMCInfo->LANConfig.SIK, SESSION_HMAC_MD5_I_KEY_SIZE);
+                }
+                else
+                {
+                    /* Use the KUID (User Password) Key */
+                    hmac_md5 (UserPswd, UserPasswdLen, pBMCInfo->LANConfig.HmacInBuf,
+                                    (sizeof (SIKhmac_T) - 16 + pSIKhmac->UsrNameLen),
+                                    pBMCInfo->LANConfig.SIK, SESSION_HMAC_MD5_I_KEY_SIZE);
+                }
+    
+                /* Create Key1 & Key2 for Rest of packet Integrity & Encryption */
+                _fmemset (TempKey, 1, HASH_KEY1_CONST_SIZE);
+                hmac_md5 (pBMCInfo->LANConfig.SIK, SESSION_HMAC_MD5_I_KEY_SIZE, TempKey, HASH_KEY1_CONST_SIZE,
+                                pSessInfo->Key1, SESSION_HMAC_MD5_I_KEY_SIZE);
+                _fmemset (TempKey2, 2, HASH_KEY2_CONST_SIZE);
+                hmac_md5 (pBMCInfo->LANConfig.SIK, SESSION_HMAC_MD5_I_KEY_SIZE, TempKey2, HASH_KEY2_CONST_SIZE,
+                                pSessInfo->Key2, SESSION_HMAC_MD5_I_KEY_SIZE);
+
+                /* Construct HMAC to send the Integrity check value using SIK got from prev hmac*/
+                pMsg4hmac = (_FAR_ RAKPMsg4hmac_T*) &pBMCInfo->LANConfig.HmacInBuf;
+                _fmemcpy (pMsg4hmac->RemConRandNo, pSessInfo->RemConRandomNo, 16);
+                pMsg4hmac->MgdSysSessionID = pSessInfo->SessionID;
+                /*Get System GUID */
+                _fmemcpy (pMsg4hmac->MgdSysGUID, BMC_GET_SHARED_MEM (BMCInst)->SystemGUID, 16);
+                hmac_md5 (pBMCInfo->LANConfig.SIK, SESSION_INTEGRITY_KEY_SIZE, pBMCInfo->LANConfig.HmacInBuf, sizeof (RAKPMsg4hmac_T),
+                &pRes [sizeof (RAKPMsg4Res_T)], SESSION_HMAC_MD5_I_KEY_SIZE);
+                ResIntigrityKeyLen = HMAC_MD5_LEN;
+            }
+            break;
+
+        
+ 
+#if 0   //algorithm not specified in IPMI spec, to be removed after review         
+        case AUTH_MD5_128:
+            {
+                // Encryption key must not be used for packets from VLAN or Loopback.
+            #ifdef  LAN_RESTRICTIONS_BYPASS_FOR_LOOPBACK_AND_VLAN
+                if ((i < HASH_KEY_LEN) && !(pParams->IsPktFromVLAN || pParams->IsPktFromLoopBack) )
+            #else
+                if ((i < HASH_KEY_LEN))
+            #endif
+                {
+                    /* Use the KG (BMC Key set through SetChSecurityKeys command) Key */
+                    MD5_128 ((char *)pBMCInfo->RMCPPlus[EthIndex].KGHashKey, HASH_KEY_LEN, (char *)pBMCInfo->LANConfig.HmacInBuf,
+                                (sizeof (SIKhmac_T) - 16 + pSIKhmac->UsrNameLen),
+                                (char *)pBMCInfo->LANConfig.SIK, SESSION_MD5_KEY_SIZE);
+                }
+                else
+                {
+                    /* Use the KUID (User Password) Key */
+                    MD5_128 ((char *)pUserInfo->UserPassword, UserPasswdLen, (char *)pBMCInfo->LANConfig.HmacInBuf,
+                                (sizeof (SIKhmac_T) - 16 + pSIKhmac->UsrNameLen), (char *)pBMCInfo->LANConfig.SIK, SESSION_MD5_KEY_SIZE);
+                }
+
+                /* Create Key1 & Key2 for Rest of packet Integrity & Encryption */
+                _fmemset (TempKey, 1, HASH_KEY1_CONST_SIZE);
+                MD5_128 ((char *)pBMCInfo->LANConfig.SIK, SESSION_INTEGRITY_KEY_SIZE, (char *)TempKey, HASH_KEY1_CONST_SIZE,
+                                (char *)pSessInfo->Key1, SESSION_MD5_KEY_SIZE);
+                _fmemset (TempKey2, 2, HASH_KEY2_CONST_SIZE);
+                MD5_128 ((char *)pBMCInfo->LANConfig.SIK, SESSION_INTEGRITY_KEY_SIZE, (char *)TempKey2, HASH_KEY2_CONST_SIZE,
+                                (char *)pSessInfo->Key2, SESSION_MD5_KEY_SIZE);
+
+                /* Construct HMAC to send the Integrity check value using SIK got from prev hmac*/
+                pMsg4hmac = (_FAR_ RAKPMsg4hmac_T*) &pBMCInfo->LANConfig.HmacInBuf;
+                _fmemcpy (pMsg4hmac->RemConRandNo, pSessInfo->RemConRandomNo, 16);
+                pMsg4hmac->MgdSysSessionID = pSessInfo->SessionID;
+
+                /*Get System GUID */
+                _fmemcpy (pMsg4hmac->MgdSysGUID, BMC_GET_SHARED_MEM (BMCInst)->SystemGUID, 16);
+                MD5_128 ((char *)pBMCInfo->LANConfig.SIK, SESSION_INTEGRITY_KEY_SIZE, (char *)pBMCInfo->LANConfig.HmacInBuf, sizeof (RAKPMsg4hmac_T),
+                                (char *)&pRes [sizeof (RAKPMsg4Res_T)], SESSION_MD5_KEY_SIZE);
+                ResIntigrityKeyLen = MD5_LEN;
+                break;
+            }
+#endif           
+            
+	case RAKP_HMAC_SHA256:
+	{
+		// Encryption key must not be used for packets from VLAN or Loopback.
+		#ifdef	LAN_RESTRICTIONS_BYPASS_FOR_LOOPBACK_AND_VLAN
+			if ((i < HASH_KEY_LEN) && !(pParams->IsPktFromVLAN || pParams->IsPktFromLoopBack) )
+		#else
+			if ((i < HASH_KEY_LEN))
+		#endif
+			{
+				/* Use the KG (BMC Key set through SetChSecurityKeys command) Key */
+				hmac_sha256((unsigned char *)pBMCInfo->RMCPPlus[EthIndex].KGHashKey, HASH_KEY_LEN, (unsigned char *)pBMCInfo->LANConfig.HmacInBuf,
+					   (sizeof (SIKhmac_T) - 16 + pSIKhmac->UsrNameLen),
+				 (unsigned char *)m_SIK, SHA2_HASH_KEY_SIZE);
+			}
+			else
+			{
+				/* Use the KUID (User Password) Key */
+				hmac_sha256 ((unsigned char *)UserPswd, UserPasswdLen, (unsigned char *)pBMCInfo->LANConfig.HmacInBuf,
+			   (sizeof (SIKhmac_T) - 16 + pSIKhmac->UsrNameLen), (unsigned char *)m_SIK, SHA2_HASH_KEY_SIZE);
+					
+			}
+
+		/* Create Key1 & Key2 for Rest of packet Integrity & Encryption */
+				_fmemset (TempKey, 1, HASH_KEY1_CONST_SIZE);
+				hmac_sha256 (m_SIK, SHA2_HASH_KEY_SIZE, TempKey, HASH_KEY1_CONST_SIZE,
+ 			      pSessInfo->Key1, SHA2_HASH_KEY_SIZE);
+				_fmemset (TempKey2, 2, HASH_KEY2_CONST_SIZE);
+				  hmac_sha256 (m_SIK, SHA2_HASH_KEY_SIZE, TempKey2, HASH_KEY2_CONST_SIZE,
+ 			     pSessInfo->Key2, SHA2_HASH_KEY_SIZE);
+       /* Construct HMAC to send the Integrity check value using SIK got from prev hmac*/
+			 pMsg4hmac = (_FAR_ RAKPMsg4hmac_T*) &pBMCInfo->LANConfig.HmacInBuf;
+			 _fmemcpy (pMsg4hmac->RemConRandNo, pSessInfo->RemConRandomNo, 16);
+			pMsg4hmac->MgdSysSessionID = pSessInfo->SessionID;
+			 /*Get System GUID */
+			 _fmemcpy (pMsg4hmac->MgdSysGUID, BMC_GET_SHARED_MEM (BMCInst)->SystemGUID, 16);
+			 hmac_sha256 (m_SIK, SHA2_HASH_KEY_SIZE, pBMCInfo->LANConfig.HmacInBuf, sizeof (RAKPMsg4hmac_T),
+				&pRes [sizeof (RAKPMsg4Res_T)], HASH_KEY1_CONST_SIZE); 
+			 ResIntigrityKeyLen = HMAC_SHA256_128_LEN;
+	 
+			break;
+	}
+        default:
+            IPMI_DBG_PRINT("\nRMCP+.c : Invalid Integrity Algorithm \n");
+    }
+
+    /* Get information abt this channel */
+    pChannelInfo = getChannelInfo (Channel, BMCInst);
+    if (NULL == pChannelInfo)
+    {
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+        IPMI_WARNING ("RMCP+.c : RAKPMsg3 - Invalid Integrity check\n");
+        Res->StatusCode = SC_INV_INTEGRITY_CHECK;
+        return sizeof (RAKPMsg4Res_T);
+    }
+
+    pUserInfo = getUserIdInfo((INT8U)pSessInfo->UserId, BMCInst);
+
+	// check the session activated or not, or it will add repeatedly. And finally it will happen "No session slot available."
+	if((!pSessInfo->IsLoopBack) && (pSessInfo->Activated!=TRUE))
+    {
+        /* Update active sessions for current user */
+        pUserInfo->CurrentSession++;
+
+        /* Number of active session */
+        pChannelInfo->ActiveSession++;
+    }
+
+    /* Get userInfo for the given Used Id & Channel */
+    pChUserInfo = getChUserIdInfo (pSessInfo->UserId, &Index, pChannelInfo->ChannelUserInfo, BMCInst);
+
+#ifdef  LAN_RESTRICTIONS_BYPASS_FOR_LOOPBACK_AND_VLAN
+    if( pParams->IsPktFromVLAN || pParams->IsPktFromLoopBack )
+    {
+        /* If the packet is from VLAN or LoopBack, then channel privilege should not be
+                    considered for session privilege calculation */
+        pSessInfo->Privilege = 0x4; //set to admin for loopback and VLAN always
+        //UTIL_MIN (pSessInfo->Privilege, pChUserInfo->AccessLimit);
+    }
+    else
+    {
+        /* if requested privilege is greater than privilege level for channel or user
+                set the minimum of Channel or user privilege*/
+        pSessInfo->Privilege =
+        UTIL_MIN (pSessInfo->Privilege, UTIL_MIN (pChannelInfo->MaxPrivilege, pChUserInfo->AccessLimit));
+    }
+#else
+    /* if requested privilege is greater than privilege level for channel or user
+            set the minimum of Channel or user privilege*/
+    pSessInfo->Privilege =
+    UTIL_MIN (pSessInfo->Privilege, UTIL_MIN (pChannelInfo->MaxPrivilege, pChUserInfo->AccessLimit));
+#endif
+
+    pSessInfo->AuthType     = RMCP_PLUS_FORMAT;
+    pSessInfo->Activated    = TRUE;
+    /* Set the Max Privilege allowed for the Session*/
+    pSessInfo->MaxPrivilege = pSessInfo->Privilege;
+    BMC_GET_SHARED_MEM (BMCInst)->SessionHandle += 1;
+    pSessInfo->SessionHandle = BMC_GET_SHARED_MEM (BMCInst)->SessionHandle;
+
+    /*Load Response */
+    Res->StatusCode      = SC_NO_ERROR;
+    Res->RemConSessionID = pSessInfo->RemConSessionID;
+    pSessInfo->EventFlag = 1;
+    pBMCInfo->LANConfig.DeleteThisLANSessionID = 0;
+    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+    return (sizeof (RAKPMsg4Res_T) + ResIntigrityKeyLen);
+}
+
+
+#endif /*#if IPMI20_SUPPORT == 1*/

+ 14 - 14
app/bmc_server/ipmi_dev/RMCP+.h → app/bmc/lan/RMCP+.h

@@ -22,9 +22,9 @@
  *****************************************************************/
 #ifndef RMCP_PLUS_H
 #define RMCP_PLUS_H
-#include "Types.h"
-#include "IPMI_RMCP.h"
-#include "IPMI_RMCP+.h"
+#include "com_BmcType.h"
+#include "com_IPMI_RMCP.h"
+#include "com_IPMI_RMCP+.h"
 #include "RMCP.h"
 #include "Ciphertable.h"
 
@@ -45,7 +45,7 @@
  * @var g_CipherRec
  * @brief Cipher suite record.
 **/
-extern const INT8U  g_CipherRec[MAX_CIPHER_SUITES_BYTES];
+extern const uint8_t  g_CipherRec[MAX_CIPHER_SUITES_BYTES];
 
 
 
@@ -58,16 +58,16 @@ extern const INT8U  g_CipherRec[MAX_CIPHER_SUITES_BYTES];
  * keys for encoding/decoding furthur messages.
  * @{
 **/
-extern int  RSSPOpenSessionReq (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes, MiscParams_T *pParams,INT8U Channel, int BMCInst);
-extern int  RAKPMsg1           (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes, MiscParams_T *pParams,INT8U Channel, int BMCInst);
-extern int  RAKPMsg3           (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes, MiscParams_T *pParams,INT8U Channel, int BMCInst);
-/** @} */
+// extern int  RSSPOpenSessionReq (  uint8_t* pReq, uint8_t ReqLen,   uint8_t* pRes, uint8_t Channel );
+// extern int  RAKPMsg1           (  uint8_t* pReq, uint8_t ReqLen,   uint8_t* pRes, uint8_t Channel );
+// extern int  RAKPMsg3           (  uint8_t* pReq, uint8_t ReqLen,   uint8_t* pRes, uint8_t Channel );
+// /** @} */
 
-/**
- * @brief  sha256 open source algorithm
-**/
-extern void hmac_sha256(unsigned char *key, unsigned int key_size,
-        unsigned char *message, unsigned int message_len,
-        unsigned char *mac, unsigned mac_size);
+// /**
+//  * @brief  sha256 open source algorithm
+// **/
+// extern void hmac_sha256(unsigned char *key, unsigned int key_size,
+//         unsigned char *message, unsigned int message_len,
+//         unsigned char *mac, unsigned mac_size);
 
 #endif /* RMCP_PLUS_H */

+ 1381 - 0
app/bmc/lan/RMCP.c

@@ -0,0 +1,1381 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************/
+/*****************************************************************
+ *
+ * RMCP.c
+ * RMCP Message Handler
+ *
+ * Author: Govind Kothandapani <govindk@ami.com>
+ *       : Bakka Ravinder Reddy <bakkar@ami.com>
+ *
+ *****************************************************************/
+#include "com_Message.h"
+#include "com_IPMIDefs.h"
+#include "Session.h"
+#include "LANIfc.h"
+#include "MD.h"
+#include "RMCP.h"
+#include "RMCP+.h"
+#include "main.h"
+#include "MD5_128.h"
+#include <string.h>
+#include "BmcType.h"
+#include "AuthCode.h"
+
+
+/*** Local definitions ***/
+#define RMCP_VERSION                6
+#define IPMI_MESSAGE_CLASS          7
+#define PRESENCE_PING_MSGTYPE       0x80
+#define RMCP_VERSION                6
+
+#define AMI_CMD_NETFN_LUN           (((0x2E | 1) << 2) | 0x00)
+#define AMI_CMD_12                  0x12
+#define PING_IPMI_15_SUPPORT        1
+#define PING_IPMI_20_SUPPORT        2
+#define MAX_AUTH_CODE_SIZE          12
+#define INIT_VECTOR_SIZE            16
+#define INTEGRITY_MASK              BIT6
+#define CONFIDENT_MASK              BIT7
+
+#define PAYLOAD_RSSP_OS_REQ         0x10
+#define PAYLOAD_RSSP_OS_RES         0x11
+#define PAYLOAD_RAKP_MSG1           0x12
+#define PAYLOAD_RAKP_MSG2           0x13
+#define PAYLOAD_RAKP_MSG3           0x14
+#define PAYLOAD_RAKP_MSG4           0x15
+
+// /*** Prototype Declaration ***/
+static int ProcIPMIReq (  SessionInfo_T*  pSessionInfo, uint8_t Payload, MsgPkt_T *pReq, MsgPkt_T *pRes);
+static uint8_t  ValidateRMCPHdr    (  RMCPHdr_T* pRMCPHdr);
+// static bool  ValidateSessionHdr (uint32_t SessionID, uint32_t SeqNo );
+static uint8_t ProcessPingMsg     (  RMCPHdr_T* pRMCPReq,
+ 								   RMCPHdr_T* pRMCPRes );
+static uint8_t  ValidateAuthCode   (  uint8_t* pAuthCode,   uint8_t* pPassword,
+ 								   SessionHdr_T* pSessionHdr,
+ 								   IPMIMsgHdr_T* pIPMIMsg);
+// static int   Proc20Payload      (  RMCPHdr_T* pRMCPReq,
+// 								   RMCPHdr_T* pRMCPRes, MiscParams_T *pParams, uint8_t Channel );
+
+/*** Local typedefs ***/
+/**
+ * @struct PreSessionCmd_T
+ * @brief Pre-session command entry.
+**/
+typedef struct
+{
+	uint8_t   NetFn;
+	uint8_t   Cmd;
+} PreSessionCmd_T;
+
+/**
+ * @brief Message Payload Handler function.
+ * @param pReq   - Request message.
+ * @param ReqLen - Request length.
+ * @param pRes   - Response message.
+ * @return 0 if success, -1 if error.
+**/
+typedef int (*pPayloadHndlr_T) (  uint8_t* pReq, uint8_t ReqLen,
+								  uint8_t* pRes, uint8_t Channel );
+
+/**
+ * @struct PayloadTbl_T;
+ * @brief Payload Table structure.
+**/
+typedef struct
+{
+	uint8_t           Payload;
+	pPayloadHndlr_T PayloadHndlr;
+} PayloadTbl_T;
+
+
+// static const PayloadTbl_T m_PayloadTbl [] =
+// {
+// 	 /*  Payload              Handler           */
+// 	{PAYLOAD_RSSP_OS_REQ,   RSSPOpenSessionReq  },
+// 	{PAYLOAD_RAKP_MSG1,     RAKPMsg1            },
+// 	{PAYLOAD_RAKP_MSG3,     RAKPMsg3            },
+// };
+
+// /* Pre-Session establishment commands */
+// static const PreSessionCmd_T m_PreSessionCmdsTbl[] =
+// {
+// 	{ NETFN_APP,    CMD_GET_CH_AUTH_CAP },
+// 	{ NETFN_APP,    CMD_GET_SESSION_CHALLENGE },
+// 	{ NETFN_APP,    CMD_GET_DEV_GUID },
+// 	{ NETFN_APP,    CMD_GET_CH_CIPHER_SUITES },
+// 	{ NETFN_APP,    CMD_GET_SYSTEM_GUID },
+// 	{ NETFN_SENSOR, CMD_PET_ACKNOWLEDGE},
+// };
+
+// /**
+//  * @struct IPMIAuditMaskTbl_T;
+//  * @brief  Maps Audit Event types to their bitmask in configuration.
+// **/
+// typedef struct
+// {
+// 	uint8_t EventType;
+// 	uint8_t EventMask;
+// }IPMIAuditMaskTbl_T;
+
+// static const IPMIAuditMaskTbl_T m_IPMIAuditMaskMap[] =
+// {
+// 	{ EVENT_LOGIN,           0x0 },
+// 	{ EVENT_LOGOUT,          0x1 },
+// 	{ EVENT_AUTO_LOGOUT,     0x2 },
+// 	{ EVENT_LOGIN_FAILURE,   0x3 },
+// };
+
+
+// int RmcpSeqNumValidation(SessionInfo_T* pSessionInfo, uint32_t SessionSeqNum, IPMIMsgHdr_T* pIPMIMsgReq)
+// {
+// 	uint32_t  SeqTrac[SIXTEEN_COUNT_WINDOW_LEN];
+// 	bool    TrackRollOver       = FALSE;
+// 	uint32_t  TrackRollOverSeq    = SEQNUM_ROLLOVER;
+// 	int     i;
+	
+// 	if((pIPMIMsgReq->Cmd != CMD_ACTIVATE_SESSION) ||
+// 	   ((pIPMIMsgReq->Cmd == CMD_ACTIVATE_SESSION) &&
+// 	   (SessionSeqNum != 0)))
+// 	{
+// 		if( pSessionInfo->InboundSeq == SessionSeqNum)
+// 			return -1;
+
+// 		 if((pSessionInfo->InboundSeq < (SEQNUM_ROLLOVER - EIGHT_COUNT_WINDOW_LEN)) && (pSessionInfo->InboundSeq > EIGHT_COUNT_WINDOW_LEN))
+// 		 {
+// 			if(SessionSeqNum < pSessionInfo->InboundSeq)
+// 			{
+// 				if((pSessionInfo->InboundSeq -SessionSeqNum) > EIGHT_COUNT_WINDOW_LEN)
+// 				{
+// 				   return -1;
+// 				}
+// 				else
+// 				{
+// 					for(i=0;i<EIGHT_COUNT_WINDOW_LEN;i++)
+// 					{
+// 						if(SessionSeqNum == pSessionInfo->InboundTrac[i])
+// 						{
+// 							if(((1 << i) & pSessionInfo->InboundRecv) != 0)
+// 							{
+// 								 return -1;
+// 							}
+// 							else
+// 							{
+// 								 pSessionInfo->InboundRecv |= (1<<i);
+// 							}
+// 						}
+// 					}
+// 				}
+// 			}
+// 			else
+// 			{
+// 				if((SessionSeqNum - pSessionInfo->InboundSeq) > EIGHT_COUNT_WINDOW_LEN)
+// 				{
+// 					return -1;
+// 				}
+
+// 				_fmemcpy((uint8_t *)SeqTrac,(uint8_t *)pSessionInfo->InboundTrac,(sizeof(uint32_t) * EIGHT_COUNT_WINDOW_LEN));
+
+// 				for(i=0; i < (SessionSeqNum - pSessionInfo->InboundSeq); i++)
+// 				{
+// 					pSessionInfo->InboundTrac[i] = SessionSeqNum - (i+1);
+// 				}
+
+// 				pSessionInfo->InboundRecv = pSessionInfo->InboundRecv << (SessionSeqNum - pSessionInfo->InboundSeq);
+// 				pSessionInfo->InboundRecv |= (1 << ((SessionSeqNum - pSessionInfo->InboundSeq)-1));
+
+// 				_fmemcpy((uint8_t *)&pSessionInfo->InboundTrac[SessionSeqNum - pSessionInfo->InboundSeq],
+// 								(uint8_t *)&SeqTrac[0],
+// 								(sizeof(uint32_t) *(EIGHT_COUNT_WINDOW_LEN - (SessionSeqNum - pSessionInfo->InboundSeq))));
+// 				pSessionInfo->InboundSeq = SessionSeqNum;
+// 			}
+// 		}
+// 		else if((pSessionInfo->InboundSeq  < EIGHT_COUNT_WINDOW_LEN)
+// 					|| (pSessionInfo->InboundSeq  > (SEQNUM_ROLLOVER -EIGHT_COUNT_WINDOW_LEN))) /* Checking for Roll over condition */
+// 		{
+// 			if(SessionSeqNum < pSessionInfo->InboundSeq)
+// 			{
+// 				if(!((((pSessionInfo->InboundSeq -SessionSeqNum) <= EIGHT_COUNT_WINDOW_LEN) &&
+// 				   (((SEQNUM_ROLLOVER - pSessionInfo->InboundSeq) + SessionSeqNum+1) >= EIGHT_COUNT_WINDOW_LEN )) ||
+// 				   ((((SEQNUM_ROLLOVER - pSessionInfo->InboundSeq) + SessionSeqNum+1) <= EIGHT_COUNT_WINDOW_LEN ) &&
+// 					   (pSessionInfo->InboundSeq -SessionSeqNum) >= EIGHT_COUNT_WINDOW_LEN)))
+// 				{
+// 				  return -1;
+// 				}
+// 				else
+// 				{
+// 					if((pSessionInfo->InboundSeq -SessionSeqNum) <= EIGHT_COUNT_WINDOW_LEN)
+// 					{
+// 						for(i=0;i<EIGHT_COUNT_WINDOW_LEN;i++)
+// 						{
+// 							if(SessionSeqNum == pSessionInfo->InboundTrac[i])
+// 							{
+// 								if(((1 << i) & pSessionInfo->InboundRecv) != 0)
+// 								{
+// 									return -1;
+// 								}
+// 								else
+// 								{
+// 									pSessionInfo->InboundRecv |= (1<<i);
+// 								}
+// 							}
+// 						}
+// 					 }
+// 					else if(((SEQNUM_ROLLOVER - pSessionInfo->InboundSeq) + SessionSeqNum+1) <= EIGHT_COUNT_WINDOW_LEN )
+// 					{
+// 						_fmemcpy((uint8_t *)SeqTrac,(uint8_t *)pSessionInfo->InboundTrac,(sizeof(uint32_t) * EIGHT_COUNT_WINDOW_LEN));
+
+// 						for(i=0; i < ((SEQNUM_ROLLOVER - pSessionInfo->InboundSeq) + SessionSeqNum+1); i++)
+// 						{
+// 							if(((SessionSeqNum - (i+1)) != 0) && (TrackRollOver == FALSE))
+// 								pSessionInfo->InboundTrac[i] = SessionSeqNum - (i+1);
+// 							else if(((SessionSeqNum - (i+1)) == 0) && (TrackRollOver == FALSE))
+// 							{
+// 								pSessionInfo->InboundTrac[i] = SessionSeqNum - (i+1);
+// 								TrackRollOver = TRUE;
+// 							}
+// 							else if(TrackRollOver ==  TRUE)
+// 							{
+// 								pSessionInfo->InboundTrac[i] = TrackRollOverSeq;
+// 								TrackRollOverSeq--;
+// 							}
+// 						}
+// 						TrackRollOverSeq = SEQNUM_ROLLOVER;
+// 						TrackRollOver = FALSE;
+
+// 						pSessionInfo->InboundRecv = pSessionInfo->InboundRecv << ((SEQNUM_ROLLOVER - pSessionInfo->InboundSeq) + SessionSeqNum+1);
+// 						pSessionInfo->InboundRecv |= (1 << (((SEQNUM_ROLLOVER - pSessionInfo->InboundSeq) + SessionSeqNum+1) -1));
+
+// 						_fmemcpy((uint8_t *)&pSessionInfo->InboundTrac[(SEQNUM_ROLLOVER - pSessionInfo->InboundSeq) + SessionSeqNum+1],
+// 						(uint8_t *)&SeqTrac[0],
+// 						(sizeof(uint32_t) *(EIGHT_COUNT_WINDOW_LEN - ((SEQNUM_ROLLOVER - pSessionInfo->InboundSeq) + SessionSeqNum+1))));
+// 						pSessionInfo->InboundSeq = SessionSeqNum;
+// 					}
+// 				}
+// 			}
+// 			else if(SessionSeqNum > pSessionInfo->InboundSeq)
+// 			{
+// 				if(!((((SessionSeqNum -pSessionInfo->InboundSeq) <= EIGHT_COUNT_WINDOW_LEN) &&
+// 				   (((SEQNUM_ROLLOVER - SessionSeqNum) + pSessionInfo->InboundSeq+1) >= EIGHT_COUNT_WINDOW_LEN )) ||
+// 				   ((((SEQNUM_ROLLOVER - SessionSeqNum) + pSessionInfo->InboundSeq+1) <= EIGHT_COUNT_WINDOW_LEN ) &&
+// 					   (SessionSeqNum-pSessionInfo->InboundSeq) >= EIGHT_COUNT_WINDOW_LEN)))
+// 				{
+// 					return -1;
+// 				}
+// 				else
+// 				{
+// 					if((SessionSeqNum  - pSessionInfo->InboundSeq) <= EIGHT_COUNT_WINDOW_LEN)
+// 					{
+// 						_fmemcpy((uint8_t *)SeqTrac,(uint8_t *)pSessionInfo->InboundTrac,(sizeof(uint32_t) * EIGHT_COUNT_WINDOW_LEN));
+// 						for(i=0;i<(SessionSeqNum  - pSessionInfo->InboundSeq) ;i++)
+// 						{
+// 							if(((SessionSeqNum - (i+1)) != 0) && (TrackRollOver == FALSE))
+// 							{
+// 								pSessionInfo->InboundTrac[i] = SessionSeqNum - (i+1);
+// 							}
+// 							else if(((SessionSeqNum - (i+1)) == 0) && (TrackRollOver == FALSE))
+// 							{
+// 								pSessionInfo->InboundTrac[i] = SessionSeqNum - (i+1);
+// 								TrackRollOver = TRUE;
+// 							}
+// 							else if(TrackRollOver ==  TRUE)
+// 							{
+// 								pSessionInfo->InboundTrac[i] = TrackRollOverSeq;
+// 								TrackRollOverSeq--;
+// 							}
+// 						}
+// 						TrackRollOverSeq = SEQNUM_ROLLOVER;
+// 						TrackRollOver = FALSE;
+
+// 						pSessionInfo->InboundRecv = pSessionInfo->InboundRecv << (SessionSeqNum  - pSessionInfo->InboundSeq);
+// 						pSessionInfo->InboundRecv |= (1 << ((SessionSeqNum  - pSessionInfo->InboundSeq) -1));
+
+// 						_fmemcpy((uint8_t *)&pSessionInfo->InboundTrac[SessionSeqNum  - pSessionInfo->InboundSeq],
+// 						(uint8_t *)&SeqTrac[0],
+// 						(sizeof(uint32_t) *(EIGHT_COUNT_WINDOW_LEN - (SessionSeqNum - pSessionInfo->InboundSeq))));
+// 						pSessionInfo->InboundSeq = SessionSeqNum;
+// 					}
+// 					else if(((SEQNUM_ROLLOVER -SessionSeqNum) + pSessionInfo->InboundSeq+1) <= EIGHT_COUNT_WINDOW_LEN)
+// 					{
+// 						for(i=0;i<EIGHT_COUNT_WINDOW_LEN;i++)
+// 						{
+// 							if(SessionSeqNum == pSessionInfo->InboundTrac[i])
+// 							{
+// 								if(((1 << i) & pSessionInfo->InboundRecv) != 0)
+// 								{
+// 									return -1;
+// 								}
+// 								else
+// 								{
+// 									pSessionInfo->InboundRecv |= (1<<i);
+// 								}
+// 							}
+// 						}
+
+// 					}
+// 				}
+// 			}
+// 		 }
+// 	}
+
+// 	return 0;
+// }
+
+/*-------------------------------------------
+ * ProcessRMCPReq
+ *-------------------------------------------*/
+uint32_t
+ProcessRMCPReq( RMCPHdr_T* pRMCPReq,  RMCPHdr_T* pRMCPRes)
+{
+	SessionInfo_T*  pSessionInfo = NULL;
+	IPMIMsgHdr_T*   pIPMIMsgReq;
+	IPMIMsgHdr_T*   pIPMIMsgRes;
+	uint8_t*          pReqMsgAuthCode;
+	uint8_t*          pResMsgAuthCode;
+	SessionHdr_T*   pReqSessionHdr = ( SessionHdr_T*)(pRMCPReq + 1);
+	SessionHdr_T*   pResSessionHdr = ( SessionHdr_T*)(pRMCPRes + 1);
+	uint8_t           IPMIMsgLen;
+	uint32_t          SessionID;
+	uint32_t          ResLen, IPMIMsgResLen;
+	MsgPkt_T	Req,Res;
+
+	/* Validate RMCP Header */
+	if (TRUE != ValidateRMCPHdr(pRMCPReq))
+	{
+		printf ("RMCP.c : RMCP header validation failed\r\n");
+		return 0;
+	}
+
+	/* If RMCP Ping, process it seperately */
+	if (pRMCPReq->MsgClass == 0x06)
+	{
+		return ProcessPingMsg (pRMCPReq, pRMCPRes);
+	}
+
+	/* Process IPMI 2.0 Separately */
+#if IPMI20_SUPPORT == 1
+//	if (RMCP_PLUS_FORMAT == pReqSessionHdr->AuthType)
+//	{
+//		ResLen = Proc20Payload (pRMCPReq, pRMCPRes);
+//	}
+//	else
+#endif
+	{
+		SessionID             = pReqSessionHdr->SessionID;
+
+		/* Get Session Information */
+		pSessionInfo = &g_BMCInfo.LanSession;
+	
+		if (0 == pReqSessionHdr->AuthType)
+		{
+			IPMIMsgLen  = (uint8_t) (*(( uint8_t*)(pReqSessionHdr + 1)));
+
+			pIPMIMsgReq = ( IPMIMsgHdr_T*) ((( uint8_t*)(pReqSessionHdr + 1)) +
+						  sizeof (IPMIMsgLen));
+			pIPMIMsgRes = ( IPMIMsgHdr_T*) ((( uint8_t*)(pResSessionHdr + 1)) +
+						  sizeof (IPMIMsgLen));
+		}
+		else
+		{
+			pReqMsgAuthCode = (( uint8_t*)(pReqSessionHdr + 1));
+			pResMsgAuthCode = (( uint8_t*)(pResSessionHdr + 1));
+			IPMIMsgLen      = *(pReqMsgAuthCode + AUTH_CODE_LEN);
+			pIPMIMsgReq     = ( IPMIMsgHdr_T*) (pReqMsgAuthCode + AUTH_CODE_LEN +
+							  sizeof (IPMIMsgLen));
+			pIPMIMsgRes     = ( IPMIMsgHdr_T*) (pResMsgAuthCode + AUTH_CODE_LEN +
+							  sizeof (IPMIMsgLen));
+			
+			if (TRUE != ValidateAuthCode (pReqMsgAuthCode, g_BMCInfo.pUserInfo->UserPassword,
+										  pReqSessionHdr, pIPMIMsgReq))
+			{
+				printf("Password error!\n");
+				return 0;
+			}
+		}
+
+		/* Frame the Message Packet for Message Handler */
+		Req.Param	  = PARAM_IFC;
+		Req.Cmd       = pIPMIMsgReq->Cmd;
+		Req.NetFnLUN  = pIPMIMsgReq->NetFnLUN;
+		Req.SessionID = SessionID;
+		Req.SessionType = LAN_SESSION_TYPE;
+		Req.Channel 	= LAN_RMCP_CHANNEL;
+		
+		//UpdateGetMsgTime( &pBMCInfo->LANConfig.MsgReq,IfcType, BMCInst);
+		Req.Size = IPMIMsgLen;
+		memcpy(Req.Data, ( uint8_t*) pIPMIMsgReq, Req.Size);
+
+		/* Post Msg to MsgHndlr and Get Res */
+		if (0 != ProcIPMIReq (pSessionInfo, PAYLOAD_IPMI_MSG, &Req, &Res))
+		{
+			return 0;
+		}
+
+		/* Fill Response data */
+		memcpy (pRMCPRes, pRMCPReq, sizeof (RMCPHdr_T) + sizeof (SessionHdr_T));
+
+		/* Fill Authentication Code */
+		if (0 != pReqSessionHdr->AuthType)
+		{
+			pResMsgAuthCode = ( uint8_t*)(pResSessionHdr + 1);
+			pIPMIMsgRes     = ( IPMIMsgHdr_T*)(( uint8_t*)(pResSessionHdr + 1) +
+							  AUTH_CODE_LEN + sizeof (IPMIMsgLen));
+			IPMIMsgResLen      = AUTH_CODE_LEN + sizeof (IPMIMsgLen) + Res.Size;
+			/* Fill IPMI Message */
+			memcpy (pIPMIMsgRes, Res.Data, Res.Size);
+			*(pResMsgAuthCode + AUTH_CODE_LEN) = Res.Size;
+
+//			ComputeAuthCode ((uint8_t*)g_BMCInfo.pUserInfo->UserPassword, pResSessionHdr, pIPMIMsgRes,
+//							 pResMsgAuthCode, MULTI_SESSION_CHANNEL);
+		}
+		else
+		{
+			pIPMIMsgRes = ( IPMIMsgHdr_T*)(( uint8_t*)(pResSessionHdr + 1) +
+						  sizeof (IPMIMsgLen));
+			IPMIMsgResLen  = Res.Size + sizeof (IPMIMsgLen);
+			/* Fill IPMI Message */
+			memcpy (pIPMIMsgRes, Res.Data, Res.Size);
+			*(( uint8_t*) (pResSessionHdr + 1)) = Res.Size;
+		}
+
+//		if( (NETFN_APP == (pIPMIMsgReq->NetFnLUN >> 2)) && (CMD_GET_SESSION_CHALLENGE == pIPMIMsgReq->Cmd) && 
+//			(CC_GET_SESSION_INVALID_USER == Res.Data[sizeof(IPMIMsgHdr_T)]) && (NULL == pSessionInfo) )
+//		{
+//			if ( 0 != AddLoginEvent( 0xFF, &pBMCInfo->LANConfig.MsgReq.Data[7], EVENT_LOGIN_FAILURE, BMCInst ))
+//			{
+//				TCRIT("Problem while adding Log record \n");
+//			}
+//		}
+		ResLen = sizeof (RMCPHdr_T) + sizeof (SessionHdr_T) + IPMIMsgResLen;
+	}
+
+	return ResLen;
+}
+
+/**
+ * @brief Process the IPMI request and prepare response.
+ * @param pSessionInfo - Session information.
+ * @param Payload     - Payload type.
+ * @return 0 if success, -1 if error.
+**/
+int ProcIPMIReq (  SessionInfo_T*  pSessionInfo, uint8_t Payload, MsgPkt_T *pReq, MsgPkt_T *pRes)
+{
+//	ChannelInfo_T*      pChannelInfo;
+//	int	RetVal = 0;
+
+	//printf("ProcIPMIReq\n");
+	/* Frame the Message Packet for Message Handler */
+	pReq->Param     = PARAM_IFC;
+	pReq->SrcQ		= gFd_LanResQ;
+	
+	if (PAYLOAD_IPMI_MSG == Payload)
+	{
+		//printf("Post to MsgHndlr from %d\n", gFd_LanResQ);
+		PostMsg (gFd_MsgHndlrIfc, pReq);
+	}
+   
+	
+		
+	if ( GetMsg (gFd_LanResQ, pRes, DEFAULT_TIMEOUT) != 0)
+	{
+		//FillIPMIResFailure (pReq, pRes);
+		printf("---> RMCP get message error!\n");
+	}
+
+	if (PARAM_NO_RESPONSE == pRes->Param)
+	{
+		printf ("RMCP.c : No response from message handler\n");
+		return -1;
+	}
+
+	//printf("ProcIPMIReq get response: Param %#x, netfn %#x, cmd %#x, len %#x\n", pRes->Param, pRes->NetFnLUN, pRes->Cmd, pRes->Size);
+	
+	if (((pReq->NetFnLUN >> 2) == 0x06) && (pReq->Cmd  == 0x3A) &&			//Active Session , ipmi2.0 page 613
+		(PAYLOAD_IPMI_MSG == Payload))
+	{
+		//TODO:
+	}    
+
+	/* If Request IPMI Message is Close Session */
+	if (((pReq->NetFnLUN >> 2) == 0x06) && (pReq->Cmd  == 0x3C) &&			//close session
+		(PAYLOAD_IPMI_MSG == Payload))
+	{
+		//TODO:
+	}
+
+	return 0;
+}
+
+/**
+ * @brief Validate RMCP Header
+ * @param pRMCPHdr - RMCP header.
+ * @return TRUE if valid, FALSE if invalid.
+**/
+static uint8_t
+ValidateRMCPHdr (  RMCPHdr_T* pRMCPHdr)
+{
+	/* If RMCP Packet is NULL */
+	if (pRMCPHdr == NULL)
+	{
+		printf ("RMCP.c : RMCP Packet is NULL\n");
+		return FALSE;
+	}
+
+	/* Verify RMCP Version */
+	if (pRMCPHdr->Version != RMCP_VERSION)
+	{
+		printf ("RMCP.c : Invalid RMCP Version\n");
+		return FALSE;
+	}
+
+	/* LOOK for RMCP MessageClass */
+	if ((pRMCPHdr->MsgClass != IPMI_MESSAGE_CLASS) &&
+		(pRMCPHdr->MsgClass != 0x06))
+	{
+		printf ("RMCP.c : Invalid Message Class\n");
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+// /**
+//  * @brief Validate session header.
+//  * @param SessionID - Session ID.
+//  * @param SeqNo    - Session Sequence Number.
+//  * @return TRUE if valid, FALSE if invalid.
+// **/
+// static bool
+// ValidateSessionHdr (uint32_t SessionID, uint32_t SeqNo )
+// {
+// 	   SessionInfo_T*   pSessionInfo;
+
+// 	/* if its Pre Session commands  */
+// 	if (0 == SessionID)
+// 	{
+// 		return TRUE;
+// 	}
+
+// 	pSessionInfo = getSessionInfo (SESSION_ID_INFO, &SessionID, BMCInst);
+// 	if ( pSessionInfo == NULL)
+// 	{
+// 		return FALSE;
+// 	}
+
+// 	/* If packet is already received - drop the packet  */
+// /*  if (ntohs(SeqNo) <= ntohs (CAST_32 (&pSessionInfo->InboundSeq)))
+// 	{
+// 		 IPMI_DBG_PRINT ("RMCP: Duplicate Seq No - Packet dropped\n");
+// 		 return FALSE;
+// 	}
+// */
+
+// 	/* inc the Sequence No  */
+
+// 	return TRUE;
+// }
+
+/**
+ * @brief Process RMCP Ping Message.
+ * @param pRMCPReq - Request RMCP message.
+ * @param pRMCPRes - Response RMCP message.
+ * @return the response length.
+**/
+static uint8_t
+ProcessPingMsg (  RMCPHdr_T* pRMCPReq,   RMCPHdr_T* pRMCPRes )
+{
+	  RMCPPingHdr_T* pReqPingHdr = (  RMCPPingHdr_T*)(pRMCPReq + 1);
+	  RMCPPingHdr_T* pResPingHdr = (  RMCPPingHdr_T*)(pRMCPRes + 1);
+
+	if (PRESENCE_PING_MSGTYPE != pReqPingHdr->MsgType) { return 0; }
+	if((pReqPingHdr->IANANum[0]!=0x00)||(pReqPingHdr->IANANum[1]!=0x00)||
+		 (pReqPingHdr->IANANum[2]!=0x11)||(pReqPingHdr->IANANum[3]!=0xBE)) 
+	   { return 0; }
+
+	/* Construct Response Header */
+	memcpy (pResPingHdr, pReqPingHdr, sizeof (RMCPPingHdr_T));
+	pResPingHdr->MsgType = 0x40;
+	pResPingHdr->DataLen = 0x10;
+
+	/* Fill Response Data */
+	memset (pResPingHdr + 1, 0, pResPingHdr->DataLen);
+	*((  uint8_t*)(pResPingHdr + 1) + 8) = 0x81;
+	*((  uint8_t*)(pResPingHdr + 1) + 4) = PING_IPMI_15_SUPPORT;
+
+#if IPMI20_SUPPORT == 1
+//	*((  uint8_t*)(pResPingHdr + 1) + 4) |= PING_IPMI_20_SUPPORT;
+#endif
+
+	// /*Update the OEM IANA Number for DCMI Discovery (36465 = Data Center Manageability Forum,Spec .1.5)*/
+	// if(g_corefeatures.dcmi_1_5_support == ENABLED)
+	// {
+	// 	if(pBMCInfo->IpmiConfig.DCMISupport == 1)
+	// 	{
+	// 		*((  uint8_t*)(pResPingHdr + 1) + 2) = 0x8E;
+	// 		*((  uint8_t*)(pResPingHdr + 1) + 3) = 0x71;
+	// 	}
+	// }
+
+	return (sizeof (RMCPHdr_T) + sizeof (RMCPPingHdr_T) + pResPingHdr->DataLen);
+}
+
+
+/**
+ * @brief Validate Authentication Code
+ * @param pAuthCode - Request authentication code.
+ * @param pPassword - Password string.
+ * @param pSessionHdr - Request Session header.
+ * @param pIPMIMsg - Request IPMI message.
+ * @return TRUE if valid, FALSE if invalid.
+**/
+static uint8_t
+ValidateAuthCode (  uint8_t* pAuthCode,   uint8_t* pPassword,
+				    SessionHdr_T* pSessionHdr,   IPMIMsgHdr_T* pIPMIMsg)
+{
+	// uint8_t   ComputedAuthCode [AUTH_CODE_LEN];
+
+	// memset(ComputedAuthCode, 0, sizeof (ComputedAuthCode));
+
+	// uint8_t passwd[20] = "hello";
+	// ComputeAuthCode (passwd, pSessionHdr, pIPMIMsg,
+	// 				 ComputedAuthCode, MULTI_SESSION_CHANNEL);
+
+	// int i;
+	// printf("pAuthCode: ");
+	// for(i=0;i<AUTH_CODE_LEN;i++)
+	// 	printf("%#x ", pAuthCode[i]);
+	// printf("\n");
+	// printf("pPassword: %s\n", pPassword);
+	// printf("pComputeAuthCode: ");
+	// for(i=0;i<AUTH_CODE_LEN;i++)
+	// 	printf("%#x ", ComputedAuthCode[i]);
+	// printf("\n");
+	
+
+	// return (0 == memcmp (pAuthCode, ComputedAuthCode, AUTH_CODE_LEN));
+	return TRUE;
+}
+
+ #if IPMI20_SUPPORT
+
+// /*-------------------------------------------
+//  * Frame20Payload
+//  *-------------------------------------------*/
+// int
+// Frame20Payload (uint8_t PayloadType,   RMCPHdr_T* pRMCPPkt,
+// 				  uint8_t* pPayload,  uint32_t PayloadLen,  
+// 				SessionInfo_T* pSessionInfo )
+// {
+// 	   BMCInfo_t*       pBMCInfo        = &g_BMCInfo[BMCInst];
+// 	  SessionHdr2_T*   pResSessionHdr  = (  SessionHdr2_T*)(pRMCPPkt + 1);
+// 	  uint8_t*           pRes            = (  uint8_t*)(pResSessionHdr + 1);
+// 	  uint8_t*           pConfHdr;
+// 	  uint8_t*           pConfPayld;
+// 	  uint8_t*           pIntPad;
+// 	  uint8_t*           pResMsgAuthCode;
+// 	uint8_t                   ConfPadLen, IntPadLen;
+// 	INT16U                  ConfPayldLen, AuthCodeLen;
+// 	int                     i, ResLen;
+// 	unsigned int            seed = 1;
+
+// 	/* Fill Session Hdr */
+// 	pResSessionHdr->AuthType      = RMCP_PLUS_FORMAT;
+// 	pResSessionHdr->PayloadType   = PayloadType;
+
+
+// 	if (NULL == pSessionInfo)
+// 	{
+// 		pResSessionHdr->SessionID = 0;
+// 		pResSessionHdr->SessionSeqNum = 0;
+// 	}
+// 	else
+// 	{
+// 		/* Response packets should send the Remote Console
+// 		 * Session ID so the remote console can correctly
+// 		 * match up the session with its own table of active
+// 		 * session IDs. */
+// 		pResSessionHdr->SessionID = pSessionInfo->RemConSessionID;
+
+// 		/* Increment session sequence number */
+// 		/* During RMCP Opensession , OutboundSeq initialized to 0 and but 0 is  reserved  */
+// 		/* and also  When It reach 0xffffffff then It  become zero */
+// 		if(0==pSessionInfo->OutboundSeq)
+// 		{
+// 			pSessionInfo->OutboundSeq=1;
+// 		}
+// 		pResSessionHdr->SessionSeqNum = htoipmi_u32(pSessionInfo->OutboundSeq++);
+// 	}
+
+// 	/* Fill Payload and Do Encryption if needed */
+// 	if ((NULL != pSessionInfo) &&
+// 		(0 != (pResSessionHdr->PayloadType & CONFIDENT_MASK)))
+// 	{
+// 		pConfHdr = (  uint8_t*)(pResSessionHdr + 1);
+// 		switch (pSessionInfo->ConfidentialityAlgorithm)
+// 		{
+// 		case CONF_AES_CBC_128:
+
+// 			/* Fill Init Vector */
+// 			for (i =0; i < CONF_AES_CBC_128_HDR_LEN; i++)
+// 			{
+// 				pConfHdr [i] = (uint8_t)rand_r (&seed);
+// 			}
+// 			pConfPayld = pConfHdr + CONF_AES_CBC_128_HDR_LEN;
+
+// 			/* Add Padding; include size of confpadlen */
+// 			ConfPadLen = (PayloadLen + 1) % CONF_BLOCK_SIZE;
+// 			if (0 != ConfPadLen)
+// 			{
+// 				ConfPadLen =  CONF_BLOCK_SIZE - ConfPadLen;
+// 			}
+// 			for (i = 0; i < ConfPadLen; i++)
+// 			{
+// 				*(pPayload + PayloadLen + i) = i + 1;
+// 			}
+// 			*(pPayload + PayloadLen + ConfPadLen) = ConfPadLen;
+// 			ConfPayldLen = PayloadLen + ConfPadLen + 1;
+// 			aesEncrypt ((  uint8_t*)pPayload,  ConfPayldLen,
+// 						(  uint8_t*)pConfHdr, pSessionInfo->Key2,
+// 						(  uint8_t*)pConfPayld);
+
+// 			IPMI_DBG_PRINT_BUF ((  uint8_t*)pConfPayld, ConfPayldLen);
+// 			PayloadLen	  = ConfPayldLen + CONF_AES_CBC_128_HDR_LEN;
+// 			pBMCInfo->LANConfig.MsgReq.Size = PayloadLen;
+// 			break;
+
+// 		case CONF_xCR4_128:
+// 		case CONF_xCR4_40:
+// 		default:
+// 			IPMI_WARNING ("RMCP.c : Invalid confidentiality Algorithm\n");
+// 			return 0;
+// 		}
+// 	}
+// 	else
+// 	{
+// 		_fmemcpy (pRes, pPayload, PayloadLen);
+// 	}
+
+// 	/* Fill Payload Length */
+// 	pResSessionHdr->IPMIMsgLen = htoipmi_u16 (PayloadLen);
+
+// 	ResLen = sizeof (RMCPHdr_T) + sizeof (SessionHdr2_T) + PayloadLen;
+
+// 	/* Add Integrity Check Value */
+// 	if ((NULL != pSessionInfo) &&
+// 		(0 != (pResSessionHdr->PayloadType & INTEGRITY_MASK)))
+// 	{
+// 		/* Add Integrity Pad */
+// 		pIntPad   = (  uint8_t*)(pResSessionHdr + 1) + PayloadLen;
+// 		IntPadLen = (sizeof (SessionHdr2_T) + PayloadLen + 2) % sizeof (uint32_t);
+// 		if (0 != IntPadLen)
+// 		{
+// 			IntPadLen  = sizeof(uint32_t) - IntPadLen;
+// 		}
+// 		_fmemset (pIntPad, 0xFF, IntPadLen);
+// 		*(pIntPad + IntPadLen)      = IntPadLen;    /* Integrity Pad Len  */
+// 		*(pIntPad + IntPadLen + 1)  = 0x07;         /* Next Header        */
+
+// 		pResMsgAuthCode =  pIntPad + IntPadLen + 2;
+// 		AuthCodeLen     = sizeof (SessionHdr2_T) + PayloadLen + IntPadLen + 2;
+// 		ResLen          += IntPadLen + 2;
+
+// 		switch (pSessionInfo->IntegrityAlgorithm)
+// 		{
+// 		case AUTH_HMAC_SHA1_96:
+
+// 			hmac_sha1 ((uint8_t *)pSessionInfo->Key1, HASH_KEY1_SIZE,
+// 					   (  uint8_t*)pResSessionHdr, AuthCodeLen,
+// 					   (uint8_t *)pResMsgAuthCode, MAX_INTEGRITY_LEN);
+// 			ResLen += HMAC_SHA1_96_LEN;
+// 			break;
+
+// 		case AUTH_HMAC_MD5_128:
+// 			hmac_md5(pSessionInfo->Key1,HASH_KEY1_SIZE,(  uint8_t*)pResSessionHdr, AuthCodeLen,
+// 			pResMsgAuthCode, MAX_HMAC_MD5_INTEGRITY_LEN);
+// 			ResLen += HMAC_MD5_LEN;
+// 			break;
+			
+// 		case AUTH_MD5_128:
+// 			MD5_128((char *)pSessionInfo->Password,MAX_PASSWORD_LEN,(  INT8S*)pResSessionHdr, AuthCodeLen,
+// 			(char *)pResMsgAuthCode, MAX_MD5_INTEGRITY_LEN);
+// 			ResLen += MD5_LEN;
+// 			break;
+			
+// 		case AUTH_HMAC_SHA256_128:
+	
+// 			hmac_sha256 ((unsigned char *)pSessionInfo->Key1, SHA2_HASH_KEY_SIZE, (unsigned char *)pResSessionHdr,
+// 					AuthCodeLen, (unsigned char *)pResMsgAuthCode, HMAC_SHA256_128_LEN);                
+// 			ResLen += HMAC_SHA256_128_LEN;  
+// 			break;
+
+// 		default:
+// 			IPMI_WARNING ("RMCP.c : Invalid Integrity Algorithm\n");
+// 			return 0;
+// 		}
+// 	}
+
+// 	return ResLen;
+// }
+
+// int RMCPplusSeqNumValidation(SessionInfo_T * pSessionInfo,uint32_t SessionSeqNum)
+// {
+// 	uint32_t SeqTrac[SIXTEEN_COUNT_WINDOW_LEN];
+// 	bool TrackRollOver = FALSE;
+// 	uint32_t TrackRollOverSeq = SEQNUM_ROLLOVER;
+// 	int i=0;
+
+
+// 	if( pSessionInfo->InboundSeq == SessionSeqNum)
+// 		return -1;
+
+// 	if((pSessionInfo->InboundSeq < (SEQNUM_ROLLOVER -RMCPPLUS_SEQUPLIMIT)) && (pSessionInfo->InboundSeq > RMCPPLUS_SEQLOWLIMIT))
+// 	{
+// 		if(SessionSeqNum < pSessionInfo->InboundSeq)
+// 		{
+// 			if((pSessionInfo->InboundSeq -SessionSeqNum) > RMCPPLUS_SEQLOWLIMIT)
+// 				return -1;
+// 			else
+// 			{
+// 				for(i=0; i < RMCPPLUS_SEQLOWLIMIT; i++)
+// 			   {
+// 					if(SessionSeqNum == pSessionInfo->InboundTrac[i])
+// 					{
+// 						if(((1 << i) & pSessionInfo->InboundRecv) != 0)
+// 							return -1;
+// 						else
+// 							pSessionInfo->InboundRecv |= (1<<i);
+// 					}
+// 				}
+// 			}
+// 		}
+// 		else
+// 		{
+// 		   if((SessionSeqNum - pSessionInfo->InboundSeq) > RMCPPLUS_SEQUPLIMIT)
+// 				   return -1;
+
+// 		   _fmemcpy((uint8_t *)SeqTrac,(uint8_t *)pSessionInfo->InboundTrac,(sizeof(uint32_t) * SIXTEEN_COUNT_WINDOW_LEN));
+
+// 			for(i=0; i < (SessionSeqNum - pSessionInfo->InboundSeq); i++)
+// 						pSessionInfo->InboundTrac[i] = SessionSeqNum - (i+1);
+
+
+// 			pSessionInfo->InboundRecv = pSessionInfo->InboundRecv << (SessionSeqNum - pSessionInfo->InboundSeq);
+// 			pSessionInfo->InboundRecv |= (1 << ((SessionSeqNum - pSessionInfo->InboundSeq)-1));
+
+// 			_fmemcpy((uint8_t *)&pSessionInfo->InboundTrac[SessionSeqNum - pSessionInfo->InboundSeq],
+// 							   (uint8_t *)&SeqTrac[0],
+// 							   (sizeof(uint32_t) *(SIXTEEN_COUNT_WINDOW_LEN - (SessionSeqNum - pSessionInfo->InboundSeq))));
+// 			pSessionInfo->InboundSeq = SessionSeqNum;
+// 		}
+// 	}
+// 	else if((pSessionInfo->InboundSeq  < RMCPPLUS_SEQLOWLIMIT)
+// 			  || (pSessionInfo->InboundSeq  > (SEQNUM_ROLLOVER -RMCPPLUS_SEQUPLIMIT)))  /* Checking condition for rollover */
+// 	{
+// 		  if(SessionSeqNum < pSessionInfo->InboundSeq)
+// 		  {
+// 			  if(!((((pSessionInfo->InboundSeq -SessionSeqNum) <= RMCPPLUS_SEQLOWLIMIT) &&
+// 				  (((SEQNUM_ROLLOVER - pSessionInfo->InboundSeq) + SessionSeqNum+1) >= RMCPPLUS_SEQLOWLIMIT )) ||
+// 				  ((((SEQNUM_ROLLOVER - pSessionInfo->InboundSeq) + SessionSeqNum+1) <= RMCPPLUS_SEQLOWLIMIT ) &&
+// 					  (pSessionInfo->InboundSeq -SessionSeqNum) >= RMCPPLUS_SEQLOWLIMIT)))
+// 			   {
+// 						 return -1;
+// 			   }
+// 			   else
+// 			   {
+// 					if((pSessionInfo->InboundSeq -SessionSeqNum) <= RMCPPLUS_SEQLOWLIMIT)
+// 					{
+// 						for(i=0; i < RMCPPLUS_SEQLOWLIMIT; i++)
+// 						{
+// 							if(SessionSeqNum == pSessionInfo->InboundTrac[i])
+// 							{
+// 								if(((1 << i) & pSessionInfo->InboundRecv) != 0)
+// 									return -1;
+// 								else
+// 									pSessionInfo->InboundRecv |= (1<<i);
+// 							}
+// 						}
+// 					}
+// 					else if(((SEQNUM_ROLLOVER - pSessionInfo->InboundSeq) + SessionSeqNum+1) <= RMCPPLUS_SEQUPLIMIT )
+// 					{
+// 						_fmemcpy((uint8_t *)SeqTrac,(uint8_t *)pSessionInfo->InboundTrac,(sizeof(uint32_t) * SIXTEEN_COUNT_WINDOW_LEN));
+
+// 						for(i=0; i < ((SEQNUM_ROLLOVER - pSessionInfo->InboundSeq) + SessionSeqNum+1) ; i++)
+// 						{
+// 							if(((SessionSeqNum - (i+1)) != 0) && (TrackRollOver == FALSE))
+// 								pSessionInfo->InboundTrac[i] = SessionSeqNum - (i+1);
+// 							else if(((SessionSeqNum - (i+1)) == 0) && (TrackRollOver == FALSE))
+// 							{
+// 								pSessionInfo->InboundTrac[i] = SessionSeqNum - (i+1);
+// 								TrackRollOver = TRUE;
+// 							}
+// 							else if(TrackRollOver ==  TRUE)
+// 							{
+// 								pSessionInfo->InboundTrac[i] = TrackRollOverSeq;
+// 								TrackRollOverSeq--;
+// 							}
+// 						}
+// 						TrackRollOverSeq = SEQNUM_ROLLOVER;
+// 						TrackRollOver = FALSE;
+
+// 						pSessionInfo->InboundRecv = pSessionInfo->InboundRecv << ((SEQNUM_ROLLOVER - pSessionInfo->InboundSeq) + SessionSeqNum+1);
+// 						pSessionInfo->InboundRecv |= (1 << (((SEQNUM_ROLLOVER - pSessionInfo->InboundSeq) + SessionSeqNum+1) -1));
+
+// 						_fmemcpy((uint8_t *)&pSessionInfo->InboundTrac[(SEQNUM_ROLLOVER - pSessionInfo->InboundSeq) + SessionSeqNum+1],
+// 									  (uint8_t *)&SeqTrac[0],
+// 									  (sizeof(uint32_t) *(SIXTEEN_COUNT_WINDOW_LEN - ((SEQNUM_ROLLOVER - pSessionInfo->InboundSeq) + SessionSeqNum+1))));
+// 						pSessionInfo->InboundSeq = SessionSeqNum;
+// 					}
+// 			  }
+// 		  }
+// 		 else if(SessionSeqNum > pSessionInfo->InboundSeq)
+// 		{
+// 			if(!((((SessionSeqNum -pSessionInfo->InboundSeq) <= RMCPPLUS_SEQUPLIMIT) &&
+// 				(((SEQNUM_ROLLOVER - SessionSeqNum) + pSessionInfo->InboundSeq+1) >= RMCPPLUS_SEQUPLIMIT )) ||
+// 				((((SEQNUM_ROLLOVER - SessionSeqNum) + pSessionInfo->InboundSeq+1) <= RMCPPLUS_SEQLOWLIMIT ) &&
+// 				  (SessionSeqNum-pSessionInfo->InboundSeq) >= RMCPPLUS_SEQLOWLIMIT)))
+// 			  {
+// 				   return -1;
+// 			  }
+// 			 else
+// 			 {
+// 				 if((SessionSeqNum  - pSessionInfo->InboundSeq) <= RMCPPLUS_SEQUPLIMIT)
+// 				 {
+// 					 _fmemcpy((uint8_t *)SeqTrac,(uint8_t *)pSessionInfo->InboundTrac,(sizeof(uint32_t) * SIXTEEN_COUNT_WINDOW_LEN));
+// 					  for(i=0; i < (SessionSeqNum  - pSessionInfo->InboundSeq) ; i++)
+// 					  {
+// 							if(((SessionSeqNum - (i+1)) != 0) && (TrackRollOver == FALSE))
+// 								   pSessionInfo->InboundTrac[i] = SessionSeqNum - (i+1);
+// 							else if(((SessionSeqNum - (i+1)) == 0) && (TrackRollOver == FALSE))
+// 							{
+// 								  pSessionInfo->InboundTrac[i] = SessionSeqNum - (i+1);
+// 								  TrackRollOver = TRUE;
+// 							}
+// 							else if(TrackRollOver ==  TRUE)
+// 							{
+// 								  pSessionInfo->InboundTrac[i] = TrackRollOverSeq;
+// 								  TrackRollOverSeq--;
+// 							}
+// 					   }
+// 						TrackRollOverSeq = SEQNUM_ROLLOVER;
+// 						TrackRollOver = FALSE;
+
+// 						pSessionInfo->InboundRecv = pSessionInfo->InboundRecv << (SessionSeqNum  - pSessionInfo->InboundSeq);
+// 						pSessionInfo->InboundRecv |= (1 << ((SessionSeqNum  - pSessionInfo->InboundSeq) -1));
+
+// 						_fmemcpy((uint8_t *)&pSessionInfo->InboundTrac[SessionSeqNum  - pSessionInfo->InboundSeq],
+// 									  (uint8_t *)&SeqTrac[0],
+// 									  (sizeof(uint32_t) *(SIXTEEN_COUNT_WINDOW_LEN - (SessionSeqNum - pSessionInfo->InboundSeq))));
+// 						pSessionInfo->InboundSeq = SessionSeqNum;
+// 				 }
+// 				 else if(((SEQNUM_ROLLOVER -SessionSeqNum) + pSessionInfo->InboundSeq+1) <= RMCPPLUS_SEQLOWLIMIT)
+// 				 {
+// 					   for(i=0; i < RMCPPLUS_SEQLOWLIMIT; i++)
+// 					   {
+// 							if(SessionSeqNum == pSessionInfo->InboundTrac[i])
+// 						   {
+// 								if(((1 << i) & pSessionInfo->InboundRecv) != 0)
+// 									 return -1;
+// 								else
+// 									 pSessionInfo->InboundRecv |= (1<<i);
+// 							}
+// 					   }
+// 				 }
+// 			 }
+// 					   }
+// 	}
+
+// 	return 0;
+// }
+
+
+// /**
+//  * @brief Process IPMI 2.0 Payload.
+//  * @param pRMCPReq - RMCP request message.
+//  * @param pRMCPRes _ RMCP response message.
+//  * @return 0 if success, -1 if error.
+// **/
+// static int
+// Proc20Payload (  RMCPHdr_T* pRMCPReq,   RMCPHdr_T* pRMCPRes, MiscParams_T *pParams,uint8_t Channel )
+// {
+// 	  SessionHdr2_T*  pReqSession2Hdr = (  SessionHdr2_T*)(pRMCPReq + 1);
+// 	  SessionHdr2_T*  pResSession2Hdr = (  SessionHdr2_T*)(pRMCPRes + 1);
+// 	  uint8_t*          pReq  = (  uint8_t *)(pReqSession2Hdr + 1);
+// 	  uint8_t*          pRes  = (  uint8_t *)(pResSession2Hdr + 1);
+// 	   SessionInfo_T*  pSessionInfo = NULL;
+// 	  uint8_t*          pIntPad;
+// 	  uint8_t*          pConfHdr;
+// 	  uint8_t*          pConfPayld;
+// 	  uint8_t*          pReqMsgAuthCode;
+// 	   UserInfo_T*     pUserInfo;
+// 	   BMCInfo_t*      pBMCInfo = &g_BMCInfo[BMCInst];
+// 		   uint8_t           Payload, IntPadLen, ComputedAuthCode [25];
+// 		   INT16U          IPMIMsgLen, AuthCodeLen, ConfPayldLen;
+// 		   uint32_t          SessionID;
+// 		   uint32_t          SessionSeqNum;
+// 		   int             len, i;
+// 		   uint8_t           UserPswd [MAX_PASSWORD_LEN];
+// 		   uint8_t PwdEncKey[MAX_SIZE_KEY + 1] = {0};
+
+// 	/* Get SessionID & Session Seq */
+// 	SessionID       = pReqSession2Hdr->SessionID;
+// 	SessionSeqNum   = pReqSession2Hdr->SessionSeqNum;
+
+// 	/* Validate IPMI Session Header */
+// 	if (TRUE != ValidateSessionHdr (SessionID, SessionSeqNum, BMCInst))
+// 	{
+// //        IPMI_WARNING ("RMCP.c : IPMI Session header validation failed\n");
+// 		return 0;
+// 	}
+
+// 	IPMIMsgLen = ipmitoh_u16 (pReqSession2Hdr->IPMIMsgLen);
+// 	Payload    = pReqSession2Hdr->PayloadType & 0x3F;
+
+// 	/* Process PreSession Payloads */
+// 	for (i = 0; i < sizeof (m_PayloadTbl) / sizeof (m_PayloadTbl [0]); i++)
+// 	{
+// 		if (m_PayloadTbl [i].Payload == Payload)
+// 		{
+// 			/* Copy RMCP & Session Hdr */
+// 			_fmemcpy ((  uint8_t*)pRMCPRes, (  uint8_t*)pRMCPReq,
+// 					   sizeof (RMCPHdr_T) +  sizeof (SessionHdr2_T));
+
+// 			/* For response the type is type + 1 */
+// 			pResSession2Hdr->PayloadType++;
+// 			/* Copy message tag from request */
+// 			*pRes = *pReq;
+
+// 			OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+// 			/* Call the function and pass the data after message tag */
+// 			len = m_PayloadTbl [i].PayloadHndlr ((pReq),
+// 				  (uint8_t)(IPMIMsgLen - sizeof (uint8_t)), (pRes), pParams,Channel,BMCInst);
+// 			OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SessionTblMutex,WAIT_INFINITE);
+
+// 			/* Copy the message length */
+// 			pResSession2Hdr->IPMIMsgLen = htoipmi_u16 ((len));
+
+// 		   if(len!=0)
+// 			len += sizeof (RMCPHdr_T) + sizeof (SessionHdr2_T);
+
+// 			return len;
+// 		}
+// 	}
+
+// 	/* Check for Invalid Payload Type */
+// 	if ((PAYLOAD_IPMI_MSG !=  Payload) && (PAYLOAD_SOL !=  Payload))
+// 	{
+// 		IPMI_WARNING ("RMCP.c : Invalid payload\n");
+// 		return 0;
+// 	}
+
+// 	/* check for the pre-session commands */
+// 	if (0 == SessionID)
+// 	{
+// 		int i;
+// 		  IPMIMsgHdr_T* pIPMIMsg = (  IPMIMsgHdr_T*) pReq;
+
+// 		for (i=0; i < sizeof (m_PreSessionCmdsTbl) / sizeof (PreSessionCmd_T); i++)
+// 		{
+// 			if ((m_PreSessionCmdsTbl[i].NetFn == (pIPMIMsg->NetFnLUN >> 2)) &&
+// 				(m_PreSessionCmdsTbl[i].Cmd == pIPMIMsg->Cmd))
+// 			{
+// 				pBMCInfo->LANConfig.MsgReq.Size = IPMIMsgLen;
+// 				_fmemcpy (pBMCInfo->LANConfig.MsgReq.Data, pReq, pBMCInfo->LANConfig.MsgReq.Size);
+// 				break;
+// 			}
+// 		}
+// 		if (i >= (sizeof (m_PreSessionCmdsTbl) / sizeof (PreSessionCmd_T)))
+// 		{
+// 			IPMI_WARNING ("RMCP.c : Presession command not found\n");
+// 			return 0;
+// 		}
+// 	}
+// 	else
+// 	{
+// 		/* Get Session Information */
+// 		pSessionInfo = getSessionInfo (SESSION_ID_INFO, &SessionID, BMCInst);
+
+// 		if (NULL == pSessionInfo)
+// 		{
+// 			IPMI_WARNING ("RMCP.c : Proc20Payload - Invalid Session Id\n");
+// 			return 0;
+// 		}
+
+// 		/* Check if session is activated */
+// 		if (TRUE != pSessionInfo->Activated)
+// 		{
+// 			IPMI_WARNING ("RMCP.c : Session not activated with session id %lx\n", SessionID);
+// 			return 0;
+// 		}
+
+// 		if(pBMCInfo->IpmiConfig.LinkDownResilentSupport == 1)
+// 		{
+// 			if(pSessionInfo->Linkstat == TRUE)
+// 			{
+// 				pSessionInfo->Linkstat = FALSE;
+// 				memset(pSessionInfo->InboundTrac,0,SIXTEEN_COUNT_WINDOW_LEN);
+// 			}
+// 		}
+
+// 		if( ((((  IPMIMsgHdr_T*)pBMCInfo->LANConfig.MsgReq.Data)->NetFnLUN)>>2==NETFN_APP) &&
+// 			((((  IPMIMsgHdr_T*)pBMCInfo->LANConfig.MsgReq.Data)->Cmd)==CMD_SET_SESSION_PRIV_LEVEL) &&
+// 			((pSessionInfo->EventFlag)== 1) )
+// 		{
+// 			 pSessionInfo->EventFlag=0;
+// 			 if ( 0 != AddLoginEvent ( pSessionInfo->UserId, NULL, EVENT_LOGIN, BMCInst ))
+// 			 {
+// 				  TCRIT("Problem while adding Log record \n");
+// 			 }
+// 		}
+		
+// 		if(RMCPplusSeqNumValidation(pSessionInfo,ipmitoh_u32(SessionSeqNum)) != 0)
+// 		{
+// 			return 0;
+// 		}
+		
+// 		if (0 != (pReqSession2Hdr->PayloadType & INTEGRITY_MASK))
+// 		{
+// 			uint8_t Len;
+
+// 			/*  check Integrity pad which starts from auth type till auth code */
+// 			pIntPad   = (  uint8_t*)(pReqSession2Hdr + 1) + IPMIMsgLen;
+
+// 				IntPadLen = (sizeof (SessionHdr2_T) + IPMIMsgLen + 2) % sizeof (uint32_t);
+// 			if (0 != IntPadLen)
+// 			{
+// 				IntPadLen  = sizeof(uint32_t) - IntPadLen;
+// 			}
+
+// 			if (pIntPad [IntPadLen] != IntPadLen)
+// 			{
+// 				IPMI_WARNING ("RMCP.c : Invalid Padlength\n");
+// 				return 0;
+// 			}
+
+// 			/* Check auth code */
+// 			pReqMsgAuthCode =  pIntPad + IntPadLen + 2;
+// 			AuthCodeLen     = sizeof (SessionHdr2_T) + IPMIMsgLen + IntPadLen + 2;
+
+
+// 			switch (pSessionInfo->IntegrityAlgorithm)
+// 			{
+// 			case AUTH_HMAC_SHA1_96:
+// 				hmac_sha1 ((uint8_t *)pSessionInfo->Key1, HASH_KEY1_SIZE,
+// 						   (  uint8_t*)pReqSession2Hdr, AuthCodeLen,
+// 						   (  uint8_t*)ComputedAuthCode, MAX_INTEGRITY_LEN);
+// 				Len = HMAC_SHA1_96_LEN;
+// 				break;
+
+// 			case AUTH_HMAC_MD5_128:
+// 				hmac_md5 (pSessionInfo->Key1, HASH_KEY1_SIZE,
+// 							(  uint8_t*)pReqSession2Hdr, AuthCodeLen,
+// 							(  uint8_t*)ComputedAuthCode, MAX_HMAC_MD5_INTEGRITY_LEN);
+// 				Len = HMAC_MD5_LEN;
+// 				break;
+				
+// 			case AUTH_MD5_128:
+// 				/* Get User Info */
+// 				pUserInfo = getUserIdInfo((uint8_t)pSessionInfo->UserId, BMCInst);
+// 				if (g_corefeatures.userpswd_encryption == ENABLED)
+// 				{
+// 					/* Get Encryption Key from the MBMCInfo_t structure */
+// 						memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
+// 					if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[pSessionInfo->UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, (INT8S *)UserPswd, MAX_PASSWORD_LEN, PwdEncKey))
+// 					{
+// 						TCRIT("Error in decrypting the user password for user ID:%d. .\n", pSessionInfo->UserId);
+// 						return -1;
+// 					}
+// 				}
+// 				else
+// 				{
+// 					_fmemcpy (UserPswd, pUserInfo->UserPassword, MAX_PASSWORD_LEN);
+// 				}
+
+// 				MD5_128((char *)pUserInfo->UserPassword, MAX_PASSWORD_LEN,
+// 							(  INT8S*)pReqSession2Hdr, AuthCodeLen,
+// 							(  INT8S*)ComputedAuthCode, MAX_MD5_INTEGRITY_LEN);
+// 				Len= MD5_LEN;
+// 				break;
+				
+// 			case AUTH_HMAC_SHA256_128:
+		
+// 				hmac_sha256 ((unsigned char *)pSessionInfo->Key1, SHA2_HASH_KEY_SIZE, (unsigned char *)pReqSession2Hdr,
+// 						AuthCodeLen, (unsigned char *)ComputedAuthCode, SHA2_HASH_KEY_SIZE);                
+// 				Len= HMAC_SHA256_128_LEN;
+// 				break;                
+				
+// 			default:
+// 				IPMI_WARNING ("RMCP.c : Invalid Integrity Algorithm\n");
+// 				return 0;
+// 			}
+
+// 			IPMI_DBG_PRINT_BUF ((  uint8_t*)ComputedAuthCode, Len);
+// 			if (0 != _fmemcmp ((  uint8_t*)ComputedAuthCode, pReqMsgAuthCode, Len))
+// 			{
+// 				return 0;
+// 			}
+// 		}
+
+// 		/*  Decrypt the message if Encrypted */
+// 		/* Verify confidentiality header and trailer */
+// 		if (0 != (pReqSession2Hdr->PayloadType & CONFIDENT_MASK))
+// 		{
+// 			pConfHdr = (  uint8_t*)(pReqSession2Hdr + 1);
+// 			switch (pSessionInfo->ConfidentialityAlgorithm)
+// 			{
+// 			case CONF_AES_CBC_128:
+// 				pConfPayld   = pConfHdr + CONF_AES_CBC_128_HDR_LEN;
+// 				ConfPayldLen = IPMIMsgLen - CONF_AES_CBC_128_HDR_LEN;
+// 				aesDecrypt ((  uint8_t*)pConfPayld,  ConfPayldLen,
+// 							(  uint8_t*)pConfHdr, pSessionInfo->Key2,
+// 							(  uint8_t*)pBMCInfo->LANConfig.MsgReq.Data);
+
+// 				/* Remove pad length */
+// 				if (pBMCInfo->LANConfig.MsgReq.Data [ConfPayldLen - 1] >  CONF_BLOCK_SIZE)
+// 				{
+// 					IPMI_WARNING ("Invalid Conf Blocke size  %d\n", pBMCInfo->LANConfig.MsgReq.Data [ConfPayldLen - 1]);
+// 					return 0;
+// 				}
+
+// 				ConfPayldLen -= (pBMCInfo->LANConfig.MsgReq.Data [ConfPayldLen - 1] + 1);
+// 				break;
+
+// 			case CONF_xCR4_128:
+
+// 			case CONF_xCR4_40:
+
+// 			default:
+// 				IPMI_WARNING ("RMCP.c : Invalid confidentiality Algorithm\n");
+// 				return 0;
+// 			}
+
+// 			pBMCInfo->LANConfig.MsgReq.Size = ConfPayldLen;
+// 		}
+// 		else
+// 		{
+// 			pBMCInfo->LANConfig.MsgReq.Size = IPMIMsgLen;
+// 			_fmemcpy (pBMCInfo->LANConfig.MsgReq.Data, pReq, pBMCInfo->LANConfig.MsgReq.Size);
+// 		}
+// 	}
+
+// 	/* Fill IPMI MsgPkt Request */
+// 	pBMCInfo->LANConfig.MsgReq.Cmd       = ((  IPMIMsgHdr_T*)pBMCInfo->LANConfig.MsgReq.Data)->Cmd;
+// 	pBMCInfo->LANConfig.MsgReq.NetFnLUN  = ((  IPMIMsgHdr_T*)pBMCInfo->LANConfig.MsgReq.Data)->NetFnLUN;
+// 	pBMCInfo->LANConfig.MsgReq.SessionID = SessionID;
+// 	pBMCInfo->LANConfig.MsgReq.SessionType = LAN_SESSION_TYPE;
+// 	pBMCInfo->LANConfig.MsgReq.Channel =Channel;
+// 	UpdateGetMsgTime( &pBMCInfo->LANConfig.MsgReq,IfcType, BMCInst);
+// 	// Moved to line 966
+// 	// Bug : if SessionID is 0 this Unlock will be called without a Lock
+// 	//UNLOCK_BMC_SHARED_MEM();
+
+// 	/* Process IPMI Request */
+// 	if (0 != ProcIPMIReq (pSessionInfo, Payload, pParams,Channel, BMCInst))
+// 	{
+// 		return 0;
+// 	}
+
+// 	/* Fill Response data */
+// 	_fmemcpy (pRMCPRes, pRMCPReq, sizeof (RMCPHdr_T) + sizeof (SessionHdr_T));
+
+
+// 	return Frame20Payload (pReqSession2Hdr->PayloadType, pRMCPRes,
+// 						   pBMCInfo->LANConfig.MsgRes.Data, pBMCInfo->LANConfig.MsgRes.Size, pSessionInfo, BMCInst);
+// }
+
+// /**************************************************************************** 
+//  * fn AddLoginEvent
+//  * params:
+//  * pRMCPSession  pointer to RMCP Session information
+//  * EvtType	0x9 - login, 0xa - logout, 0xb - autologout, 0xc - connection lost
+//  *
+//  * return 	0 - success, -1 - failure
+//  ***************************************************************************/
+// int AddLoginEvent ( uint8_t UserID, uint8_t* UserName, uint8_t EvtType )
+// {
+// 	  BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+	
+// 	int reslen = 0, ret = -1;
+// 	int i = 0;
+// 	AddSELRes_T  AddSelRes;
+// 	uint8_t IPAddr[IP_ADDR_LEN];
+// 	SELOEM1Record_T  OEMSELRec;
+	
+// #ifdef  CONFIG_SPX_FEATURE_IANA_0
+// 	uint8_t  MfgID[] = {  CONFIG_SPX_FEATURE_IANA_2,
+// 						CONFIG_SPX_FEATURE_IANA_1, 
+// 						CONFIG_SPX_FEATURE_IANA_0 };
+// #else
+// 	uint8_t MfgID[] = { 0, 0, 0 };
+// #endif
+// 	/* Hook for RMCP Login Audit */
+// 	if  (g_PDKHandle[PDK_RMCPLOGINAUDIT] != NULL) 
+// 	{
+// 		/* Return if event type bit is not set in event mask */
+// 		for (i = 0; i < sizeof(m_IPMIAuditMaskMap)/sizeof(IPMIAuditMaskTbl_T); i++)
+// 		{
+// 			if ((EvtType == m_IPMIAuditMaskMap[i].EventType) && 
+// 				(!(pBMCInfo->LoginAuditCfg.IPMIEventMask >> m_IPMIAuditMaskMap[i].EventMask) & 0x01))
+// 			{
+// 				return reslen;
+// 			}
+// 		}
+
+// 		ret = ((int(*)(uint8_t , uint8_t, uint8_t*, uint8_t*,int))(g_PDKHandle[PDK_RMCPLOGINAUDIT]))(EvtType, UserID, UserName, pBMCInfo->LANConfig.MsgReq.IPAddr, BMCInst);
+// 		if (ret != -1)
+// 		{
+// 			return 0;
+// 		}
+	
+// 		if(g_corefeatures.global_ipv6  == ENABLED)
+// 		{
+// 			if(IN6_IS_ADDR_V4MAPPED(pBMCInfo->LANConfig.MsgReq.IPAddr))
+// 			{
+// 				/* The last bytes of IP6 contains IP4 address */
+// 				_fmemcpy(IPAddr, &pBMCInfo->LANConfig.MsgReq.IPAddr[IP6_ADDR_LEN - IP_ADDR_LEN], sizeof (struct in_addr));
+// 			}
+// 			else
+// 			{
+// 				/*
+// 				*  IPV6 address so it will be filled with 0xff. 
+// 				*/
+// 				memset(IPAddr, 0xFF, sizeof (struct in_addr));
+// 			}
+// 		}
+// 		else
+// 		{
+// 			_fmemcpy(IPAddr, pBMCInfo->LANConfig.MsgReq.IPAddr, sizeof (struct in_addr));
+// 		}
+
+// 		/* This structure values are AMI specific SEL Record data */
+// 		OEMSELRec.ID = 0x00;
+// 		OEMSELRec.Type = 0xc1;
+// 		OEMSELRec.TimeStamp = 0x00;
+// 		memcpy(OEMSELRec.MftrID, MfgID, sizeof(MfgID));
+// 		OEMSELRec.OEMData[0] = EvtType;
+// 		OEMSELRec.OEMData[1] = UserID;
+// 		memcpy (&OEMSELRec.OEMData[2], IPAddr, IP_ADDR_LEN);
+		
+// 		OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SELConfig.SELMutex, WAIT_INFINITE);
+// 		/*we are not posting login/logout audit logs to PEF*/
+// 		reslen = LockedAddSELEntry((uint8_t *)&OEMSELRec, sizeof(SELOEM1Record_T), (uint8_t *)&AddSelRes, FALSE,POST_ONLY_SEL, BMCInst);
+// 		/* Enable Reservation ID which was cancelled by this event */
+// 		pBMCInfo->SELConfig.RsrvIDCancelled = FALSE;
+// 		OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SELConfig.SELMutex);
+
+// 		return ( (sizeof(uint8_t) == reslen) ? -1 : 0 );  //reslen is only Completion code size if error
+// 	}
+// 	return 0;
+// }
+
+#endif /*#if IPMI20_SUPPORT*/

+ 103 - 0
app/bmc/lan/RMCP.h

@@ -0,0 +1,103 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ *****************************************************************
+ *
+ * rmcp.h
+ * RMCP Packet Handler
+ *
+ * Author: Govind Kothandapani <govindk@ami.com>
+ *       : Bakka Ravinder Reddy <bakkar@ami.com>
+ *
+ *****************************************************************/
+#ifndef RMCP_H
+#define RMCP_H
+
+#include "com_BmcType.h"
+#include "com_IPMI_RMCP.h"
+#include "com_IPMIDefs.h"
+
+
+/* Integrity Algorithm Numbers */
+#define AUTH_NONE                   0
+#define AUTH_HMAC_SHA1_96           1
+#define AUTH_HMAC_MD5_128           2
+#define AUTH_MD5_128                3
+#define AUTH_HMAC_SHA256_128        4
+
+#define CONF_AES_CBC_128            1
+#define CONF_xCR4_128               2
+#define CONF_xCR4_40                3
+
+/* Login Event OEMType definitions */
+#define EVENT_LOGIN 	            0x9
+#define EVENT_LOGOUT 	            0xA
+#define EVENT_AUTO_LOGOUT           0xB
+#define EVENT_LOGIN_FAILURE         0xE
+
+#define NULL_USER                   1
+// /**
+//  * This structure holds various params/flags that are collected/accumulated/set/reset on the way during the flow of packets in API chain.
+//  * 
+// */
+// typedef struct {
+//     uint8_t	IsPktFromLoopBack; /** packet is received thru LoopBack */
+//     uint8_t	IsPktFromVLAN; /** packet is received thru VLAN */
+// }MiscParams_T;
+
+// /**
+//  * @var   uint32_t g_DeleteThisLANSSession
+//  * @brief Flag indicates LAN ifc to delete the session after sending response
+//  **/
+// //extern      uint32_t      g_DeleteThisLANSessionID;
+
+
+// /**
+//  * @brief Process RMCP request received over LAN interface.
+//  * @param pRMCPReq - Request message.
+//  * @param pRMCPRes - Response message.
+//  * @return Message length.
+// **/
+// extern uint32_t ProcessRMCPReq(  RMCPHdr_T* pRMCPReq,   RMCPHdr_T* pRMCPRes, MiscParams_T *pParams,uint8_t Channel, int BMCInst);
+
+
+// *
+//  * @brief Compute authentication code.
+//  * @param pPassword     - User password.
+//  * @param pSessionHdr   - Session header RMCP message.
+//  * @param pIPMIMsg      - IPMI message payload.
+//  * @param pAuthCode     - Authentication Code being generated.
+//  * @param ChannelType   - Channel Type.
+// *
+// extern void  ComputeAuthCode (  uint8_t* pPassword,   SessionHdr_T* pSessionHdr,
+//                                 IPMIMsgHdr_T* pIPMIMsg,   uint8_t* pAuthCode,
+//                               uint8_t ChannelType);
+
+
+// /**
+//  * @brief Frame IPMI 2.0 payload.
+//  * @param PayloadType - Payload Type.
+//  * @param pRMCPPkt    - RMCP data.
+//  * @param pPayload    - Payload data.
+//  * @param PayloadLen  - Payload Length.
+//  * @param pSessionInfo - Session information.
+//  * @return 0 if success, -1 if error.
+// **/
+// extern int   Frame20Payload     (uint8_t PayloadType,   RMCPHdr_T* pRMCPPkt,
+//                                    uint8_t* pPayload,  uint32_t PayloadLen,  
+//                                  SessionInfo_T* pSessionInfo, int BMCInst);
+
+
+// extern int AddLoginEvent ( uint8_t UserID, uint8_t* UserName, uint8_t EvtType, int BMCInst);
+
+
+#endif /* RMCP_H */

+ 306 - 0
app/bmc/libipmi_struct.h

@@ -0,0 +1,306 @@
+/**
+ * @file   libipmi_struct.h
+ * @author Rajasekhar (rajasekharj@amiindia.co.in)
+ * @date   02-Sep-2004
+ *
+ * @brief  Contains data structures	required for establishing a session
+ *
+ */
+
+#ifndef __LIBIPMI_STRUCT_H__
+#define __LIBIPMI_STRUCT_H__
+
+#include "com_BmcType.h"
+
+#pragma pack(1)
+
+#define	MAX_REQUEST_SIZE		1024
+#define	MAX_RESPONSE_SIZE		1024
+
+#define IP4_VERSION     4
+#define IP6_VERSION     6
+#define IP4_ADDR_LEN    4
+#define IP6_ADDR_LEN   16
+
+///**
+// @def LAN_CHANNEL_T
+// @brief holds data required for network medium
+//*/
+//typedef struct LAN_CHANNEL_T_tag {
+//	char			szIPAddress[46];
+//	uint16			wPort;
+//	SOCKET			hSocket;
+//	uint8_t			byIsConnected;
+//	uint8_t			bProtocol;
+//    uint8_t                   bFamily;
+//}  LAN_CHANNEL_T;
+
+///**
+// @def UDS_CHANNEL_T
+// @brief holds data required for network medium
+//*/
+//typedef struct UDS_CHANNEL_T_tag {
+//	uint16			hSocketPath;
+//	SOCKET			hSocket;
+//	uint8_t			byIsConnected;
+//}  UDS_CHANNEL_T;
+///**
+// @def SERIAL_CHANNEL_T
+// @brief holds data required for Serial medium
+//*/
+//typedef struct SERIAL_CHANNEL_T_tag {
+//	char			szdevice[32];
+//}  SERIAL_CHANNEL_T;
+
+/* Authentication Types */
+#define	AUTHTYPE_NONE									0x00
+#define	AUTHTYPE_MD2									0x01
+#define	AUTHTYPE_MD5									0x02
+#define	AUTHTYPE_RESERVED								0x03
+#define	AUTHTYPE_STRAIGHT_PASSWORD						0x04
+#define	AUTHTYPE_OEM_PROPRIETARY						0x05
+#define	AUTHTYPE_RMCP_PLUS_FORMAT						0x06
+
+/* Privilege levels */
+#define PRIV_LEVEL_NO_ACCESS                            0x0F
+#define PRIV_LEVEL_PROPRIETARY							0x05
+#define PRIV_LEVEL_ADMIN								0x04
+#define PRIV_LEVEL_OPERATOR								0x03
+#define PRIV_LEVEL_USER									0x02
+#define PRIV_LEVEL_CALLBACK								0x01
+#define PRIV_LEVEL_RESERVED								0x00
+
+
+/* Authentication Algorithms */
+#define AUTH_ALG_RAKP_NONE								0x00
+#define AUTH_ALG_RAKP_HMAC_SHA1							0x01
+#define AUTH_ALG_RAKP_HMAC_MD5							0x02
+
+/* Integrity Algorithms */
+#define INTEGRITY_ALG_NONE								0x00
+#define INTEGRITY_ALG_HMAC_SHA1_96						0x01
+#define INTEGRITY_ALG_HMAC_SHA1_128						0x02
+#define INTEGRITY_ALG_MD5_128							0x03
+
+/* Confidentiality Algorithms */
+#define CONFIDENTIALITY_ALG_NONE						0x00
+#define CONFIDENTIALITY_ALG_AES_CBC_128					0x01
+#define CONFIDENTIALITY_ALG_XRC4_128					0x02
+#define CONFIDENTIALITY_ALG_XRC4_40						0x03
+
+/* Payload Types */
+#define PAYLOAD_TYPE_IPMI								0
+#define PAYLOAD_TYPE_SOL								1
+#define PAYLOAD_TYPE_RSSP_OPEN_SES_REQ					0x10
+#define PAYLOAD_TYPE_RSSP_OPEN_SES_RES					0x11
+#define PAYLOAD_TYPE_RAKP_MSG_1							0x12
+#define PAYLOAD_TYPE_RAKP_MSG_2							0x13
+#define PAYLOAD_TYPE_RAKP_MSG_3							0x14
+#define PAYLOAD_TYPE_RAKP_MSG_4							0x15
+
+#define	MAX_KEY1_SIZE									20
+#define	MAX_KEY2_SIZE									20
+#define	MAX_GUID_SIZE									16
+//#define	MAX_USER_NAME_LEN								(16+1) //1 for stroing the null character
+//#define	MAX_USER_PWD_LEN								(20+1) //1 for storing the null character
+#define MAX_RAND_NO_LEN									16
+
+
+/* (0x6 << 2) == 0x18 */
+#define DEFAULT_NET_FN_LUN					0x18
+#define NETFNLUN_IPMI_APP					0x18
+#define NETFNLUN_IPMI_SENSOR					0x10
+#define NETFNLUN_IPMI_STORAGE					0x28
+#define NETFNLUN_IPMI_CHASSIS                                   0x00
+
+///**
+// @def IPMI20_NETWORK_SESSION_T
+// @brief holds data required for maintaining session with network medium
+//*/
+//typedef struct IPMI20_NETWORK_SESSION_tag
+//{
+//	LAN_CHANNEL_T	hLANInfo;
+//	char			szUserName [MAX_USER_NAME_LEN];
+//	char			szPwd [MAX_USER_PWD_LEN];
+//	uint32_t			dwSessionID;
+//	uint8_t			byIPMBSeqNum;
+//	uint32_t			dwSessionSeqNum;
+//	uint8_t			byAuthType;
+//	uint8_t			byChannelNum;
+//	uint8_t			byPerMsgAuthentication;
+//	uint8_t			byRole;
+//	uint8_t			byAuthAlgthm;
+//	uint8_t			byIntegrityAlgthm;
+//	uint8_t			byEncryptAlgthm;
+//	uint8_t			byPreSession;
+//	uint8_t			byResAddr;
+//	uint8_t			byReqAddr;
+//	uint8_t			byGUID [MAX_GUID_SIZE];
+//	uint8_t			byIsEncryptionReq;
+//	uint8_t			byKey1 [MAX_KEY1_SIZE];
+//	uint8_t			byKey2 [MAX_KEY2_SIZE];
+//	uint8_t			byMsgTag;
+//	uint32_t			dwRemConSessID;
+//	uint8_t			byRemConRandomNo [16];
+//	uint8_t			byMgdSysRandomNo [16];
+//	uint8_t			byDefTimeout;
+//}  IPMI20_NETWORK_SESSION_T;
+
+
+///**
+// @def IPMI20_SERIAL_SESSION_T
+// @brief holds data required for maintaining session with serial medium
+//*/
+//typedef struct IPMI20_SERIAL_SESSION_T_tag {
+//	SERIAL_CHANNEL_T	hSerialInfo;
+//	char			szUserName [MAX_USER_NAME_LEN];
+//	char			szPwd [MAX_USER_PWD_LEN];
+//	HANDLE			hSerialPort;
+//	uint8_t			byMaxRetries;
+//	uint32_t			dwSessionID;
+//	uint8_t			byAuthType;
+//	uint32_t			dwInboundSeqNum;
+//	uint32_t			dwOutboundSeqNum;
+//	uint8_t			byIPMBSeqNum;
+//	uint8_t			byPrivLevel;
+//	uint8_t			byResAddr;
+//	uint8_t			byReqAddr;
+//	uint8_t			byDefTimeout;
+//}  IPMI20_SERIAL_SESSION_T;
+
+///**
+// @def IPMI20_UDS_SESSION_T
+// @brief holds data required for maintaining session with unix domain socket medium
+//*/
+//typedef struct IPMI20_UDS_SESSION_T_tag {
+//  UDS_CHANNEL_T hUDSInfo;
+//  char szUserName[MAX_USER_NAME_LEN];
+//  char szPwd[MAX_USER_PWD_LEN];
+//  char szUName[MAX_USER_NAME_LEN];
+//  char abyIPAddr[IP6_ADDR_LEN];
+//  uint32_t dwSessionID;
+//  uint8_t byPreSession;
+//  uint8_t byAuthType;
+//  uint8_t byRole;
+//  uint8_t byChannelNum;
+//  uint8_t byDefTimeout;
+//  uint8_t byMaxRetries;
+//} IPMI20_UDS_SESSION_T;
+
+///**
+// @def IPMI20_KCS_SESSION_T
+// @brief holds data required for maintaining session with KCS medium
+//*/
+//typedef struct IPMI20_KCS_SESSION_T_tag {
+//	HANDLE			hKCSDevice;
+//	uint8_t			byResAddr;
+//}  IPMI20_KCS_SESSION_T;
+
+///**
+// @def IPMI20_IPMB_SESSION_T
+// @brief holds data required for maintaining session with IPMB medium
+//*/
+//typedef struct IPMI20_IPMB_SESSION_T_tag {
+//	HANDLE			hIPMBDevice;
+//	uint8_t			bySlaveAddr;
+//}  IPMI20_IPMB_SESSION_T;
+
+///**
+// @def LIBIPMI_SERIAL_SETTINGS_T
+// @brief holds settings for a session
+//*/
+//typedef struct {
+///* settings state */
+//	uint8_t		bySettings;
+//#define	SETTINGS_NOTSET			0x00
+//#define	SETTINGS_DEFAULT		0x01
+//#define	SETTINGS_USER			0x02
+
+///* BaudRate */
+//	uint32_t		dwBaudRate;
+
+///* Parity */
+//	uint8_t		byParity;
+//#define			EVEN_PARITY					0x00
+//#define			ODD_PARITY					0x01
+//#define			NO_PARITY					0x02
+//#define			MARK_PARITY					0x03
+//#define			SPACE_PARITY				0x04
+
+///* Stop Bits */
+//	uint8_t		byStopBit;
+//#define			STOPBIT_ONE					0x00
+//#define			STOPBIT_ONE5				0x01
+//#define			STOPBIT_TWO					0x02
+
+//	uint8_t		byByteSize;
+
+///* Byte Size */
+//}  LIBIPMI_SERIAL_SETTINGS_T;
+
+//#define DEFAULT_BAUD_RATE					115200
+//#define DEFAULT_PARITY						NO_PARITY
+//#define	DEFAULT_STOPBITS					STOPBIT_ONE
+//#define DEFAULT_BYTESIZE					8
+
+///**
+// @def IPMI20_USB_SESSION_T
+// @brief holds data required for maintaining session with USB medium
+//*/
+//typedef struct IPMI20_USB_SESSION_T_tag {
+//	union {
+//		HANDLE			hUSBDevice;
+//		int				hUSBDesc;
+//	};
+//	uint8_t			byResAddr;
+//}  IPMI20_USB_SESSION_T;
+
+
+///**
+// @def IPMI20_SESSION_T
+// @brief holds info for maintaining a session
+//*/
+//typedef struct IPMI20_SESSION_T_tag {
+///* Medium type (Network, Serial, KCS, IPMB, USB) */
+//	uint8_t	byMediumType;
+
+//#define NETWORK_MEDIUM_TCP      0x01
+//#define NETWORK_MEDIUM_UDP      0x04
+
+//#define	NETWORK_MEDIUM	        NETWORK_MEDIUM_TCP
+//#define	SERIAL_MEDIUM	        0x02
+//#define KCS_MEDIUM		        0x03
+//#define IPMB_MEDIUM		        0x05
+//#define USB_MEDIUM		        0x06
+//#define	UDS_MEDIUM	          0x07
+
+///* tells whether session has started or not. */
+//	uint8_t	bySessionStarted;
+//#define SESSION_NOT_STARTED 0x00
+//#define SESSION_STARTED	0x01
+
+///* if this value is > 0, session reestablishment will be tried for byMaxRetries times. */
+//	uint8_t	byMaxRetries;
+///* LAN Eth Index for hold Eth number if multi NIc supported */
+//	uint8_t         EthIndex;
+
+//	IPMI20_NETWORK_SESSION_T	*hNetworkSession;
+//	IPMI20_SERIAL_SESSION_T		*hSerialSession;
+//	IPMI20_KCS_SESSION_T		*hKCSSession;
+//	IPMI20_IPMB_SESSION_T		*hIPMBSession;
+//	IPMI20_USB_SESSION_T		*hUSBSession;
+//	IPMI20_UDS_SESSION_T		*hUDSSession;
+
+//	LIBIPMI_SERIAL_SETTINGS_T	Settings;
+
+//}  IPMI20_SESSION_T;
+
+//typedef enum
+//{
+//    AUTH_FLAG = 1,
+//    AUTH_BYPASS_FLAG,
+//}USER_Auth;
+
+#pragma pack()
+
+#endif /* __LIBIPMI_STRUCT_H__ */

+ 126 - 0
app/bmc/main.c

@@ -0,0 +1,126 @@
+/*
+* bmc_app application main code.
+*/
+
+
+
+#include <stdio.h>
+#include <stdint.h>
+#include <sys/prctl.h>
+#include <semaphore.h>
+#include <pthread.h>
+
+
+#include "com_BmcType.h"
+#include "com_IPMIDefs.h"
+#include "com_Message.h"
+
+#include "BmcType.h"
+#include "main.h"
+#include "Session.h"
+
+#include "LANIfc.h"
+#include "UDSIfc.h"
+#include "IPMBIfc.h"
+#include "MsgHndlrTask.h"
+#include "ChassisTimerTask.h"
+#include "TimerTask.h"
+
+
+/* gloabl varible */
+BMCInfo_t 	g_BMCInfo;
+pthread_t 	gThreadIDs[256];
+uint8_t		gThreadIndex = 0;
+
+
+void main(void)
+{
+	PlatformInit();
+	Init_IPMI_FRU_SDR_SEL();
+	InitSdrConfig();
+	InitSelConfig();
+	Init_SessionTbl();
+	InitTimerTaskTbl();
+
+	printf("\tChassisID %#02x, SlotID %#02x\r\n", g_BMCInfo.ChassisID, g_BMCInfo.SlotID);
+	if(g_BMCInfo.IpmiConfig.PrimaryIPMBSupport)
+	{
+		printf("\tPrimaryIPMBBus: %d, channel %d, Addr %#02x\n", g_BMCInfo.IpmiConfig.PrimaryIPMBBus, 
+			PRIMARY_IPMB_CHANNEL, g_BMCInfo.IpmiConfig.PrimaryIPMBAddr);
+	}
+	if(g_BMCInfo.IpmiConfig.SecondaryIPMBSupport)
+	{
+		printf("\tSecondaryIPMBBus %d, Channel %d, Addr %#02x\n", g_BMCInfo.IpmiConfig.SecondaryIPMBBus,
+			SECONDARY_IPMB_CHANNEL, g_BMCInfo.IpmiConfig.SecondaryIPMBAddr);
+	}
+
+	/* Create TimerTask */
+	gThreadIndex = 0;
+	if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,TimerTask,NULL))
+    {
+        printf("%s: Create TimerTask thread failed!\n", __FUNCTION__);
+    }
+
+	/* Create MsgHndlr Task */
+	gThreadIndex++;
+	if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,MsgHndlrTask,NULL))
+    {
+        printf("%s: Create MsgHndlrTask thread failed!\n", __FUNCTION__);
+    }
+
+    /* Create ChassisTimerTask */
+	gThreadIndex++;
+	if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,ChassisTimerTask,NULL))
+    {
+        printf("%s: Create ChassisTimerTask thread failed!\n", __FUNCTION__);
+    }
+
+    /* Create SensorMonitorTask */
+	gThreadIndex++;
+	if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,SensorMonitorTask,NULL))
+    {
+        printf("%s: Create SensorMonitorTask thread failed!\n", __FUNCTION__);
+    }
+
+	/* Create UDS interface */
+	gThreadIndex++;
+	if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,UDSIfcTask,NULL))
+    {
+        printf("%s: Create UDSIfcTask thread failed!\n", __FUNCTION__);
+    }
+
+	/* Create LAN interface */
+	gThreadIndex++;
+	if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,LANIfcTask,NULL))
+    {
+        printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
+    }
+	/* Create IPMB interface */
+	uint8_t primaryIpmbSelect = 0;	//primary
+	gThreadIndex++;
+	if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,IPMBIfcTask,&primaryIpmbSelect))
+    {
+        printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
+    }
+    uint8_t secondaryIpmbSelect = 1;	//secondary
+    gThreadIndex++;
+	if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,IPMBIfcTask,&secondaryIpmbSelect))
+    {
+        printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
+    }
+
+	/* Create Update FPGA thread */
+
+	/* Create UDS interface */
+
+	/* Create UDS interface */
+
+	/* Create UDS interface */
+
+	UpdateUserInfoTable();
+	while(1)
+	{
+		sleep(100);
+		//printf("Hello...\n");
+	}
+}

+ 106 - 0
app/bmc/main.h

@@ -0,0 +1,106 @@
+#ifndef __MAIN_H__
+#define __MAIN_H__
+
+#include <stdint.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include "com_BmcType.h"
+#include "com_IPMIDefs.h"
+#include "BmcType.h"
+#include "com_IPMI_SDRRecord.h"
+
+#include "Session.h"
+#include "sensor_tbl.h"
+#include "MsgHndlr.h"
+#include "hal_interface_api.h"
+/* Declare global variable */
+
+/*---------------------------------------------------------------------------*
+ * Interface SUPPORTED
+ *---------------------------------------------------------------------------*/
+#define LAN_IFC_SUPPORT					1
+#define SERIAL_IFC_SUPPORT				0
+#define SERIAL_TERMINAL_SUPPORT			0
+#define SYS_IFC_SUPPORT					0
+#define PRIMARY_IPMB_SUPPORT		1
+#define SECONDARY_IPMB_SUPPORT		1
+#define GROUP_EXTERN_SUPPORT		1
+
+#define SENSOR_NUMBERS				(11)
+#define FW_VERSION_MAJOR			(1)
+#define FW_VERSION_MINOR			(0)
+
+
+#define PWR_CYCLE_INTERVAL			(3) 	//unit: 1s
+#define REARM_SET_SENSOR_THRESHOLD	(0)		//whether rearm sensor event when change sensor threshold
+#define CHASSIS_TIMER_INTERVAL		(1)		//1 second
+#define FAN_CONTROL_INTERVAL		(5)		//5	second 
+//IPMB
+#define PRIMARY_IPMB_BUS			2	// /dev/i2c2
+#define SECONDARY_IPMB_BUS			1	// /dev/i2c1
+#define PRIMARY_IPMB_ADDR			0x20
+#define SECONDARY_IPMB_ADDR			0x20
+
+//RACK-ID
+#define RACKID0_PORT	GPIOI
+#define RACKID1_PORT	GPIOI
+#define RACKID2_PORT	GPIOH
+#define RACKID3_PORT	GPIOI
+#define RACKID4_PORT	GPIOI
+#define RACKID5_PORT	GPIOI
+#define RACKID0_PIN		GPIO_PIN_6
+#define RACKID1_PIN		GPIO_PIN_7
+#define RACKID2_PIN		GPIO_PIN_15
+#define RACKID3_PIN		GPIO_PIN_9
+#define RACKID4_PIN		GPIO_PIN_10
+#define RACKID5_PIN		GPIO_PIN_11
+
+//SLOT-ID
+#define GA0_PORT	GPIOH
+#define GA1_PORT	GPIOH
+#define GA2_PORT	GPIOH
+#define GA3_PORT	GPIOH
+#define GA4_PORT	GPIOH
+#define GAP_PORT	GPIOI
+#define GA0_PIN		GPIO_PIN_10
+#define GA1_PIN		GPIO_PIN_11
+#define GA2_PIN		GPIO_PIN_12
+#define GA3_PIN		GPIO_PIN_13
+#define GA4_PIN		GPIO_PIN_14
+#define GAP_PIN		GPIO_PIN_5
+
+extern sensor_tbl_t 				sensor_tbl[];
+extern const OemFRUData_T 			Default_FRUData;
+//extern OEM_SENSOR_CAPABILITY_T 		g_sensorList[SENSOR_NUMBERS];
+extern const MgmtCtrlrDevLocator_T 	bmc_sdr;
+extern const FullSensorRec_T 		full_sdr_tbl[];
+extern const CompactSensorRec_T 	Compact_sdr_tbl[];
+
+#define RESTORE_IPMI 	0x01
+#define RESTORE_FRU		0x02
+#define RESTORE_SDR		0x04
+#define RESTORE_SEL		0x08
+#define RESTORE_ALL		(RESTORE_IPMI | RESTORE_FRU | RESTORE_SDR | RESTORE_SEL)
+
+
+extern pthread_t 	gThreadIDs[256];
+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_PrimaryIpmbIfcQ, gFd_PrimaryIpmbResQ;
+extern int gFd_SecondaryIpmbIfcQ, gFd_SecondaryIpmbResQ;
+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];
+extern KCSBridgeResInfo_T       m_KCSBridgeResInfo;
+extern TimerTaskTbl_T    		m_TimerTaskTbl [20];
+
+extern BMCInfo_t 	g_BMCInfo;
+
+#endif /* __MAIN_H__ */

+ 133 - 0
app/bmc/message.c

@@ -0,0 +1,133 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/prctl.h>
+#include "com_IPMI_App.h"
+#include "com_IPMIDefs.h"
+#include "com_Message.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+/**
+ ** @fn PostMsg
+ ** @brief Post a message to the destination task.
+ ** @param MsgPkt   - Message to be posted.
+ ** @param Queue       - Queue to post this message to.
+ ** @return   0 if success, -1 if failed.
+ ***/
+int
+PostMsg (int fd, MsgPkt_T* pMsgPkt)
+{
+    int     Err,i=0;
+    uint16_t  Size;
+
+    Size    = sizeof (MsgPkt_T) - MSG_PAYLOAD_SIZE + pMsgPkt->Size;
+    
+    Err = write (fd, pMsgPkt, Size) ;
+    if ((Err == -1) || (Err != Size))
+    {
+        printf ("Message.c : PostMsg %x %s\n",errno, strerror(errno));
+        return -1;
+    }             
+
+    //printf("---> PostMsg ok, fd = %d\n", fd);
+    return 0;
+}
+
+
+/*------ Get the message from the queue -----------------------------*/
+int OS_GET_FROM_Q( int fd, uint8_t *pBuf, int Size, int16_t timeout)    
+{                                                           
+    int ReadLen = 0, Left, Len;
+    int Err = 0;                             
+    Left = Size;                                            
+    while( Left > 0 )                                       
+    {                                                       
+        Len = read (fd, (uint8_t*)pBuf + ReadLen, Left ); 
+        if( Len < 0 )                                       
+        {                                                   
+            if( errno == EINTR || errno == EAGAIN )         
+            {                                               
+                continue;                                   
+            }                                               
+            else                                            
+            {                                               
+                Err = -1;                                 
+                break;                                      
+            }                                               
+        }                                                   
+        ReadLen += Len;                                     
+        Left -= Len;                                        
+    }                                                       
+    Err = ReadLen;                                        
+    return Err;
+}
+
+/**
+ * @fn GetMsg
+ * @brief Gets the message posted to this task.
+ * @param MsgPkt   - Pointer to the buffer to hold the message packet.
+ * @param Queue    - Queue to fetch the message from.
+ * @param Timeout    - Number of seconds to wait.
+ * 
+ * WAIT_NONE       - If the function has to return immediately.
+ * WAIT_INFINITE   - If the function has to wait infinitely.
+ * NOTE :
+ * @return   0 if success, -1 if failed.
+**/
+int
+GetMsg (int fd, MsgPkt_T* pMsgPkt, int16_t Timeout)
+{
+    int     Err;
+    int     Size;
+    
+    /* check for limited wait time */
+    if (Timeout >= 0)
+    {
+        struct timeval      Timeval;
+        fd_set              fdRead;
+        int                 n, RetVal;
+
+        FD_ZERO (&fdRead);
+        FD_SET (fd, &fdRead);
+        n = fd + 1;
+
+        Timeval.tv_sec  = Timeout;
+        Timeval.tv_usec = 0;
+        RetVal = select (n, &fdRead, NULL, NULL, &Timeval);
+        if (-1 == RetVal)
+        {
+            printf ("Message.c : Error waiting on Queue, log1\n");
+            return -1;
+        }
+        else if (0 == RetVal)
+        {
+            //printf ("Message.c : Error waiting on Queue, log2\n");
+            return -2;
+        }
+    }
+
+    /* Get the header first*/
+    Size = sizeof (MsgPkt_T) - MSG_PAYLOAD_SIZE;
+
+    if(-1 == OS_GET_FROM_Q (fd, (uint8_t*)pMsgPkt, Size, WAIT_INFINITE))
+    {
+        printf ("Message.c : GetMsg %s\n",strerror(errno));
+        return -1;
+    }
+
+    /* Get the payload data */
+    Size = pMsgPkt->Size;
+    if(-1 == OS_GET_FROM_Q (fd, pMsgPkt->Data, Size, WAIT_INFINITE))
+    {
+        printf ("Message.c : GetMsg %s\n",strerror(errno));
+        return -1;
+    }
+
+    return 0;
+}

+ 30 - 0
app/bmc/message.h

@@ -0,0 +1,30 @@
+#ifndef __MESSAGE_H__
+#define __MESSAGE_H__
+
+/**
+ ** @fn PostMsg
+ ** @brief Post a message to the destination task.
+ ** @param MsgPkt   - Message to be posted.
+ ** @param Queue       - Queue to post this message to.
+ ** @return   0 if success, -1 if failed.
+ ***/
+int
+PostMsg (int fd, MsgPkt_T* pMsgPkt);
+
+/**
+ * @fn GetMsg
+ * @brief Gets the message posted to this task.
+ * @param MsgPkt   - Pointer to the buffer to hold the message packet.
+ * @param Queue    - Queue to fetch the message from.
+ * @param Timeout    - Number of seconds to wait.
+ * 
+ * WAIT_NONE       - If the function has to return immediately.
+ * WAIT_INFINITE   - If the function has to wait infinitely.
+ * NOTE :
+ * @return   0 if success, -1 if failed.
+**/
+int
+GetMsg (int fd, MsgPkt_T* pMsgPkt, int16_t Timeout);
+
+
+#endif /* __MESSAGE_H__ */

+ 27 - 48
app/bmc_server/libipmimsghndler/App/App.c → app/bmc/msghndlr/App/App.c

@@ -21,35 +21,14 @@
  *       : Bakka Ravinder Reddy <bakkar@ami.com>
  * 
  *****************************************************************/
-#define UNIMPLEMENTED_AS_FUNC
-
-// #include "Types.h"
-// #include "MsgHndlr.h"
-#include "Support.h"
-// #include "App.h"
-// #include "IPMDevice.h"
-// #include "AppDevice.h"
-// #include "AppDevice+.h"
-// #include "Firewall.h"
-#include "IPMI_IPM.h"
-// #include "IPMI_AppDevice.h"
-// #include "IPMI_AppDevice+.h"
-// #include "IPMI_Firewall.h"
-#include "bmc_type.h"
-#include "bmc_conf.h"
-#include "bmc_main.h"
 #include "MsgHndlr.h"
+#include "com_IPMI_App.h"
+#include "com_IPMI_IPM.h"
+//#include "com_IPMI_Firewall.h"
+#include "com_IPMI_App+.h"
+#include "libipmi_struct.h"
 #include "Support.h"
-#include "IPMDevice.h"
-#include "Firewall.h"
-#include "IPMI_Firewall.h"
-#include "AppDevice.h"
-#include "IPMI_AppDevice.h"
-#include "IPMI_AppDevice+.h"
-#include "AppDevice+.h" 
-#include "session.h"
-
-#include "IPMI_App.h"
+#include "com_IPMI_AppDevice.h"
 
 /*** Global Variables ***/
 const CmdHndlrMap_T g_App_CmdHndlr [] =	//notice!
@@ -58,13 +37,13 @@ const CmdHndlrMap_T g_App_CmdHndlr [] =	//notice!
     /*------------------------- IPM Device Commands -------------------------*/
     { CMD_GET_DEV_ID,               PRIV_USER,      GET_DEV_ID,             0x00,                           0xAAAA , 0xFFFF},
 //    { CMD_BROADCAST_GET_DEV_ID,     PRIV_LOCAL,     BROADCAST_GET_DEV_ID,   0x00,                           0xAAAA ,0xFFFF},
-//    { CMD_COLD_RESET,               PRIV_ADMIN,     COLD_RESET,             0x00,                           0xAAAA ,0xFFFF},
-//    { CMD_WARM_RESET,               PRIV_ADMIN,     WARM_RESET,             0x00,                           0xAAAA , 0xFFFF},
-//    { CMD_GET_SELF_TEST_RESULTS,    PRIV_USER,      GET_SELF_TEST_RESULTS,  0x00,                           0xAAAA , 0xFFFF},
-//    { CMD_MFG_TEST_ON,              PRIV_ADMIN,     MFG_TEST_ON,            0xFF,                           0xAAAA ,0xFFFF},
-//    { CMD_SET_ACPI_PWR_STATE,       PRIV_ADMIN,     SET_ACPI_PWR_STATE,     sizeof (SetACPIPwrStateReq_T),  0xAAAA ,0xFFFF},
-//    { CMD_GET_ACPI_PWR_STATE,       PRIV_USER,      GET_ACPI_PWR_STATE,     0x00,                           0xAAAA ,0xFFFF},
-//    { CMD_GET_DEV_GUID,             PRIV_USER,      GET_DEV_GUID,           0x00,                           0xAAAA ,0xFFFF},
+    { CMD_COLD_RESET,               PRIV_ADMIN,     COLD_RESET,             0x00,                           0xAAAA ,0xFFFF},
+    { CMD_WARM_RESET,               PRIV_ADMIN,     WARM_RESET,             0x00,                           0xAAAA , 0xFFFF},
+    { CMD_GET_SELF_TEST_RESULTS,    PRIV_USER,      GET_SELF_TEST_RESULTS,  0x00,                           0xAAAA , 0xFFFF},
+    { CMD_MFG_TEST_ON,              PRIV_ADMIN,     MFG_TEST_ON,            0xFF,                           0xAAAA ,0xFFFF},
+    { CMD_SET_ACPI_PWR_STATE,       PRIV_ADMIN,     SET_ACPI_PWR_STATE,     sizeof (SetACPIPwrStateReq_T),  0xAAAA ,0xFFFF},
+    { CMD_GET_ACPI_PWR_STATE,       PRIV_USER,      GET_ACPI_PWR_STATE,     0x00,                           0xAAAA ,0xFFFF},
+    { CMD_GET_DEV_GUID,             PRIV_USER,      GET_DEV_GUID,           0x00,                           0xAAAA ,0xFFFF},
 //    { CMD_GET_NETFN_SUP,            PRIV_USER,      GET_NETFN_SUP,          0x01,                           0xAAAA ,0xFFFF},
 //    { CMD_GET_CMD_SUP,              PRIV_USER,      GET_CMD_SUP,            0xFF,                           0xAAAA ,0xFFFF},
 //    { CMD_GET_SUBFN_SUP,            PRIV_USER,      GET_SUBFN_SUP,          0xFF,                           0xAAAA ,0xFFFF},
@@ -78,41 +57,41 @@ const CmdHndlrMap_T g_App_CmdHndlr [] =	//notice!
 #endif /* IPM_DEVICE */
 
 #if APP_DEVICE == 1
-    /*--------------------- Watch Dog Timer Commands -----------------------*/
+//    /*--------------------- Watch Dog Timer Commands -----------------------*/
 //    { CMD_RESET_WDT,                PRIV_OPERATOR,  RESET_WDT,              0x00,                           0xAAAA ,0xFFFF},
 //    { CMD_SET_WDT,                  PRIV_OPERATOR,  SET_WDT,                sizeof (SetWDTReq_T),           0xAAAA ,0xFFFF},
 //    { CMD_GET_WDT,                  PRIV_USER,      GET_WDT,                0x00,                           0xAAAA ,0xFFFF},
-//
+
 //    /*----------------- BMC Device and Messaging Commands ------------------*/
-//    { CMD_SET_BMC_GBL_ENABLES,      PRIV_LOCAL,   SET_BMC_GBL_ENABLES,    sizeof (INT8U),                 0xAAAA ,0xFFFF},
+//    { CMD_SET_BMC_GBL_ENABLES,      PRIV_LOCAL,   SET_BMC_GBL_ENABLES,    sizeof (uint8_t),                 0xAAAA ,0xFFFF},
 //    { CMD_GET_BMC_GBL_ENABLES,      PRIV_USER,      GET_BMC_GBL_ENABLES,    0x00,                           0xAAAA ,0xFFFF},
-//    { CMD_CLR_MSG_FLAGS,            PRIV_LOCAL,   CLR_MSG_FLAGS,          sizeof (INT8U),                 0xAAAA ,0xFFFF},
+//    { CMD_CLR_MSG_FLAGS,            PRIV_LOCAL,   CLR_MSG_FLAGS,          sizeof (uint8_t),                 0xAAAA ,0xFFFF},
 //    { CMD_GET_MSG_FLAGS,            PRIV_LOCAL,   GET_MSG_FLAGS,          0x00,                           0xAAAA ,0xFFFF},
 //    { CMD_ENBL_MSG_CH_RCV,          PRIV_LOCAL,   ENBL_MSG_CH_RCV,        sizeof (EnblMsgChRcvReq_T),     0xAAAA ,0xFFFF},
-//    { CMD_GET_MSG,                  PRIV_LOCAL,      GET_MSG,                0x00,                           0xAAAA ,0xFFFF},
-//    { CMD_SEND_MSG,                 PRIV_USER,      SEND_MSG,               0xFF,                           0xAAAA ,0xFFFF},
+    { CMD_GET_MSG,                  PRIV_LOCAL,      GET_MSG,                0x00,                           0xAAAA ,0xFFFF},
+    { CMD_SEND_MSG,                 PRIV_USER,      SEND_MSG,               0xFF,                           0xAAAA ,0xFFFF},
 //    { CMD_READ_EVT_MSG_BUFFER,      PRIV_LOCAL,     READ_EVT_MSG_BUFFER,    0x00,                           0xAAAA ,0xFFFF},
 //    { CMD_GET_BTIFC_CAP,            PRIV_USER,      GET_BTIFC_CAP,          0x00,                           0xAAAA ,0xFFFF},
 //    { CMD_GET_SYSTEM_GUID,          PRIV_NONE,      GET_SYSTEM_GUID,        0x00,                           0xAAAA ,0xFFFF},
     { CMD_GET_CH_AUTH_CAP,          PRIV_NONE,      GET_CH_AUTH_CAP,        sizeof (GetChAuthCapReq_T),     0xAAAA ,0xFFFF},
     { CMD_GET_SESSION_CHALLENGE,    PRIV_NONE,      GET_SESSION_CHALLENGE,  sizeof (GetSesChallengeReq_T),  0xAAAA ,0xFFFF},
     { CMD_ACTIVATE_SESSION,         PRIV_NONE,      ACTIVATE_SESSION,       sizeof (ActivateSesReq_T),      0xAAAA ,0xFFFF},
-    { CMD_SET_SESSION_PRIV_LEVEL,   PRIV_USER,      SET_SESSION_PRIV_LEVEL, sizeof (INT8U),                 0xAAAA ,0xFFFF},
+    { CMD_SET_SESSION_PRIV_LEVEL,   PRIV_USER,      SET_SESSION_PRIV_LEVEL, sizeof (uint8_t),                 0xAAAA ,0xFFFF},
     { CMD_CLOSE_SESSION,            PRIV_CALLBACK,  CLOSE_SESSION,          0xFF,                           0xAAAA ,0xFFFF},
 //    { CMD_GET_SESSION_INFO,         PRIV_USER,      GET_SESSION_INFO,       0xFF,                           0xAAAA ,0xFFFF},
 //    { CMD_GET_AUTH_CODE,            PRIV_OPERATOR,  GET_AUTH_CODE,          sizeof (GetAuthCodeReq_T),      0xAAAA ,0xFFFF},
 //    { CMD_SET_CH_ACCESS,            PRIV_ADMIN,     SET_CH_ACCESS,          sizeof (SetChAccessReq_T),      0xAAAA ,0xFFFF},
 //    { CMD_GET_CH_ACCESS,            PRIV_USER,      GET_CH_ACCESS,          sizeof (GetChAccessReq_T),      0xAAAA ,0xFFFF},
-//    { CMD_GET_CH_INFO,              PRIV_USER,      GET_CH_INFO,            sizeof (INT8U),                 0xAAAA ,0xFFFF},
-//    { CMD_SET_USER_ACCESS,          PRIV_ADMIN,     SET_USER_ACCESS,        0xFF,    0xAAAA ,0xFFFF},
-//    { CMD_GET_USER_ACCESS,          PRIV_OPERATOR,  GET_USER_ACCESS,        sizeof (GetUserAccessReq_T),    0xAAAA ,0xFFFF},
-//    { CMD_SET_USER_NAME,            PRIV_ADMIN,     SET_USER_NAME,          sizeof (SetUserNameReq_T),      0xAAAA ,0xFFFF},
-//    { CMD_GET_USER_NAME,            PRIV_OPERATOR,  GET_USER_NAME,          sizeof (INT8U),                 0xAAAA ,0xFFFF},
-//    { CMD_SET_USER_PASSWORD,        PRIV_ADMIN,     SET_USER_PASSWORD,      0xFF,      0xAAAA ,0xFFFF},
+//    { CMD_GET_CH_INFO,              PRIV_USER,      GET_CH_INFO,            sizeof (uint8_t),                 0xAAAA ,0xFFFF},
+    { CMD_SET_USER_ACCESS,          PRIV_ADMIN,     SET_USER_ACCESS,        0xFF,    0xAAAA ,0xFFFF},
+    { CMD_GET_USER_ACCESS,          PRIV_OPERATOR,  GET_USER_ACCESS,        sizeof (GetUserAccessReq_T),    0xAAAA ,0xFFFF},
+    { CMD_SET_USER_NAME,            PRIV_ADMIN,     SET_USER_NAME,          sizeof (SetUserNameReq_T),      0xAAAA ,0xFFFF},
+    { CMD_GET_USER_NAME,            PRIV_OPERATOR,  GET_USER_NAME,          sizeof (uint8_t),                 0xAAAA ,0xFFFF},
+    { CMD_SET_USER_PASSWORD,        PRIV_ADMIN,     SET_USER_PASSWORD,      0xFF,      0xAAAA ,0xFFFF},
 //    { CMD_MASTER_WRITE_READ,        PRIV_OPERATOR,  MASTER_WRITE_READ,      0xFF,                           0xAAAA ,0xFFFF},
 //    { CMD_SET_SYSTEM_INFO_PARAM,    PRIV_ADMIN,     SET_SYSTEM_INFO_PARAM,  0xFF,                           0xAAAA ,0xFFFF},
 //    { CMD_GET_SYSTEM_INFO_PARAM,    PRIV_USER ,  GET_SYSTEM_INFO_PARAM,  sizeof (GetSystemInfoParamReq_T),      0xAAAA ,0xFFFF},
-//
+
 //    /*------------------------ IPMI 2.0 specific Commands ------------------*/
 //    { CMD_ACTIVATE_PAYLOAD,         PRIV_CALLBACK,  ACTIVATE_PAYLOAD,       sizeof (ActivatePayloadReq_T),  0xAAAA ,0xFFFF},
 //    { CMD_DEACTIVATE_PAYLOAD,       PRIV_CALLBACK,  DEACTIVATE_PAYLOAD,     sizeof (DeactivatePayloadReq_T),0xAAAA ,0xFFFF},

+ 19 - 0
app/bmc/msghndlr/App/App.h

@@ -0,0 +1,19 @@
+/*
+* Brief:	The header file of MsgHndlr_App packet.
+* Author:	Jimbo_Zhang@outlook.com
+* Date:		2019-9-16
+*/
+
+#ifndef __MSG_HNDLR_APP_H__
+#define __MSG_HNDLR_APP_H__
+
+#include "MsgHndlr.h"
+
+
+/*** Extern Definitions ***/
+extern const CmdHndlrMap_T  g_App_CmdHndlr []; /**< IPM Device and
+                        Application Device command handler table. */
+
+
+
+#endif /* __MSG_HNDLR_APP_H__ */

+ 14 - 14
app/bmc_server/ipmi_dev/AppDevice+.h → app/bmc/msghndlr/App/AppDevice+.h

@@ -25,7 +25,7 @@
 #ifndef APPDEVICE_PLUS_H
 #define APPDEVICE_PLUS_H
 
-#include "Types.h"
+#include "com_BmcType.h"
 
 /*** Function Prototypes ***/
 /**
@@ -34,19 +34,19 @@
  * IPMI2.0 RMCP+ Payload Command Handlers. Invoked by the message handler
  * @{
  **/
-extern int  ActivatePayload     (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int  DeactivatePayload   (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int  GetPayldActStatus   (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int  GetPayldInstInfo    (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int  SetUsrPayloadAccess (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int  GetUsrPayloadAccess (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int  GetChPayloadSupport (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int  GetChPayloadVersion (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int  GetChOemPayloadInfo (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int  GetChCipherSuites   (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int  SusResPayldEncrypt  (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int  SetChSecurityKeys   (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int  GetSysIfcCaps       (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
+extern int  ActivatePayload     ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int  DeactivatePayload   ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int  GetPayldActStatus   ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int  GetPayldInstInfo    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int  SetUsrPayloadAccess ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int  GetUsrPayloadAccess ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int  GetChPayloadSupport ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int  GetChPayloadVersion ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int  GetChOemPayloadInfo ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int  GetChCipherSuites   ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int  SusResPayldEncrypt  ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int  SetChSecurityKeys   ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int  GetSysIfcCaps       ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
 /** @} */
 
 #endif  /* APPDEVICE_H */

+ 95 - 0
app/bmc/msghndlr/App/AppDevice.h

@@ -0,0 +1,95 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************
+ *
+ * AppDevice.h
+ * AppDevice Commands Handler
+ *
+ * Author: Govind Kothandapani <govindk@ami.com>
+ *       : Rama Bisa <ramab@ami.com>
+ *       : Basavaraj Astekar <basavaraja@ami.com>
+ *       : Bakka Ravinder Reddy <bakkar@ami.com>
+ *
+ *****************************************************************/
+#ifndef APPDEVICE_H
+#define APPDEVICE_H
+
+#include "com_BmcType.h"
+#define EVT_MSG_BUF_SIZE    1  /**<Event Message maximum Buffer size */
+//#define USER_ID             (((uint32_t)'U'<< 24) | ((uint32_t)'S'<< 16) | ('E'<<8) | 'R')
+#define IPMI_ROOT_USER      ( 2 )
+#define TWENTY_BYTE_PWD  0x80
+#define CURRENT_CHANNEL_NUM		0x0E
+#define MASTER_RW_ERRCODE 0xFF
+#define IGNORE_ADD_OR_REMOVE 0
+#define IGNORE_ADD_OR_REMOVE_SHELL -1
+#define IPMI_15_PASSWORD_LEN (16 + 2)
+#define IPMI_20_PASSWORD_LEN (20 + 2)
+#define SYS_SEND_MSG_LUN 0x02
+
+/*** Extern Declaration ***/
+
+
+/*** Function Prototypes ***/
+/**
+ * @defgroup apcf2 BMC Watchdog Timer Commands
+ * @ingroup apcf
+ * IPMI BMC Watchdog Timer Command Handlers. Invoked by the message handler
+ * @{
+ **/
+extern int      ResetWDT            ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      SetWDT              ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      GetWDT              ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+/** @} */
+
+/**
+ * @defgroup apcf3 BMC Device and Messaging Commands
+ * @ingroup apcf
+ * IPMI BMC Device and Messaging Command Handlers. Invoked by the message handler
+ * @{
+ **/
+extern int      SetBMCGlobalEnables ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      GetBMCGlobalEnables ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      ClrMsgFlags         ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      GetMsgFlags         ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      EnblMsgChannelRcv   ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      GetMessage          ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      SendMessage         ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      ReadEvtMsgBuffer    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      GetBTIfcCap         ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      GetSystemGUID       ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      GetChAuthCap        ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      GetSessionChallenge ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      ActivateSession     ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      SetSessionPrivLevel ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      CloseSession        ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      GetSessionInfo      ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      GetAuthCode         ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      SetChAccess         ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      GetChAccess         ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      GetChInfo           ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      SetUserAccess       ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      GetUserAccess       ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      SetUserName         ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      GetUserName         ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      SetUserPassword     ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int      MasterWriteRead     ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int		SetSystemInfoParam  ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int 		GetSystemInfoParam  ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern uint8_t  IsChannelSuppGroups(uint8_t ChannelNum);
+extern int ModifyUsrGrp(char * UserName,uint8_t ChannelNum,uint8_t OldAccessLimit, uint8_t NewAccessLimit );
+
+/** @} */
+
+#endif  /* APPDEVICE_H */
+

+ 3768 - 4386
app/bmc_server/libipmimsghndler/App/AppDevice/AppDevice.c → app/bmc/msghndlr/App/AppDevice/AppDevice.c

@@ -1,4386 +1,3768 @@
-/****************************************************************
-****************************************************************
-**                                                            **
-**    (C)Copyright 2005-2006, American Megatrends Inc.        **
-**                                                            **
-**            All Rights Reserved.                            **
-**                                                            **
-**        6145-F, Northbelt Parkway, Norcross,                **
-**                                                            **
-**        Georgia - 30071, USA. Phone-(770)-246-8600.         **
-**                                                            **
-****************************************************************
-****************************************************************/
-/*****************************************************************
-*
-* AppDevice.c
-* AppDevice Commands Handler
-*
-* Author: Govind Kothandapani <govindk@ami.com>
-*       : Rama Bisa <ramab@ami.com>
-*       : Basavaraj Astekar <basavaraja@ami.com>
-*       : Bakka Ravinder Reddy <bakkar@ami.com>
-*
-*****************************************************************/
-#define ENABLE_DEBUG_MACROS  0
-
-#include "Types.h"
-#include "Debug.h"
-#include "IPMI_Main.h"
-#include "SharedMem.h"
-#include "Support.h"
-#include "Message.h"
-#include "IPMIDefs.h"
-#include "MsgHndlr.h"
-#include "IPMI_IPM.h"
-#include "IPMI_AppDevice.h"
-#include "AppDevice.h"
-#include "RMCP.h"
-#include "MD.h"
-#include "LANIfc.h"
-#include "WDT.h"
-#include "NVRAccess.h"
-#include "Util.h"
-//#include "libipmi_struct.h"
-//#include "nwcfg.h"
-#include "Ethaddr.h"
-//#include "IPMIConf.h"
-#include "IPMBIfc.h"
-#include "IPMI_KCS.h"
-//#include "ipmi_userifc.h"
-//#include "hmac_md5.h" 
-//#include "hmac.h" 
-//#include "MD5_128.h"
-#include "Badpasswd.h"
-#include "hal_hw.h"
-//#include "iniparser.h"
-#include "Session.h"
-//#include <linux/if.h>
-#include "LANConfig.h"
-#include <netdb.h>        /* getaddrinfo(3) et al.                       */
-#include <netinet/in.h>   /* sockaddr_in & sockaddr_in6 definition.      */
-//#include "userprivilege.h"
-#include <ctype.h>
-//#include "PDKBridgeMsg.h"
-//#include "featuredef.h"
-//#include "blowfish.h"
-#include "bmc_main.h"
-#include "session.h"
-#include "bmc_type.h"
-#define USER_ID_ENABLED 	0x01
-#define USER_ID_DISABLED 	0x02
-#define OP_USERID_ONLY_LENGTH    2
-#define OP_ENABLE_USER_ID    	 1
-#define OP_DISABLE_USER_ID    	 0
-#define BIT3_BIT0_MASK     0xf
-#define GET_AUTH_TYPE_MASK  0xc0
-#define AUTH_TYPE_V15	0x0
-#define AUTH_TYPE_V20	0x40
-#define AUTH_CODE_V15_MASK  0x0f
-#define AUTH_CODE_V15_1  0x1
-#define AUTH_CODE_V15_2  0x2
-#define AUTH_CODE_V15_3  0x5
-#define AUTH_CODE_V20_MASK  0x3f
-#define MIN_AUTH_CODE_V20 0x04
-#define MAX_AUTH_CODE_V20 0xc0
-#define NULL_USER                 1
-#define ZERO_SETSELECTOR 0x00
-#define MAX_TYPE_OF_ENCODING 0x02
-#define MAX_STRING_LENGTH_COPY 14
-
-#define ASCII_LATIN1        0x00
-#define UTF_8                     0x01
-#define UNICODE                 0x02
-
-/* Reserved bit macro definitions */
-#define RESERVED_BITS_SENDMS 0x03 //(BIT1 | BIT0)
-
-/* Auth code length */
-#define HMAC_SHA1_96_LEN            12
-
-//#if APP_DEVICE == 1
-
-#define COUNT_INCREASE  1	
-#define COUNT_DECREASE -1
-#define MAX_BT_PKT_LEN 255
-
-#define RESERVED_USERS_FILE "/etc/reservedusers"
-
-/*macro definitions for set user password options*/
-#define DISABLE_USER    0
-#define ENABLE_USER     1
-#define SET_PASSWORD    2
-#define TEST_PASSWORD   3
-
-/*** Global variables ***/
-_FAR_   INT8U   g_TmrRunning;
-/*** Module variables ***/
-static  _FAR_   MsgPkt_T    m_MsgPkt; /**< Message Packet for posting and retrieving messaged to/from queue */
-static INT8U m_Set_ChReserveBit[] ={0xF0,0x0,0x30};
-
-//extern IfcName_T Ifcnametable[MAX_LAN_CHANNELS];
-
-/**
- * @fn CheckReservedUsers
- * @brief This function will checks for reserved users.
- * @param  Username - Username.
- * @retval availability of reserved users.
- */
-static int CheckForReservedUsers(char *Username)
-{
-	//dictionary *dict = NULL;
-	//char *sectionname = NULL;
-	//int nsec=0 , i=0;
-
-	//TDBG("filename is %s\n",RESERVED_USERS_FILE);
-	//dict = iniparser_load(RESERVED_USERS_FILE);
-	//if(dict == NULL)
-	//{
-	//	TINFO("Unable to parse dummy users file :%s", RESERVED_USERS_FILE);
-	//	return -1;
-	//}
-	//nsec = iniparser_getnsec(dict);
-	//for (i=0;i<nsec;i++)
-	//{
-	//	sectionname = iniparser_getsecname (dict, i);
-	//	if(NULL == sectionname)
-	//	{
-	//		TINFO("Unable to get setion name of dummy users file :%s",RESERVED_USERS_FILE);
-	//		iniparser_freedict(dict);
-	//		return -1;
-	//	}
-	//	if(strcmp(sectionname, Username)==0)
-	//	{
-	//		iniparser_freedict(dict);
-	//		return -1;
-	//	}
-	//}
-	//iniparser_freedict(dict);
-	return 0;
-}
-
-static void UpdateCurrentEnabledUserCount(int value, int bmcInstId)
-{
-//	if (value == 0) return;
-//
-//	_FAR_ ChannelInfo_T* pChannelInfo = NULL;
-//	_FAR_ ChannelInfo_T* pNvrChannelInfo = NULL;
-//	_FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[bmcInstId];
-//	INT8U maxUserCount = pBMCInfo->IpmiConfig.MaxChUsers;
-//	INT8U channelIndex = 0;
-//
-//
-//	for (channelIndex = 0; channelIndex < MAX_NUM_CHANNELS; channelIndex++)
-//	{
-//		if (pBMCInfo->ChConfig[channelIndex].ChType == 0xff) continue;
-//
-//		pChannelInfo = (ChannelInfo_T*)&pBMCInfo->ChConfig[channelIndex].ChannelInfo;
-//
-//		if (((value > 0) && ((pChannelInfo->NoCurrentUser + value) > maxUserCount)) || 
-//			((value < 0) && ((pChannelInfo->NoCurrentUser + value) < 0)))
-//		{
-//			continue;
-//		}
-//
-//		pNvrChannelInfo = GetNVRChConfigs(pChannelInfo, bmcInstId);
-//
-//		pChannelInfo->NoCurrentUser+=value;	
-//		pNvrChannelInfo->NoCurrentUser+=value;
-//              FlushChConfigs((INT8U*)pNvrChannelInfo,pNvrChannelInfo->ChannelNumber,bmcInstId);
-//}
-}
-
-static int IsPrivilegeAvailable(INT8U requestedPrivilege, INT8U channelNumber, int bmcInstId)  
-{  
-//	//_FAR_   PMConfig_T* pPMConfig = (_FAR_ PMConfig_T*) GetNVRAddr(NVRH_PMCONFIG, bmcInstId);  
-//       BMCInfo_t *pBMCInfo = &g_BMCInfo;//[bmcInstId];
-//	INT8U EthIndex = GetEthIndex(channelNumber & 0x0F, bmcInstId);  
-//	INT8U privilege = 0x00;  
-//	
-//	if(0xff == EthIndex) return -1;  
-//	
-//	//Get requested privilege status (enabled or disabled) from PMConfig by channel 
-//	switch (requestedPrivilege)  
-//	{  
-//	case PRIV_CALLBACK:  
-//		privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeCallBack;  
-//		break;  
-//	
-//	case PRIV_USER:  
-//		privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeUser;  
-//		break;  
-//	
-//	case PRIV_OPERATOR:  
-//		privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeOperator;  
-//		break;  
-//	
-//	case PRIV_ADMIN:  
-//		privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeAdmin;  
-//		break;  
-//	
-//	case PRIV_OEM:  
-//		privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeOem;  
-//		break;  
-//	
-//	default:  
-//		return -1;  
-//	} 
-//	
-//	//All bits are 0 that means privilege level is disabled  
-//	return ((privilege != 0x00) ? 0 : -1);  
-}
-
-/*-------------------------------------
-* ValidateIPMBChksum1
-*-------------------------------------*/
-/* Function to validate IPMB Checksum1 for SendMessage Cmd */
-static int ValidateIPMBChksum1(_NEAR_ INT8U* Data)
-{
-    int i=0;
-    INT8U chksum=0;
-
-    for (i = 0; i < 3; i++)
-    {
-        chksum += *(Data + i);
-    }
-
-    if (chksum != 0)
-    {
-        return FALSE;
-    }
-    return TRUE;
-
-}
-
-
-/*-------------------------------------
-* ResetWDT
-*-------------------------------------*/
-int
-ResetWDT (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    INT8U	u8ExpirationFlag;
-//    BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
-//
-//
-//    if (pBMCInfo->Msghndlr.TmrSet == FALSE)
-//    {
-//        *pRes = CC_ATTEMPT_TO_RESET_UNIN_WATCHDOG;
-//        return sizeof (*pRes);
-//    }
-//
-//    // save the WDT expiration flag for later use
-//    u8ExpirationFlag = g_WDTTmrMgr.WDTTmr.ExpirationFlag;
-//
-//
-//    /* Reset of Watchdog should not happen once
-//        once pretimeout interrupt interval is reached*/
-//    if(pBMCInfo->WDTPreTmtStat == TRUE)
-//    {
-//        *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
-//        return sizeof (*pRes);
-//    }
-//
-//    g_WDTTmrMgr.TmrPresent  = TRUE;
-//    g_WDTTmrMgr.TmrInterval = pBMCInfo->WDTConfig.InitCountDown;
-//    g_WDTTmrMgr.PreTimeOutInterval = SEC_TO_MS * pBMCInfo->WDTConfig.PreTimeOutInterval;
-//
-//    /* if the pre-timeout interrupt is not configured, adjust the pre-timeout interrupt
-//        timeout value beyound the regular WDT timeout value so that it won't get triggered
-//        before the WDT timeout. */
-//    if ((pBMCInfo->WDTConfig.TmrActions & 0x70) == 0)
-//    {
-//        g_WDTTmrMgr.PreTimeOutInterval = g_WDTTmrMgr.TmrInterval+ 1;
-//    }
-//
-//    _fmemcpy (&g_WDTTmrMgr.WDTTmr, &pBMCInfo->WDTConfig, sizeof (WDTConfig_T));
-//
-//    // restore the WDT expiration flag, don't use the one from the flash
-//    g_WDTTmrMgr.WDTTmr.ExpirationFlag = u8ExpirationFlag;
-//
-//    // clear WDT sensor event history
-//    if( g_corefeatures.internal_sensor == ENABLED )
-//        RestartWD2Sensor(BMCInst);
-//
-//    if(g_corefeatures.wdt_flush_support == ENABLED )
-//    {
-//        FlushIPMI((INT8U*)&pBMCInfo->WDTConfig,(INT8U*)&pBMCInfo->WDTConfig,pBMCInfo->IPMIConfLoc.WDTDATAddr,
-//                       sizeof(WDTConfig_T),BMCInst);
-//    }
-//
-//    if(BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent == FALSE)
-//    {
-//        LOCK_BMC_SHARED_MEM(BMCInst);
-//        BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning=TRUE;
-//        BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent=TRUE;
-//        UNLOCK_BMC_SHARED_MEM(BMCInst);
-//        sem_post(&g_BMCInfo;//[BMCInst].WDTSem);
-//    }
-//    else
-//    {
-//        LOCK_BMC_SHARED_MEM(BMCInst);
-//        BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning=TRUE;
-//        BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent=TRUE;
-//        UNLOCK_BMC_SHARED_MEM(BMCInst);
-//        //Set SetWDTUpdated flag to reload initial countdown value.
-//        g_BMCInfo[BMCInst].SetWDTUpdated = TRUE; 
-//    }
-//
-//
-//    *pRes = CC_NORMAL;
-//
-//    return sizeof (*pRes);
-}
-
-
-
-/*---------------------------------------
-* SetWDT
-*---------------------------------------*/
-int
-SetWDT (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_  SetWDTReq_T*    pSetWDTReq = (_NEAR_ SetWDTReq_T*)pReq;
-//#if GET_MSG_FLAGS != UNIMPLEMENTED
-//    GetMsgFlagsRes_T   GetMsgFlagsRes;
-//#endif
-//    _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
-//
-//
-//    //Check for Reserved bits
-//     if((pSetWDTReq->TmrUse & (BIT5 | BIT4 | BIT3)) || !(pSetWDTReq->TmrUse & (BIT2 | BIT1 | BIT0)) || ((pSetWDTReq->TmrUse & (BIT1 | BIT2)) == (BIT1 | BIT2)) || 
-//        (pSetWDTReq->TmrActions & (BIT7 |BIT6 | BIT3 | BIT2)) || (pSetWDTReq->ExpirationFlag & (BIT7 | BIT6 | BIT0)))
-//    {
-//        *pRes = CC_INV_DATA_FIELD;
-//        return sizeof(*pRes);
-//    }
-//
-//#if NO_WDT_PRETIMEOUT_INTERRUPT == 1
-//    // do not support pre-timeout interrupt
-//    if (pSetWDTReq->TmrActions & 0x70)
-//    {
-//        *pRes = CC_INV_DATA_FIELD;
-//        return sizeof(*pRes);
-//    }
-//#endif
-//
-//    pSetWDTReq->InitCountDown = htoipmi_u16(pSetWDTReq->InitCountDown);
-//
-//    // error out if the pre-timeout interrupt is greater than the initial countdown value
-//    if (pSetWDTReq->InitCountDown < 10 * pSetWDTReq->PreTimeOutInterval)
-//    {
-//        *pRes = CC_INV_DATA_FIELD;
-//        return sizeof(*pRes);
-//    }
-//
-//    // only clear the memory version of the bit(s) when the input bit is set #31175
-//    g_WDTTmrMgr.WDTTmr.ExpirationFlag &= ~pSetWDTReq->ExpirationFlag;
-//    pSetWDTReq->ExpirationFlag = g_WDTTmrMgr.WDTTmr.ExpirationFlag;
-//
-//
-//    /* Copy the Timer configuration in NVRAM */
-//    LOCK_BMC_SHARED_MEM(BMCInst);
-//    _fmemset ((_FAR_ INT8U*)&pBMCInfo->WDTConfig, 0, sizeof (WDTConfig_T));
-//    _fmemcpy ((_FAR_ INT8U*)&pBMCInfo->WDTConfig, (_FAR_ INT8U*)pSetWDTReq, sizeof (SetWDTReq_T));
-//    UNLOCK_BMC_SHARED_MEM(BMCInst);
-//
-//    if (TRUE ==BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning)
-//    {
-//        /* To check wheather Dont stop bit is set or not */
-//        if (pSetWDTReq->TmrUse & 0x40)
-//        {
-//            /* Set the count down value to given value */
-//            g_WDTTmrMgr.TmrPresent = TRUE;
-//            LOCK_BMC_SHARED_MEM(BMCInst);
-//            BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent =TRUE;
-//            UNLOCK_BMC_SHARED_MEM(BMCInst);
-//            g_WDTTmrMgr.TmrInterval= pSetWDTReq->InitCountDown;
-//            g_WDTTmrMgr.PreTimeOutInterval = (SEC_TO_MS * pSetWDTReq->PreTimeOutInterval);
-//
-//            /* If PreTimeOutInt is set, clear it */
-//            if (0 != (pSetWDTReq->TmrActions & 0x70))
-//            {
-//                pSetWDTReq->TmrActions &= ~0x70;
-//            }
-//            else
-//            {
-//                // if the pre-timeout interrupt is not configured, adjust the pre-timeout interrupt
-//                // timeout value beyound the regular WDT timeout value so that it won't get triggered
-//                // before the WDT timeout.
-//                g_WDTTmrMgr.PreTimeOutInterval = pSetWDTReq->InitCountDown + 1;
-//            }
-//            _fmemcpy (&g_WDTTmrMgr.WDTTmr, pSetWDTReq, sizeof (WDTConfig_T ));
-//
-//        }
-//        else
-//        {
-//            /* Stop the timer */
-//            g_WDTTmrMgr.TmrPresent = FALSE;
-//            LOCK_BMC_SHARED_MEM(BMCInst);
-//            BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning=FALSE;
-//            BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent =FALSE;
-//            UNLOCK_BMC_SHARED_MEM(BMCInst);
-//            g_WDTTmrMgr.TmrInterval= pSetWDTReq->InitCountDown;
-//            g_WDTTmrMgr.PreTimeOutInterval = SEC_TO_MS * pSetWDTReq->PreTimeOutInterval;
-//            // clear WDT sensor event history
-//            if( g_corefeatures.internal_sensor == ENABLED)
-//                RestartWD2Sensor(BMCInst);
-//        }
-//
-//        /* Clear the  pre-timeout interupt flag */
-//        LOCK_BMC_SHARED_MEM(BMCInst);
-//        pBMCInfo->WDTConfig.PreTimeoutActionTaken = 0x00;
-//        BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x08; /* Clear the flag */
-//#if GET_MSG_FLAGS != UNIMPLEMENTED
-//        // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
-//        GetMsgFlags (NULL, 0, (INT8U *)&GetMsgFlagsRes,BMCInst);
-//        TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
-//                GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
-//        if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
-//#else
-//        if((BMC_GET_SHARED_MEM(BMCInst)->MsgFlags & BIT3_BIT0_MASK) == 0)
-//#endif
-//        {
-//            /* Clear the SMS_ATN bit */
-//            if (pBMCInfo->IpmiConfig.KCS1IfcSupport == 1)
-//            {
-//                CLEAR_SMS_ATN (0, BMCInst);
-//            }
-//            if (pBMCInfo->IpmiConfig.KCS2IfcSupport == 1)
-//            {
-//                CLEAR_SMS_ATN (1, BMCInst);
-//            }
-//            if (pBMCInfo->IpmiConfig.KCS3IfcSuppport == 1)
-//            {
-//                CLEAR_SMS_ATN (2, BMCInst);
-//            }
-//        }
-//            UNLOCK_BMC_SHARED_MEM(BMCInst);
-//
-//        }
-//        else
-//        {
-//            g_WDTTmrMgr.TmrInterval = pSetWDTReq->InitCountDown;
-//            g_WDTTmrMgr.TmrPresent = FALSE;
-//            LOCK_BMC_SHARED_MEM(BMCInst);
-//            BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent =FALSE;
-//            UNLOCK_BMC_SHARED_MEM(BMCInst);
-//            // clear WDT sensor event history
-//            if( g_corefeatures.internal_sensor == ENABLED)
-//                RestartWD2Sensor(BMCInst);
-//        }
-//
-//    // Modify ARP status to resume the thread
-//    // after receiving set Watchdog Timer command
-//    //BMC_GET_SHARED_MEM(BMCInst)->GratArpStatus = RESUME_ARPS;
-//    
-//    int i = 0; 
-//
-//    for (i = 0; i < MAX_LAN_CHANNELS; i++)	
-//    {
-//        if((pBMCInfo->LanIfcConfig[i].Enabled == TRUE)
-//                && (pBMCInfo->LanIfcConfig[i].Up_Status == LAN_IFC_UP))
-//        {
-//            BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[i] = RESUME_ARPS; 	
-//            UpdateArpStatus(pBMCInfo->LanIfcConfig[i].Ethindex, BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning, BMCInst);  
-//        }
-//    }
-//    if(g_corefeatures.wdt_flush_support == ENABLED )
-//    {
-//        FlushIPMI((INT8U*)&pBMCInfo->WDTConfig,(INT8U*)&pBMCInfo->WDTConfig,pBMCInfo->IPMIConfLoc.WDTDATAddr,
-//              sizeof(WDTConfig_T),BMCInst);
-//    }
-//    // set the "Don't Log" bit
-//    g_WDTTmrMgr.WDTTmr.TmrUse &= 0x7F;
-//    g_WDTTmrMgr.WDTTmr.TmrUse |= (pSetWDTReq->TmrUse & 0x80);
-//
-//    g_BMCInfo[BMCInst].SetWDTUpdated = TRUE;
-//    g_BMCInfo[BMCInst].Msghndlr.TmrSet = TRUE;
-//    pBMCInfo->WDTPreTmtStat = FALSE;
-//    *pRes = CC_NORMAL;
-//
-//    return sizeof (*pRes);
-}
-
-
-/*---------------------------------------
-* GetWDT
-*---------------------------------------*/
-int
-GetWDT (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_  GetWDTRes_T*    pGetWDTRes = (_NEAR_ GetWDTRes_T*)pRes;
-//    BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
-//
-//    /* Copy the current settings from the NVRAM */
-//    LOCK_BMC_SHARED_MEM(BMCInst);
-//    _fmemcpy ((_FAR_ INT8U*)&pGetWDTRes->CurrentSettings,
-//            (_FAR_ INT8U*)&pBMCInfo->WDTConfig, sizeof (WDTConfig_T));
-//    UNLOCK_BMC_SHARED_MEM(BMCInst);
-//
-//    // get the WDT expiration from the global veriable in memory, not from the flash
-//    pGetWDTRes->CurrentSettings.ExpirationFlag = g_WDTTmrMgr.WDTTmr.ExpirationFlag;
-//
-//    // get the current "Don't Log" bit
-//    pGetWDTRes->CurrentSettings.TmrUse &= 0x7F;
-//    pGetWDTRes->CurrentSettings.TmrUse |= (g_WDTTmrMgr.WDTTmr.TmrUse & 0x80);
-//    if (TRUE == BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent)
-//    {
-//         // set the WDT running bit #30235/30467
-//        pGetWDTRes->CurrentSettings.TmrUse |= 0x40;
-//        /* Present count down in 1/100 of second */
-//    }
-//    else
-//    {
-//         // clear the WDT running bit #30235/30467  for Timer Use (ie) WatchDog Timer status
-//        pGetWDTRes->CurrentSettings.TmrUse &= ~0x40;
-//        pGetWDTRes->CurrentSettings.ExpirationFlag = (pGetWDTRes->CurrentSettings.ExpirationFlag) & 0x3E;
-//    }
-//
-//    pGetWDTRes->PresentCountDown			   = g_WDTTmrMgr.TmrInterval;
-//    pGetWDTRes->CurrentSettings.InitCountDown = htoipmi_u16(pGetWDTRes->CurrentSettings.InitCountDown);
-//    pGetWDTRes->CompletionCode                = CC_NORMAL;
-//
-//    return sizeof (GetWDTRes_T);
-}
-
-
-/*---------------------------------------
-* SetBMCGlobalEnables
-*---------------------------------------*/
-int
-SetBMCGlobalEnables (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    INT8U GblEnblByte = *pReq;
-//    BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
-//    MsgPkt_T MsgPkt;
-//
-//    _fmemset (&MsgPkt, 0, sizeof (MsgPkt_T));
-//
-//    /* Check For the reserved bit 4 */
-//    if ( GblEnblByte & BIT4)
-//      {
-//         *pRes = CC_INV_DATA_FIELD;
-//          return sizeof (*pRes);
-//      }
-//
-//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
-//    if (((BMC_GET_SHARED_MEM (BMCInst)->GlobalEnables ^ GblEnblByte)) & 0x20) 
-//    {
-//        /* OEM 0 puts us in ICTS compatibility mode for IPMIv2,
-//         * Send a message to lan process so it can change behavior
-//         */
-//        MsgPkt.Channel    = GetLANChannel(0, BMCInst);
-//        MsgPkt.Param      = LAN_ICTS_MODE;
-//        MsgPkt.Privilege  = PRIV_LOCAL;
-//        if (GblEnblByte & 0x20)
-//            MsgPkt.Cmd = 1;
-//        else
-//            MsgPkt.Cmd = 0;
-//        PostMsg(&MsgPkt,LAN_IFC_Q,BMCInst);
-//    }
-//
-//    BMC_GET_SHARED_MEM (BMCInst)->GlobalEnables = GblEnblByte;
-//    *pRes = CC_NORMAL;
-//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-
-    return sizeof (*pRes);
-}
-
-
-/*---------------------------------------
-* GetBMCGlobalEnables
-*---------------------------------------*/
-int
-GetBMCGlobalEnables (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-   // _NEAR_  GetBMCGblEnblRes_T* pGetBMCGblEnblRes = (_NEAR_ GetBMCGblEnblRes_T*)pRes;
-   // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
-
-   // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
-   // pGetBMCGblEnblRes->CompletionCode = CC_NORMAL;
-   // pGetBMCGblEnblRes->BMCGblEnblByte = BMC_GET_SHARED_MEM (BMCInst)->GlobalEnables;
-   // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-
-   // return sizeof (GetBMCGblEnblRes_T);
-}
-
-
-/*---------------------------------------
-* ClrMsgFlags
-*---------------------------------------*/
-int
-ClrMsgFlags (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_ ClearMsgsFlagReq_T* pClearMsgsFlagReq = (_NEAR_ ClearMsgsFlagReq_T*)pReq;
-//    INT8U *kcsifcnum;
-//#if GET_MSG_FLAGS != UNIMPLEMENTED
-//    GetMsgFlagsRes_T   GetMsgFlagsRes;
-//#endif
-//    _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
-//
-//    //Check for Reserved bits
-//    if(pClearMsgsFlagReq->Flag & (BIT4 | BIT2))
-//    {
-//        *pRes = CC_INV_DATA_FIELD;
-//        return sizeof(*pRes);
-//    }
-//
-//    OS_THREAD_TLS_GET(g_tls.CurKCSIfcNum,kcsifcnum);
-//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
-//    /* Flush Receive Message Queue */
-//    if (0 != (pClearMsgsFlagReq->Flag & 0x01))
-//    {
-//        while (0 == GetMsg (&m_MsgPkt, &g_RcvMsgQ[*kcsifcnum][0], WAIT_NONE,BMCInst))
-//        {
-//            BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum]--;
-//        }
-//
-//        BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x01; /* Clear the flag */
-//    }
-//
-//    /* Flush Event Message Buffer */
-//    if (0 != (pClearMsgsFlagReq->Flag & 0x02))
-//    {
-//        OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->EventMutex,WAIT_INFINITE);
-//        while (0 == GetMsg (&m_MsgPkt, EVT_MSG_Q, WAIT_NONE,BMCInst))
-//        {
-//            BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg--;
-//        }
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
-//        BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x02; /* Clear the flag */
-//    }
-//
-//    /* Clear WatchdogTimer Interrupt*/
-//    if (0 != (pClearMsgsFlagReq->Flag & 0x08))
-//    {
-//        /* Clear the  pre-timeout interupt flag */
-//        pBMCInfo->WDTConfig.PreTimeoutActionTaken = 0x00;
-//        BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x08; /* Clear the flag */
-//	if(g_corefeatures.wdt_flush_support == ENABLED )
-//    	{
-//            FlushIPMI((INT8U*)&pBMCInfo->WDTConfig,(INT8U*)&pBMCInfo->WDTConfig,pBMCInfo->IPMIConfLoc.WDTDATAddr,
-//                           sizeof(WDTConfig_T),BMCInst);
-//       }
-//
-//    }
-//
-//#if GET_MSG_FLAGS != UNIMPLEMENTED
-//    // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
-//    GetMsgFlags (NULL, 0, (INT8U *)&GetMsgFlagsRes,BMCInst);
-//    TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
-//            GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
-//    if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
-//#else
-//    if((BMC_GET_SHARED_MEM(BMCInst)->MsgFlags & BIT3_BIT0_MASK) == 0)
-//#endif
-//    {
-//        /* Clear the SMS_ATN bit */
-//        if (pBMCInfo->IpmiConfig.KCS1IfcSupport == 1)
-//        {
-//            CLEAR_SMS_ATN (0, BMCInst);
-//        }
-//        if (pBMCInfo->IpmiConfig.KCS2IfcSupport == 1)
-//        {
-//            CLEAR_SMS_ATN (1, BMCInst);
-//        }
-//        if (pBMCInfo->IpmiConfig.KCS3IfcSuppport == 1)
-//        {
-//            CLEAR_SMS_ATN (2, BMCInst);
-//        }
-//    }
-//
-//    *pRes = CC_NORMAL;
-//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//
-//    return sizeof (*pRes);
-}
-
-
-/*---------------------------------------
- GetMsgFlags
----------------------------------------*/
-int
-GetMsgFlags (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_  GetMsgFlagsRes_T*   pGetMsgFlagsRes = (_NEAR_ GetMsgFlagsRes_T*)pRes;
-//    BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
-//    INT8U *kcsifcnum;
-//
-//    OS_THREAD_TLS_GET(g_tls.CurKCSIfcNum,kcsifcnum);
-//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
-//    /* get the message flags */
-//    pGetMsgFlagsRes->MsgFlags = BMC_GET_SHARED_MEM (BMCInst)->MsgFlags;
-//
-//    if (BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg >= EVT_MSG_BUF_SIZE)
-//    {
-//        /* If Event MessageBuffer is Full set the BIT */
-//        pGetMsgFlagsRes->MsgFlags |= 0x02;
-//    }
-//    else
-//    {
-//        /* else reset the Flag */
-//        pGetMsgFlagsRes->MsgFlags &= ~0x02;
-//    }
-//
-//    if(kcsifcnum != NULL && 0 != BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum])
-//    {
-//        /* if any Message in ReceiveMsgQ set the Flag */
-//        pGetMsgFlagsRes->MsgFlags |= 0x01;
-//    }
-//    else
-//    {
-//        /* else reset the Flag */
-//        pGetMsgFlagsRes->MsgFlags &= ~0x01;
-//    }
-//
-//    /* get the  Pre-Timeout Bits Value & Set it to Response Data */
-//    //PRETIMEOUT BIT is 3rd bit so changed accordingly
-//    pGetMsgFlagsRes->MsgFlags |= (pBMCInfo->WDTConfig.PreTimeoutActionTaken & 0x08);
-//
-//    /* Update the Message flags in shared Mem */
-//    BMC_GET_SHARED_MEM (BMCInst)->MsgFlags |=  pGetMsgFlagsRes->MsgFlags;
-//    pGetMsgFlagsRes->CompletionCode = CC_NORMAL;
-//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//
-//    return sizeof (GetMsgFlagsRes_T);
-}
-
-
-/*---------------------------------------
-* EnblMsgChannelRcv
-*---------------------------------------*/
-int
-EnblMsgChannelRcv (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_  EnblMsgChRcvReq_T*  pEnblMsgChRcvReq = (_NEAR_ EnblMsgChRcvReq_T*)pReq;
-//    _NEAR_  EnblMsgChRcvRes_T*  pEnblMsgChRcvRes = (_NEAR_ EnblMsgChRcvRes_T*)pRes;
-//    _FAR_   ChannelInfo_T*      pChannelInfo;
-//    BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
-//
-//    //Check for Reserved bits
-//    if(pEnblMsgChRcvReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4))
-//    {
-//        pEnblMsgChRcvRes->CompletionCode = CC_INV_DATA_FIELD;
-//        return sizeof(*pRes);
-//    }
-//
-//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
-//    pChannelInfo = getChannelInfo (pEnblMsgChRcvReq->ChannelNum & 0x0F, BMCInst);
-//
-//    TDBG ("ENBL_MSG_CH_RCV: processing..\n");
-//
-//    if (NULL == pChannelInfo)
-//    {
-//        pEnblMsgChRcvRes->CompletionCode = CC_INV_DATA_FIELD;
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        return sizeof (*pRes);
-//    }
-//
-//    switch (pEnblMsgChRcvReq->ChannelState)
-//    {
-//        case 0:
-//            /* disable Receive Message Queue for this Channel */
-//            pChannelInfo->ReceiveMsgQ = 0x0;
-//            break;
-//
-//        case 1:
-//            /*enable Recevive Message Queue for this Channel */
-//            pChannelInfo->ReceiveMsgQ = 0x1;
-//            break;
-//
-//        case 2:
-//            /*get Channel State */
-//            pEnblMsgChRcvRes->ChannelState = pChannelInfo->ReceiveMsgQ;
-//            break;
-//
-//        default:
-//            pEnblMsgChRcvRes->CompletionCode = CC_INV_DATA_FIELD;
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//            return sizeof (*pRes);
-//    }
-//
-//    pEnblMsgChRcvRes->CompletionCode = CC_NORMAL;
-//
-//    /*get Channel Number */
-//    pEnblMsgChRcvRes->ChannelNum = pEnblMsgChRcvReq->ChannelNum & 0x0F;
-//
-//    pEnblMsgChRcvRes->ChannelState = pChannelInfo->ReceiveMsgQ;
-//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//
-//    return sizeof (EnblMsgChRcvRes_T);
-}
-
-
-/*---------------------------------------
-* GetMessage
-*---------------------------------------*/
-int
-GetMessage (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_  GetMsgRes_T*    pGetMsgRes = (_NEAR_ GetMsgRes_T*)pRes;
-//    _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];        
-//    INT8U           Index = 0,*kcsifcnum;
-//#if GET_MSG_FLAGS != UNIMPLEMENTED
-//    GetMsgFlagsRes_T   GetMsgFlagsRes;
-//#endif
-//
-//    OS_THREAD_TLS_GET(g_tls.CurKCSIfcNum,kcsifcnum);
-//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
-//    if (0 != GetMsg (&m_MsgPkt, &g_RcvMsgQ[*kcsifcnum][0], WAIT_NONE,BMCInst))
-//    {
-//        /* if Queue is Empty */
-//        pGetMsgRes->CompletionCode = CC_GET_MSG_QUEUE_EMPTY;
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//        return  sizeof (*pRes);
-//    }
-//
-//    BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum]--;
-//
-//#if GET_MSG_FLAGS != UNIMPLEMENTED
-//    // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
-//    GetMsgFlags (NULL, 0, (INT8U *)&GetMsgFlagsRes,BMCInst);
-//    TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
-//            GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
-//    if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
-//#else
-//    if (0 == BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum])
-//#endif
-//    {
-//        /* Clear the SMS_ATN bit */
-//        CLEAR_SMS_ATN (*kcsifcnum,BMCInst);
-//    }
-//
-//    /* Completion Code  */
-//    pGetMsgRes->CompletionCode  = CC_NORMAL;
-//    /* Channel number and privilege level */
-//    pGetMsgRes->ChannelNum      = m_MsgPkt.Channel;
-//
-//    Index = sizeof (GetMsgRes_T);
-//
-//    /* First byte should be session handle */
-//    if(pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)
-//    {
-//        if ((PRIMARY_IPMB_CHANNEL != m_MsgPkt.Channel) && (pBMCInfo->SecondaryIPMBCh != m_MsgPkt.Channel))
-//        {
-//            pGetMsgRes->ChannelNum |= m_MsgPkt.Privilege << 0x04;
-//            pRes [Index++] = m_MsgPkt.Param;
-//        }
-//    }
-//    else
-//    {
-//        if(PRIMARY_IPMB_CHANNEL != m_MsgPkt.Channel)
-//        {
-//                pGetMsgRes->ChannelNum |= m_MsgPkt.Privilege << 0x04;
-//                pRes [Index++] = m_MsgPkt.Param;
-//        }
-//    }
-//
-//    /* copy the Message data    */
-//    _fmemcpy ((_FAR_ INT8U*)&pRes[Index], &m_MsgPkt.Data[1], m_MsgPkt.Size-1);
-//
-//    IPMI_DBG_PRINT ("GetMsg: Sending the following data through requested channel\n");
-//    IPMI_DBG_PRINT_BUF (pRes, m_MsgPkt.Size + Index);
-//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//
-//    return  ((m_MsgPkt.Size-1)+ Index);      /*+ 2 for completion code & channel No. */
-}
-
-
-/*---------------------------------------
-* SendMessage
-*---------------------------------------*/
-int
-SendMessage (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_  SendMsgReq_T* pSendMsgReq = (_NEAR_ SendMsgReq_T*)pReq;
-//    _NEAR_  SendMsgRes_T* pSendMsgRes = (_NEAR_ SendMsgRes_T*)pRes;
-//    _NEAR_  IPMIMsgHdr_T* pIPMIMsgHdr;
-//    char QueueName[MAX_STR_LENGTH];
-//    _FAR_  BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
-//    INT8U         Tracking;
-//    INT8U         Channel=0,resaddr=0;
-//    INT8U         ResLen = 1;
-//    INT8U         RetVal = 0;
-//    INT8U         Offset = 1;
-//    INT8U         SeqNum = pBMCInfo->SendMsgSeqNum;
-//    INT8U         PBTbl = PRIMARY_PB_TBL;
-//    INT8U         SrcSessionHndl = 0;
-//    _FAR_   ChannelInfo_T*      pChannelInfo;
-//    int tmpBMCInst= 0;
-//    MsgPkt_T ResPkt;
-//    _FAR_ SessionInfo_T* pSessionInfo = NULL;
-//    INT32U *CurSesID;
-//    INT8U *curprivlevel,*curchannel,*kcsifcnum;
-//
-//    if (ReqLen < 1)
-//    {
-//        *pRes = CC_REQ_INV_LEN;
-//        return  sizeof (*pRes);
-//    }
-//
-//    if(pSendMsgReq->ChNoTrackReq == 0xC0)
-//    {
-//        *pRes = CC_INV_DATA_FIELD;
-//        return sizeof (*pRes);
-//    }
-//
-//    /* Get the channel number */
-//    Channel = pSendMsgReq->ChNoTrackReq & 0x0F;
-//
-//    /* Get Tracking field */
-//    Tracking = pSendMsgReq->ChNoTrackReq >> 6;
-//
-//    if (Tracking == RESERVED_BITS_SENDMS)
-//    {
-//        *pRes = CC_INV_DATA_FIELD;
-//        return sizeof (*pRes);
-//    }
-//
-//    OS_THREAD_TLS_GET(g_tls.CurSessionID,CurSesID);
-//    OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
-//    OS_THREAD_TLS_GET(g_tls.CurKCSIfcNum,kcsifcnum);
-//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
-//    if(g_corefeatures.mbmc_single_nic == ENABLED
-//        && g_corefeatures.ifc_specific_msg_handling != ENABLED)
-//    {
-//        ResLen = 0;
-//        g_MBMCInfo.sbmcinst = BMCInst;
-//        memset((char *)&ResPkt,0,sizeof(MsgPkt_T));
-//        pIPMIMsgHdr = (IPMIMsgHdr_T*)(&pBMCInfo->LANConfig.MsgReq.Data[sizeof (IPMIMsgHdr_T) + 1]);
-//        m_MsgPkt.Param    = PARAM_IFC;
-//        m_MsgPkt.Channel  = *curchannel;
-//        m_MsgPkt.NetFnLUN = pIPMIMsgHdr->NetFnLUN;
-//        m_MsgPkt.Cmd      = pIPMIMsgHdr->Cmd;
-//        m_MsgPkt.Privilege =  PRIV_ADMIN;
-//        m_MsgPkt.Size     = pBMCInfo->LANConfig.MsgReq.Size - sizeof (IPMIMsgHdr_T) - 2;
-//        _fmemcpy (m_MsgPkt.Data, pIPMIMsgHdr, m_MsgPkt.Size);
-//
-//        if(g_PDKHandle[PDK_MBMCSINGLENICSENDMSG] != NULL)
-//        {
-//            tmpBMCInst = ( (int (*)(INT8U,int) ) g_PDKHandle[PDK_MBMCSINGLENICSENDMSG]) ( m_MsgPkt.Data[0],BMCInst);
-//        }
-//
-//        if(tmpBMCInst == 0)
-//        {
-//            resaddr = (m_MsgPkt.Data[0] - pBMCInfo->IpmiConfig.BMCSlaveAddr) >> 1;
-//            if(0 <= resaddr && resaddr < BMCInstCount && (m_MsgPkt.Data[0] - pBMCInfo->IpmiConfig.BMCSlaveAddr)%2 == 0) 
-//            {
-//                tmpBMCInst = resaddr + 1;
-//            }
-//            else
-//            {
-//                *pRes = CC_INV_DATA_FIELD;
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//                return sizeof(*pRes);
-//            }
-//        }
-//
-//        _fmemcpy(ResPkt.Data,pBMCInfo->LANConfig.MsgReq.Data,sizeof(IPMIMsgHdr_T));
-//         ResPkt.Param = BRIDGING_REQUEST;
-//         ResPkt.Cmd = pIPMIMsgHdr->Cmd;
-//         ((IPMIMsgHdr_T *)ResPkt.Data)->NetFnLUN = ((pBMCInfo->LANConfig.MsgReq.NetFnLUN >> 2) +1) << 2;
-//         ResPkt.Data [sizeof(IPMIMsgHdr_T)] = CC_NORMAL;
-//         ResPkt.Size = sizeof (IPMIMsgHdr_T) + 1 + 1; // IPMI Header + Completion Code + Second Checksum
-//         /* Calculate the Second CheckSum */
-//         ResPkt.Data[ResPkt.Size - 1] = CalculateCheckSum2 (ResPkt.Data, ResPkt.Size-1);
-//        if (0 != PostMsg (&ResPkt,LAN_RES_Q,BMCInst))
-//        {
-//            TDBG ("SendMsg: Failed to post message to interface queue\n");
-//        }
-//
-//        pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID,BMCInst);
-//        if (NULL != pSessionInfo)
-//        {
-//            g_MBMCInfo.SrcSessionHndl = pSessionInfo->SessionHandle;
-//        }
-//        else
-//        {
-//            *pRes = CC_UNSPECIFIED_ERR;
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//            return sizeof(*pRes);
-//        }
-//        
-//        memset(QueueName,0,sizeof(QueueName));
-//        sprintf(QueueName,"%s%d",LAN_IFC_Q,BMCInst);
-//        strcpy ((char *)m_MsgPkt.SrcQ,QueueName);
-//
-//        /* Post the message to Message Handler */
-//        if (0 != PostMsg (&m_MsgPkt,MSG_HNDLR_Q,tmpBMCInst))
-//        {
-//            TDBG ("SendMsg: Failed to post message to interface queue\n");
-//        }
-//    }
-//    else
-//    {
-//        m_MsgPkt.Param    = BRIDGING_REQUEST;
-//        m_MsgPkt.Channel  = Channel;
-//        m_MsgPkt.Size     = ReqLen - 1; /* -1 to skip channel num */
-//
-//        /* Copy the message data */
-//        _fmemcpy (m_MsgPkt.Data, &pReq[1], m_MsgPkt.Size);
-//        /* Copy the IPMI Message header */
-//        pIPMIMsgHdr =  (_NEAR_ IPMIMsgHdr_T*)&m_MsgPkt.Data[Offset - 1];
-//        if(ValidateIPMBChksum1((_NEAR_ INT8U*)pIPMIMsgHdr) == FALSE)
-//        {
-//            *pRes = CC_INV_DATA_FIELD;
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//            return  sizeof (*pRes);
-//        }
-//
-//       if(m_MsgPkt.Data[ReqLen - 2] != CalculateCheckSum2 ((_FAR_ INT8U*)pIPMIMsgHdr, ReqLen - Offset - 1))
-//       {
-//            *pRes = CC_INV_DATA_FIELD;
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//            return  sizeof (*pRes);
-//       }
-//
-//#if 0
-//    	printf("SendMsg: ReqLen = %d, size = %ld\n",ReqLen,m_MsgPkt.Size);
-//
-//    	for(i = 0; i < m_MsgPkt.Size;i++)
-//    		printf("MsgPkt_Data %02X\n",m_MsgPkt.Data[i]);
-//    	printf("\n");
-//#endif
-//
-//        if(pBMCInfo->IpmiConfig.LANIfcSupport == 1)
-//        {
-//            /* To Check the Wheather  LAN Channel */
-//            if (IsLANChannel(*curchannel & 0xF, BMCInst))
-//            {
-//                _FAR_ SessionInfo_T* pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID,BMCInst);
-//
-//                if (NULL != pSessionInfo)
-//                {
-//                    SrcSessionHndl = pSessionInfo->SessionHandle;
-//                }
-//
-//                TDBG ("SendMsg: To LAN Interface for reference\n");
-//                // Offset++; : causes bridging issues
-//                strcpy ((char *)m_MsgPkt.SrcQ, LAN_IFC_Q);
-//            }
-//        }
-//
-//        if(pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
-//        {
-//            /* To Check the Wheather  Serial Channel */
-//            if (pBMCInfo->SERIALch != CH_NOT_USED && (*curchannel  & 0xF) == pBMCInfo->SERIALch && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
-//            {
-//                _FAR_ SessionInfo_T* pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID,BMCInst);
-//
-//                if (NULL != pSessionInfo)
-//                {
-//                    SrcSessionHndl = pSessionInfo->SessionHandle;
-//                }
-//
-//                TDBG ("SendMsg: To Serial Interface for reference\n");
-//                // Offset++; : causes bridging issues
-//                strcpy ((char *)m_MsgPkt.SrcQ, SERIAL_IFC_Q);
-//            }
-//        }
-//
-//        if((Channel == PRIMARY_IPMB_CHANNEL) && pBMCInfo->IpmiConfig.PrimaryIPMBSupport == 1)
-//        {
-//            TDBG ("SendMsg: To Primary IPMB Interface\n");
-//            strcpy ((char *)m_MsgPkt.SrcQ, IPMB_PRIMARY_IFC_Q);
-//        }
-//        else if((pBMCInfo->SecondaryIPMBCh != CH_NOT_USED && Channel == pBMCInfo->SecondaryIPMBCh) && pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 1)
-//        {
-//            TDBG ("SendMsg: To SMLink IPMB Interface\n");
-//            strcpy ((char *)m_MsgPkt.SrcQ, IPMB_SECONDARY_IFC_Q);
-//        }
-//        else if ((pBMCInfo->SERIALch != CH_NOT_USED && Channel == pBMCInfo->SERIALch) && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
-//        {
-//            TDBG ("SendMsg: To Serial Interface\n");
-//            Offset++;
-//            strcpy ((char *)m_MsgPkt.SrcQ, SERIAL_IFC_Q);
-//        }
-//        else if ((pBMCInfo->ICMBCh != CH_NOT_USED && Channel == pBMCInfo->ICMBCh) && pBMCInfo->IpmiConfig.ICMBIfcSupport == 1)
-//        {
-//            TDBG ("SendMsg: To ICMB Interface\n");
-//            strcpy ((char *)m_MsgPkt.SrcQ, ICMB_IFC_Q);
-//        }
-//        else if(pBMCInfo->SYSCh != CH_NOT_USED && Channel == pBMCInfo->SYSCh)
-//        {
-//            TDBG ("SendMsg: To System Interface\n");
-//            /*
-//             * According to IPMI Spec v2.0.
-//             * It is recommended to send CC_DEST_UNAVAILABLE
-//             * completion code, if the channel is disabled for
-//             * receiving messages.
-//             * */
-//             OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
-//            pChannelInfo = getChannelInfo(Channel,BMCInst);
-//            if(NULL == pChannelInfo)
-//            {
-//                *pRes = CC_INV_DATA_FIELD;
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//                return  sizeof (*pRes);
-//            }
-//            if (0x0 == pChannelInfo->ReceiveMsgQ)
-//            {
-//                printf ("The Channel(0x%x) has been Disabled "
-//                            "for Receive message\n", Channel);
-//                *pRes = CC_DEST_UNAVAILABLE;
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//                return sizeof (*pRes);
-//            }
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//            strcpy ((char *)m_MsgPkt.SrcQ, &g_RcvMsgQ[*kcsifcnum][0]);
-//            m_MsgPkt.Param = SrcSessionHndl;
-//        }
-//        else
-//        {
-//            printf ("SendMsg: Invalid Channel\n");
-//            *pRes = CC_DEST_UNAVAILABLE;
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//            return sizeof (*pRes);
-//        }
-//
-//        if( (TRUE == pBMCInfo->NMConfig.NMSupport) && (pBMCInfo->NMConfig.NMDevSlaveAddress == pIPMIMsgHdr->ResAddr) &&
-//            (Channel == (NM_PRIMARY_IPMB_BUS == pBMCInfo->NMConfig.NM_IPMBBus) ? pBMCInfo->PrimaryIPMBCh : pBMCInfo->SecondaryIPMBCh) )
-//        {
-//            if( (pBMCInfo->RMCPLAN1Ch == *curchannel) ||
-//                (pBMCInfo->RMCPLAN2Ch == *curchannel) ||
-//                (pBMCInfo->RMCPLAN3Ch == *curchannel) ||
-//                (pBMCInfo->RMCPLAN4Ch == *curchannel) ||
-//                (pBMCInfo->SERIALch   == *curchannel) )
-//            {
-//                OS_THREAD_TLS_GET(g_tls.CurPrivLevel,curprivlevel);
-//                if(PRIV_ADMIN != *curprivlevel)
-//                {
-//                    TDBG("Insufficient Privilege\n");
-//                    *pRes = CC_INSUFFIENT_PRIVILEGE;
-//                    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//                    return sizeof(*pRes);
-//                }
-//            }
-//        }
-//    
-//        if(g_PDKHandle[PDK_BEFORESENDMESSAGE] != NULL)
-//        {
-//            RetVal = ( (int (*)(INT8U*, INT8U, INT8U*, int) ) g_PDKHandle[PDK_BEFORESENDMESSAGE]) ( pReq, ReqLen, pRes, BMCInst);
-//            
-//            if(0 < RetVal)
-//            {
-//                return RetVal;
-//            }
-//        }
-//    
-//        if (1 == Tracking)
-//        {
-//            /* Response length is set to zero to make MsgHndlr skip responding to this request 
-//             * The Response will be handled by the ipmb interface after verifying NAK.
-//             */
-//            ResLen = 0;
-//            
-//            /* Tracking is not required if originator is System ifc */
-//            if (SYS_IFC_CHANNEL == (*curchannel & 0xF))
-//            {
-//                *pRes = CC_INV_DATA_FIELD;
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//                return sizeof (*pRes);
-//            }
-//            
-//            PBTbl = (Channel == pBMCInfo->SecondaryIPMBCh) ? SECONDARY_PB_TBL : PRIMARY_PB_TBL ;
-//            
-//            OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->PendBridgeMutex, WAIT_INFINITE);
-//
-//            /* Store in the table for response tracking */
-//            while(TRUE)
-//            {
-//                if (FALSE == m_PendingBridgedResTbl[PBTbl][SeqNum].Used)
-//                {
-//                    m_PendingBridgedResTbl[PBTbl][SeqNum].TimeOut = pBMCInfo->IpmiConfig.SendMsgTimeout;
-//                    m_PendingBridgedResTbl[PBTbl][SeqNum].ChannelNum = (*curchannel & 0xF);
-//                    m_PendingBridgedResTbl[PBTbl][SeqNum].OriginSrc  = ORIGIN_SENDMSG;
-//                    pBMCInfo->SendMsgSeqNum = SeqNum;
-//                    
-//                    if (1 != Offset)
-//                    {
-//                        m_PendingBridgedResTbl[PBTbl][SeqNum].DstSessionHandle = pReq[Offset]; /* Session handle */
-//                    }
-//
-//                    m_PendingBridgedResTbl[PBTbl][SeqNum].SrcSessionHandle = SrcSessionHndl;
-//
-//                    _fmemcpy (&m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr, pIPMIMsgHdr, sizeof (IPMIMsgHdr_T));
-//
-//                    /* Format the IPMI Msg Hdr */
-//                    if(Channel == pBMCInfo->PrimaryIPMBCh)  
-//                    {
-//                        pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.PrimaryIPMBAddr;
-//                    }
-//                    else if(Channel == pBMCInfo->SecondaryIPMBCh)
-//                    {
-//                        pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.SecondaryIPMBAddr;
-//                    }
-//                    else
-//                    {
-//                        pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
-//                    }
-//
-//                    pIPMIMsgHdr->RqSeqLUN = (pBMCInfo->SendMsgSeqNum << 2) & 0xFC; /* Seq Num and LUN =00 */
-//
-//                    /* Recalculate the checksum */
-//                    m_MsgPkt.Data[ReqLen - 2] = CalculateCheckSum2 ((_FAR_ INT8U*)pIPMIMsgHdr, ReqLen - Offset - 1);
-//                    if(IsLANChannel(*curchannel & 0xF, BMCInst))
-//                    {
-//                        memset(QueueName,0,sizeof(QueueName));
-//                        sprintf(QueueName,"%s%d",LAN_IFC_Q,BMCInst);
-//                        strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
-//                    }
-//                    else if (pBMCInfo->SERIALch != CH_NOT_USED && (*curchannel & 0xF) == pBMCInfo->SERIALch && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
-//                    {
-//                        memset(QueueName,0,sizeof(QueueName));
-//                        sprintf(QueueName,"%s%d",SERIAL_IFC_Q,BMCInst);
-//                        strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
-//                    }
-//                    else
-//                    {
-//                        if(( (*curchannel & 0xF) == PRIMARY_IPMB_CHANNEL) && (pBMCInfo->IpmiConfig.PrimaryIPMBSupport == 1 ))
-//                        {
-//                            memset(QueueName,0,sizeof(QueueName));
-//                            sprintf(QueueName,"%s%d",IPMB_PRIMARY_IFC_Q,BMCInst);
-//                            strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
-//                        }
-//                        else if((pBMCInfo->SecondaryIPMBCh != CH_NOT_USED && Channel == pBMCInfo->SecondaryIPMBCh) && pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 1)
-//                        {
-//                            memset(QueueName,0,sizeof(QueueName));
-//                            sprintf(QueueName,"%s%d",IPMB_SECONDARY_IFC_Q,BMCInst);
-//                            strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
-//                        }
-//                        else if ((pBMCInfo->SERIALch != CH_NOT_USED && Channel == pBMCInfo->SERIALch) && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
-//                        {
-//                            memset(QueueName,0,sizeof(QueueName));
-//                            sprintf(QueueName,"%s%d",SERIAL_IFC_Q,BMCInst);
-//                            strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
-//                        }
-//                        else if((pBMCInfo->SMBUSCh != CH_NOT_USED && Channel == pBMCInfo->SMBUSCh) && pBMCInfo->IpmiConfig.SMBUSIfcSupport == 1)
-//                        {
-//                        //strcpy ((char *)m_PendingBridgedResTbl[i].DestQ, NULL);
-//                        }
-//                        else if ((pBMCInfo->ICMBCh != CH_NOT_USED && Channel == pBMCInfo->ICMBCh) && pBMCInfo->IpmiConfig.ICMBIfcSupport == 1)
-//                        {
-//                           memset(QueueName,0,sizeof(QueueName));
-//                           sprintf(QueueName,"%s%d",ICMB_IFC_Q,BMCInst);
-//                           strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
-//                        }
-//                    }
-//                    m_PendingBridgedResTbl[PBTbl][SeqNum].Used = TRUE;
-//                    IPMI_DBG_PRINT_1( "SendMessage:  Bridged message added index = %d.\n", SeqNum);
-//
-//                    break;
-//                }
-//                else
-//                {
-//                    SeqNum = (SeqNum + 1) & 0x3F;
-//
-//                    if (SeqNum == pBMCInfo->SendMsgSeqNum)
-//                    {
-//                        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PendBridgeMutex);
-//                        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//                        /* If not been added to the Pending Bridge table, an error should be reported back.
-//                        If not, for internal channel, the thread calling it may end up waiting! */
-//                        *pRes = CC_NODE_BUSY;
-//                        return  sizeof (*pRes);
-//                    }
-//                 }
-//            }
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PendBridgeMutex);
-//        }
-//
-//        if ((pBMCInfo->SYSCh == (*curchannel & 0xF)) && pBMCInfo->IpmiConfig.SYSIfcSupport == 0x01)
-//        {
-//
-//            ResLen = 0;
-//            /* Format the IPMI Msg Hdr */
-//            // Fill the address from Infrastrucure function instead of using PRIMARY_IPMB_ADDR/SECONDARY_IPMB_ADDR
-//            if(Channel == pBMCInfo->PrimaryIPMBCh)
-//            {
-//                pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.PrimaryIPMBAddr;
-//            }
-//            else if(Channel == pBMCInfo->SecondaryIPMBCh)
-//            {
-//                pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.SecondaryIPMBAddr;
-//            }
-//            else
-//            {
-//                pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
-//            }
-//
-//            /*Change the encapsulated request's LUN based on originating KCS interface */
-//            pIPMIMsgHdr->RqSeqLUN = (pIPMIMsgHdr->RqSeqLUN & 0xFC) | (*kcsifcnum + 0x01);
-//            m_MsgPkt.Data[ReqLen - 2] = CalculateCheckSum2 ((_FAR_ INT8U*)pIPMIMsgHdr, ReqLen - Offset - 1);
-//            pBMCInfo->BridgeMsgKCSIfc = *kcsifcnum;
-//        }
-//
-//        IPMI_DBG_PRINT ("SendMsgCmd:Posting to interface");
-//        IPMI_DBG_PRINT_BUF (m_MsgPkt.Data, m_MsgPkt.Size);
-//
-//        m_MsgPkt.Cmd = PAYLOAD_IPMI_MSG;
-//
-//        /* Post the message to interface */
-//        if (0 != PostMsg (&m_MsgPkt,(INT8S *)m_MsgPkt.SrcQ, BMCInst))
-//        {
-//            TDBG ("SendMsg: Failed to post message to interface queue\n");
-//        }
-//
-//        pSendMsgRes->CompletionCode = CC_NORMAL;
-//
-//        if(pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)
-//        {
-//            if ((PRIMARY_IPMB_CHANNEL== (*curchannel & 0xF) || pBMCInfo->SecondaryIPMBCh == (*curchannel & 0xF)) && 1 == Tracking)
-//            {
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//                return 0;
-//            }
-//        }
-//        else
-//        {
-//            if ( PRIMARY_IPMB_CHANNEL == (*curchannel & 0xF) && (1 == Tracking))
-//            {
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//                return 0;
-//            }
-//        }
-//    }
-//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//    return ResLen;
-}
-
-
-/*---------------------------------------
-* ReadEvtMsgBuffer
-*---------------------------------------*/
-int
-ReadEvtMsgBuffer (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_  ReadEvtMsgBufRes_T* pReadEvtMsgBufRes = (_NEAR_ ReadEvtMsgBufRes_T*)pRes;
-//#if GET_MSG_FLAGS != UNIMPLEMENTED
-//    GetMsgFlagsRes_T   GetMsgFlagsRes;
-//#endif
-//    _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
-//
-//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
-//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->EventMutex,WAIT_INFINITE);
-//    if (-2 == GetMsg(&m_MsgPkt, EVT_MSG_Q, WAIT_NONE, BMCInst))
-//    {
-//        /*If queue is empty */
-//        pReadEvtMsgBufRes->CompletionCode = CC_EVT_MSG_QUEUE_EMPTY;/* Queue is empty    */
-//		OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
-//		OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//        return  sizeof (*pRes);
-//    }
-//
-//    if (BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg == 0) 
-//    { 
-//        pReadEvtMsgBufRes->CompletionCode = CC_EVT_MSG_QUEUE_EMPTY; 
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
-//		OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//        return  sizeof (*pRes); 
-//    }
-//
-//    BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg--;
-//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
-//
-//#if GET_MSG_FLAGS != UNIMPLEMENTED
-//    // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
-//    GetMsgFlags (NULL, 0, (INT8U *)&GetMsgFlagsRes,BMCInst);
-//    TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
-//            GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
-//    if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
-//#else
-//    if (0 == BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg)
-//#endif
-//    {
-//        /* if there is no messssage in buffer reset SMS/EVT ATN bit */
-//        //       CLEAR_SMS_ATN ();
-//        if (pBMCInfo->IpmiConfig.KCS1IfcSupport == 1)
-//        {
-//            CLEAR_SMS_ATN (0, BMCInst);
-//        }
-//        if (pBMCInfo->IpmiConfig.KCS2IfcSupport == 1)
-//        {
-//            CLEAR_SMS_ATN (1, BMCInst);
-//        }
-//        if (pBMCInfo->IpmiConfig.KCS3IfcSuppport == 1)
-//        {
-//            CLEAR_SMS_ATN (2, BMCInst);
-//        }
-//    }
-//
-//    /* clear EventMessageBuffer full flag */
-//    BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x02;
-//
-//    pReadEvtMsgBufRes->CompletionCode = CC_NORMAL; /* Completion Code   */
-//
-//    /* copy the Message data */
-//    _fmemcpy (pReadEvtMsgBufRes->ResData, m_MsgPkt.Data, m_MsgPkt.Size);
-//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
-//
-//    return sizeof (ReadEvtMsgBufRes_T);
-}
-
-
-/*---------------------------------------
-* GetBTIfcCap
-*---------------------------------------*/
-int
-GetBTIfcCap (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-    _NEAR_  GetBTIfcCapRes_T* pGetBTIfcCapRes = (_NEAR_ GetBTIfcCapRes_T*)pRes;
-
-    pGetBTIfcCapRes->CompletionCode     = CC_NORMAL;
-    pGetBTIfcCapRes->NumReqSupported    = 2;
-    pGetBTIfcCapRes->InputBufSize       = MAX_BT_PKT_LEN;
-    pGetBTIfcCapRes->OutputBufSize      = MAX_BT_PKT_LEN;
-    pGetBTIfcCapRes->RespTime           = 1;
-    pGetBTIfcCapRes->Retries            = 0;
-
-    return sizeof (GetBTIfcCapRes_T);
-}
-
-
-/*---------------------------------------
-* GetSystemGUID
-*---------------------------------------*/
-int
-GetSystemGUID (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-    //_NEAR_ GetSysGUIDRes_T* pGetSysGUIDRes = (_NEAR_ GetSysGUIDRes_T*)pRes;
-
-    //pGetSysGUIDRes->CompletionCode  = CC_NORMAL;
-    //LOCK_BMC_SHARED_MEM (BMCInst);
-    //_fmemcpy (&pGetSysGUIDRes->Node, BMC_GET_SHARED_MEM (BMCInst)->SystemGUID, 16);
-    //UNLOCK_BMC_SHARED_MEM (BMCInst);
-
-    //return sizeof (GetSysGUIDRes_T);
-}
-
-
-#define SUPPORT_IPMI20  0x02
-#define SUPPORT_IPMI15  0x01
-/*---------------------------------------
-* GetChAuthCap
-*---------------------------------------*/
-int
-GetChAuthCap (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//	printf("start GetChAuthCap\n");
-	_NEAR_ GetChAuthCapReq_T*   pGetChAuthCapReq = (_NEAR_ GetChAuthCapReq_T*)pReq;
-	_NEAR_ GetChAuthCapRes_T*   pGetChAuthCapRes = (_NEAR_ GetChAuthCapRes_T*)pRes;
-
-
-	memset (pGetChAuthCapRes, 0, sizeof (GetChAuthCapRes_T));
-	
-	pGetChAuthCapRes->CompletionCode=0x00;
-	pGetChAuthCapRes->ChannelNum=0x01;
-	pGetChAuthCapRes->AuthType=0x36;
-	pGetChAuthCapRes->PerMsgUserAuthLoginStatus=0x04;
-	SessionSequenceNumberCount=0;
-	return sizeof(GetChAuthCapRes_T);
-}
-
-
-/*---------------------------------------
-* GetSessionChallenge
-*---------------------------------------*/
-int
-GetSessionChallenge (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//	printf("start GetSessionChallenge\n");
-	_NEAR_ GetSesChallengeReq_T* pGetSesChalReq = (_NEAR_ GetSesChallengeReq_T*)pReq;
-	_NEAR_ GetSesChallengeRes_T* pGetSesChalRes = (_NEAR_ GetSesChallengeRes_T*)pRes;
-	INT32U TemId=0xffb52dfb;//0xfb2db5ff
-	
-	memset (pGetSesChalRes, 0, sizeof (GetSesChallengeRes_T));
-	
-	pGetSesChalRes->CompletionCode=0x00;
-	pGetSesChalRes->TempSessionID=TemId;
-	pGetSesChalRes->ChallengeString[0]=0x54;
-	pGetSesChalRes->ChallengeString[1]=0xdf;
-	pGetSesChalRes->ChallengeString[2]=0xe1;
-	pGetSesChalRes->ChallengeString[3]=0xbf;
-	pGetSesChalRes->ChallengeString[4]=0x56;
-	pGetSesChalRes->ChallengeString[5]=0x47;
-	pGetSesChalRes->ChallengeString[6]=0x87;
-	pGetSesChalRes->ChallengeString[7]=0x88;
-	pGetSesChalRes->ChallengeString[8]=0xea;
-	pGetSesChalRes->ChallengeString[9]=0x7b;
-	pGetSesChalRes->ChallengeString[10]=0xa1;
-	pGetSesChalRes->ChallengeString[11]=0x54;
-	pGetSesChalRes->ChallengeString[12]=0x37;
-	pGetSesChalRes->ChallengeString[13]=0x5b;
-	pGetSesChalRes->ChallengeString[14]=0x79;
-	pGetSesChalRes->ChallengeString[15]=0xe3;
-//	SessionSequenceNumberCount=SessionSequenceNumberCount+1;
-    return sizeof (GetSesChallengeRes_T);
-}
-
-/*---------------------------------------
-* ActivateSession
-*---------------------------------------*/
-int
-ActivateSession (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//	printf("start ActivateSession:\n");
-	_NEAR_  ActivateSesReq_T*   pAcvtSesReq = (_NEAR_ ActivateSesReq_T*)pReq;
-	_NEAR_  ActivateSesRes_T*   pAcvtSesRes = (_NEAR_ ActivateSesRes_T*)pRes;
-    	INT32U  SesId=0xffb52dfb;//0xfb2db5ff;
-	INT32U  InbSeq=0x2ae8944a;//0x4a94e82a;
-	
-	memset (pAcvtSesRes, 0, sizeof (ActivateSesRes_T));
-	
-	pAcvtSesRes->CompletionCode=0x00;
-	pAcvtSesRes->AuthType=0x02;
-	pAcvtSesRes->SessionID=SesId;
-	pAcvtSesRes->InboundSeq=InbSeq;
-	pAcvtSesRes->Privilege=0x04;
-	SessionSequenceNumberCount=SessionSequenceNumberCount+1;
-	return sizeof (ActivateSesRes_T);
-	
-}
-
-
-/*---------------------------------------
-* SetSessionPrivLevel
-*---------------------------------------*/
-int
-SetSessionPrivLevel (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-	_NEAR_  SetSesPrivLevelReq_T*   pSetSesPrivLevelReq = (_NEAR_ SetSesPrivLevelReq_T*)pReq;
-	_NEAR_  SetSesPrivLevelRes_T*   pSetSesPrivLevelRes = (_NEAR_ SetSesPrivLevelRes_T*)pRes;
-	
-	memset (pSetSesPrivLevelRes, 0, sizeof (SetSesPrivLevelRes_T));
-
-	pSetSesPrivLevelRes->CompletionCode=0x00;
-	pSetSesPrivLevelRes->Privilege=0x04;
-	SessionSequenceNumberCount=SessionSequenceNumberCount+1;
-        return sizeof (SetSesPrivLevelRes_T);
-}
-
-
-/*---------------------------------------
-* CloseSession
-*---------------------------------------*/
-int
-CloseSession (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-	SessionSequenceNumberCount=SessionSequenceNumberCount+1;
-    	return sizeof (*pRes);
-}
-
-//#if GET_SESSION_INFO != UNIMPLEMENTED
-/*---------------------------------------
-* GetSessionInfo
-*---------------------------------------*/
-int
-GetSessionInfo (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_  GetSesInfoReq_T* pGetSesInfoReq = (_NEAR_ GetSesInfoReq_T*)pReq;
-//    _NEAR_  GetSesInfoRes_T* pGetSesInfoRes = (_NEAR_ GetSesInfoRes_T*)pRes;
-//    _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
-//    LANSesInfoRes_T     LANSesInfo;
-//    LANIPv6SesInfoRes_T     LANIPv6SesInfo;
-//    _FAR_   SessionInfo_T*   pSessInfo;
-//    _FAR_   ChannelInfo_T*   pChannelInfo;
-//    _FAR_   void*            SessionArg;
-//    INT8U 	     SessionArgAlign[4];
-//    INT8U            SessionArgType,EthIndex, netindex = 0xFF;
-//    char    IfcName[IFNAMSIZ];
-//    INT32U *CurSesID,*curchannel;
-//    int i;
-//
-//    *pRes = CC_REQ_INV_LEN;
-//
-//    switch (pGetSesInfoReq->SessionIndex)
-//    {
-//        case 0:
-//            /* Get session information for this session */
-//            if (1 != ReqLen)
-//            {
-//                return sizeof (*pRes);
-//            }
-//            SessionArgType  = SESSION_ID_INFO;
-//            OS_THREAD_TLS_GET(g_tls.CurSessionID,CurSesID);
-//            SessionArg      = CurSesID;
-//            break;
-//
-//        case 0xFF:
-//            if (5 != ReqLen)
-//            {
-//                return sizeof (*pRes);
-//            }
-//            SessionArgType  = SESSION_ID_INFO;
-//
-//            SessionArgAlign[0]      = pGetSesInfoReq->SessionHandleOrID[0];
-//            SessionArgAlign[1]      = pGetSesInfoReq->SessionHandleOrID[1];
-//            SessionArgAlign[2]      = pGetSesInfoReq->SessionHandleOrID[2];
-//            SessionArgAlign[3]      = pGetSesInfoReq->SessionHandleOrID[3];
-//            SessionArg = SessionArgAlign;
-//            break;
-//
-//        case 0xFE:
-//            if (2 != ReqLen)
-//            {
-//                return sizeof (*pRes);
-//            }
-//            if (pGetSesInfoReq->SessionHandleOrID[0] == 0)
-//            {
-//                *pRes=CC_INV_DATA_FIELD;
-//                return sizeof (*pRes);
-//            }
-//            SessionArgType  = SESSION_HANDLE_INFO;
-//            SessionArgAlign[0]      = pGetSesInfoReq->SessionHandleOrID[0];
-//            SessionArgAlign[1]      = pGetSesInfoReq->SessionHandleOrID[1];
-//            SessionArgAlign[2]      = pGetSesInfoReq->SessionHandleOrID[2];
-//            SessionArgAlign[3]      = pGetSesInfoReq->SessionHandleOrID[3];
-//            SessionArg = SessionArgAlign;
-//            break;
-//
-//        default:
-//            if (1 != ReqLen)
-//            {
-//                return sizeof (*pRes);
-//            }
-//            SessionArgType  = SESSION_INDEX_INFO;
-//            SessionArg      = &pGetSesInfoReq->SessionIndex;
-//            break;
-//    }
-//
-//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SessionTblMutex, WAIT_INFINITE);
-//    pSessInfo = getSessionInfo (SessionArgType, SessionArg, BMCInst);
-//    if (NULL == pSessInfo)
-//    {
-//        TDBG ("GetSessionInfo: pSessInfo is NULL\n");
-//        /* if there is no active channel for the current session Index
-//        * return the following bytes
-//        */
-//
-//        OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
-//        pChannelInfo = getChannelInfo (*curchannel & 0xF, BMCInst);
-//        if(NULL == pChannelInfo)
-//        {
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
-//            pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
-//            return	sizeof (*pRes);
-//        }
-//
-//        pGetSesInfoRes->CompletionCode          = CC_NORMAL;
-//        pGetSesInfoRes->SessionHandle           = BMC_GET_SHARED_MEM (BMCInst)->SessionHandle;
-//        pGetSesInfoRes->NumPossibleActiveSession=  pBMCInfo->IpmiConfig.MaxSession;
-//        pGetSesInfoRes->NumActiveSession        = GetNumOfActiveSessions (BMCInst);
-//
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
-//        return (sizeof (GetSesInfoRes_T) - sizeof (ActiveSesInfo_T) - sizeof (SessionInfoRes_T));
-//    }
-//
-//    memset (pGetSesInfoRes,0,sizeof(GetSesInfoRes_T));
-//    pChannelInfo = getChannelInfo (pSessInfo->Channel, BMCInst);
-//    if(NULL == pChannelInfo)
-//    {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
-//        pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
-//        return	sizeof (*pRes);
-//    }
-//    pGetSesInfoRes->CompletionCode              = CC_NORMAL;
-//    pGetSesInfoRes->SessionHandle               = pSessInfo->SessionHandle;
-//    pGetSesInfoRes->NumPossibleActiveSession    = pBMCInfo->IpmiConfig.MaxSession;
-//    pGetSesInfoRes->NumActiveSession            = GetNumOfActiveSessions (BMCInst);
-//    pGetSesInfoRes->ActiveSesinfo.UserID        = pSessInfo->UserId & 0x3F;
-//    pGetSesInfoRes->ActiveSesinfo.Privilege     = pSessInfo->Privilege & 0x0F;
-//    /* Set protocol bit as per Auth Type, bit4 must be 1 for IPMIv2.0 RMCP, 0 for IPMIv1.5 */
-//    if( AUTHTYPE_RMCP_PLUS_FORMAT == pSessInfo->AuthType )
-//    {
-//        pGetSesInfoRes->ActiveSesinfo.ChannelNum    = (pSessInfo->Channel & 0x0F) | 0x10;
-//    }else
-//    {
-//        pGetSesInfoRes->ActiveSesinfo.ChannelNum    = pSessInfo->Channel & 0x0F;
-//    }
-//    EthIndex= GetEthIndex(pSessInfo->Channel & 0x0F, BMCInst);
-//    if(0xff == EthIndex)
-//    {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
-//       *pRes = CC_INV_DATA_FIELD;
-//       DeleteSession (pSessInfo,BMCInst);
-//       return sizeof (INT8U);
-//    }
-//    memset(IfcName,0,sizeof(IfcName));
-//    /*Get the EthIndex*/
-//    if(GetIfcName(EthIndex,IfcName, BMCInst) == -1)
-//    {
-//       TCRIT("Error in Getting Ifc name\n");
-//       OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
-//       *pRes = CC_INV_DATA_FIELD;
-//       return sizeof (INT8U);
-//    }
-//
-//    for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
-//    {
-//       if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
-//       {
-//           netindex= Ifcnametable[i].Index;
-//           break;
-//       }
-//    }
-//
-//    if(netindex == 0xFF)
-//    {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
-//       *pRes = CC_INV_DATA_FIELD;
-//       return sizeof (INT8U);
-//    }
-//    if (IsLANChannel( pSessInfo->Channel, BMCInst))
-//    {
-//        if(g_corefeatures.global_ipv6  == ENABLED)
-//        {
-//            if(GetIPAdrressType(&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[0])==4) 
-//            {
-//                memset(&LANSesInfo,0,sizeof(LANSesInfo));
-//                /* IP Address */
-//                _fmemcpy (&(LANSesInfo.IPAddress),
-//                                    &pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[sizeof(struct in6_addr)-sizeof(struct in_addr)],
-//                                    sizeof(struct in_addr));
-//                /* MAC Address */
-//                if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
-//                nwGetSrcCacheMacAddr((INT8U*)&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[12],
-//                                                        netindex, pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
-//
-//                _fmemcpy(LANSesInfo.MACAddress, pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
-//                /* Port number */
-//                LANSesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
-//
-//                _fmemcpy ((pRes+sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)),&LANSesInfo, sizeof (LANSesInfoRes_T));
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
-//                return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)+sizeof (LANSesInfoRes_T));
-//                }
-//            else
-//            {
-//                /* IP Address */
-//                memset(&LANIPv6SesInfo,0,sizeof(LANIPv6SesInfo));
-//                _fmemcpy (&(LANIPv6SesInfo.IPv6Address),
-//                		pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr,
-//                		sizeof(struct in6_addr));
-//                /* MAC Address */
-//                if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
-//                    nwGetSrcMacAddr_IPV6((INT8U*)&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr,
-//                                        pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
-//
-//                _fmemcpy(LANIPv6SesInfo.MACAddress, pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
-//                /* Port number */
-//                LANIPv6SesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
-//
-//                _fmemcpy ((pRes+sizeof (GetSesInfoRes_T) - sizeof(SessionInfoRes_T)),&LANIPv6SesInfo, sizeof (LANIPv6SesInfoRes_T));
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
-//                return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)+sizeof (LANIPv6SesInfoRes_T));
-//                }
-//        }
-//        else
-//        {
-//
-//            /* IP Address */
-//            _fmemcpy (pGetSesInfoRes->SesInfo.LANSesInfo.IPAddress,
-//            		pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr,
-//            		sizeof (pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr));
-//            /* MAC Address */
-//            if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
-//                nwGetSrcCacheMacAddr((INT8U*)pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr, netindex, 
-//                                pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
-//            _fmemcpy(pGetSesInfoRes->SesInfo.LANSesInfo.MACAddress, 
-//                    pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
-//            /* Port number */
-//            pGetSesInfoRes->SesInfo.LANSesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
-//            return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T) + sizeof (LANSesInfoRes_T));
-//        }
-//    }
-//    else if (pBMCInfo->IpmiConfig.SerialIfcSupport == 1 && pBMCInfo->SERIALch== pSessInfo->Channel)
-//    {
-//
-//        pChannelInfo = getChannelInfo (pBMCInfo->SERIALch, BMCInst);
-//        if(NULL == pChannelInfo)
-//        {
-//            pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
-//            return	sizeof (*pRes);
-//        }
-//
-//        pGetSesInfoRes->SesInfo.SerialSesInfo.SessionActivityType = 0;
-//        pGetSesInfoRes->SesInfo.SerialSesInfo.DestinationSelector = 0;
-//
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
-//        return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T) + sizeof (SerialSesInfoRes_T));
-//    }
-//    else
-//    {
-//        pChannelInfo = getChannelInfo(pSessInfo->Channel, BMCInst);
-//        if(NULL == pChannelInfo)
-//        {
-//            pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
-//            return sizeof (*pRes);
-//        }
-//
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
-//        return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T));
-//    }
-}
-//#endif
-
-
-/**
- * @fn GetAuthCodeForTypeV15
- * @brief This function will use the encryption technique supported 
- * 			in IPMI V1.5 in order to produce Auth Code.
- * @param[in] pUserInfo - Pointer to User info structure.
- * @param[in] pGetAuthCodeReq - Pointer to the structure of request data
- * @param[out] pGetAuthCodeRes - Pointer to the resultant data.
- * @retval size of the result data.
- */
-static int
-GetAuthCodeForTypeV15 (UserInfo_T* pUserInfo,
-        GetAuthCodeReq_T* pGetAuthCodeReq,
-        GetAuthCodeRes_T* pGetAuthCodeRes,int BMCInst)
-{
-//    INT8U   AuthCode;
-//    INT8U   InBuffer[2*IPMI15_MAX_PASSWORD_LEN + HASH_DATA_LENGTH];
-//    char    UserPswd[MAX_PASSWD_LEN];
-//    INT8U   PwdEncKey[MAX_SIZE_KEY + 1] = {0};
-//    _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
-//
-//    memset(&(pGetAuthCodeRes->AuthCode), 0, AUTH_CODE_HASH_LEN);
-//    AuthCode = pGetAuthCodeReq->AuthType & AUTH_CODE_V15_MASK;
-//    if((pGetAuthCodeReq->AuthType & (BIT5 | BIT4)) ||
-//       (AuthCode == AUTHTYPE_RESERVED) || (AuthCode == AUTHTYPE_NONE) ||
-//       (AuthCode == AUTHTYPE_STRAIGHT_PASSWORD) ||
-//       (AuthCode > AUTHTYPE_OEM_PROPRIETARY))
-//    {
-//        pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
-//        return (sizeof (GetAuthCodeRes_T) - 4);
-//    }
-//
-//    if (g_corefeatures.userpswd_encryption == ENABLED)
-//    {
-//        /* Get Encryption Key from the MBMCInfo_t structure */
-//        LOCK_BMC_SHARED_MEM(BMCInst);
-//            memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
-//        UNLOCK_BMC_SHARED_MEM(BMCInst);
-//
-//        if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[pUserInfo->UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, UserPswd, MAX_PASSWORD_LEN, PwdEncKey))
-//        {
-//            TCRIT("Error in decrypting the IPMI User password for User ID:%d.\n", pUserInfo->UserId);
-//            pGetAuthCodeRes->CompletionCode = CC_UNSPECIFIED_ERR;
-//            return sizeof(*pGetAuthCodeRes);
-//        }
-//    	memcpy(&InBuffer[0],UserPswd,IPMI15_MAX_PASSWORD_LEN);
-//    }
-//    else
-//    {
-//    	memcpy(&InBuffer[0],pUserInfo->UserPassword,IPMI15_MAX_PASSWORD_LEN);
-//    }
-//
-//    LOCK_BMC_SHARED_MEM(BMCInst);
-//    switch (AuthCode)
-//    {
-//        #if 0 // As per IPMIv2 Markup E4, Straight Password key is Reserved
-//        case AUTH_TYPE_PASSWORD: /* Straight password */
-//            if (0 == _fmemcmp (pUserInfo->UserPassword,pGetAuthCodeReq->HashData,IPMI15_MAX_PASSWORD_LEN))
-//            {
-//                _fmemcpy (pGetAuthCodeRes->AuthCode, "OK", 2);
-//            }
-//            else
-//            {
-//                pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
-//            }
-//            break;
-//        #endif
-//
-//        case AUTH_TYPE_MD2: /* MD2 */
-//            _fmemcpy (&InBuffer[IPMI15_MAX_PASSWORD_LEN],
-//                    pGetAuthCodeReq->HashData, HASH_DATA_LENGTH);
-//            if (g_corefeatures.userpswd_encryption == ENABLED)
-//            {
-//            	_fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
-//                    UserPswd, IPMI15_MAX_PASSWORD_LEN);
-//            }
-//            else
-//            {
-//            	_fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
-//                    pUserInfo->UserPassword, IPMI15_MAX_PASSWORD_LEN);
-//            }
-//
-//            AuthCodeCalMD2 (InBuffer, pGetAuthCodeRes->AuthCode, sizeof (InBuffer));
-//            break;
-//
-//        case AUTH_TYPE_MD5: /* MD5 */
-//            _fmemcpy (&InBuffer[IPMI15_MAX_PASSWORD_LEN],
-//                    pGetAuthCodeReq->HashData, HASH_DATA_LENGTH);
-//            if (g_corefeatures.userpswd_encryption == ENABLED)
-//            {
-//            	_fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
-//                    UserPswd,IPMI15_MAX_PASSWORD_LEN);
-//            }
-//            else
-//            {
-//            	_fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
-//                    pUserInfo->UserPassword,IPMI15_MAX_PASSWORD_LEN);
-//            }
-//            AuthCodeCalMD5 (InBuffer, pGetAuthCodeRes->AuthCode, sizeof (InBuffer));
-//            break;
-//
-//        default:
-//            pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
-//    }
-//
-//    UNLOCK_BMC_SHARED_MEM(BMCInst);
-//    // IPMI V1.5 AuthCode is only 16 byte.
-//    return (sizeof (GetAuthCodeRes_T) - 4);
-}
-
-/**
- * @fn GetAuthCodeForTypeV20
- * @brief This function will use the encryption technique supported 
- * 			in IPMI V2.0 in order to produce Auth Code.
- * @param[in] pUserInfo - Pointer to User info structure.
- * @param[in] pGetAuthCodeReq - Pointer to the structure of request data
- * @param[out] pGetAuthCodeRes - Pointer to the resultant data.
- * @retval size of the result data.
- */
-static int
-GetAuthCodeForTypeV20 (UserInfo_T* pUserInfo,
-        GetAuthCodeReq_T* pGetAuthCodeReq,
-        GetAuthCodeRes_T* pGetAuthCodeRes,int BMCInst)
-{
-//    INT8U   AuthCode;
-//    INT8U   UserPasswdLen=0;
-//    INT8U   DecVal = 0;
-//    _FAR_ INT8U m_SIK [SESSION_INTEGRITY_KEY_SIZE];
-//    char   UserPswd[MAX_PASSWD_LEN];
-//    unsigned char PwdEncKey[MAX_SIZE_KEY + 1] = {0};
-//    _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
-//
-//    if (g_corefeatures.userpswd_encryption == ENABLED)
-//    {
-//        /* Get Encryption Key from the MBMCInfo_t structure */
-//        LOCK_BMC_SHARED_MEM(BMCInst);
-//            memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
-//        UNLOCK_BMC_SHARED_MEM(BMCInst);
-//
-//        if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[pUserInfo->UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, UserPswd, MAX_PASSWORD_LEN, PwdEncKey))
-//        {
-//            TCRIT("\nError in decrypting the IPMI User password for user with ID:%d.\n", pUserInfo->UserId);
-//            pGetAuthCodeRes->CompletionCode = CC_UNSPECIFIED_ERR;
-//            return sizeof (*pGetAuthCodeRes);
-//        }
-//    }
-//    else
-//    {
-//        memcpy(&UserPswd, pUserInfo->UserPassword, MAX_PASSWD_LEN);
-//    }
-//
-//    /* Calculate password length */
-//    UserPasswdLen = _fstrlen ((_FAR_ char*)UserPswd);
-//    UserPasswdLen = (UserPasswdLen > MAX_PASSWORD_LEN) ?
-//            MAX_PASSWORD_LEN : UserPasswdLen;
-//
-//    memset(&(pGetAuthCodeRes->AuthCode), 0, AUTH_CODE_HASH_LEN);
-//    AuthCode = pGetAuthCodeReq->AuthType & AUTH_CODE_V20_MASK;
-//    /* Validate the Auth Code */
-//    if ((AuthCode > MIN_AUTH_CODE_V20) && (AuthCode < MAX_AUTH_CODE_V20))
-//    {
-//        pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
-//        return sizeof(GetAuthCodeRes_T);
-//    }
-//
-//    LOCK_BMC_SHARED_MEM(BMCInst);
-//    switch(AuthCode)
-//    {
-//        case AUTH_NONE: /* none */
-//            TDBG ("\nInside AUTH_NONE in GetAuthCode");
-//            pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
-//            break;
-//
-//        case AUTH_HMAC_SHA1_96: /* HMAC-SHA1-96 */
-//            TDBG ("\nInside AUTH_HMAC_SHA1_96 in GetAuthCode");
-//            hmac_sha1 ((INT8U *)UserPswd, UserPasswdLen,
-//                    (INT8U *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
-//                    (INT8U *)m_SIK, SESSION_INTEGRITY_KEY_SIZE);
-//
-//            hmac_sha1 ((INT8U *)m_SIK, SESSION_INTEGRITY_KEY_SIZE,
-//                    (INT8U *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
-//                    (INT8U *)&(pGetAuthCodeRes->AuthCode), HMAC_SHA1_96_LEN);
-//
-//            DecVal = AUTH_CODE_HASH_LEN - HMAC_SHA1_96_LEN;
-//            break;
-//
-//        case AUTH_HMAC_MD5_128: /* HMAC-MD5-128 */
-//            TDBG ("\nInside AUTH_HMAC_MD5_128 in GetAuthCode");
-//            hmac_md5 ((unsigned char*)UserPswd, UserPasswdLen,
-//                    pGetAuthCodeReq->HashData, HASH_DATA_LEN,
-//                    m_SIK, SESSION_HMAC_MD5_I_KEY_SIZE);
-//
-//            hmac_md5 (m_SIK, SESSION_HMAC_MD5_I_KEY_SIZE,
-//                    pGetAuthCodeReq->HashData, HASH_DATA_LEN,
-//                    (unsigned char *)&(pGetAuthCodeRes->AuthCode), 
-//                    SESSION_HMAC_MD5_I_KEY_SIZE);
-//            DecVal = AUTH_CODE_HASH_LEN - SESSION_HMAC_MD5_I_KEY_SIZE;
-//            break;
-//
-//        case AUTH_MD5_128: /* MD5-128 */
-//            TDBG ("\nInside AUTH_MD5_128 in GetAuthCode");
-//            MD5_128 ((char *)UserPswd, UserPasswdLen,
-//                    (char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
-//                    (char *)m_SIK, SESSION_MD5_KEY_SIZE);
-//
-//            MD5_128 ((char *)m_SIK, SESSION_INTEGRITY_KEY_SIZE,
-//                    (char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
-//                    (char *)&(pGetAuthCodeRes->AuthCode), SESSION_MD5_KEY_SIZE);
-//            DecVal = AUTH_CODE_HASH_LEN - SESSION_MD5_KEY_SIZE;
-//            break;
-//
-//        case AUTH_HMAC_SHA256_128: /* HMAC-SHA256-128 */
-//            TDBG ("\nInside AUTH_HMAC_SHA256_128 in GetAuthCode");
-//            hmac_sha256 ((unsigned char *)UserPswd, UserPasswdLen, 
-//    				(unsigned char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
-//    				(unsigned char *)m_SIK, SHA2_HASH_KEY_SIZE);
-//
-//			hmac_sha256 (m_SIK, SHA2_HASH_KEY_SIZE,  
-//    				(unsigned char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
-//    				(unsigned char *)&(pGetAuthCodeRes->AuthCode), HMAC_SHA256_128_LEN);    		
-//            DecVal = AUTH_CODE_HASH_LEN - HMAC_SHA256_128_LEN;
-//            break;            
-//
-//            //! TODO: Need support in openssl.
-//        default: /* OEM or Reserved */
-//            pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
-//    }
-//
-//    UNLOCK_BMC_SHARED_MEM(BMCInst);
-//    if (DecVal > sizeof(GetAuthCodeRes_T))
-//        return sizeof(GetAuthCodeRes_T);
-//    else
-//        return (sizeof(GetAuthCodeRes_T) - DecVal);
-}
-
-/**
- * @fn GetAuthCode
- * @brief This function will encrypt the given 16 byte data with
- *          the algorithm given and return Auth Code.
- * @param[in] pReq - Request data.
- * @param[in] ReqLen - Length of the request data.
- * @param[out] pRes - Result data
- * @retval size of the result data.
- */
-int
-GetAuthCode (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,int BMCInst)
-{
-    _NEAR_  GetAuthCodeReq_T*   pGetAuthCodeReq = (_NEAR_ GetAuthCodeReq_T*)pReq;
-    _NEAR_  GetAuthCodeRes_T*   pGetAuthCodeRes = (_NEAR_ GetAuthCodeRes_T*)pRes;
-    BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
-    _FAR_   UserInfo_T*         pUserInfo;
-    INT8U               AuthType,*curchannel;
-    _FAR_   ChannelInfo_T*      pChannelInfo;
-    int nRetSize = 0;
-
-//    printf("start GetAuthCode\n");
-    /* Check for Reserved Bits */
-    if((pGetAuthCodeReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4)) ||
-            (pGetAuthCodeReq->UserID & (BIT7 | BIT6)))
-    {
-        pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
-        return sizeof(*pRes);
-    }
-
-    //OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
-    /* Validate the channel number given */
-    if (CURRENT_CHANNEL_NUM == pGetAuthCodeReq->ChannelNum)
-    {
-        OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
-        pChannelInfo = getChannelInfo(*curchannel & 0xF,BMCInst);
-    }
-    else
-        pChannelInfo = getChannelInfo(pGetAuthCodeReq->ChannelNum,BMCInst);
-
-    if (NULL == pChannelInfo)
-    {
-    //    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-        *pRes = CC_INV_DATA_FIELD;
-        return sizeof(*pRes);
-    }
-
-    /* Get the user information for the given userID */
-    pUserInfo = getUserIdInfo (pGetAuthCodeReq->UserID,BMCInst);
-    if (NULL == pUserInfo)
-    {
-    //    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-        TDBG ("AppDevice.c : GetAuthCode - Invalid user Id\n");
-        pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
-        return sizeof (*pRes);
-    }
-
-    AuthType = pGetAuthCodeReq->AuthType & GET_AUTH_TYPE_MASK;
-    pGetAuthCodeRes->CompletionCode = CC_NORMAL;
-
-    switch(AuthType)
-    {
-        case AUTH_TYPE_V15: /* IPMI v1.5 AuthCode Algorithms */
-            nRetSize = GetAuthCodeForTypeV15(pUserInfo, pGetAuthCodeReq, pGetAuthCodeRes,BMCInst);
-            break;
-
-        case AUTH_TYPE_V20: /* IPMI v2.0/RMCP+ Algorithm Number */
-            nRetSize = GetAuthCodeForTypeV20(pUserInfo, pGetAuthCodeReq, pGetAuthCodeRes,BMCInst);
-            break;
-
-        default:
-    //        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-            pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
-            return sizeof(*pRes);
-    }
- //   OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-    return nRetSize;
-}
-
-
-/*---------------------------------------
-* SetChAccess
-*---------------------------------------*/
-int
-SetChAccess (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_  SetChAccessReq_T*   pSetChAccessReq = (_NEAR_ SetChAccessReq_T*)pReq;
-//            INT8U               ChannelNum, AccessMode;
-//    _FAR_   ChannelInfo_T*      pNvrChInfo;
-//    _FAR_   ChannelInfo_T*      pChannelInfo;
-//    _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
-//    INT8U AccessFlags = 0,i=0,*curchannel;
-////    char ChFilename[MAX_CHFILE_NAME];
-//
-//    /* Reserve Bit Checking for Set Channel Acces */
-//    for(i=0;i<ReqLen;i++)
-//    {
-//        if( 0 != (pReq[i] & m_Set_ChReserveBit[i]))
-//        {
-//            *pRes = CC_INV_DATA_FIELD;
-//            return	sizeof (*pRes);
-//        }
-//    }
-//    /* Reserve Value checking */
-//
-//    if((pReq[1] & 0xC0)== 0xC0 || (pReq[2] & 0xC0) == 0xC0)
-//    {
-//        *pRes = CC_INV_DATA_FIELD;
-//        return	sizeof (*pRes);
-//    }
-//
-//    ChannelNum = pSetChAccessReq->ChannelNum & 0x0F;
-//    if (CURRENT_CHANNEL_NUM == ChannelNum)
-//    {
-//        OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
-//        ChannelNum = *curchannel & 0xF;
-//    }
-//
-//    if (((GetBits (pSetChAccessReq->Privilege, 0x0F)) < PRIV_LEVEL_CALLBACK) ||
-//        ((GetBits (pSetChAccessReq->Privilege, 0x0F)) > PRIV_LEVEL_PROPRIETARY))
-//    {
-//        IPMI_DBG_PRINT_1 ("Invalid Channel Privilege = 0x%x\n", pSetChAccessReq->Privilege);
-//        *pRes = CC_INV_DATA_FIELD;
-//        return  sizeof (*pRes);
-//    }
-//
-//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
-//    pChannelInfo = getChannelInfo(ChannelNum, BMCInst);
-//    if (NULL == pChannelInfo)
-//    {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        *pRes = CC_INV_DATA_FIELD;
-//        return  sizeof (*pRes);
-//    }
-//
-//    /*point to NVRAM ChannelInfo */
-//    pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
-//
-//    if (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport)
-//    {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        /* Channel is sessionless channel this command is not supported */
-//        *pRes = CC_SET_CH_COMMAND_NOT_SUPPORTED;
-//        return  sizeof (*pRes);
-//    }
-//
-//
-//    AccessMode = pSetChAccessReq->ChannelAccess & 0x07;
-//    if(ChannelNum == pBMCInfo->SERIALch)
-//    {
-//        if( NULL != g_PDKHandle[PDK_SWITCHMUX])
-//        {
-//            ((void(*)(INT8U, int))(g_PDKHandle[PDK_SWITCHMUX]))(AccessMode ,BMCInst);
-//        }
-//     }
-//
-//    /* if the requested access mode is supported for the given channel */
-//    if (0 == (pChannelInfo->AccessModeSupported & (1 << AccessMode)))
-//    {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        *pRes = CC_SET_CH_ACCES_MODE_NOT_SUPPORTED;
-//        return  sizeof (*pRes);
-//    }
-//
-//    AccessFlags = GetBits (pSetChAccessReq->ChannelAccess, 0xC0);
-//
-//    switch (AccessFlags)
-//    {
-//        case 0:
-//            /* dont set channel access */
-//            break;
-//
-//        case 1:
-//            /*set in  Non volatile Memory and in voatile Memory */
-//            pNvrChInfo->Alerting        = GetBits (pSetChAccessReq->ChannelAccess , 0x20);
-//            pNvrChInfo->PerMessageAuth  = GetBits (pSetChAccessReq->ChannelAccess , 0x10);
-//            pNvrChInfo->UserLevelAuth   = GetBits (pSetChAccessReq->ChannelAccess , 0x08);
-//            pNvrChInfo->AccessMode = AccessMode;
-//            /* write to NVRAM   */
-//            FlushChConfigs((INT8U*)pNvrChInfo,pNvrChInfo->ChannelNumber,BMCInst);
-//            pChannelInfo->Alerting      = pNvrChInfo->Alerting;
-//            pChannelInfo->PerMessageAuth= pNvrChInfo->PerMessageAuth;
-//            pChannelInfo->UserLevelAuth = pNvrChInfo->UserLevelAuth;
-//            pChannelInfo->AccessMode = AccessMode;
-//            break;
-//
-//        case 2:
-//            /*set in volatile Memmory only      */
-//            pChannelInfo->Alerting      = GetBits (pSetChAccessReq->ChannelAccess, 0x20);
-//            pChannelInfo->PerMessageAuth= GetBits (pSetChAccessReq->ChannelAccess, 0x10);
-//            pChannelInfo->UserLevelAuth = GetBits (pSetChAccessReq->ChannelAccess, 0x08);
-//            pChannelInfo->AccessMode = AccessMode;
-//    }
-//
-//    switch (GetBits (pSetChAccessReq->Privilege, 0xC0))
-//    {
-//        case 0:
-//            /* dont set prilivege level */
-//            break;
-//
-//        case 1:
-//            /* set in non volatile mem  and volatile  memeory*/ /*set privilege*/
-//            pNvrChInfo->MaxPrivilege = GetBits (pSetChAccessReq->Privilege, 0x0F);
-//            pChannelInfo->MaxPrivilege = pNvrChInfo->MaxPrivilege;
-//            break;
-//
-//        case 2:
-//            /*set privilege*/
-//            /*  set in volatile memeory only    */
-//            pChannelInfo->MaxPrivilege = GetBits (pSetChAccessReq->Privilege, 0x0F);
-//    }
-//
-//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//    *pRes = CC_NORMAL;
-//
-//    return sizeof (*pRes);
-}
-
-
-/*---------------------------------------
-* GetChAccess
-*---------------------------------------*/
-int
-GetChAccess (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_  GetChAccessReq_T*   pGetChAccessReq = (_NEAR_ GetChAccessReq_T*)pReq;
-//    _NEAR_  GetChAccessRes_T*   pGetChAccessRes = (_NEAR_ GetChAccessRes_T*)pRes;
-//    _FAR_   ChannelInfo_T*      pChannelInfo;
-//    _FAR_   ChannelInfo_T*      pNvrChInfo;
-//    INT8U               ChannelNum,AccessFlag,*curchannel;
-//    BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
-//
-//    /* Check for reserved bits */
-//    if((0 != (pGetChAccessReq->ChannelNum & 0xf0)) ||
-//        (0 != (pGetChAccessReq->	AccessFlag & 0x3f)))
-//    {
-//        pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
-//        return  sizeof (*pRes);
-//    }
-//
-//    ChannelNum = pGetChAccessReq->ChannelNum & 0x0F;
-//    if (CURRENT_CHANNEL_NUM == ChannelNum)
-//    {
-//        OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
-//        ChannelNum = *curchannel & 0xF;
-//    }
-//
-//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
-//    pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
-//
-//    if (NULL == pChannelInfo)
-//    {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
-//        return  sizeof (*pRes);
-//    }
-//
-//    if (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport)
-//    {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        /* Channel is sessionless channel this command is not supported */
-//        pGetChAccessRes->CompletionCode = CC_GET_CH_COMMAND_NOT_SUPPORTED;
-//        return  sizeof (*pRes);
-//    }
-//
-//    AccessFlag = GetBits (pGetChAccessReq->AccessFlag, 0xC0);
-//
-//    pGetChAccessRes->CompletionCode = CC_NORMAL;
-//
-//    switch (AccessFlag)
-//    {
-//        case 1:
-//            /*  Get Channel Information from NVRAM */
-//            pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
-//
-//            pGetChAccessRes->ChannelAccess  = SetBits (0x20, pNvrChInfo->Alerting);
-//            pGetChAccessRes->ChannelAccess |= SetBits (0x10, pNvrChInfo->PerMessageAuth);
-//            pGetChAccessRes->ChannelAccess |= SetBits (0x08, pNvrChInfo->UserLevelAuth);
-//            pGetChAccessRes->ChannelAccess |= SetBits (0x07, pNvrChInfo->AccessMode);
-//            pGetChAccessRes->Privilege      = SetBits (0x0F, pNvrChInfo->MaxPrivilege);
-//            break;
-//
-//        case 2:
-//            /*  Get  Channel Information from  Volatile RAM */
-//            pGetChAccessRes->ChannelAccess  = SetBits (0x20, pChannelInfo->Alerting);
-//            pGetChAccessRes->ChannelAccess |= SetBits (0x10, pChannelInfo->PerMessageAuth);
-//            pGetChAccessRes->ChannelAccess |= SetBits (0x08, pChannelInfo->UserLevelAuth);
-//            pGetChAccessRes->ChannelAccess |= SetBits (0x07, pChannelInfo->AccessMode);
-//            pGetChAccessRes->Privilege      = SetBits (0x0F, pChannelInfo->MaxPrivilege);
-//            break;
-//
-//        default:
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//            pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
-//            return  sizeof (*pRes);
-//    }
-//
-//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//    return sizeof (GetChAccessRes_T);
-}
-
-
-/*---------------------------------------
-* GetChInfo
-*---------------------------------------*/
-int
-GetChInfo (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_  GetChInfoReq_T*     pGetChInfoReq = (_NEAR_ GetChInfoReq_T*)pReq;
-//    _NEAR_  GetChInfoRes_T*     pGetChInfoRes = (_NEAR_ GetChInfoRes_T*)pRes;
-//    BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
-//    _FAR_   ChannelInfo_T*      pChannelInfo;
-//    INT8U               ChannelNum,*curchannel;
-//
-//    if(pGetChInfoReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4)) //Check for Reserved bits
-//    {
-//        pGetChInfoRes->CompletionCode = CC_INV_DATA_FIELD;
-//        return sizeof(*pRes);
-//    }
-//
-//    ChannelNum = pGetChInfoReq->ChannelNum;
-//    if (CURRENT_CHANNEL_NUM == ChannelNum)
-//    {
-//        OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
-//        ChannelNum = *curchannel & 0xF;
-//        
-//        /* UDS, not being a physical channel, will hold LAN properties */ 
-//        if(UDS_CHANNEL == ChannelNum)
-//        {
-//        	ChannelNum = LAN_RMCP_CHANNEL1_TYPE;
-//        }
-//    }
-//
-//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
-//    pChannelInfo = getChannelInfo(ChannelNum, BMCInst);
-//    if (NULL == pChannelInfo)
-//    {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        pGetChInfoRes->CompletionCode = CC_INV_DATA_FIELD ;
-//        return  sizeof (*pRes);
-//    }
-//
-//    pGetChInfoRes->CompletionCode        = CC_NORMAL;
-//    pGetChInfoRes->ChannelNum            = ChannelNum;
-//    pGetChInfoRes->ChannelMedium         = pChannelInfo->ChannelMedium;
-//    pGetChInfoRes->ChannelProtocol       = pChannelInfo->ChannelProtocol;
-//    pGetChInfoRes->SessionActiveSupport  = pChannelInfo->SessionSupport << 6;
-//    pGetChInfoRes->SessionActiveSupport |= pChannelInfo->ActiveSession;
-//
-//    _fmemcpy (pGetChInfoRes->VendorID, pChannelInfo->ProtocolVendorId,
-//                sizeof (pGetChInfoRes->VendorID));
-//    _fmemcpy (pGetChInfoRes->AuxiliaryInfo, pChannelInfo->AuxiliaryInfo,
-//                sizeof (pGetChInfoRes->AuxiliaryInfo));
-//
-//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//
-//    return sizeof (GetChInfoRes_T);
-}
-
-/*---------------------------------------
-* IsChannelSuppGroups
-*---------------------------------------*/
-INT8U  IsChannelSuppGroups(INT8U ChannelNum,int BMCInst)
-{
-//    _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
-//    _FAR_   ChannelInfo_T*          pChannelInfo;
-//    if(IsLANChannel(ChannelNum, BMCInst))
-//    {
-//        
-//        pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
-//        if(pChannelInfo==NULL)
-//            return 0;
-//        if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL1_TYPE) 
-//        {
-//           return pChannelInfo->ChannelType;
-//        }
-//        else
-//        {
-//            if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL2_TYPE)
-//            {
-//               return pChannelInfo->ChannelType;
-//            }
-//            else
-//            {
-//                if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL3_TYPE)
-//                {
-//                   return pChannelInfo->ChannelType;
-//                }
-//                else
-//                    return 0;
-//            }
-//        }
-//        return 0;
-//    }
-//    else
-//    {
-//        if (pBMCInfo->IpmiConfig.SerialIfcSupport == 1 && (pBMCInfo->SERIALch != CH_NOT_USED && ChannelNum == pBMCInfo->SERIALch))
-//        {
-//            pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
-//            if(pChannelInfo==NULL)
-//                return 0;
-//            return pChannelInfo->ChannelType;
-//        }
-//        else 
-//            return 0;
-//    }
-}
-/*---------------------------------------
-* ModifyUsrGRP
-*---------------------------------------*/
-int
-ModifyUsrGrp(char * UserName,INT8U ChannelNum,INT8U OldAccessLimit, INT8U NewAccessLimit )
-{
-//
-//    char oldgrp[20]="",newgrp[20]="";
-//
-//    if(0 == NewAccessLimit)
-//    {
-//        DeleteUsrFromIPMIGrp(UserName);
-//    }
-//
-//    if(PRIV_LEVEL_NO_ACCESS == OldAccessLimit)
-//    {
-//        strcpy(oldgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege].grpname);
-//    }
-//    else if(IGNORE_ADD_OR_REMOVE != OldAccessLimit)
-//    {
-//        strcpy(oldgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege+OldAccessLimit].grpname);
-//    }
-//
-//    if(PRIV_LEVEL_NO_ACCESS == NewAccessLimit)
-//    {
-//        strcpy(newgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege].grpname);
-//    }
-//    else if(IGNORE_ADD_OR_REMOVE != NewAccessLimit)
-//    {
-//        strcpy(newgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege+NewAccessLimit].grpname);
-//    }
-//
-//    AddIPMIUsrtoChGrp(UserName,(char *)oldgrp,(char *)newgrp);
-    return 0;
-}
-
-/*---------------------------------------
-* SetUserAccess
-*---------------------------------------*/
-int
-SetUserAccess (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_  SetUserAccessReq_T*     pSetUserAccessReq = (_NEAR_ SetUserAccessReq_T*)pReq;
-//    _FAR_   ChannelUserInfo_T*      pChUserInfo;
-//    _FAR_   UserInfo_T*             pUserInfo;
-//    _FAR_   ChannelInfo_T*          pChannelInfo;
-//    _FAR_   ChannelInfo_T*          pNvrChInfo;
-//    _FAR_   BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
-//    _FAR_ ChannelUserInfo_T * pNVRChUserInfo=NULL;
-////    char ChFilename[MAX_CHFILE_NAME];
-//    INT8U                   Index;
-//    INT8U                   ChannelNum,IPMIMessaging,*curchannel;
-//    INT8U                   OldAccessLimit;
-//    int ret=0;
-//    
-//    if (ReqLen == sizeof(SetUserAccessReq_T) - sizeof(pSetUserAccessReq->SessionLimit) )
-//    {
-//        pSetUserAccessReq->SessionLimit = 0;
-//    }
-//    else if(ReqLen == sizeof(SetUserAccessReq_T))
-//    {
-//        if(0 != pSetUserAccessReq->SessionLimit)
-//        {
-//            *pRes = CC_INV_DATA_FIELD;
-//            return  sizeof (*pRes);
-//        }
-//    }
-//    else
-//    {
-//        *pRes = CC_REQ_INV_LEN;
-//        return  sizeof (*pRes);
-//    }
-//
-//    // Check for Reserved bits
-//    if((pSetUserAccessReq->UserID & (BIT7 | BIT6)) || (pSetUserAccessReq->SessionLimit & (BIT7 | BIT6 | BIT5 | BIT4)) || (pSetUserAccessReq->AccessLimit == PRIV_LEVEL_RESERVED) || (pSetUserAccessReq->AccessLimit > PRIV_LEVEL_PROPRIETARY && pSetUserAccessReq->AccessLimit != PRIV_LEVEL_NO_ACCESS))
-//    {
-//        *pRes = CC_INV_DATA_FIELD;
-//        return sizeof(*pRes);
-//    }
-//
-//    ChannelNum = pSetUserAccessReq->ChannelNoUserAccess & 0x0F;
-//    if (CURRENT_CHANNEL_NUM == ChannelNum)
-//    {
-//        OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
-//        ChannelNum = *curchannel & 0xF;
-//    }
-//    
-//   /*Removing the Hard coding of admin user 
-//   if(pSetUserAccessReq->UserID == IPMI_ROOT_USER)
-//   {
-//       *pRes = CC_INV_DATA_FIELD;
-//        return  sizeof (*pRes);
-//   }
-//   */
-//
-//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
-//    pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
-//    if((NULL == pChannelInfo) || (pSetUserAccessReq->UserID > pBMCInfo->IpmiConfig.MaxUsers) || (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport))
-//    {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        *pRes = CC_INV_DATA_FIELD;
-//        return  sizeof (*pRes);
-//    }
-//
-//    pUserInfo = getUserIdInfo(pSetUserAccessReq->UserID, BMCInst);
-//    if (NULL == pUserInfo)
-//    {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        TDBG ("AppDevice.c : SetUserAccess - Invalid user Id\n");
-//        *pRes = CC_INV_DATA_FIELD;
-//        return sizeof (*pRes);
-//    }
-//
-//
-//    TDBG("pChannle info is %p\n",pChannelInfo);
-//    TDBG("UserId id is %d\n",pSetUserAccessReq->UserID);
-//    TDBG("pUserInfo->ID is %ld and USERID is %ld\n",pUserInfo->ID,USER_ID);
-//
-//    if (pUserInfo->ID != USER_ID)
-//    {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        TCRIT("Invalid data field\n");
-//        *pRes = CC_INV_DATA_FIELD;
-//        return  sizeof (*pRes);
-//    }
-//
-//    /* User 's session limit should be lesser than Channel 's session limit */
-//    if(pSetUserAccessReq->SessionLimit > pBMCInfo->IpmiConfig.MaxSession)
-//    {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        *pRes = CC_INV_DATA_FIELD;
-//        return sizeof (*pRes);
-//    }
-//
-//
-//    pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
-//    pNVRChUserInfo = GetNVRChUserConfigs(pChannelInfo,BMCInst);
-//    pChUserInfo  = getChUserIdInfo (pSetUserAccessReq->UserID , &Index, pChannelInfo->ChannelUserInfo, BMCInst);
-//
-//    if (NULL == pChUserInfo)
-//    {
-//        /* Add the user in NVRAM    */
-//        pChUserInfo         = AddChUser (pChannelInfo->ChannelUserInfo, &Index, BMCInst);
-//        if(pChUserInfo == NULL)
-//        {
-//            /*Return proper completion if the user exceeds the max channel users*/
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//            *pRes = CC_INV_DATA_FIELD;
-//            return sizeof (*pRes);
-//        }
-//
-//        pChUserInfo->ID     = USER_ID;
-//        pChUserInfo->UserId = pSetUserAccessReq->UserID;
-//        pNVRChUserInfo[Index].UserId = pSetUserAccessReq->UserID;
-//
-//        pChUserInfo->AccessLimit = PRIV_LEVEL_NO_ACCESS;
-//        /* Initial depends on the  Request Bit */
-//         pChUserInfo->IPMIMessaging=FALSE;
-//         pChUserInfo->ActivatingSOL=FALSE;
-//         pChUserInfo->UserAccessCallback = FALSE;
-//         pChUserInfo->LinkAuth  = FALSE;
-//         pNVRChUserInfo[Index].ID = USER_ID;
-//         pNVRChUserInfo[Index].IPMIMessaging=FALSE;
-//         pNVRChUserInfo[Index].ActivatingSOL=FALSE;
-//         pNVRChUserInfo[Index].UserId = pSetUserAccessReq->UserID;
-//         pNVRChUserInfo[Index].LinkAuth    = FALSE;
-//         pNVRChUserInfo[Index].UserAccessCallback   =FALSE;
-//    }
-//
-//    if (0 != (pSetUserAccessReq->ChannelNoUserAccess & 0x80))
-//    {
-//        /* set the user access for the channel  */
-//        IPMIMessaging = GetBits (pSetUserAccessReq->ChannelNoUserAccess, 0x10);
-//        if (FALSE == IPMIMessaging)
-//        {
-//            /* Disable the IPMI Messaging if Its in Enables state */
-//            if((TRUE == pChUserInfo->IPMIMessaging)&& (pChannelInfo->NoCurrentUser > 1) )
-//            {
-//                 /* Initialize based on the Request Bit */
-//                 pChUserInfo->IPMIMessaging=IPMIMessaging;
-//                 pNVRChUserInfo[Index].IPMIMessaging=IPMIMessaging;
-//            }
-//        }
-//        else
-//        {
-//            if(TRUE == pChUserInfo->IPMIMessaging)
-//            {
-//                pChUserInfo->Lock = USER_UNLOCKED;
-//                pChUserInfo->LockedTime = 0;
-//                pChUserInfo->FailureAttempts = 0;
-//            }
-//            else if(FALSE == pChUserInfo->IPMIMessaging) /* Enable the IPMI Messaging  ,If its in disabled state */
-//            {
-//                /* Initialize based on the  Request Bit */
-//                pChUserInfo->IPMIMessaging=IPMIMessaging;
-//                pNVRChUserInfo[Index].IPMIMessaging=IPMIMessaging;
-//                pChUserInfo->Lock = USER_UNLOCKED;
-//                pChUserInfo->LockedTime = 0;
-//                pChUserInfo->FailureAttempts = 0;
-//            }
-//    }
-//
-//    /* set in RAM   */
-//    pChUserInfo->UserAccessCallback = GetBits (pSetUserAccessReq->ChannelNoUserAccess, 0x40);
-//    pChUserInfo->LinkAuth           = GetBits (pSetUserAccessReq->ChannelNoUserAccess, 0x20);
-//
-//    pNVRChUserInfo[Index].UserId   = pSetUserAccessReq->UserID;
-//    pNVRChUserInfo[Index].LinkAuth =
-//        GetBits (pSetUserAccessReq->ChannelNoUserAccess, 0x20);
-//    pNVRChUserInfo[Index].UserAccessCallback   =
-//        GetBits (pSetUserAccessReq->ChannelNoUserAccess, 0x40);
-//
-//
-//        }
-//    OldAccessLimit=pChUserInfo->AccessLimit;
-//    pChUserInfo->AccessLimit = GetBits (pSetUserAccessReq->AccessLimit, 0x0F);
-//
-//    ret=ModifyUsrGrp((char *)pUserInfo->UserName,ChannelNum,OldAccessLimit,pChUserInfo->AccessLimit);
-//    if(ret < 0)
-//    {
-//        TCRIT("User Has No LAN or Serial Preivilege!!\n");
-//    }
-//
-//    pNVRChUserInfo[Index].AccessLimit = pChUserInfo->AccessLimit;
-//    /* set in NVRAM */
-//    if (0 == (pUserInfo->MaxSession))
-//    {
-//    /* This is MAX User session Limit */
-//        pUserInfo->MaxSession = pBMCInfo->IpmiConfig.MaxSession;
-//    }
-//
-//
-//    FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0],(INT8U*)&pBMCInfo->UserInfo[0],pBMCInfo->IPMIConfLoc.UserInfoAddr,
-//                      sizeof(UserInfo_T)*MAX_USER_CFG_MDS,BMCInst);
-//    FlushChConfigs((INT8U*)pNvrChInfo,pNvrChInfo->ChannelNumber,BMCInst);
-//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//
-//    *pRes = CC_NORMAL;
-//
-//    return sizeof (*pRes);
-}
-
-
-/*---------------------------------------
-* GetUserAccess
-*---------------------------------------*/
-int
-GetUserAccess (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_  GetUserAccessReq_T*     pGetUserAccessReq = (_NEAR_ GetUserAccessReq_T*)pReq;
-//    _NEAR_  GetUserAccessRes_T*     pGetUserAccessRes = (_NEAR_ GetUserAccessRes_T*)pRes;
-//    _FAR_   ChannelUserInfo_T*      pChUserInfo;
-//    _FAR_   UserInfo_T*             pUserInfo;
-//    _FAR_   ChannelInfo_T*          pChannelInfo;
-//    _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
-//    INT8U                   Index,*curchannel;
-//
-//    // Check for Reserved bits
-//    if((pGetUserAccessReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4)) || (pGetUserAccessReq->UserID & (BIT7 | BIT6)) || (pGetUserAccessReq->UserID == 0x00))
-//    {
-//        pGetUserAccessRes->CompletionCode = CC_INV_DATA_FIELD;
-//        return sizeof(*pRes);
-//    }
-//
-//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
-//    if (pGetUserAccessReq->ChannelNum == CURRENT_CHANNEL_NUM)
-//    {
-//        OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
-//        pChannelInfo = getChannelInfo(*curchannel,BMCInst);
-//    }
-//    else
-//    pChannelInfo = getChannelInfo(pGetUserAccessReq->ChannelNum,BMCInst);
-//
-//    //TDBG("UserID is  %d\n",pGetUserAccessReq->UserID);
-//
-//    if ((NULL == pChannelInfo)      ||
-//        (pGetUserAccessReq->UserID > pBMCInfo->IpmiConfig.MaxUsers)    ||
-//        (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport))
-//    {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        pGetUserAccessRes->CompletionCode = CC_INV_DATA_FIELD;
-//        return  sizeof (*pRes);
-//    }
-//
-//    pUserInfo = getUserIdInfo (pGetUserAccessReq->UserID, BMCInst);
-//
-//    if (NULL == pUserInfo)
-//   {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//       pGetUserAccessRes->CompletionCode = CC_INV_DATA_FIELD;
-//       return  sizeof (*pRes);
-//   }
-//
-//    if (TRUE == pUserInfo->UserStatus)
-//    {
-//        pGetUserAccessRes->CurrentUserID  = SetBits (0xC0, USER_ID_ENABLED);
-//    }
-//    else
-//    {
-//        pGetUserAccessRes->CurrentUserID  = SetBits (0xC0, USER_ID_DISABLED);
-//    }
-//
-//    pChUserInfo = getChUserIdInfo (pGetUserAccessReq->UserID, &Index, pChannelInfo->ChannelUserInfo ,BMCInst);
-//
-//    if (NULL == pChUserInfo)
-//    {
-//        pGetUserAccessRes->ChannelAccess  = SetBits (0x0F, 0x0F);
-//        pGetUserAccessRes->ChannelAccess |= SetBits (0x10, FALSE);
-//        pGetUserAccessRes->ChannelAccess |= SetBits (0x20, FALSE);
-//        pGetUserAccessRes->ChannelAccess |= SetBits (0x40, FALSE);
-//    }
-//    else
-//    {
-//        pGetUserAccessRes->ChannelAccess  = SetBits (0x0F, pChUserInfo->AccessLimit);
-//        pGetUserAccessRes->ChannelAccess |= SetBits (0x10, pChUserInfo->IPMIMessaging);
-//        pGetUserAccessRes->ChannelAccess |= SetBits (0x20, pChUserInfo->LinkAuth);
-//        pGetUserAccessRes->ChannelAccess |= SetBits (0x40, pChUserInfo->UserAccessCallback);
-//    }
-//
-//    pGetUserAccessRes->CompletionCode = CC_NORMAL;
-//    pGetUserAccessRes->MaxNoUserID    = SetBits (0x3F, pChannelInfo->MaxUser);
-//    pGetUserAccessRes->CurrentUserID  |= SetBits (0x3F, pChannelInfo->NoCurrentUser);
-//    pGetUserAccessRes->FixedUserID      = SetBits (0x3F, pChannelInfo->NoFixedUser);
-//
-//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//
-//    return sizeof (GetUserAccessRes_T);
-}
-
-
-/*---------------------------------------
-* SetUserName
-*---------------------------------------*/
-int
-SetUserName (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_  SetUserNameReq_T*       pSetUserNameReq = (_NEAR_ SetUserNameReq_T*)pReq;
-//    _FAR_   UserInfo_T*             pUserInfo;
-//    _FAR_   ChannelInfo_T*          pChannelInfo=NULL;
-//    _FAR_   ChannelInfo_T*          pNvrChInfo;
-//    _FAR_   ChannelUserInfo_T*      pChUserInfo;
-//    _FAR_   ChannelUserInfo_T * pNVRChUserInfo=NULL;
-//    _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
-//    INT8U                   Ch, Index,Chtype;
-//    //INT16S                  Err;
-//    INT8U                   i;
-//    INT8U   UserName[MAX_USERNAME_LEN + 1];   //plus 1 for null terminator
-//    INT8U InvalidChar[]={  ' ' , ',' , '.' , '/' , ':' , ';' , '\\' , '(', ')' , 0x01 ,
-//    		               0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09, 0x0A ,
-//    		               0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x10 , 0x11 , 0x12, 0x13 ,
-//    		               0x14 , 0x15 , 0x16 , 0x17 , 0x18 , 0x19 , 0x1A , 0x1B, 0x1C ,
-//    		               0x1D , 0x1E , 0x1F , 0x7F} ;
-//
-////    char ChFilename[MAX_CHFILE_NAME];
-//    //INT8U Handle = sizeof(ChInfo_T)-sizeof(ChannelInfo_T);
-//
-//    // Check for Reserved bits
-//    if(pSetUserNameReq->UserID & (BIT7 | BIT6) || (pSetUserNameReq->UserID == 0x00))
-//    {
-//        *pRes = CC_INV_DATA_FIELD;
-//        return sizeof(*pRes);
-//    }
-//
-//    /*User Id exceeded the limit or  Cant set NULL User */
-//    if (pSetUserNameReq->UserID > pBMCInfo->IpmiConfig.MaxUsers )
-//    {
-//        *pRes = CC_INV_DATA_FIELD ;
-//        return  sizeof (*pRes);
-//    }
-//
-//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
-//    pUserInfo = getUserIdInfo(pSetUserNameReq->UserID, BMCInst);
-//
-//    /* If the user is fixed user */
-//    if (((pUserInfo != NULL) && (pUserInfo->FixedUser == TRUE)))
-//    {
-//	    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        *pRes = CC_INV_DATA_FIELD ;
-//        return  sizeof (*pRes);
-//    }
-//    
-//    /* We should not set the NULL user */
-//    if(0== pSetUserNameReq->UserName [0] )
-//    {
-//        printf("\n Setting the NULL user :%x",pSetUserNameReq->UserID);
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        *pRes = CC_INV_DATA_FIELD ;
-//        return	sizeof (*pRes);
-//    }
-//
-//    /* check for numeric first char and special chars */
-//    if( 0 != isdigit(pSetUserNameReq->UserName[0] ) )
-//    {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        *pRes = CC_INV_DATA_FIELD;
-//        return sizeof(*pRes);
-//    }
-//    else
-//    {
-//        for(i=0;i<sizeof(InvalidChar);i++)
-//        {
-//            strncpy((char *)UserName,(const char *) pSetUserNameReq->UserName, sizeof(pSetUserNameReq->UserName));
-//            UserName[MAX_USERNAME_LEN] = '\0';
-//            if( NULL != strchr((const char *)UserName, InvalidChar[i] ))
-//            {
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                *pRes = CC_INV_DATA_FIELD;
-//                return sizeof(*pRes);
-//            }
-//        }
-//    }
-//    
-//    //Don't check duplicated user names for 0xFF, this request is for deleting user
-//    if(0xFF != pSetUserNameReq->UserName [0])
-//    {
-//        //checking for Duplicate user names
-//        if(CheckForDuplicateUsers(pSetUserNameReq->UserName,BMCInst)==FALSE)
-//        {
-//            //setting user's name with same name
-//            if(!strncmp((char *)pUserInfo->UserName,(char *)pSetUserNameReq->UserName, MAX_USERNAME_LEN))
-//            {
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                *pRes = CC_NORMAL;
-//                return sizeof (*pRes);
-//            }
-//            TINFO("Duplicate ipmi user!!\n");
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//            *pRes = CC_INV_DATA_FIELD;
-//            return	sizeof (*pRes);    		
-//        }
-//    }
-//    //checking for reserved user names
-//	if(CheckForReservedUsers((char *)pSetUserNameReq->UserName) != 0)
-//	{
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//		*pRes = CC_INV_DATA_FIELD;
-//		return  sizeof (*pRes);
-//	}
-//
-//
-//    /* Add to Linux data base */
-//    //Err = 0;
-//
-//    /* If User[0] is 0xFF means the user is requested to delete */
-//    if ((0xFF == pSetUserNameReq->UserName [0]) ||
-//         (0 == pSetUserNameReq->UserName [0] ))
-//    {
-//        if ((0 == pUserInfo->CurrentSession) && (0 != disableUser (pSetUserNameReq->UserID,BMCInst)))
-//        {
-//            /* Delete this user form all the channel */
-//            for (Ch = 0; Ch < MAX_NUM_CHANNELS; Ch++)
-//            {
-//                if(pBMCInfo->ChConfig[Ch].ChType != 0xff)
-//                {
-//                    pChannelInfo = (ChannelInfo_T*)&pBMCInfo->ChConfig[Ch].ChannelInfo;
-//                }
-//                else
-//                {
-//                    continue;
-//                }
-//
-//                pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
-//                pNVRChUserInfo = GetNVRChUserConfigs(pChannelInfo,BMCInst);
-//
-//                pChUserInfo = getChUserIdInfo(pSetUserNameReq->UserID, &Index, pChannelInfo->ChannelUserInfo,BMCInst);
-//
-//                if (pChUserInfo != NULL)
-//                {
-//                    ModifyUsrGrp((char *)pUserInfo->UserName,pChannelInfo->ChannelNumber,pChUserInfo->AccessLimit,IGNORE_ADD_OR_REMOVE);
-//                    AddIPMIUsrtoShellGrp((char *)pUserInfo->UserName, pUserInfo->UserShell, IGNORE_ADD_OR_REMOVE_SHELL);
-//                    AddIPMIUsrtoFlagsGrp((char *)pUserInfo->UserName,pUserInfo->ExtendedPrivilege,IGNORE_ADD_OR_REMOVE);
-//                    pNVRChUserInfo[Index].UserId = 0;
-//                    pNVRChUserInfo[Index].IPMIMessaging=FALSE;
-//                    pNVRChUserInfo[Index].ActivatingSOL=FALSE;
-//                    pNVRChUserInfo[Index].ID=0;
-//                    pChUserInfo->ID=0;
-//                    pChUserInfo->UserId = 0;
-//                    pChUserInfo->IPMIMessaging=FALSE;
-//                    pChUserInfo->ActivatingSOL=FALSE;
-//                    if( pUserInfo->UserStatus == TRUE)
-//                    {
-//                        pChannelInfo->NoCurrentUser--;
-//                        pNvrChInfo->NoCurrentUser--;
-//                    }
-//                    FlushChConfigs((INT8U*)pNvrChInfo,pNvrChInfo->ChannelNumber,BMCInst);
-//                }
-//                else
-//                    {
-//                        if(pUserInfo != NULL)
-//                            DeleteUsrFromIPMIGrp((char *)pUserInfo->UserName);
-//                    }
-//            }
-//
-//            /* Checking for valid user, empty users doesnt conatain user directories*/
-//            if (USER_ID == pUserInfo->ID)
-//            {
-//                //removing the user directory created in add user	   
-//                if(RemoveUsrDir((char *)pUserInfo->UserName)!=0)
-//                {
-//                    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                    *pRes = CC_UNSPECIFIED_ERR;
-//                    return  sizeof (*pRes);
-//                }
-//            }	
-//            /* Delete the user both in Volatile & Non Volatile memory*/
-//            pBMCInfo->GenConfig.CurrentNoUser--;
-//            _fmemset (pUserInfo,    0, sizeof (UserInfo_T));
-//            FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0],(INT8U*)&pBMCInfo->UserInfo[0],pBMCInfo->IPMIConfLoc.UserInfoAddr,
-//                              sizeof(UserInfo_T)*MAX_USER_CFG_MDS,BMCInst);
-//        }
-//        else
-//        {
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//            *pRes = CC_INV_DATA_FIELD ;
-//            return  sizeof (*pRes);
-//        }
-//    }
-//    else if (USER_ID != pUserInfo->ID)//adding users
-//    {
-//        for (i = 0; i < MAX_USERNAME_LEN; i++)
-//        {
-//            if(!(isascii(pSetUserNameReq->UserName[i])))
-//            {
-//                *pRes = CC_INV_DATA_FIELD ;
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                return  sizeof (*pRes);
-//            }
-//        }
-//        /* If First time-if user ID does not exist  */
-//        /* if the user name is set for the first time */
-//        pUserInfo->ID            = USER_ID;
-//        pUserInfo->UserId        = pSetUserNameReq->UserID;
-//        /* allow for IPMI Mesaging  */
-//        pUserInfo->UserStatus    = FALSE;
-//        /* set default max session  */
-//        pUserInfo->MaxSession    = pBMCInfo->IpmiConfig.MaxSession;
-//
-//        pBMCInfo->GenConfig.CurrentNoUser++;
-//        for (Ch = 0; Ch < MAX_NUM_CHANNELS; Ch++)
-//        {
-//            if((Chtype = IsChannelSuppGroups(Ch,BMCInst)) == 0)
-//                continue;
-//            AddUsrtoIPMIGrp((char *)pSetUserNameReq->UserName,Chtype);
-//            ModifyUsrGrp((char *)pSetUserNameReq->UserName,Ch,IGNORE_ADD_OR_REMOVE,PRIV_LEVEL_NO_ACCESS);
-//        }
-//        AddIPMIUsrtoShellGrp((char *)pSetUserNameReq->UserName, IGNORE_ADD_OR_REMOVE_SHELL, pUserInfo->UserShell);
-//        AddIPMIUsrtoFlagsGrp((char *)pSetUserNameReq->UserName, IGNORE_ADD_OR_REMOVE, pUserInfo->ExtendedPrivilege);
-//        //creating ssh directorys for new user
-//        if( CreateSSHUserDir((char *)pSetUserNameReq->UserName)  != 0)
-//        {
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//            *pRes = CC_UNSPECIFIED_ERR;
-//            return  sizeof (*pRes);
-//        }
-//        //creating authentication key for new user
-//        if (CreateSSHAuthKeyFile((char *)pSetUserNameReq->UserName)!= 0)
-//        {
-//            *pRes = CC_UNSPECIFIED_ERR;
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//            return	sizeof (*pRes);
-//        }
-//        TINFO("user folders created successfuy----\n");
-//
-//    }
-//    else if (USER_ID == pUserInfo->ID)//modifying users
-//    {
-//        for (i = 0; i < MAX_USERNAME_LEN; i++)
-//        {
-//            if(!(isascii(pSetUserNameReq->UserName[i])))
-//            {
-//                *pRes = CC_INV_DATA_FIELD ;
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                return  sizeof (*pRes);
-//            }
-//        }
-//        /* If user name isn't set before we create a folder */
-//        if( 0 == pUserInfo->UserName[0] ) 
-//        {
-//            CreateSSHUserDir((char *)pSetUserNameReq->UserName);
-//        }
-//        else
-//        {
-//            RenameUserDir((char *)pUserInfo->UserName, (char *)pSetUserNameReq->UserName);
-//        }
-//
-//        for (Ch = 0; Ch < MAX_NUM_CHANNELS; Ch++)
-//        {
-//            if((Chtype = IsChannelSuppGroups(Ch,BMCInst)) == 0)
-//            {
-//                continue;
-//            }
-//            AddUsrtoIPMIGrp((char *)pSetUserNameReq->UserName,Chtype);
-//            pChannelInfo = getChannelInfo (Ch, BMCInst);
-//            if(NULL == pChannelInfo)
-//            {
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                *pRes = CC_INV_DATA_FIELD;
-//                return	sizeof (*pRes);
-//            }
-//			
-//            pChUserInfo = getChUserIdInfo(pSetUserNameReq->UserID, &Index, pChannelInfo->ChannelUserInfo,BMCInst);
-//            if (pChUserInfo != NULL)
-//            {
-//                ModifyUsrGrp((char *)pUserInfo->UserName, pChannelInfo->ChannelNumber, pChUserInfo->AccessLimit, IGNORE_ADD_OR_REMOVE);//Remove User
-//                ModifyUsrGrp((char *)pSetUserNameReq->UserName, pChannelInfo->ChannelNumber, IGNORE_ADD_OR_REMOVE, pChUserInfo->AccessLimit);//add user
-//            }
-//            else
-//            {
-//                ModifyUsrGrp((char *)pUserInfo->UserName, Ch,PRIV_LEVEL_NO_ACCESS, IGNORE_ADD_OR_REMOVE);//Remove User
-//                ModifyUsrGrp((char *)pSetUserNameReq->UserName, Ch, IGNORE_ADD_OR_REMOVE, PRIV_LEVEL_NO_ACCESS);//add user
-//            }
-//        }
-//        AddIPMIUsrtoShellGrp((char *)pUserInfo->UserName, pUserInfo->UserShell, IGNORE_ADD_OR_REMOVE_SHELL);//Remove User from Shell Group
-//        AddIPMIUsrtoShellGrp((char *)pSetUserNameReq->UserName, IGNORE_ADD_OR_REMOVE_SHELL, pUserInfo->UserShell);//Add User in Shell Group
-//        AddIPMIUsrtoFlagsGrp((char *)pUserInfo->UserName, pUserInfo->ExtendedPrivilege, IGNORE_ADD_OR_REMOVE);//Remove User from Flags Group
-//        AddIPMIUsrtoFlagsGrp((char *)pSetUserNameReq->UserName, IGNORE_ADD_OR_REMOVE, pUserInfo->ExtendedPrivilege);//Add User in Flags Group
-//    }    
-//        _fmemcpy (pUserInfo->UserName, pSetUserNameReq->UserName, MAX_USERNAME_LEN);
-//
-//        FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0],(INT8U*)&pBMCInfo->UserInfo[0],pBMCInfo->IPMIConfLoc.UserInfoAddr,
-//                          sizeof(UserInfo_T)*MAX_USER_CFG_MDS,BMCInst);
-//        FlushIPMI((INT8U*)&pBMCInfo->GenConfig,(INT8U*)&pBMCInfo->GenConfig,pBMCInfo->IPMIConfLoc.GenConfigAddr,
-//                          sizeof(GENConfig_T),BMCInst);
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        *pRes = CC_NORMAL;
-//        return sizeof (*pRes);
-}
-
-
-/*---------------------------------------
-* GetUserName
-*---------------------------------------*/
-int
-GetUserName (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_  GetUserNameReq_T*       pGetUserNameReq = (_NEAR_ GetUserNameReq_T*)pReq;
-//    _NEAR_  GetUserNameRes_T*       pGetUserNameRes = (_NEAR_ GetUserNameRes_T*)pRes;
-//    _FAR_   UserInfo_T*             pUserInfo;
-//    _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
-//    //INT16S                  Err;
-//
-//    // Check for Reserved bits
-//    if(pGetUserNameReq->UserID & (BIT7 | BIT6) || (pGetUserNameReq->UserID == 0x00))
-//    {
-//        pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
-//        return sizeof(*pRes);
-//    }
-//
-//    if (pGetUserNameReq->UserID > pBMCInfo->IpmiConfig.MaxUsers)
-//    {
-//        /*  if user ID exceeded the Max limit */
-//        pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
-//        return  sizeof (*pRes);/* Invalied user id */
-//    }
-//
-//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
-//    pUserInfo = getUserIdInfo(pGetUserNameReq->UserID, BMCInst);
-//
-//    /* if User is disabled or if User is not created */
-//
-//    //if user is disabled we dont have to return invalid data field
-//    //instead we return everything possible about the user
-//    // if pUserInfo is NULL then nothing in the structure at all
-//    // pUserInfo being NULL is probably not possible
-//    // If the signature doesnt match then the useris not yet configured
-//    // so reasonable to return an error
-//    if ((NULL == pUserInfo) || (pUserInfo->ID != USER_ID))
-//    {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        /* User with given ID is disabled */
-//        *pRes = CC_INV_DATA_FIELD;
-//        return sizeof (*pRes);
-//    }
-//
-//    //if we are here then the user is just disabled
-//    if(FALSE == pUserInfo->UserStatus)
-//    {
-//        TDBG("user is just dissabled\n");
-//        //user is just disabled!!
-//    }
-//
-//    //Err = 0;
-//    pGetUserNameRes->CompletionCode = CC_NORMAL;
-//    _fmemcpy (pGetUserNameRes->UserName, pUserInfo->UserName, MAX_USERNAME_LEN);
-//
-//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//
-//    return sizeof (GetUserNameRes_T);
-}
-
-
-/*---------------------------------------
-* SetUserPassword
-*---------------------------------------*/
-int
-SetUserPassword (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_  SetUserPswdReq_T*       pSetUserPswdReq = (_NEAR_ SetUserPswdReq_T*)pReq;
-//    _FAR_   UserInfo_T*             pUserInfo;
-//    _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
-//    INT8U                   UserId=0, Operation;
-//    INT8U   UserPswd[MAX_PASSWD_LEN];
-//    INT8S EncryptedUserPswd[MAX_ENCRYPTED_PSWD_LEN] = {0};
-//    INT8U PwdEncKey[MAX_SIZE_KEY + 1] = {0};
-//    INT8U          i;
-//    INT8U          UserPassword[ MAX_PASSWORD_LEN + 1 ];
-//    INT8U InvalidChar[] = {  0x01 , 0x02 , 0x03 , 0x04 ,0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x0A, 
-//                             0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x10 , 0x11 , 0x12 , 0x13 , 0x14,
-//                             0x15 , 0x16 , 0x17 , 0x18 , 0x19 , 0x1A , 0x1B , 0x1C , 0x1D , 0x1E , 
-//                             0x1F , 0x7F };
-//
-//
-//    Operation = pSetUserPswdReq->Operation & 0x03;
-//    UserId    = pSetUserPswdReq->UserID & 0x3F;
-//
-//    if ((((pSetUserPswdReq->UserID & TWENTY_BYTE_PWD) == 0) && (ReqLen != IPMI_15_PASSWORD_LEN))
-//         ||(((pSetUserPswdReq->UserID & TWENTY_BYTE_PWD) == TWENTY_BYTE_PWD) && (ReqLen != IPMI_20_PASSWORD_LEN)))
-//    {
-//        /* For enable or disable using the password field is optional */
-//        if (ReqLen == OP_USERID_ONLY_LENGTH)
-//        {
-//            if ((Operation != OP_ENABLE_USER_ID) && (Operation != OP_DISABLE_USER_ID))
-//            {
-//                *pRes = CC_REQ_INV_LEN;
-//                return  sizeof (*pRes); //Invalid operation.
-//            }
-//        }
-//        else
-//        {
-//            *pRes = CC_REQ_INV_LEN;
-//            return  sizeof (*pRes); //password len invalid
-//        }
-//    }
-//
-//    /* Reserved bits checking */
-//    if((pSetUserPswdReq->UserID & BIT6) || (UserId == 0) || (pSetUserPswdReq->Operation & (BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)))
-//    {
-//        *pRes = CC_INV_DATA_FIELD;
-//        return	sizeof (*pRes);
-//    }
-//
-//    if (ReqLen == IPMI_15_PASSWORD_LEN)
-//    {
-//        _fmemset (pSetUserPswdReq->Password + 16, 0, 4);
-//    }
-//    ReqLen -=2;
-//
-//    if (UserId > pBMCInfo->IpmiConfig.MaxUsers)
-//    {
-//        *pRes = CC_INV_DATA_FIELD;
-//        return  sizeof (*pRes); /*User Id exceeded the limit*/
-//    }
-//
-//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
-//    pUserInfo = getUserIdInfo (UserId, BMCInst);
-//
-//    if ( NULL ==  pUserInfo )
-//    {
-//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//        IPMI_WARNING ("Invalid User Id \n");
-//        *pRes = CC_INV_DATA_FIELD;
-//        return  sizeof (*pRes);
-//    }
-//
-//    TDBG("pUserInfo is %p\n",pUserInfo);
-//
-//    *pRes = CC_NORMAL;
-//
-//    switch (Operation)
-//    {
-//
-//        case DISABLE_USER:
-//            TDBG("In disable user for user id %d\n",UserId);
-//            /*disable user  */
-//            if(pUserInfo == NULL)
-//            {
-//                //the user is already disabled!!
-//                //no point in disabling him again
-//            }
-//            else if(disableUser(UserId, BMCInst) == 0)
-//            {
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                //we cannot disable this user because he is the only user in the channel
-//                TDBG("not disabling user\n");
-//                /* cannot disable user since this user is the only user in the channel*/
-//                *pRes = CC_SETPASSWORD_CANNOT_DISABLE_USER;
-//                return  sizeof (*pRes);
-//            }
-//            else
-//            {
-//                //here we can disable the user
-//
-//                TDBG("will disable user\n");
-//
-//                if (pUserInfo->UserStatus == TRUE)  	
-//                {
-//                    pBMCInfo->GenConfig.CurrentNoUser--;
-//                    UpdateCurrentEnabledUserCount(COUNT_DECREASE, BMCInst);  
-//                }
-//
-//                pUserInfo->UserStatus    = FALSE;
-//
-//                //when user is disabled ".ssh" folder of the user  is renamed to restrict user login
-//                TDBG("renaming the .ssh folder to _.ssh\n");
-//                if(RenameUserSSHDir((char *)pUserInfo->UserName)!=0)
-//                {
-//                    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                    *pRes = CC_UNSPECIFIED_ERR;
-//                    return  sizeof (*pRes);
-//                }
-//            }
-//
-//            break;
-//
-//        case ENABLE_USER:
-//            /*enable user   */
-//            if (USER_ID == pUserInfo->ID)
-//            {
-//                /* if for the first time then Increment the Current user No */
-//                if ( pUserInfo->UserStatus == FALSE )
-//                {
-//                    pBMCInfo->GenConfig.CurrentNoUser++;
-//                    UpdateCurrentEnabledUserCount(COUNT_INCREASE, BMCInst);
-//                }
-//                pUserInfo->UserStatus    = TRUE;
-//
-//                //when user is enabled the pub key is restored to original name to allow login
-//                TDBG("restoring the ._ssh folder to .ssh\n");
-//                if( RestoreUsrSSHDir((char *)pUserInfo->UserName)!=0)
-//                {
-//                    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                    *pRes = CC_UNSPECIFIED_ERR;
-//                    return  sizeof (*pRes);
-//                }
-//                if (0 == pUserInfo->UserName [0])
-//                {
-//                    TDBG ("The user Name is Not yet set.. So No synching with the linux \n");
-//                    *pRes = CC_NORMAL;
-//                    FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0],(INT8U*)&pBMCInfo->UserInfo[0],pBMCInfo->IPMIConfLoc.UserInfoAddr,
-//                                      sizeof(UserInfo_T)*MAX_USER_CFG_MDS,BMCInst);
-//                    FlushIPMI((INT8U*)&pBMCInfo->GenConfig,(INT8U*)&pBMCInfo->GenConfig,pBMCInfo->IPMIConfLoc.GenConfigAddr,
-//                                      sizeof(GENConfig_T),BMCInst);
-//                    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                    return  sizeof (*pRes);
-//                }
-//                TDBG  ("Synching with the Linux User dataBase \n");
-//            }
-//            else
-//            {
-//                /* Looks like the User info is not there So just enable the user in the IPMI  */
-//                /* no need to Ssync with  the linux databse since there will b No corresponding user in the linux database  */
-//                TCRIT("Enable user called on a not yet enabled user!!\n");
-//                /* If First time-if user ID does not exist  */
-//                /* if the user is enabled for the first time  */
-//                pUserInfo->ID            = USER_ID;
-//                pUserInfo->UserId        = UserId;
-//                pUserInfo->UserStatus    = TRUE;
-//                pUserInfo->MaxSession    = pBMCInfo->IpmiConfig.MaxSession;
-//
-//                pBMCInfo->GenConfig.CurrentNoUser++;
-//                UpdateCurrentEnabledUserCount(COUNT_INCREASE, BMCInst);
-//
-//                //when user is enabled the pub key is restored to original name to allow login
-//                TDBG("restoring the ._ssh folder to .ssh\n");
-//                if(RestoreUsrSSHDir((char *)pUserInfo->UserName)!=0)
-//                {
-//                    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                    *pRes = CC_UNSPECIFIED_ERR;
-//                    return	sizeof (*pRes);
-//                }
-//                memset(pUserInfo->UserName, 0, MAX_USERNAME_LEN);
-//                /* If user name isn't set before we save the configuration */
-//                FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0], (INT8U*)&pBMCInfo->UserInfo[0], pBMCInfo->IPMIConfLoc.UserInfoAddr,
-//                                  sizeof(UserInfo_T)*MAX_USER_CFG_MDS, BMCInst);
-//                FlushIPMI((INT8U*)&pBMCInfo->GenConfig, (INT8U*)&pBMCInfo->GenConfig, pBMCInfo->IPMIConfLoc.GenConfigAddr,
-//                                  sizeof(GENConfig_T), BMCInst);
-//                *pRes = CC_NORMAL;
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                return  sizeof (*pRes);
-//            }
-//            break;
-//
-//        case SET_PASSWORD:
-//            /*set password  */
-//            if (USER_ID == pUserInfo->ID)
-//            {
-//            	/*check for special characters*/
-//                for( i = 0 ; i < sizeof(InvalidChar) ; i++ )
-//                {
-//                     strncpy((char *)UserPassword,(const char *) pSetUserPswdReq->Password, sizeof(pSetUserPswdReq->Password));
-//                     UserPassword[MAX_PASSWORD_LEN] = '\0';
-//                     if( NULL != strchr((const char *)UserPassword, InvalidChar[i] ))
-//                     {
-//                        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                         *pRes = CC_INV_DATA_FIELD;
-//                         return sizeof(*pRes);
-//                     }
-//                }
-//
-//                pUserInfo->MaxPasswordSize = ReqLen;
-//                if (g_corefeatures.userpswd_encryption == ENABLED)
-//                {
-//                    /* Get Encryption Key from the MBMCInfo_t structure */
-//                        memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
-//
-//                    if(EncryptPassword((INT8S *)pSetUserPswdReq->Password, MAX_PASSWORD_LEN, EncryptedUserPswd, MAX_PASSWORD_LEN, PwdEncKey))
-//                    {
-//                        TCRIT("Error in encrypting the IPMI User Password for user ID:%d\n", pSetUserPswdReq->UserID);
-//                        *pRes = CC_UNSPECIFIED_ERR;
-//                        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                        return sizeof(INT8U);
-//                    }
-//                        memset(&(pBMCInfo->EncryptedUserInfo[UserId - 1].EncryptedPswd), 0, MAX_ENCRYPTED_PSWD_LEN);
-//                        memcpy(&(pBMCInfo->EncryptedUserInfo[UserId - 1].EncryptedPswd), EncryptedUserPswd, MAX_ENCRYPTED_PSWD_LEN);
-//                        memcpy(pBMCInfo->UserInfo[UserId - 1].UserPassword, "$ENCRYPTED$", 11);
-//                }
-//                else
-//                {
-//                	_fmemcpy (pUserInfo->UserPassword, pSetUserPswdReq->Password, MAX_PASSWORD_LEN);
-//                }
-//                if(ENABLED != g_corefeatures.disable_empty_passwd_login)
-//                {
-//                    TDBG("\nSet User Password .Password is configured succussfully...\n");
-//                    pUserInfo->UserPasswdConfigured = 1;
-//                }
-//            }
-//            else
-//            {
-//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                *pRes = CC_INV_DATA_FIELD;
-//                return sizeof (*pRes);
-//            }
-//            break;
-//
-//        case TEST_PASSWORD:
-//            if (g_corefeatures.userpswd_encryption == ENABLED)
-//            {
-//                /* Get Encryption Key from the MBMCInfo_t structure */
-//                    memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
-//
-//                if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, (char *)UserPswd, MAX_PASSWORD_LEN, PwdEncKey))
-//                {
-//                    TCRIT("Error in Decrypting IPMI User Password for user with ID:%d\n", UserId);
-//                    *pRes = CC_UNSPECIFIED_ERR;
-//                    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//                    return sizeof(*pRes);
-//                }
-//            }
-//            else
-//            {
-//            	_fmemcpy (UserPswd, pUserInfo->UserPassword, MAX_PASSWORD_LEN);
-//    		}
-//            /*Test Password */
-//            if( ReqLen != pUserInfo->MaxPasswordSize  && (pUserInfo->MaxPasswordSize != 0))
-//            {
-//                *pRes = CC_PASSWORD_TEST_FAILED_WRONG_SIZE;
-//            }
-//            else if (((FALSE == pUserInfo->UserStatus) && (pUserInfo->ID != USER_ID)) ||
-//            (0 != _fmemcmp (UserPswd, pSetUserPswdReq->Password, MAX_PASSWORD_LEN)))
-//            {
-//                *pRes = CC_PASSWORD_TEST_FAILED;
-//            }
-//
-//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//            return sizeof (*pRes);
-//            break;
-//    }
-//
-//    FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0],(INT8U*)&pBMCInfo->UserInfo[0],pBMCInfo->IPMIConfLoc.UserInfoAddr,
-//                      sizeof(UserInfo_T)*MAX_USER_CFG_MDS,BMCInst);
-//    FlushIPMI((INT8U*)&pBMCInfo->GenConfig,(INT8U*)&pBMCInfo->GenConfig,pBMCInfo->IPMIConfLoc.GenConfigAddr,
-//                      sizeof(GENConfig_T),BMCInst);
-//    FlushIPMI((INT8U*)&pBMCInfo->EncryptedUserInfo[0], (INT8U*)&pBMCInfo->EncryptedUserInfo[0], pBMCInfo->IPMIConfLoc.EncUserPasswdAddr,
-//                      sizeof(EncryptedUserInfo_T) * MAX_USER_CFG_MDS, BMCInst);
-//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
-//    return sizeof (*pRes);
-}
-
-
-/*---------------------------------------
-* MasterWriteRead
-*---------------------------------------*/
-int
-MasterWriteRead (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_ MasterWriteReadReq_T* pMasterWriteReadReq = (_NEAR_ MasterWriteReadReq_T*)pReq;
-//    _NEAR_ MasterWriteReadRes_T* pMasterWriteReadRes = (_NEAR_ MasterWriteReadRes_T*)pRes;
-//    _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
-//    _NEAR_ INT8U*                OutBuffer;
-//    _NEAR_ INT8U*                InBuffer;
-//    INT8U                 ChannelNum, BusID, BusType, SlaveAddr, ReadCount, WriteCount;
-//    INT8S	BusName[64];
-//    int retval = 0;
-//    INT8U OrgReadCount;
-//    INT8U	I2CBusId=0;
-//    INT8U DevID = 0;            // This will be '0' by Default... /dev/peci0
-//    INT8U Target = 0x30;        // This is the Client address. 30h = 48 is Default for CPU0
-//    INT8U Domain = 0;           // Multi-Domain support. Default is '0'
-//    INT8U Xmit_Feedback = 0;    // If full response is Desired, enable this. Default is '1'
-//    INT8U AWFCS = 0;            // Enable AWFCS in the Transmitted packet by Hw. Default is '0'
-//    INT8U Read_Len = 0;         // Number of bytes of read back Data from PECI Client
-//    INT8U Write_Len = 0;        // Number of bytes of data, host is sending to client
-//    INT8U *Write_Data = NULL;   // Pointer to the Data sent by User to the PECI Client
-//    INT8U *Read_Data = NULL;    // Pointer to the Data received from PECI Client to be sent to user
-//    int ret_val = 0;
-//
-//    if(pMasterWriteReadReq->SlaveAddress & BIT0)
-//    {
-//        *pRes = CC_INV_DATA_FIELD;
-//         return sizeof (*pRes);
-//    }
-//
-//    ReadCount     = pMasterWriteReadReq->ReadCount;
-//    ChannelNum    = GetBits (pMasterWriteReadReq->BusTypeChNo, 0xF0);
-//    BusID         = GetBits (pMasterWriteReadReq->BusTypeChNo, 0x0E);
-//    BusType       = GetBits (pMasterWriteReadReq->BusTypeChNo, 0x01);
-//    SlaveAddr     = (pMasterWriteReadReq->SlaveAddress >> 1);
-//
-//    if ((BusType == 0x00 && BusID != 0x00) || ((BusType == 0x01) && (BusID == 0x00)))
-//    {
-//        *pRes = CC_INV_DATA_FIELD;
-//        return  sizeof (*pRes);
-//    }
-//    // Command order:
-//    // ipmitool -H <IP> -I lan -U <Username> -P <Password> bus=7 <Slave_Addr> <Read_Len> <Write_Len> <AWFCS> <Domain> <Data>
-//    // <bus=7> : Bus# must be 0x07 for comunicating with PECI over IPMI. Other buses are not for this feature
-//    // <Slave_Addr> : This is the PECI Client target address.
-//    // <Read_Len> : Number of bytes of data to read from the PECI Response
-//    // <Write_Len> : Number of bytes of data being written, as per the PECI Spec. Number of Bytes after Domain.
-//    // <AWFCS> : 0x01 or 0x00 indicates enabling or disabling of AWFCS feature respectively
-//    // <Domain> : 0x01 or 0x00 indicates domain=1 or domain=0 for multi-domain commands respectively
-//    // <Data> : Rest of data like Command, and other params as per the PECI Spec.
-//
-//    // If BusType is External (0x01) and BusID is 7, then we consider to communicate with PECI
-//    
-//    if(g_corefeatures.peci_over_ipmi == ENABLED )
-//    {
-//        if ((BusType & 0x01) && (BusID == 0x07))
-//        {
-//            DevID               = 0;
-//            Xmit_Feedback       = 0;
-//            Target              = pMasterWriteReadReq->SlaveAddress;
-//            Read_Len            = ReadCount;
-//            Write_Len           = pMasterWriteReadReq->Data[0];
-//            AWFCS               = pMasterWriteReadReq->Data[1];
-//            Domain              = pMasterWriteReadReq->Data[2];
-//            Write_Data          = &pMasterWriteReadReq->Data[3];
-//            Read_Data           = &pMasterWriteReadRes->Data[0];
-//
-//            memset(&pMasterWriteReadRes->Data[0], 0, sizeof(pMasterWriteReadRes->Data));
-//            
-//            // Call the PECI Generic Handler for passing the command to the PECI Controller
-//            if(g_HALPECIHandle[HAL_PECI_COMMAND] != NULL)
-//            {
-//                ret_val = ((int(*)(char, char, char, char, char, char *, char, char *, char))g_HALPECIHandle[HAL_PECI_COMMAND]) (DevID, Target,
-//                                                                                                Domain, Xmit_Feedback, AWFCS,
-//                                                                                                (char *)Write_Data, Write_Len,
-//                                                                                                (char *)Read_Data, Read_Len );
-//            }
-//            else
-//            {
-//                pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
-//                return sizeof (*pRes);
-//            }
-//
-//            /* Check if peci issue command operation is success or not */
-//            if (ret_val == -1)
-//            {
-//                pMasterWriteReadRes->CompletionCode = CC_INV_DATA_FIELD;
-//                return sizeof (*pRes);
-//            }
-//
-//            pMasterWriteReadRes->CompletionCode = CC_NORMAL;
-//
-//            return (sizeof (*pRes) + ReadCount);
-//        }
-//    }
-//
-//    if(0 ==BusType){
-//        if(PRIMARY_IPMB_CHANNEL == ChannelNum)
-//        {
-//            I2CBusId=pBMCInfo->IpmiConfig.PrimaryIPMBBusNumber;
-//        }
-//        else if((pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)&&(pBMCInfo->SecondaryIPMBCh == ChannelNum))
-//        {
-//            I2CBusId=pBMCInfo->IpmiConfig.SecondaryIPMBBusNumber;
-//        }else{
-//            *pRes = CC_INV_DATA_FIELD;
-//            return  sizeof (*pRes);
-//        }
-//    }
-//    else
-//    {
-//        if(BusID==pBMCInfo->IpmiConfig.PrimaryIPMBBusNumber)
-//        {
-//            *pRes = CC_INV_DATA_FIELD;
-//            return  sizeof (*pRes);
-//        }else if((pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)&&(BusID==pBMCInfo->IpmiConfig.SecondaryIPMBBusNumber))
-//        {
-//            *pRes = CC_INV_DATA_FIELD;
-//            return  sizeof (*pRes);
-//        }else{
-//            I2CBusId=BusID;
-//        }
-//    }
-//
-//    if (ReqLen < 3)
-//    {
-//        *pRes = CC_REQ_INV_LEN;
-//        return  sizeof (*pRes);
-//    }
-//
-//    /* number of bytes to write
-//    * = pMasterWriteReadReq length - 3 for  Request Data byte -
-//    * BusTypeChNo,SlaveAddr,Readcount + 1 byte for address
-//    */
-//    WriteCount = ReqLen - 3;
-//
-//    OutBuffer = (pMasterWriteReadReq->Data);
-//    InBuffer = pMasterWriteReadRes->Data;
-//    sprintf(BusName,"/dev/i2c%d",I2CBusId);
-//
-//    // Save original ReadCount in case we need to modify it
-//    OrgReadCount = ReadCount;
-//
-//    // If both ReadCount and WriteCount are zero, then force a read of 1 byte.
-//    // If we do not do this, the write command will fail.
-//    // Having both counts 0 is a way of "pinging" the given device to see if it
-//    // is responding to its address.
-//    
-//    if (ReadCount == 0 && WriteCount == 0)
-//    {
-//        ReadCount = 1;
-//    }
-//
-//    if (ReadCount > 0 && WriteCount == 0) 
-//    {
-//        if(g_HALI2CHandle[HAL_I2C_MR] != NULL)
-//        {
-//            retval = ((int(*)(char *,u8,u8 *,size_t))g_HALI2CHandle[HAL_I2C_MR]) (BusName, SlaveAddr, InBuffer, ReadCount);
-//            if (retval < 0)
-//            {
-//                 pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
-//                return sizeof (*pRes);
-//            }
-//        }
-//        else
-//        {
-//            pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
-//            return sizeof(*pRes);
-//        }
-//
-//        ReadCount = OrgReadCount;
-//
-//        /* copy the bytes read  to Response Data */
-//        _fmemcpy (pMasterWriteReadRes->Data, InBuffer, ReadCount);
-//    }
-//    else if(ReadCount > 0 && WriteCount > 0 )
-//    {
-//        if(g_HALI2CHandle[HAL_I2C_RW] != NULL)
-//        {
-//            retval = ((int(*)(char *,u8,u8 *,u8 *,size_t,size_t))g_HALI2CHandle[HAL_I2C_RW]) (BusName, SlaveAddr, OutBuffer, InBuffer, WriteCount, ReadCount);
-//            if (retval < 0)
-//            {
-//                 pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
-//                return sizeof (*pRes);
-//            }
-//        }
-//        else
-//        {
-//            pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
-//            return sizeof(*pRes);
-//        }
-//
-//        ReadCount = OrgReadCount;
-//
-//        /* copy the bytes read  to Response Data */
-//        _fmemcpy (pMasterWriteReadRes->Data, InBuffer, ReadCount);
-//    }
-//    else
-//    {
-//        /* No data to read so use master write instead,
-//         * otherwise some devices (EEPROM) that have not finished writing
-//         * will fail on the read transaction and possibly corrupt data
-//         */
-//        if(g_HALI2CHandle[HAL_I2C_MW] != NULL)
-//        {
-//            retval= ((ssize_t(*)(char *,u8,u8 *,size_t))g_HALI2CHandle[HAL_I2C_MW]) (BusName, SlaveAddr, OutBuffer, WriteCount);
-//            if(retval < 0)
-//            {
-//                pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
-//                return sizeof (*pRes);
-//            }
-//        }
-//        else
-//        {
-//            pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
-//            return sizeof(*pRes);
-//        }
-//    }
-//
-//    pMasterWriteReadRes->CompletionCode = CC_NORMAL;
-//
-//    return (sizeof (*pRes) + ReadCount);
-}
-
-
-//#if 0
-/*-------------------------------------------
-* ComputeAuthCode
-*-------------------------------------------*/
-void
-ComputeAuthCode (_FAR_ INT8U* pPassword, _NEAR_ SessionHdr_T* pSessionHdr,
-                _NEAR_ IPMIMsgHdr_T* pIPMIMsg, _NEAR_ INT8U* pAuthCode,
-                INT8U ChannelType)
-{
-//    if (AUTH_TYPE_PASSWORD == pSessionHdr->AuthType)
-//    {
-//        _fmemcpy (pAuthCode, pPassword, MAX_PASSWORD_LEN);
-//    }
-//    else
-//    {
-//        INT8U   AuthBuf [MAX_AUTH_PARAM_SIZE];
-//        INT16U  AuthBufLen = 0;
-//        INT8U   IPMIMsgLen = *((_NEAR_ INT8U*) pIPMIMsg - 1);
-//
-//        /* Password */
-//        _fmemcpy (AuthBuf, pPassword, MAX_PASSWORD_LEN);
-//        AuthBufLen += MAX_PASSWORD_LEN;
-//        /* Session ID */
-//        _fmemcpy (AuthBuf + AuthBufLen, &pSessionHdr->SessionID, sizeof (INT32U));
-//        AuthBufLen += sizeof (INT32U);
-//        /* IPMI Response Message */
-//        _fmemcpy (AuthBuf + AuthBufLen, pIPMIMsg, IPMIMsgLen);
-//        AuthBufLen += IPMIMsgLen;
-//
-//        if (ChannelType == MULTI_SESSION_CHANNEL)
-//        {
-//            /* Session Sequence Number */
-//            _fmemcpy (AuthBuf + AuthBufLen,
-//                    &pSessionHdr->SessionSeqNum, sizeof (INT32U));
-//            AuthBufLen += sizeof (INT32U);
-//        }
-//        /* Password */
-//        _fmemcpy (AuthBuf + AuthBufLen, pPassword, MAX_PASSWORD_LEN);
-//        AuthBufLen += MAX_PASSWORD_LEN;
-//
-//        switch (pSessionHdr->AuthType)
-//        {
-//        case AUTH_TYPE_MD2 :
-//            AuthCodeCalMD2 (AuthBuf, pAuthCode, AuthBufLen);
-//            break;
-//
-//        case AUTH_TYPE_MD5 :
-//            AuthCodeCalMD5 (AuthBuf, pAuthCode, AuthBufLen);
-//            break;
-//
-//        default  :
-//            TDBG ("RMCP: Invalid Authentication Type \n");
-//        }
-//    }
-}
-//#endif
-
-/*---------------------------------------
-* GetSystemInfoParam
-*---------------------------------------*/
-int
-GetSystemInfoParam (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-
-//    _NEAR_ GetSystemInfoParamReq_T* pGetSysInfoReq = (_NEAR_ GetSystemInfoParamReq_T*)pReq;
-//    _NEAR_ GetSystemInfoParamRes_T* pGetSysInfoRes = ( _NEAR_ GetSystemInfoParamRes_T* ) pRes ;
-//    _NEAR_ GetSystemInfoParamOEMRes_T* pGetSysInfoOEMRes = ( _NEAR_ GetSystemInfoParamOEMRes_T* ) pRes ;
-//    BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
-//    _FAR_   SystemInfoConfig_T*	pSysInfoCfg;
-//    INT8U resSize = sizeof(pGetSysInfoRes->CompletionCode) + sizeof(pGetSysInfoRes->ParamRevision);
-//    INT8U oem_len;
-//    unsigned long oem_addr;
-//
-//    // Check for Reserved bits
-//    if(pGetSysInfoReq->ParamRev & (BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0))
-//    {
-//        pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
-//        return sizeof(pGetSysInfoRes->CompletionCode);
-//    }
-//
-//    pGetSysInfoRes->CompletionCode   = CC_NORMAL;
-//
-//    /* Fill the param's older Version and the present version */
-//    pGetSysInfoRes->ParamRevision    = ((PARAM_OLDER_REVISION << 4) & 0xF0 ) | PARAM_PRESENT_REVISION;
-//
-//    /* Check for Revision only parameter */
-//    if (pGetSysInfoReq->ParamRev & GET_PARAM_REV_ONLY )
-//    {
-//        if((MAX_APP_CONF_PARAM >= pGetSysInfoReq->ParamSelector))
-//        {
-//            return resSize;
-//        }
-//        else if(( NULL != g_PDKHandle[PDK_GETSYSINFOPARAM]) && 
-//                    ((MIN_SYSINFO_OEM_CONF_PARAM <= pGetSysInfoReq->ParamSelector) && (MAX_SYSINFO_OEM_CONF_PARAM >= pGetSysInfoReq->ParamSelector)))
-//        {
-//            oem_len = ((int(*)(INT8U, unsigned long*,int))(g_PDKHandle[PDK_GETSYSINFOPARAM]))(pGetSysInfoReq->ParamSelector, &oem_addr ,BMCInst);
-//            if( oem_len == 0)
-//            {
-//                pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
-//                return sizeof(INT8U);
-//            }
-//            else
-//                return resSize;
-//        }
-//        else
-//        {
-//            *pRes = CC_PARAM_NOT_SUPPORTED;
-//            return sizeof (*pRes);  
-//        }
-//    }
-//
-//    /* Get Systen Info parameters from NVRAM */
-//    pSysInfoCfg = &pBMCInfo->SystemInfoConfig;
-//
-//    switch(pGetSysInfoReq->ParamSelector)
-//    {
-//        case SET_IN_PROGRESS_PARAM:		/*Parameter 0 volatile*/
-//            if( (0x00 != pGetSysInfoReq->SetSelector) || (0x00 != pGetSysInfoReq->BlockSelector) )
-//            {
-//                pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
-//                return sizeof(pGetSysInfoRes->CompletionCode);
-//            }
-//
-//            LOCK_BMC_SHARED_MEM(BMCInst);
-//            pGetSysInfoRes->SysInfo.SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_Sys_SetInProgress;
-//            UNLOCK_BMC_SHARED_MEM(BMCInst);
-//            resSize++;
-//            break;
-//
-//        case SYS_FW_VERSION_PARAM:
-//            _fmemset(&pGetSysInfoRes->SysInfo.SysVerInfo,0,sizeof(SysVerInfo_T));
-//            if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
-//            {
-//                pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
-//                return sizeof(pGetSysInfoRes->CompletionCode);
-//            }
-//
-//            pGetSysInfoRes->SysInfo.SysVerInfo.SetSelector = pGetSysInfoReq->SetSelector;
-//            resSize++;
-//            if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
-//            {
-//                pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[0]=pSysInfoCfg->SysFWVersion.TypeOfEncoding;
-//                pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[1]=pSysInfoCfg->SysFWVersion.StringLength;
-//                _fmemcpy(&pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[2], pSysInfoCfg->SysFWVersion.SysFWVersionName,MAX_STRING_LENGTH_COPY);
-//                resSize += MAX_BLOCK_SIZE;
-//            }
-//            else
-//            {
-//               _fmemcpy(&pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[0],
-//                                        &pSysInfoCfg->SysFWVersion.SysFWVersionName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
-//                resSize += MAX_BLOCK_SIZE;
-//            }
-//            break;
-//
-//        case SYS_NAME_PARAM:
-//            if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
-//            {
-//                pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
-//                return sizeof(pGetSysInfoRes->CompletionCode);
-//            }
-//
-//            pGetSysInfoRes->SysInfo.SysNameInfo.SetSelector = pGetSysInfoReq->SetSelector;
-//            resSize++;
-//            if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
-//            {
-//                pGetSysInfoRes->SysInfo.SysNameInfo.SysName[0]=pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name;
-//                pGetSysInfoRes->SysInfo.SysNameInfo.SysName[1]=pSysInfoCfg->SysName.StringLength_Sys_Name;
-//                _fmemcpy(&pGetSysInfoRes->SysInfo.SysNameInfo.SysName[2],&pSysInfoCfg->SysName.SystemName,MAX_STRING_LENGTH_COPY);
-//                resSize += MAX_BLOCK_SIZE;
-//             }
-//            else
-//            {
-//                _fmemcpy(&pGetSysInfoRes->SysInfo.SysNameInfo.SysName[0],
-//                                &pSysInfoCfg->SysName.SystemName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2], MAX_BLOCK_SIZE);
-//                resSize += MAX_BLOCK_SIZE;
-//            }
-//            break;
-//
-//        case PRIM_OS_NAME_PARAM:
-//            if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
-//            {
-//                pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
-//                return sizeof(pGetSysInfoRes->CompletionCode);
-//            }
-//
-//            pGetSysInfoRes->SysInfo.PrimOSInfo.SetSelector  = pGetSysInfoReq->SetSelector;
-//            resSize++;
-//            if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
-//            {
-//                pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[0]=pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName;
-//                pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[1]=pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName;
-//                _fmemcpy(&pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[2], &pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName, MAX_STRING_LENGTH_COPY);
-//                resSize += MAX_BLOCK_SIZE;
-//             }
-//             else
-//             {
-//                 _fmemcpy(&pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[0],
-//                             &pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
-//                 resSize += MAX_BLOCK_SIZE;
-//              }
-//            break;
-//
-//        case OS_NAME_PARAM:
-//            /*Parameter 4 volatile*/
-//            _fmemset(&pGetSysInfoRes->SysInfo.OSInfo,0,sizeof(OSInfo_T));
-//            if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)||(0x00 != pGetSysInfoReq->BlockSelector))
-//            {
-//                pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
-//                return sizeof(pGetSysInfoRes->CompletionCode);
-//            }
-//            pGetSysInfoRes->SysInfo.OSInfo.SetSelector  = pGetSysInfoReq->SetSelector;
-//            resSize++;
-//            if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
-//            {
-//                LOCK_BMC_SHARED_MEM(BMCInst);
-//                pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[0]=BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName;
-//                pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[1]=BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName;
-//                _fmemcpy(&pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[2], BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName, MAX_STRING_LENGTH_COPY);
-//                UNLOCK_BMC_SHARED_MEM(BMCInst);
-//                resSize += MAX_BLOCK_SIZE;
-//            }
-//            else
-//            {
-//                LOCK_BMC_SHARED_MEM(BMCInst);
-//                _fmemcpy(&pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[0],
-//                    &BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
-//                UNLOCK_BMC_SHARED_MEM(BMCInst);
-//                resSize += MAX_BLOCK_SIZE;
-//           }
-//            
-//            break;
-//
-//        default:
-//            if(g_PDKHandle[PDK_GETSYSINFOPARAM] != NULL &&
-//            (pGetSysInfoReq->ParamSelector >= 192 && pGetSysInfoReq->ParamSelector <= 255))
-//            {
-//                oem_len = ((int(*)(INT8U, unsigned long*,int))(g_PDKHandle[PDK_GETSYSINFOPARAM]))(pGetSysInfoReq->ParamSelector, &oem_addr ,BMCInst);
-//                if( oem_len == 0)
-//                {
-//                    pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
-//                    return sizeof(INT8U);
-//                }
-//                else
-//                {
-//                    //Acquire the OEM parameters
-//                    if( oem_len < MSG_PAYLOAD_SIZE - sizeof(GetLanCCRev_T))
-//                    {
-//                        memcpy((char*)pGetSysInfoOEMRes + sizeof(GetSystemInfoParamOEMRes_T) ,\
-//                                    (unsigned int*)oem_addr , oem_len);
-//                    }
-//                    else
-//                    {
-//                        pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
-//                        return sizeof(INT8U);
-//                    }
-//                    return sizeof(GetSystemInfoParamOEMRes_T) + oem_len;
-//                }
-//            }
-//            else
-//            {
-//                pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
-//                return sizeof(pGetSysInfoRes->CompletionCode);
-//            }
-//    }
-//    /* return the size of the response */
-//    return resSize;
-}
-
-int validatestring(INT8U* String,int len,INT8U TOE)
-{
-    int i,delimit = 0,strlen = 0;
-
-    for(i=0;i<len;i++)
-    {
-        if(String[i] == 0)
-        {
-            delimit++;
-        }
-        else
-        {
-            if(delimit != 0)
-            {
-                if(TOE == UNICODE)
-                {
-                    if(delimit == 2)
-                    {
-                        strlen = strlen + 2;
-                    }
-                    else
-                    {
-                        return -1;
-                    }
-                }
-                else
-                {
-                    if(delimit == 1)
-                    {
-                        strlen = strlen + 1;
-                    }
-                    else
-                    {
-                        return -1;
-                    }
-                }
-                delimit = 0;
-            }
-            strlen++;
-        }
-    }
-
-    return strlen;
-}
-
-/*---------------------------------------
-* SetSystemInfoParam
-*---------------------------------------*/
-int
-SetSystemInfoParam (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
-{
-//    _NEAR_ SetSystemInfoParamReq_T*	pSetSysInfoReq = (_NEAR_ SetSystemInfoParamReq_T*)pReq;
-//    _NEAR_ SetSystemInfoParamOEMReq_T*	pSetSysInfoOEMReq = (_NEAR_ SetSystemInfoParamOEMReq_T*)pReq;
-//    _NEAR_ SetSystemInfoParamRes_T*	pSetSysInfoRes = (_NEAR_ SetSystemInfoParamRes_T*)pRes;
-//    BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
-//    _FAR_ SystemInfoConfig_T*	pSysInfoCfg;
-//    INT8U *pSetInProgress;
-//    unsigned long oem_addr[2]={0};      // use oem_addr[1] as read-only/write-only flag
-//    int size,strlen,len;
-//    INT8U OSName[MAX_OS_NAME_LENGTH] = {0};
-//
-//    //If the OEM parameter is existing, then skip the length check.
-//    if(g_PDKHandle[PDK_SETSYSINFOPARAM] == NULL && (pSetSysInfoReq->ParamSelector < 192 )){
-//        if( !( (SET_IN_PROGRESS_PARAM == pSetSysInfoReq->ParamSelector && ( ReqLen == ( sizeof(pSetSysInfoReq->ParamSelector) + sizeof(INT8U) /* for Data */ ) )) ||
-//    ( pSetSysInfoReq->ParamSelector < MAX_PARAM_SELECTOR && ReqLen == ( sizeof(pSetSysInfoReq->ParamSelector) + sizeof(INT8U) /* for set Selector */ + MAX_BLOCK_SIZE))) )
-//        {
-//            pSetSysInfoRes->CompletionCode = CC_REQ_INV_LEN;
-//            return sizeof(pSetSysInfoRes->CompletionCode);
-//        }
-//    }
-//
-//        pSetInProgress = &BMC_GET_SHARED_MEM(BMCInst)->m_Sys_SetInProgress;
-//
-//        pSetSysInfoRes->CompletionCode = CC_NORMAL;
-//
-//        /*Get NVRAM System Info Configuration parameters */
-//        pSysInfoCfg = &pBMCInfo->SystemInfoConfig;
-//
-//    switch (pSetSysInfoReq->ParamSelector)
-//    {
-//        /*Parameter 0 volatile */
-//        case SET_IN_PROGRESS_PARAM:
-//            LOCK_BMC_SHARED_MEM(BMCInst);
-//            /* If Request for Set In progress */
-//            if(( SYS_INFO_SET_IN_PROGRESS == *pSetInProgress ) &&
-//            ( SYS_INFO_SET_IN_PROGRESS == pSetSysInfoReq->SysInfo.SetInProgress ))
-//            {
-//                UNLOCK_BMC_SHARED_MEM(BMCInst);
-//                /* Trying to SetinProgress when already in set*/
-//                pSetSysInfoRes->CompletionCode = CC_SYS_INFO_SET_IN_PROGRESS ;
-//                return sizeof(pSetSysInfoRes->CompletionCode);
-//            } else if( SYS_INFO_COMMIT_WRITE == pSetSysInfoReq->SysInfo.SetInProgress )
-//            {
-//                /* Write SysInfoConfig to NVR */
-//                FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig,
-//                                  pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SystemInfoConfig_T),BMCInst);
-//                /* Write volatile data to the BMC Shared memory */
-//                
-//            } else if ( SYS_INFO_SET_COMPLETE == pSetSysInfoReq->SysInfo.SetInProgress )
-//            {
-//                //PMCONFIG_FILE(BMCInst,PMConfigFile);
-//                /* Set it to set Complete */
-//                *pSetInProgress = pSetSysInfoReq->SysInfo.SetInProgress;
-//                FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig,
-//                                  pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SystemInfoConfig_T),BMCInst);
-//            } else if ( SYS_INFO_SET_IN_PROGRESS != pSetSysInfoReq->SysInfo.SetInProgress )
-//            {
-//                UNLOCK_BMC_SHARED_MEM(BMCInst);
-//                pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
-//                return sizeof(pSetSysInfoRes->CompletionCode);
-//            }
-//
-//            *pSetInProgress = pSetSysInfoReq->SysInfo.SetInProgress;
-//            UNLOCK_BMC_SHARED_MEM(BMCInst);
-//            break;
-//
-//            case SYS_FW_VERSION_PARAM:
-//                
-//                if(pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector >= MAX_BLOCK_SIZE)
-//                {
-//                    pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
-//                    return sizeof(pSetSysInfoRes->CompletionCode);
-//                }
-//                if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector==ZERO_SETSELECTOR)
-//                {
-//                     if(pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]> MAX_FW_VER_LENGTH)
-//                     {
-//                        pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
-//                        return sizeof(pSetSysInfoRes->CompletionCode);
-//                     }
-//                     if(pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0] > MAX_TYPE_OF_ENCODING)
-//                     {
-//                         pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
-//                         return sizeof(pSetSysInfoRes->CompletionCode);
-//                     }
-//                     memset(&pSysInfoCfg->SysFWVersion,0,sizeof(pSysInfoCfg->SysFWVersion));
-//                     pSysInfoCfg->SysFWVersion.TypeOfEncoding=pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0];
-//                     pSysInfoCfg->SysFWVersion.StringLength=pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1];
-//                     /*First character should not be a delimiter*/
-//                     if(pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2] == 0x0 || ((pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0] == UNICODE) && (pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2] == 0x0 || pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[3] == 0x0)))
-//                    {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                    }
-//                     strlen = validatestring(&pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0]);
-//                     if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]) || ((pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]))
-//                     {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                     }
-//                     if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
-//                     {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                     }
-//                     _fmemcpy(&pSysInfoCfg->SysFWVersion.SysFWVersionName[0],&pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2], MAX_STRING_LENGTH_COPY);
-//                     FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig.SysFWVersion,
-//                                                 pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysFWVersion_T),BMCInst);
-//                }
-//                else
-//                {
-//                    _fmemcpy(&pSysInfoCfg->SysFWVersion.SysFWVersionName[(pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector* MAX_BLOCK_SIZE) - 2], 
-//                                                 &pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0],MAX_BLOCK_SIZE); 
-//                    len = ((pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
-//                    strlen = validatestring(&pSysInfoCfg->SysFWVersion.SysFWVersionName[0],len,pSysInfoCfg->SysFWVersion.TypeOfEncoding);
-//                    if(strlen == -1 || (strlen > pSysInfoCfg->SysFWVersion.StringLength))
-//                    {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                    }
-//                    /*Check the String length*/
-//                    if(((len < pSysInfoCfg->SysFWVersion.StringLength) && (len != strlen)) || ((len > pSysInfoCfg->SysFWVersion.StringLength) && (pSysInfoCfg->SysFWVersion.StringLength != strlen)))
-//                    {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                    }
-//                    if((len == pSysInfoCfg->SysFWVersion.StringLength) && (pSysInfoCfg->SysFWVersion.StringLength != strlen))
-//                    {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                    }
-//
-//                    FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,
-//                                (INT8U*)&pBMCInfo->SystemInfoConfig.SysFWVersion,pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysFWVersion_T),BMCInst);
-//                }
-//                break;
-//
-//            case SYS_NAME_PARAM:
-//                if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector >= MAX_BLOCK_SIZE )
-//                {
-//                    pSetSysInfoRes->CompletionCode	= CC_INV_DATA_FIELD;
-//                    return sizeof(pSetSysInfoRes->CompletionCode);
-//                }
-//                if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector==ZERO_SETSELECTOR)
-//                {
-//                    if((pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1] > MAX_SYS_NAME_LENGTH))
-//                    {
-//                        pSetSysInfoRes->CompletionCode	= CC_INV_DATA_FIELD;
-//                        return sizeof(pSetSysInfoRes->CompletionCode);
-//                    }
-//                    if(pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0]>MAX_TYPE_OF_ENCODING)
-//                    {
-//                        pSetSysInfoRes->CompletionCode	= CC_INV_DATA_FIELD;
-//                        return sizeof(pSetSysInfoRes->CompletionCode);
-//                    }
-//                    memset(&pSysInfoCfg->SysName,0,sizeof(pSysInfoCfg->SysName));
-//                    pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name=pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0];
-//                    pSysInfoCfg->SysName.StringLength_Sys_Name=pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1];
-//
-//                     /*First character should not be a delimiter*/
-//                     if(pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2] == 0x0 || ((pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0] == UNICODE) && (pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2] == 0x0 || pSetSysInfoReq->SysInfo.SysNameInfo.SysName[3] == 0x0)))
-//                    {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                    }
-//
-//                    strlen = validatestring(&pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0]);
-//                    if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]) || ((pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]))
-//                    {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                    }
-//                     if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
-//                     {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                     }
-//
-//                    _fmemcpy(&pSysInfoCfg->SysName.SystemName[0], &pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2],MAX_STRING_LENGTH_COPY);
-//                    FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig.SysName,
-//                                            pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysName_T),BMCInst);
-//                }
-//                else
-//                {
-//                    _fmemcpy(&pSysInfoCfg->SysName.SystemName[(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector* MAX_BLOCK_SIZE) - 2],
-//                                    &pSetSysInfoReq->SysInfo.SysNameInfo.SysName,MAX_BLOCK_SIZE);
-//                    len = ((pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
-//                    strlen = validatestring(&pSysInfoCfg->SysName.SystemName[0],len,pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name);
-//                    if(strlen == -1 || (strlen > pSysInfoCfg->SysName.StringLength_Sys_Name))
-//                    {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                    }
-//                    /*Check the String length*/
-//                    if(((len < pSysInfoCfg->SysName.StringLength_Sys_Name) && (len != strlen)) || ((len > pSysInfoCfg->SysName.StringLength_Sys_Name) && (pSysInfoCfg->SysName.StringLength_Sys_Name != strlen)))
-//                    {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                    }
-//                    if((len == pSysInfoCfg->SysName.StringLength_Sys_Name) && (pSysInfoCfg->SysName.StringLength_Sys_Name != strlen))
-//                    {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                    }
-//
-//                    FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig.SysName, 
-//                                pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysName_T),BMCInst);
-//                }
-//                break;
-//
-//            case PRIM_OS_NAME_PARAM:
-//                if(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector >= MAX_BLOCK_SIZE )
-//                {
-//                    pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
-//                    return sizeof(pSetSysInfoRes->CompletionCode);
-//                }
-//                if(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector==ZERO_SETSELECTOR)
-//                {
-//                    if((pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1] > MAX_PRIM_OS_NAME_LENGTH))
-//                    {
-//                        pSetSysInfoRes->CompletionCode	= CC_INV_DATA_FIELD;
-//                        return sizeof(pSetSysInfoRes->CompletionCode);
-//                        
-//                    }
-//                    if(pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0]>MAX_TYPE_OF_ENCODING)
-//                    {
-//                        pSetSysInfoRes->CompletionCode	= CC_INV_DATA_FIELD;
-//                        return sizeof(pSetSysInfoRes->CompletionCode);
-//                    }
-//                    memset(&pSysInfoCfg->PrimaryOSName,0,sizeof(pSysInfoCfg->PrimaryOSName));
-//                    pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName=pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0];
-//                    pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName=pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1];
-//
-//                     /*First character should not be a delimiter*/
-//                     if(pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2] == 0x0 || ((pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0] == UNICODE) && (pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2] == 0x0 || pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[3] == 0x0)))
-//                    {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                    }
-//
-//                    strlen = validatestring(&pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0]);
-//                    if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]) || ((pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]))
-//                    {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                    }
-//                     if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
-//                     {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                     }
-//
-//                    _fmemcpy(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[0], &pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2], MAX_STRING_LENGTH_COPY);
-//                    FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig.PrimaryOSName,
-//                                                    pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(PrimaryOSName_T),BMCInst);
-//                }
-//                else
-//                {
-//                    _fmemcpy(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector * MAX_BLOCK_SIZE) - 2],
-//                                            &pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName, MAX_BLOCK_SIZE);
-//                    len = ((pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
-//                    strlen = validatestring(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[0],len,pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName);
-//                    if(strlen == -1 || (strlen > pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName))
-//                    {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                    }
-//                    /*Check the String length*/
-//                    if(((len < pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (len != strlen)) || ((len > pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName != strlen)))
-//                    {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                    }
-//                    if((len == pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName != strlen))
-//                    {
-//                        *pRes = CC_INV_DATA_FIELD;
-//                        return sizeof(INT8U);
-//                    }
-//
-//                    FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,
-//                                (INT8U*)&pBMCInfo->SystemInfoConfig.PrimaryOSName,pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(PrimaryOSName_T),BMCInst);
-//                }
-//                break;
-//
-//        case OS_NAME_PARAM:		
-//            /*Parameter 4 volatile*/
-//            if(pSetSysInfoReq->SysInfo.OSInfo.SetSelector >= MAX_BLOCK_SIZE )
-//            {
-//                pSetSysInfoRes->CompletionCode	= CC_INV_DATA_FIELD;
-//                return sizeof(pSetSysInfoRes->CompletionCode);
-//            }
-//            if(pSetSysInfoReq->SysInfo.OSInfo.SetSelector==ZERO_SETSELECTOR)
-//            {
-//                if(pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1] > MAX_OS_NAME_LENGTH)
-//                {
-//                    pSetSysInfoRes->CompletionCode	= CC_INV_DATA_FIELD;
-//                    return sizeof(pSetSysInfoRes->CompletionCode);
-//                }
-//                if(pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0] > MAX_TYPE_OF_ENCODING)
-//                {
-//                    pSetSysInfoRes->CompletionCode	= CC_INV_DATA_FIELD;
-//                    return sizeof(pSetSysInfoRes->CompletionCode);
-//                }
-//
-//                 /*First character should not be a delimiter*/
-//                 if(pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2] == 0x0 || ((pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0] == UNICODE) && (pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2] == 0x0 || pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[3] == 0x0)))
-//                {
-//                    *pRes = CC_INV_DATA_FIELD;
-//                    return sizeof(INT8U);
-//                }
-//
-//                strlen = validatestring(&pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0]);
-//                if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]) || ((pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]))
-//                {
-//                    *pRes = CC_INV_DATA_FIELD;
-//                    return sizeof(INT8U);
-//                }
-//                 if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
-//                 {
-//                    *pRes = CC_INV_DATA_FIELD;
-//                    return sizeof(INT8U);
-//                 }
-//
-//                memset(&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName,0,sizeof(OSName_T));
-//                LOCK_BMC_SHARED_MEM(BMCInst);
-//                BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName=pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0];
-//                BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName=pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1];
-//                _fmemcpy(&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName, &pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2], 
-//                                                      MAX_STRING_LENGTH_COPY);
-//                UNLOCK_BMC_SHARED_MEM (BMCInst);
-//            }
-//            else
-//            {
-//                LOCK_BMC_SHARED_MEM(BMCInst);
-//                _fmemcpy(&OSName[0],&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[0],MAX_OS_NAME_LENGTH);
-//                _fmemcpy(&OSName[(pSetSysInfoReq->SysInfo.OSInfo.SetSelector * MAX_BLOCK_SIZE) - 2],&pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName,MAX_BLOCK_SIZE);
-//                len = ((pSetSysInfoReq->SysInfo.OSInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
-//                strlen = validatestring(&OSName[0],len,BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName);
-//                if(strlen == -1 || (strlen > BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName))
-//                {
-//                    *pRes = CC_INV_DATA_FIELD;
-//                    UNLOCK_BMC_SHARED_MEM(BMCInst);
-//                    return sizeof(INT8U);
-//                }
-//                /*Check the String length*/
-//                if(((len < BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName) && (len != strlen)) || ((len > BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName) && (BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName != strlen)))
-//                {
-//                    *pRes = CC_INV_DATA_FIELD;
-//                    return sizeof(INT8U);
-//                }
-//                if((len == BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName) && (BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName != strlen))
-//                {
-//                    *pRes = CC_INV_DATA_FIELD;
-//                    return sizeof(INT8U);
-//                }
-//
-//                _fmemcpy(&(BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[(pSetSysInfoReq->SysInfo.OSInfo.SetSelector * MAX_BLOCK_SIZE) - 2]),
-//                                                                &pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName,MAX_BLOCK_SIZE);
-//                UNLOCK_BMC_SHARED_MEM (BMCInst);
-//            }
-//            break;
-//
-//        default:
-//            if(g_PDKHandle[PDK_SETSYSINFOPARAM] != NULL &&
-//               (pSetSysInfoReq->ParamSelector >= 192 && pSetSysInfoReq->ParamSelector <= 255))
-//            {
-//                oem_addr[0] = (unsigned long)((char*)pSetSysInfoOEMReq + sizeof(SetSystemInfoParamOEMReq_T));
-//                size = ((int(*)(INT8U, unsigned long*,int))(g_PDKHandle[PDK_SETSYSINFOPARAM]))(pSetSysInfoReq->ParamSelector, oem_addr ,BMCInst);
-//                if(size <= 0)
-//               {
-//                    switch (oem_addr[1]) {
-//                    case CC_SYS_INFO_READ_ONLY_PARAM:
-//                        pSetSysInfoRes->CompletionCode = CC_SYS_INFO_READ_ONLY_PARAM;
-//                        break;
-//                    default:
-//                        pSetSysInfoRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
-//                    }
-//                }
-//                else
-//                {
-//                    pSetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
-//                    return sizeof(pSetSysInfoRes->CompletionCode);
-//                }
-//            }
-//    }
-//    return sizeof(pSetSysInfoRes->CompletionCode);
-}
-
-//#endif  /* APP_DEVICE */
+/****************************************************************
+****************************************************************
+**                                                            **
+**    (C)Copyright 2005-2006, American Megatrends Inc.        **
+**                                                            **
+**            All Rights Reserved.                            **
+**                                                            **
+**        6145-F, Northbelt Parkway, Norcross,                **
+**                                                            **
+**        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+**                                                            **
+****************************************************************
+****************************************************************/
+/*****************************************************************
+*
+* AppDevice.c
+* AppDevice Commands Handler
+*
+* Author: Govind Kothandapani <govindk@ami.com>
+*       : Rama Bisa <ramab@ami.com>
+*       : Basavaraj Astekar <basavaraja@ami.com>
+*       : Bakka Ravinder Reddy <bakkar@ami.com>
+*
+*****************************************************************/
+
+#include "com_BmcType.h"
+#include "Support.h"
+#include "com_IPMIDefs.h"
+#include "com_IPMI_IPM.h"
+#include "com_IPMI_AppDevice.h"
+#include "AppDevice.h"
+#include "RMCP.h"
+#include "Session.h"
+#include "libipmi_struct.h"
+#include "PMConfig.h"
+#include "main.h"
+#include <string.h>
+
+#define USER_ID_ENABLED 	0x01
+#define USER_ID_DISABLED 	0x02
+#define OP_USERID_ONLY_LENGTH    2
+#define OP_ENABLE_USER_ID    	 1
+#define OP_DISABLE_USER_ID    	 0
+#define BIT3_BIT0_MASK     0xf
+#define GET_AUTH_TYPE_MASK  0xc0
+#define AUTH_TYPE_V15	0x0
+#define AUTH_TYPE_V20	0x40
+#define AUTH_CODE_V15_MASK  0x0f
+#define AUTH_CODE_V15_1  0x1
+#define AUTH_CODE_V15_2  0x2
+#define AUTH_CODE_V15_3  0x5
+#define AUTH_CODE_V20_MASK  0x3f
+#define MIN_AUTH_CODE_V20 0x04
+#define MAX_AUTH_CODE_V20 0xc0
+#define NULL_USER                 1
+#define ZERO_SETSELECTOR 0x00
+#define MAX_TYPE_OF_ENCODING 0x02
+#define MAX_STRING_LENGTH_COPY 14
+
+#define ASCII_LATIN1        0x00
+#define UTF_8                     0x01
+#define UNICODE                 0x02
+
+/* Reserved bit macro definitions */
+#define RESERVED_BITS_SENDMS 0x03 //(BIT1 | BIT0)
+
+/* Auth code length */
+#define HMAC_SHA1_96_LEN            12
+
+#if APP_DEVICE == 1
+
+#define COUNT_INCREASE  1	
+#define COUNT_DECREASE -1
+#define MAX_BT_PKT_LEN 255
+
+/*macro definitions for set user password options*/
+#define DISABLE_USER    0
+#define ENABLE_USER     1
+#define SET_PASSWORD    2
+#define TEST_PASSWORD   3
+
+/*** Global variables ***/
+uint8_t   g_TmrRunning;
+/*** Module variables ***/
+static     MsgPkt_T    m_MsgPkt; /**< Message Packet for posting and retrieving messaged to/from queue */
+static uint8_t m_Set_ChReserveBit[] ={0xF0,0x0,0x30};
+
+//extern IfcName_T Ifcnametable[MAX_LAN_CHANNELS];
+
+//static void UpdateCurrentEnabledUserCount(int value, int bmcInstId)
+//{
+//	if (value == 0) return;
+
+//	 ChannelInfo_T* pChannelInfo = NULL;
+//	 ChannelInfo_T* pNvrChannelInfo = NULL;
+//	 BMCInfo_t* pBMCInfo = &g_BMCInfo[bmcInstId];
+//	uint8_t maxUserCount = pBMCInfo->IpmiConfig.MaxChUsers;
+//	uint8_t channelIndex = 0;
+
+
+//	for (channelIndex = 0; channelIndex < MAX_NUM_CHANNELS; channelIndex++)
+//	{
+//		if (pBMCInfo->ChConfig[channelIndex].ChType == 0xff) continue;
+
+//		pChannelInfo = (ChannelInfo_T*)&pBMCInfo->ChConfig[channelIndex].ChannelInfo;
+
+//		if (((value > 0) && ((pChannelInfo->NoCurrentUser + value) > maxUserCount)) || 
+//			((value < 0) && ((pChannelInfo->NoCurrentUser + value) < 0)))
+//		{
+//			continue;
+//		}
+
+//		pNvrChannelInfo = GetNVRChConfigs(pChannelInfo, bmcInstId);
+
+//		pChannelInfo->NoCurrentUser+=value;	
+//		pNvrChannelInfo->NoCurrentUser+=value;
+//              FlushChConfigs((uint8_t*)pNvrChannelInfo,pNvrChannelInfo->ChannelNumber,bmcInstId);
+//}
+//}
+
+//static int IsPrivilegeAvailable(uint8_t requestedPrivilege, uint8_t channelNumber, int bmcInstId)  
+//{  
+//	//   PMConfig_T* pPMConfig = ( PMConfig_T*) GetNVRAddr(NVRH_PMCONFIG, bmcInstId);  
+//       BMCInfo_t *pBMCInfo = &g_BMCInfo[bmcInstId];
+//	uint8_t EthIndex = GetEthIndex(channelNumber & 0x0F, bmcInstId);  
+//	uint8_t privilege = 0x00;  
+//	
+//	if(0xff == EthIndex) return -1;  
+//	
+//	//Get requested privilege status (enabled or disabled) from PMConfig by channel 
+//	switch (requestedPrivilege)  
+//	{  
+//	case PRIV_CALLBACK:  
+//		privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeCallBack;  
+//		break;  
+//	
+//	case PRIV_USER:  
+//		privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeUser;  
+//		break;  
+//	
+//	case PRIV_OPERATOR:  
+//		privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeOperator;  
+//		break;  
+//	
+//	case PRIV_ADMIN:  
+//		privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeAdmin;  
+//		break;  
+//	
+//	case PRIV_OEM:  
+//		privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeOem;  
+//		break;  
+//	
+//	default:  
+//		return -1;  
+//	} 
+//	
+//	//All bits are 0 that means privilege level is disabled  
+//	return ((privilege != 0x00) ? 0 : -1);  
+//}
+
+/*-------------------------------------
+* ValidateIPMBChksum1
+*-------------------------------------*/
+/* Function to validate IPMB Checksum1 for SendMessage Cmd */
+static int ValidateIPMBChksum1( uint8_t* Data)
+{
+   int i=0;
+   uint8_t chksum=0;
+
+   for (i = 0; i < 3; i++)
+   {
+       chksum += *(Data + i);
+   }
+
+   if (chksum != 0)
+   {
+       return FALSE;
+   }
+   return TRUE;
+
+}
+
+
+///*-------------------------------------
+//* ResetWDT
+//*-------------------------------------*/
+//int
+//ResetWDT ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes, int BMCInst)
+//{
+//    uint8_t	u8ExpirationFlag;
+//    BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+
+
+//    if (pBMCInfo->Msghndlr.TmrSet == FALSE)
+//    {
+//        *pRes = CC_ATTEMPT_TO_RESET_UNIN_WATCHDOG;
+//        return sizeof (*pRes);
+//    }
+
+//    // save the WDT expiration flag for later use
+//    u8ExpirationFlag = g_WDTTmrMgr.WDTTmr.ExpirationFlag;
+
+
+//    /* Reset of Watchdog should not happen once
+//        once pretimeout interrupt interval is reached*/
+//    if(pBMCInfo->WDTPreTmtStat == TRUE)
+//    {
+//        *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//        return sizeof (*pRes);
+//    }
+
+//    g_WDTTmrMgr.TmrPresent  = TRUE;
+//    g_WDTTmrMgr.TmrInterval = pBMCInfo->WDTConfig.InitCountDown;
+//    g_WDTTmrMgr.PreTimeOutInterval = SEC_TO_MS * pBMCInfo->WDTConfig.PreTimeOutInterval;
+
+//    /* if the pre-timeout interrupt is not configured, adjust the pre-timeout interrupt
+//        timeout value beyound the regular WDT timeout value so that it won't get triggered
+//        before the WDT timeout. */
+//    if ((pBMCInfo->WDTConfig.TmrActions & 0x70) == 0)
+//    {
+//        g_WDTTmrMgr.PreTimeOutInterval = g_WDTTmrMgr.TmrInterval+ 1;
+//    }
+
+//    _fmemcpy (&g_WDTTmrMgr.WDTTmr, &pBMCInfo->WDTConfig, sizeof (WDTConfig_T));
+
+//    // restore the WDT expiration flag, don't use the one from the flash
+//    g_WDTTmrMgr.WDTTmr.ExpirationFlag = u8ExpirationFlag;
+
+//    // clear WDT sensor event history
+//    if( g_corefeatures.internal_sensor == ENABLED )
+//        RestartWD2Sensor(BMCInst);
+
+//    if(g_corefeatures.wdt_flush_support == ENABLED )
+//    {
+//        FlushIPMI((uint8_t*)&pBMCInfo->WDTConfig,(uint8_t*)&pBMCInfo->WDTConfig,pBMCInfo->IPMIConfLoc.WDTDATAddr,
+//                       sizeof(WDTConfig_T),BMCInst);
+//    }
+
+//    if(BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent == FALSE)
+//    {
+//        LOCK_BMC_SHARED_MEM(BMCInst);
+//        BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning=TRUE;
+//        BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent=TRUE;
+//        UNLOCK_BMC_SHARED_MEM(BMCInst);
+//        sem_post(&g_BMCInfo[BMCInst].WDTSem);
+//    }
+//    else
+//    {
+//        LOCK_BMC_SHARED_MEM(BMCInst);
+//        BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning=TRUE;
+//        BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent=TRUE;
+//        UNLOCK_BMC_SHARED_MEM(BMCInst);
+//        //Set SetWDTUpdated flag to reload initial countdown value.
+//        g_BMCInfo[BMCInst].SetWDTUpdated = TRUE; 
+//    }
+
+
+//    *pRes = CC_NORMAL;
+
+//    return sizeof (*pRes);
+//}
+
+
+
+///*---------------------------------------
+//* SetWDT
+//*---------------------------------------*/
+//int
+//SetWDT ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes, int BMCInst)
+//{
+//      SetWDTReq_T*    pSetWDTReq = ( SetWDTReq_T*)pReq;
+//#if GET_MSG_FLAGS != UNIMPLEMENTED
+//    GetMsgFlagsRes_T   GetMsgFlagsRes;
+//#endif
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+
+
+//    //Check for Reserved bits
+//     if((pSetWDTReq->TmrUse & (BIT5 | BIT4 | BIT3)) || !(pSetWDTReq->TmrUse & (BIT2 | BIT1 | BIT0)) || ((pSetWDTReq->TmrUse & (BIT1 | BIT2)) == (BIT1 | BIT2)) || 
+//        (pSetWDTReq->TmrActions & (BIT7 |BIT6 | BIT3 | BIT2)) || (pSetWDTReq->ExpirationFlag & (BIT7 | BIT6 | BIT0)))
+//    {
+//        *pRes = CC_INV_DATA_FIELD;
+//        return sizeof(*pRes);
+//    }
+
+//#if NO_WDT_PRETIMEOUT_INTERRUPT == 1
+//    // do not support pre-timeout interrupt
+//    if (pSetWDTReq->TmrActions & 0x70)
+//    {
+//        *pRes = CC_INV_DATA_FIELD;
+//        return sizeof(*pRes);
+//    }
+//#endif
+
+//    pSetWDTReq->InitCountDown = htoipmi_u16(pSetWDTReq->InitCountDown);
+
+//    // error out if the pre-timeout interrupt is greater than the initial countdown value
+//    if (pSetWDTReq->InitCountDown < 10 * pSetWDTReq->PreTimeOutInterval)
+//    {
+//        *pRes = CC_INV_DATA_FIELD;
+//        return sizeof(*pRes);
+//    }
+
+//    // only clear the memory version of the bit(s) when the input bit is set #31175
+//    g_WDTTmrMgr.WDTTmr.ExpirationFlag &= ~pSetWDTReq->ExpirationFlag;
+//    pSetWDTReq->ExpirationFlag = g_WDTTmrMgr.WDTTmr.ExpirationFlag;
+
+
+//    /* Copy the Timer configuration in NVRAM */
+//    LOCK_BMC_SHARED_MEM(BMCInst);
+//    _fmemset (( uint8_t*)&pBMCInfo->WDTConfig, 0, sizeof (WDTConfig_T));
+//    _fmemcpy (( uint8_t*)&pBMCInfo->WDTConfig, ( uint8_t*)pSetWDTReq, sizeof (SetWDTReq_T));
+//    UNLOCK_BMC_SHARED_MEM(BMCInst);
+
+//    if (TRUE ==BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning)
+//    {
+//        /* To check wheather Dont stop bit is set or not */
+//        if (pSetWDTReq->TmrUse & 0x40)
+//        {
+//            /* Set the count down value to given value */
+//            g_WDTTmrMgr.TmrPresent = TRUE;
+//            LOCK_BMC_SHARED_MEM(BMCInst);
+//            BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent =TRUE;
+//            UNLOCK_BMC_SHARED_MEM(BMCInst);
+//            g_WDTTmrMgr.TmrInterval= pSetWDTReq->InitCountDown;
+//            g_WDTTmrMgr.PreTimeOutInterval = (SEC_TO_MS * pSetWDTReq->PreTimeOutInterval);
+
+//            /* If PreTimeOutInt is set, clear it */
+//            if (0 != (pSetWDTReq->TmrActions & 0x70))
+//            {
+//                pSetWDTReq->TmrActions &= ~0x70;
+//            }
+//            else
+//            {
+//                // if the pre-timeout interrupt is not configured, adjust the pre-timeout interrupt
+//                // timeout value beyound the regular WDT timeout value so that it won't get triggered
+//                // before the WDT timeout.
+//                g_WDTTmrMgr.PreTimeOutInterval = pSetWDTReq->InitCountDown + 1;
+//            }
+//            _fmemcpy (&g_WDTTmrMgr.WDTTmr, pSetWDTReq, sizeof (WDTConfig_T ));
+
+//        }
+//        else
+//        {
+//            /* Stop the timer */
+//            g_WDTTmrMgr.TmrPresent = FALSE;
+//            LOCK_BMC_SHARED_MEM(BMCInst);
+//            BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning=FALSE;
+//            BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent =FALSE;
+//            UNLOCK_BMC_SHARED_MEM(BMCInst);
+//            g_WDTTmrMgr.TmrInterval= pSetWDTReq->InitCountDown;
+//            g_WDTTmrMgr.PreTimeOutInterval = SEC_TO_MS * pSetWDTReq->PreTimeOutInterval;
+//            // clear WDT sensor event history
+//            if( g_corefeatures.internal_sensor == ENABLED)
+//                RestartWD2Sensor(BMCInst);
+//        }
+
+//        /* Clear the  pre-timeout interupt flag */
+//        LOCK_BMC_SHARED_MEM(BMCInst);
+//        pBMCInfo->WDTConfig.PreTimeoutActionTaken = 0x00;
+//        BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x08; /* Clear the flag */
+//#if GET_MSG_FLAGS != UNIMPLEMENTED
+//        // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
+//        GetMsgFlags (NULL, 0, (uint8_t *)&GetMsgFlagsRes,BMCInst);
+//        TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
+//                GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
+//        if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
+//#else
+//        if((BMC_GET_SHARED_MEM(BMCInst)->MsgFlags & BIT3_BIT0_MASK) == 0)
+//#endif
+//        {
+//            /* Clear the SMS_ATN bit */
+//            if (pBMCInfo->IpmiConfig.KCS1IfcSupport == 1)
+//            {
+//                CLEAR_SMS_ATN (0, BMCInst);
+//            }
+//            if (pBMCInfo->IpmiConfig.KCS2IfcSupport == 1)
+//            {
+//                CLEAR_SMS_ATN (1, BMCInst);
+//            }
+//            if (pBMCInfo->IpmiConfig.KCS3IfcSuppport == 1)
+//            {
+//                CLEAR_SMS_ATN (2, BMCInst);
+//            }
+//        }
+//            UNLOCK_BMC_SHARED_MEM(BMCInst);
+
+//        }
+//        else
+//        {
+//            g_WDTTmrMgr.TmrInterval = pSetWDTReq->InitCountDown;
+//            g_WDTTmrMgr.TmrPresent = FALSE;
+//            LOCK_BMC_SHARED_MEM(BMCInst);
+//            BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent =FALSE;
+//            UNLOCK_BMC_SHARED_MEM(BMCInst);
+//            // clear WDT sensor event history
+//            if( g_corefeatures.internal_sensor == ENABLED)
+//                RestartWD2Sensor(BMCInst);
+//        }
+
+//    // Modify ARP status to resume the thread
+//    // after receiving set Watchdog Timer command
+//    //BMC_GET_SHARED_MEM(BMCInst)->GratArpStatus = RESUME_ARPS;
+//    
+//    int i = 0; 
+
+//    for (i = 0; i < MAX_LAN_CHANNELS; i++)	
+//    {
+//        if((pBMCInfo->LanIfcConfig[i].Enabled == TRUE)
+//                && (pBMCInfo->LanIfcConfig[i].Up_Status == LAN_IFC_UP))
+//        {
+//            BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[i] = RESUME_ARPS; 	
+//            UpdateArpStatus(pBMCInfo->LanIfcConfig[i].Ethindex, BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning, BMCInst);  
+//        }
+//    }
+//    if(g_corefeatures.wdt_flush_support == ENABLED )
+//    {
+//        FlushIPMI((uint8_t*)&pBMCInfo->WDTConfig,(uint8_t*)&pBMCInfo->WDTConfig,pBMCInfo->IPMIConfLoc.WDTDATAddr,
+//              sizeof(WDTConfig_T),BMCInst);
+//    }
+//    // set the "Don't Log" bit
+//    g_WDTTmrMgr.WDTTmr.TmrUse &= 0x7F;
+//    g_WDTTmrMgr.WDTTmr.TmrUse |= (pSetWDTReq->TmrUse & 0x80);
+
+//    g_BMCInfo[BMCInst].SetWDTUpdated = TRUE;
+//    g_BMCInfo[BMCInst].Msghndlr.TmrSet = TRUE;
+//    pBMCInfo->WDTPreTmtStat = FALSE;
+//    *pRes = CC_NORMAL;
+
+//    return sizeof (*pRes);
+//}
+
+
+///*---------------------------------------
+//* GetWDT
+//*---------------------------------------*/
+//int
+//GetWDT ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes, int BMCInst)
+//{
+//      GetWDTRes_T*    pGetWDTRes = ( GetWDTRes_T*)pRes;
+//    BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    /* Copy the current settings from the NVRAM */
+//    LOCK_BMC_SHARED_MEM(BMCInst);
+//    _fmemcpy (( uint8_t*)&pGetWDTRes->CurrentSettings,
+//            ( uint8_t*)&pBMCInfo->WDTConfig, sizeof (WDTConfig_T));
+//    UNLOCK_BMC_SHARED_MEM(BMCInst);
+
+//    // get the WDT expiration from the global veriable in memory, not from the flash
+//    pGetWDTRes->CurrentSettings.ExpirationFlag = g_WDTTmrMgr.WDTTmr.ExpirationFlag;
+
+//    // get the current "Don't Log" bit
+//    pGetWDTRes->CurrentSettings.TmrUse &= 0x7F;
+//    pGetWDTRes->CurrentSettings.TmrUse |= (g_WDTTmrMgr.WDTTmr.TmrUse & 0x80);
+//    if (TRUE == BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent)
+//    {
+//         // set the WDT running bit #30235/30467
+//        pGetWDTRes->CurrentSettings.TmrUse |= 0x40;
+//        /* Present count down in 1/100 of second */
+//    }
+//    else
+//    {
+//         // clear the WDT running bit #30235/30467  for Timer Use (ie) WatchDog Timer status
+//        pGetWDTRes->CurrentSettings.TmrUse &= ~0x40;
+//        pGetWDTRes->CurrentSettings.ExpirationFlag = (pGetWDTRes->CurrentSettings.ExpirationFlag) & 0x3E;
+//    }
+
+//    pGetWDTRes->PresentCountDown			   = g_WDTTmrMgr.TmrInterval;
+//    pGetWDTRes->CurrentSettings.InitCountDown = htoipmi_u16(pGetWDTRes->CurrentSettings.InitCountDown);
+//    pGetWDTRes->CompletionCode                = CC_NORMAL;
+
+//    return sizeof (GetWDTRes_T);
+//}
+
+
+///*---------------------------------------
+//* SetBMCGlobalEnables
+//*---------------------------------------*/
+//int
+//SetBMCGlobalEnables ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes, int BMCInst)
+//{
+//    uint8_t GblEnblByte = *pReq;
+//    BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+//    MsgPkt_T MsgPkt;
+
+//    _fmemset (&MsgPkt, 0, sizeof (MsgPkt_T));
+
+//    /* Check For the reserved bit 4 */
+//    if ( GblEnblByte & BIT4)
+//      {
+//         *pRes = CC_INV_DATA_FIELD;
+//          return sizeof (*pRes);
+//      }
+
+//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
+//    if (((BMC_GET_SHARED_MEM (BMCInst)->GlobalEnables ^ GblEnblByte)) & 0x20) 
+//    {
+//        /* OEM 0 puts us in ICTS compatibility mode for IPMIv2,
+//         * Send a message to lan process so it can change behavior
+//         */
+//        MsgPkt.Channel    = GetLANChannel(0, BMCInst);
+//        MsgPkt.Param      = LAN_ICTS_MODE;
+//        MsgPkt.Privilege  = PRIV_LOCAL;
+//        if (GblEnblByte & 0x20)
+//            MsgPkt.Cmd = 1;
+//        else
+//            MsgPkt.Cmd = 0;
+//        PostMsg(&MsgPkt,LAN_IFC_Q,BMCInst);
+//    }
+
+//    BMC_GET_SHARED_MEM (BMCInst)->GlobalEnables = GblEnblByte;
+//    *pRes = CC_NORMAL;
+//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
+
+//    return sizeof (*pRes);
+//}
+
+
+///*---------------------------------------
+//* GetBMCGlobalEnables
+//*---------------------------------------*/
+//int
+//GetBMCGlobalEnables ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes, int BMCInst)
+//{
+//      GetBMCGblEnblRes_T* pGetBMCGblEnblRes = ( GetBMCGblEnblRes_T*)pRes;
+//    BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
+//    pGetBMCGblEnblRes->CompletionCode = CC_NORMAL;
+//    pGetBMCGblEnblRes->BMCGblEnblByte = BMC_GET_SHARED_MEM (BMCInst)->GlobalEnables;
+//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
+
+//    return sizeof (GetBMCGblEnblRes_T);
+//}
+
+
+///*---------------------------------------
+//* ClrMsgFlags
+//*---------------------------------------*/
+//int
+//ClrMsgFlags ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes, int BMCInst)
+//{
+//     ClearMsgsFlagReq_T* pClearMsgsFlagReq = ( ClearMsgsFlagReq_T*)pReq;
+//    uint8_t *kcsifcnum;
+//#if GET_MSG_FLAGS != UNIMPLEMENTED
+//    GetMsgFlagsRes_T   GetMsgFlagsRes;
+//#endif
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    //Check for Reserved bits
+//    if(pClearMsgsFlagReq->Flag & (BIT4 | BIT2))
+//    {
+//        *pRes = CC_INV_DATA_FIELD;
+//        return sizeof(*pRes);
+//    }
+
+//    OS_THREAD_TLS_GET(g_tls.CurKCSIfcNum,kcsifcnum);
+//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
+//    /* Flush Receive Message Queue */
+//    if (0 != (pClearMsgsFlagReq->Flag & 0x01))
+//    {
+//        while (0 == GetMsg (&m_MsgPkt, &g_RcvMsgQ[*kcsifcnum][0], WAIT_NONE,BMCInst))
+//        {
+//            BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum]--;
+//        }
+
+//        BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x01; /* Clear the flag */
+//    }
+
+//    /* Flush Event Message Buffer */
+//    if (0 != (pClearMsgsFlagReq->Flag & 0x02))
+//    {
+//        OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->EventMutex,WAIT_INFINITE);
+//        while (0 == GetMsg (&m_MsgPkt, EVT_MSG_Q, WAIT_NONE,BMCInst))
+//        {
+//            BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg--;
+//        }
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
+//        BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x02; /* Clear the flag */
+//    }
+
+//    /* Clear WatchdogTimer Interrupt*/
+//    if (0 != (pClearMsgsFlagReq->Flag & 0x08))
+//    {
+//        /* Clear the  pre-timeout interupt flag */
+//        pBMCInfo->WDTConfig.PreTimeoutActionTaken = 0x00;
+//        BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x08; /* Clear the flag */
+//	if(g_corefeatures.wdt_flush_support == ENABLED )
+//    	{
+//            FlushIPMI((uint8_t*)&pBMCInfo->WDTConfig,(uint8_t*)&pBMCInfo->WDTConfig,pBMCInfo->IPMIConfLoc.WDTDATAddr,
+//                           sizeof(WDTConfig_T),BMCInst);
+//       }
+
+//    }
+
+//#if GET_MSG_FLAGS != UNIMPLEMENTED
+//    // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
+//    GetMsgFlags (NULL, 0, (uint8_t *)&GetMsgFlagsRes,BMCInst);
+//    TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
+//            GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
+//    if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
+//#else
+//    if((BMC_GET_SHARED_MEM(BMCInst)->MsgFlags & BIT3_BIT0_MASK) == 0)
+//#endif
+//    {
+//        /* Clear the SMS_ATN bit */
+//        if (pBMCInfo->IpmiConfig.KCS1IfcSupport == 1)
+//        {
+//            CLEAR_SMS_ATN (0, BMCInst);
+//        }
+//        if (pBMCInfo->IpmiConfig.KCS2IfcSupport == 1)
+//        {
+//            CLEAR_SMS_ATN (1, BMCInst);
+//        }
+//        if (pBMCInfo->IpmiConfig.KCS3IfcSuppport == 1)
+//        {
+//            CLEAR_SMS_ATN (2, BMCInst);
+//        }
+//    }
+
+//    *pRes = CC_NORMAL;
+//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
+
+//    return sizeof (*pRes);
+//}
+
+
+// /*---------------------------------------
+// GetMsgFlags
+// ---------------------------------------*/
+// int
+// GetMsgFlags ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+// {
+//     GetMsgFlagsRes_T*   pGetMsgFlagsRes = ( GetMsgFlagsRes_T*)pRes;
+//     uint8_t *kcsifcnum;
+
+//    /* get the message flags */
+//    pGetMsgFlagsRes->MsgFlags = BMC_GET_SHARED_MEM (BMCInst)->MsgFlags;
+
+//    if (BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg >= EVT_MSG_BUF_SIZE)
+//    {
+//        /* If Event MessageBuffer is Full set the BIT */
+//        pGetMsgFlagsRes->MsgFlags |= 0x02;
+//    }
+//    else
+//    {
+//        /* else reset the Flag */
+//        pGetMsgFlagsRes->MsgFlags &= ~0x02;
+//    }
+
+//    if(kcsifcnum != NULL && 0 != BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum])
+//    {
+//        /* if any Message in ReceiveMsgQ set the Flag */
+//        pGetMsgFlagsRes->MsgFlags |= 0x01;
+//    }
+//    else
+//    {
+//        /* else reset the Flag */
+//        pGetMsgFlagsRes->MsgFlags &= ~0x01;
+//    }
+
+//    /* get the  Pre-Timeout Bits Value & Set it to Response Data */
+//    //PRETIMEOUT BIT is 3rd bit so changed accordingly
+//    pGetMsgFlagsRes->MsgFlags |= (pBMCInfo->WDTConfig.PreTimeoutActionTaken & 0x08);
+
+//    /* Update the Message flags in shared Mem */
+//    BMC_GET_SHARED_MEM (BMCInst)->MsgFlags |=  pGetMsgFlagsRes->MsgFlags;
+//    pGetMsgFlagsRes->CompletionCode = CC_NORMAL;
+
+//    return sizeof (GetMsgFlagsRes_T);
+// }
+
+
+///*---------------------------------------
+//* EnblMsgChannelRcv
+//*---------------------------------------*/
+//int
+//EnblMsgChannelRcv ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes, int BMCInst)
+//{
+//      EnblMsgChRcvReq_T*  pEnblMsgChRcvReq = ( EnblMsgChRcvReq_T*)pReq;
+//      EnblMsgChRcvRes_T*  pEnblMsgChRcvRes = ( EnblMsgChRcvRes_T*)pRes;
+//       ChannelInfo_T*      pChannelInfo;
+//    BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    //Check for Reserved bits
+//    if(pEnblMsgChRcvReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4))
+//    {
+//        pEnblMsgChRcvRes->CompletionCode = CC_INV_DATA_FIELD;
+//        return sizeof(*pRes);
+//    }
+
+//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
+//    pChannelInfo = getChannelInfo (pEnblMsgChRcvReq->ChannelNum & 0x0F, BMCInst);
+
+//    TDBG ("ENBL_MSG_CH_RCV: processing..\n");
+
+//    if (NULL == pChannelInfo)
+//    {
+//        pEnblMsgChRcvRes->CompletionCode = CC_INV_DATA_FIELD;
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//        return sizeof (*pRes);
+//    }
+
+//    switch (pEnblMsgChRcvReq->ChannelState)
+//    {
+//        case 0:
+//            /* disable Receive Message Queue for this Channel */
+//            pChannelInfo->ReceiveMsgQ = 0x0;
+//            break;
+
+//        case 1:
+//            /*enable Recevive Message Queue for this Channel */
+//            pChannelInfo->ReceiveMsgQ = 0x1;
+//            break;
+
+//        case 2:
+//            /*get Channel State */
+//            pEnblMsgChRcvRes->ChannelState = pChannelInfo->ReceiveMsgQ;
+//            break;
+
+//        default:
+//            pEnblMsgChRcvRes->CompletionCode = CC_INV_DATA_FIELD;
+//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//            return sizeof (*pRes);
+//    }
+
+//    pEnblMsgChRcvRes->CompletionCode = CC_NORMAL;
+
+//    /*get Channel Number */
+//    pEnblMsgChRcvRes->ChannelNum = pEnblMsgChRcvReq->ChannelNum & 0x0F;
+
+//    pEnblMsgChRcvRes->ChannelState = pChannelInfo->ReceiveMsgQ;
+//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+
+//    return sizeof (EnblMsgChRcvRes_T);
+//}
+
+
+/*---------------------------------------
+* GetMessage
+*---------------------------------------*/
+int
+GetMessage ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    GetMsgRes_T*    pGetMsgRes = ( GetMsgRes_T*)pRes;      
+    uint8_t         Index = 0,*kcsifcnum;
+#if GET_MSG_FLAGS != UNIMPLEMENTED
+   GetMsgFlagsRes_T   GetMsgFlagsRes;
+#endif
+   printf("GetMessage!\n");
+
+//    if (0 != GetMsg (&m_MsgPkt, &g_RcvMsgQ[*kcsifcnum][0], WAIT_NONE))
+//    {
+//        /* if Queue is Empty */
+//        pGetMsgRes->CompletionCode = CC_GET_MSG_QUEUE_EMPTY;
+//        return  sizeof (*pRes);
+//    }
+
+// #if GET_MSG_FLAGS != UNIMPLEMENTED
+//    // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
+//    GetMsgFlags (NULL, 0, (uint8_t *)&GetMsgFlagsRes,BMCInst);
+//    TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
+//            GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
+//    if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
+// #else
+//    if (0 == BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum])
+// #endif
+//    {
+//        /* Clear the SMS_ATN bit */
+//        CLEAR_SMS_ATN (*kcsifcnum,BMCInst);
+//    }
+
+//    /* Completion Code  */
+//    pGetMsgRes->CompletionCode  = CC_NORMAL;
+//    /* Channel number and privilege level */
+//    pGetMsgRes->ChannelNum      = m_MsgPkt.Channel;
+
+//    Index = sizeof (GetMsgRes_T);
+
+//    /* First byte should be session handle */
+//    if(pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)
+//    {
+//        if ((PRIMARY_IPMB_CHANNEL != m_MsgPkt.Channel) && (pBMCInfo->SecondaryIPMBCh != m_MsgPkt.Channel))
+//        {
+//            pGetMsgRes->ChannelNum |= m_MsgPkt.Privilege << 0x04;
+//            pRes [Index++] = m_MsgPkt.Param;
+//        }
+//    }
+//    else
+//    {
+//        if(PRIMARY_IPMB_CHANNEL != m_MsgPkt.Channel)
+//        {
+//                pGetMsgRes->ChannelNum |= m_MsgPkt.Privilege << 0x04;
+//                pRes [Index++] = m_MsgPkt.Param;
+//        }
+//    }
+
+//    /* copy the Message data    */
+//    _fmemcpy (( uint8_t*)&pRes[Index], &m_MsgPkt.Data[1], m_MsgPkt.Size-1);
+
+//    IPMI_DBG_PRINT ("GetMsg: Sending the following data through requested channel\n");
+//    IPMI_DBG_PRINT_BUF (pRes, m_MsgPkt.Size + Index);
+//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
+
+//   return  ((m_MsgPkt.Size-1)+ Index);      /*+ 2 for completion code & channel No. */
+   return 1;
+}
+
+
+/*---------------------------------------
+* SendMessage
+*---------------------------------------*/
+int
+SendMessage ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    SendMsgReq_T* pSendMsgReq = ( SendMsgReq_T*)pReq;
+    SendMsgRes_T* pSendMsgRes = ( SendMsgRes_T*)pRes;
+    IPMIMsgHdr_T* pIPMIMsgHdr;
+    int Queuefd = 0;
+   uint8_t         Tracking;
+   uint8_t         Channel=0,resaddr=0;
+   uint8_t         ResLen = 1;
+   uint8_t         RetVal = 0;
+   uint8_t         Offset = 1;
+   uint8_t         SeqNum = g_BMCInfo.SendMsgSeqNum;
+   uint8_t         PBTbl = PRIMARY_PB_TBL;
+   uint8_t         SrcSessionHndl = 0;
+   ChannelInfo_T*      pChannelInfo;
+   MsgPkt_T ResPkt;
+    SessionInfo_T* pSessionInfo = NULL;
+   uint32_t *CurSesID;
+   uint8_t *curprivlevel,*curchannel,*kcsifcnum;
+
+   if (ReqLen < 1)
+   {
+       *pRes = CC_REQ_INV_LEN;
+       return  sizeof (*pRes);
+   }
+
+   if(pSendMsgReq->ChNoTrackReq == 0xC0)
+   {
+       *pRes = CC_INV_DATA_FIELD;
+       return sizeof (*pRes);
+   }
+
+   /* Get the channel number */
+   Channel = pSendMsgReq->ChNoTrackReq & 0x0F;
+
+   /* Get Tracking field */
+   Tracking = pSendMsgReq->ChNoTrackReq >> 6;
+
+   if (Tracking == RESERVED_BITS_SENDMS)
+   {
+       *pRes = CC_INV_DATA_FIELD;
+       return sizeof (*pRes);
+   }
+
+   CurSesID = pthread_getspecific(g_tls.CurSessionID);       
+   curchannel = pthread_getspecific(g_tls.CurChannel);       
+   kcsifcnum = pthread_getspecific(g_tls.CurKCSIfcNum);       
+
+
+   // if(g_corefeatures.mbmc_single_nic == ENABLED
+   //     && g_corefeatures.ifc_specific_msg_handling != ENABLED)
+   // {
+   //     ResLen = 0;
+   //     g_MBMCInfo.sbmcinst = BMCInst;
+   //     memset((char *)&ResPkt,0,sizeof(MsgPkt_T));
+   //     pIPMIMsgHdr = (IPMIMsgHdr_T*)(&pBMCInfo->LANConfig.MsgReq.Data[sizeof (IPMIMsgHdr_T) + 1]);
+   //     m_MsgPkt.Param    = PARAM_IFC;
+   //     m_MsgPkt.Channel  = *curchannel;
+   //     m_MsgPkt.NetFnLUN = pIPMIMsgHdr->NetFnLUN;
+   //     m_MsgPkt.Cmd      = pIPMIMsgHdr->Cmd;
+   //     m_MsgPkt.Privilege =  PRIV_ADMIN;
+   //     m_MsgPkt.Size     = pBMCInfo->LANConfig.MsgReq.Size - sizeof (IPMIMsgHdr_T) - 2;
+   //     _fmemcpy (m_MsgPkt.Data, pIPMIMsgHdr, m_MsgPkt.Size);
+
+   //     if(g_PDKHandle[PDK_MBMCSINGLENICSENDMSG] != NULL)
+   //     {
+   //         tmpBMCInst = ( (int (*)(uint8_t,int) ) g_PDKHandle[PDK_MBMCSINGLENICSENDMSG]) ( m_MsgPkt.Data[0],BMCInst);
+   //     }
+
+   //     if(tmpBMCInst == 0)
+   //     {
+   //         resaddr = (m_MsgPkt.Data[0] - pBMCInfo->IpmiConfig.BMCSlaveAddr) >> 1;
+   //         if(0 <= resaddr && resaddr < BMCInstCount && (m_MsgPkt.Data[0] - pBMCInfo->IpmiConfig.BMCSlaveAddr)%2 == 0) 
+   //         {
+   //             tmpBMCInst = resaddr + 1;
+   //         }
+   //         else
+   //         {
+   //             *pRes = CC_INV_DATA_FIELD;
+   //             OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
+   //             return sizeof(*pRes);
+   //         }
+   //     }
+
+   //     _fmemcpy(ResPkt.Data,pBMCInfo->LANConfig.MsgReq.Data,sizeof(IPMIMsgHdr_T));
+   //      ResPkt.Param = BRIDGING_REQUEST;
+   //      ResPkt.Cmd = pIPMIMsgHdr->Cmd;
+   //      ((IPMIMsgHdr_T *)ResPkt.Data)->NetFnLUN = ((pBMCInfo->LANConfig.MsgReq.NetFnLUN >> 2) +1) << 2;
+   //      ResPkt.Data [sizeof(IPMIMsgHdr_T)] = CC_NORMAL;
+   //      ResPkt.Size = sizeof (IPMIMsgHdr_T) + 1 + 1; // IPMI Header + Completion Code + Second Checksum
+   //      /* Calculate the Second CheckSum */
+   //      ResPkt.Data[ResPkt.Size - 1] = CalculateCheckSum2 (ResPkt.Data, ResPkt.Size-1);
+   //     if (0 != PostMsg (&ResPkt,LAN_RES_Q,BMCInst))
+   //     {
+   //         TDBG ("SendMsg: Failed to post message to interface queue\n");
+   //     }
+
+   //     pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID,BMCInst);
+   //     if (NULL != pSessionInfo)
+   //     {
+   //         g_MBMCInfo.SrcSessionHndl = pSessionInfo->SessionHandle;
+   //     }
+   //     else
+   //     {
+   //         *pRes = CC_UNSPECIFIED_ERR;
+   //         OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
+   //         return sizeof(*pRes);
+   //     }
+       
+   //     memset(QueueName,0,sizeof(QueueName));
+   //     sprintf(QueueName,"%s%d",LAN_IFC_Q,BMCInst);
+   //     strcpy ((char *)m_MsgPkt.SrcQ,QueueName);
+
+   //     /* Post the message to Message Handler */
+   //     if (0 != PostMsg (&m_MsgPkt,MSG_HNDLR_Q,tmpBMCInst))
+   //     {
+   //         TDBG ("SendMsg: Failed to post message to interface queue\n");
+   //     }
+   // }
+   // else
+   {
+       m_MsgPkt.Param    = BRIDGING_REQUEST;
+       m_MsgPkt.Channel  = Channel;
+       m_MsgPkt.Size     = ReqLen - 1; /* -1 to skip channel num */
+
+       /* Copy the message data */
+       memcpy (m_MsgPkt.Data, &pReq[1], m_MsgPkt.Size);
+       /* Copy the IPMI Message header */
+       pIPMIMsgHdr =  ( IPMIMsgHdr_T*)&m_MsgPkt.Data[Offset - 1];
+       if(ValidateIPMBChksum1(( uint8_t*)pIPMIMsgHdr) == FALSE)
+       {
+           *pRes = CC_INV_DATA_FIELD;
+           return  sizeof (*pRes);
+       }
+
+      if(m_MsgPkt.Data[ReqLen - 2] != CalculateCheckSum2 (( uint8_t*)pIPMIMsgHdr, ReqLen - Offset - 1))
+      {
+           *pRes = CC_INV_DATA_FIELD;
+           return  sizeof (*pRes);
+      }
+
+#if 1
+   	printf("SendMsg: ReqLen = %d, size = %ld\n",ReqLen,m_MsgPkt.Size);
+	int z;
+	printf("m_MsgPkt: \n");
+   	for(z = 0; z < m_MsgPkt.Size;z++)
+   		printf("%02x ", m_MsgPkt.Data[z]);
+   	printf("\n");
+#endif
+
+      
+
+       // if(pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
+       // {
+       //     /* To Check the Wheather  Serial Channel */
+       //     if (pBMCInfo->SERIALch != CH_NOT_USED && (*curchannel  & 0xF) == pBMCInfo->SERIALch && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
+       //     {
+       //          SessionInfo_T* pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID,BMCInst);
+
+       //         if (NULL != pSessionInfo)
+       //         {
+       //             SrcSessionHndl = pSessionInfo->SessionHandle;
+       //         }
+
+       //         TDBG ("SendMsg: To Serial Interface for reference\n");
+       //         // Offset++; : causes bridging issues
+       //         strcpy ((char *)m_MsgPkt.SrcQ, SERIAL_IFC_Q);
+       //     }
+       // }
+
+   		printf("curchannel: %d, Channel: %d\n", *curchannel, Channel);
+   		if(g_BMCInfo.IpmiConfig.LANIfcSupport == 1)
+       	{
+           /* To Check the Wheather  LAN Channel */
+           //if (IsLANChannel(*curchannel & 0xF, BMCInst))
+       		if(*curchannel&0xf == LAN_RMCP_CHANNEL)	//jimbo
+           {
+                SessionInfo_T* pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID);
+
+               if (NULL != pSessionInfo)
+               {
+                   SrcSessionHndl = pSessionInfo->SessionHandle;
+               }
+
+               printf ("SendMsg: To LAN Interface for reference\n");
+               // Offset++; : causes bridging issues
+               strcpy ((char *)m_MsgPkt.SrcQ, LAN_IFC_Q);
+           }
+       }
+
+       if((Channel == PRIMARY_IPMB_CHANNEL) && g_BMCInfo.IpmiConfig.PrimaryIPMBSupport == 1)
+       {
+           printf ("SendMsg: To Primary IPMB Interface\n");
+           m_MsgPkt.SrcQ 	= gFd_PrimaryIpmbIfcQ;
+       }
+       else if(( Channel == SECONDARY_IPMB_CHANNEL) && (g_BMCInfo.IpmiConfig.SecondaryIPMBSupport == 1))
+       {
+           printf ("SendMsg: To SMLink IPMB Interface\n");
+           m_MsgPkt.SrcQ = gFd_SecondaryIpmbIfcQ;
+       }
+       // else if ((pBMCInfo->SERIALch != CH_NOT_USED && Channel == pBMCInfo->SERIALch) && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
+       // {
+       //     TDBG ("SendMsg: To Serial Interface\n");
+       //     Offset++;
+       //     strcpy ((char *)m_MsgPkt.SrcQ, SERIAL_IFC_Q);
+       // }
+       // else if ((pBMCInfo->ICMBCh != CH_NOT_USED && Channel == pBMCInfo->ICMBCh) && pBMCInfo->IpmiConfig.ICMBIfcSupport == 1)
+       // {
+       //     TDBG ("SendMsg: To ICMB Interface\n");
+       //     strcpy ((char *)m_MsgPkt.SrcQ, ICMB_IFC_Q);
+       // }
+       // else if(pBMCInfo->SYSCh != CH_NOT_USED && Channel == pBMCInfo->SYSCh)
+       // {
+       //     TDBG ("SendMsg: To System Interface\n");
+       //     /*
+       //      * According to IPMI Spec v2.0.
+       //      * It is recommended to send CC_DEST_UNAVAILABLE
+       //      * completion code, if the channel is disabled for
+       //      * receiving messages.
+       //      * */
+       //      OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
+       //     pChannelInfo = getChannelInfo(Channel,BMCInst);
+       //     if(NULL == pChannelInfo)
+       //     {
+       //         *pRes = CC_INV_DATA_FIELD;
+       //         OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+       //         OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
+       //         return  sizeof (*pRes);
+       //     }
+       //     if (0x0 == pChannelInfo->ReceiveMsgQ)
+       //     {
+       //         printf ("The Channel(0x%x) has been Disabled "
+       //                     "for Receive message\n", Channel);
+       //         *pRes = CC_DEST_UNAVAILABLE;
+       //         OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+       //         OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
+       //         return sizeof (*pRes);
+       //     }
+       //     OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+       //     strcpy ((char *)m_MsgPkt.SrcQ, &g_RcvMsgQ[*kcsifcnum][0]);
+       //     m_MsgPkt.Param = SrcSessionHndl;
+       // }
+       else
+       {
+           printf ("SendMsg: Invalid Channel\n");
+           *pRes = CC_DEST_UNAVAILABLE;
+           return sizeof (*pRes);
+       }
+
+       // if( (TRUE == pBMCInfo->NMConfig.NMSupport) && (pBMCInfo->NMConfig.NMDevSlaveAddress == pIPMIMsgHdr->ResAddr) &&
+       //     (Channel == (NM_PRIMARY_IPMB_BUS == pBMCInfo->NMConfig.NM_IPMBBus) ? pBMCInfo->PrimaryIPMBCh : pBMCInfo->SecondaryIPMBCh) )
+       // {
+       //     if( (pBMCInfo->RMCPLAN1Ch == *curchannel) ||
+       //         (pBMCInfo->RMCPLAN2Ch == *curchannel) ||
+       //         (pBMCInfo->RMCPLAN3Ch == *curchannel) ||
+       //         (pBMCInfo->RMCPLAN4Ch == *curchannel) ||
+       //         (pBMCInfo->SERIALch   == *curchannel) )
+       //     {
+       //         OS_THREAD_TLS_GET(g_tls.CurPrivLevel,curprivlevel);
+       //         if(PRIV_ADMIN != *curprivlevel)
+       //         {
+       //             TDBG("Insufficient Privilege\n");
+       //             *pRes = CC_INSUFFIENT_PRIVILEGE;
+       //             OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
+       //             return sizeof(*pRes);
+       //         }
+       //     }
+       // }
+   
+       if (1 == Tracking)
+       {
+           /* Response length is set to zero to make MsgHndlr skip responding to this request 
+            * The Response will be handled by the ipmb interface after verifying NAK.
+            */
+           ResLen = 0;
+           
+           /* Tracking is not required if originator is System ifc */
+           if (SYS_IFC_CHANNEL == (*curchannel & 0xF))
+           {
+               *pRes = CC_INV_DATA_FIELD;
+               return sizeof (*pRes);
+           }
+           
+           PBTbl = (Channel == SECONDARY_IPMB_CHANNEL) ? SECONDARY_PB_TBL : PRIMARY_PB_TBL ;
+
+           /* Store in the table for response tracking */
+           while(TRUE)
+           {
+               if (FALSE == m_PendingBridgedResTbl[PBTbl][SeqNum].Used)
+               {
+                   m_PendingBridgedResTbl[PBTbl][SeqNum].TimeOut = g_BMCInfo.IpmiConfig.SendMsgTimeout;
+                   m_PendingBridgedResTbl[PBTbl][SeqNum].ChannelNum = (*curchannel & 0xF);
+                   m_PendingBridgedResTbl[PBTbl][SeqNum].OriginSrc  = ORIGIN_SENDMSG;
+                   g_BMCInfo.SendMsgSeqNum = SeqNum;
+                   
+                   if (1 != Offset)
+                   {
+                       m_PendingBridgedResTbl[PBTbl][SeqNum].DstSessionHandle = pReq[Offset]; /* Session handle */
+                   }
+
+                   m_PendingBridgedResTbl[PBTbl][SeqNum].SrcSessionHandle = SrcSessionHndl;
+
+                   memcpy (&m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr, pIPMIMsgHdr, sizeof (IPMIMsgHdr_T));
+
+                   /* Format the IPMI Msg Hdr */
+                   if(Channel == PRIMARY_IPMB_CHANNEL)  
+                   {
+                       pIPMIMsgHdr->ReqAddr = g_BMCInfo.IpmiConfig.PrimaryIPMBAddr;
+                   }
+                   else if(Channel == SECONDARY_IPMB_CHANNEL)
+                   {
+                       pIPMIMsgHdr->ReqAddr =  g_BMCInfo.IpmiConfig.SecondaryIPMBAddr;
+                   }
+                   else
+                   {
+                       printf("Invalid channel %d\n", Channel);//pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
+                   }
+
+                   pIPMIMsgHdr->RqSeqLUN = (g_BMCInfo.SendMsgSeqNum << 2) & 0xFC; /* Seq Num and LUN =00 */
+
+                   /* Recalculate the checksum */
+                   m_MsgPkt.Data[ReqLen - 2] = CalculateCheckSum2 (( uint8_t*)pIPMIMsgHdr, ReqLen - Offset - 1);
+                   if((*curchannel & 0xF) == LAN_RMCP_CHANNEL)
+                   {                 
+                       m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ = gFd_LanIfcQ;
+                   }
+                   // else if (pBMCInfo->SERIALch != CH_NOT_USED && (*curchannel & 0xF) == pBMCInfo->SERIALch && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
+                   // {
+                   //     memset(QueueName,0,sizeof(QueueName));
+                   //     sprintf(QueueName,"%s%d",SERIAL_IFC_Q,BMCInst);
+                   //     strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
+                   // }
+                   else
+                   {
+                       if(( (*curchannel & 0xF) == PRIMARY_IPMB_CHANNEL) && (g_BMCInfo.IpmiConfig.PrimaryIPMBSupport == 1 ))
+                       {          
+                           m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ = gFd_PrimaryIpmbIfcQ;
+                       }
+                       else if(((*curchannel & 0xF) == SECONDARY_IPMB_CHANNEL) && g_BMCInfo.IpmiConfig.SecondaryIPMBSupport == 1)
+                       {
+                           m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ = gFd_SecondaryIpmbIfcQ;
+                       }
+                       // else if ((pBMCInfo->SERIALch != CH_NOT_USED && Channel == pBMCInfo->SERIALch) && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
+                       // {
+                       //     memset(QueueName,0,sizeof(QueueName));
+                       //     sprintf(QueueName,"%s%d",SERIAL_IFC_Q,BMCInst);
+                       //     strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
+                       // }
+                       // else if((pBMCInfo->SMBUSCh != CH_NOT_USED && Channel == pBMCInfo->SMBUSCh) && pBMCInfo->IpmiConfig.SMBUSIfcSupport == 1)
+                       // {
+                       // //strcpy ((char *)m_PendingBridgedResTbl[i].DestQ, NULL);
+                       // }
+                       // else if ((pBMCInfo->ICMBCh != CH_NOT_USED && Channel == pBMCInfo->ICMBCh) && pBMCInfo->IpmiConfig.ICMBIfcSupport == 1)
+                       // {
+                       //    memset(QueueName,0,sizeof(QueueName));
+                       //    sprintf(QueueName,"%s%d",ICMB_IFC_Q,BMCInst);
+                       //    strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
+                       // }
+                   }
+                   m_PendingBridgedResTbl[PBTbl][SeqNum].Used = TRUE;
+                   printf( "SendMessage:  Bridged message added index = %d.\n", SeqNum);
+
+                   break;
+               }
+               else
+               {
+                   SeqNum = (SeqNum + 1) & 0x3F;
+
+                   if (SeqNum == g_BMCInfo.SendMsgSeqNum)
+                   {
+                       /* If not been added to the Pending Bridge table, an error should be reported back.
+                       If not, for internal channel, the thread calling it may end up waiting! */
+                       *pRes = CC_NODE_BUSY;
+                       return  sizeof (*pRes);
+                   }
+                }
+           }
+       }
+
+       // if ((pBMCInfo->SYSCh == (*curchannel & 0xF)) && pBMCInfo->IpmiConfig.SYSIfcSupport == 0x01)
+       // {
+       //     ResLen = 0;
+       //     /* Format the IPMI Msg Hdr */
+       //     // Fill the address from Infrastrucure function instead of using PRIMARY_IPMB_ADDR/SECONDARY_IPMB_ADDR
+       //     if(Channel == pBMCInfo->PrimaryIPMBCh)
+       //     {
+       //         pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.PrimaryIPMBAddr;
+       //     }
+       //     else if(Channel == pBMCInfo->SecondaryIPMBCh)
+       //     {
+       //         pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.SecondaryIPMBAddr;
+       //     }
+       //     else
+       //     {
+       //         pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
+       //     }
+
+       //     /*Change the encapsulated request's LUN based on originating KCS interface */
+       //     pIPMIMsgHdr->RqSeqLUN = (pIPMIMsgHdr->RqSeqLUN & 0xFC) | (*kcsifcnum + 0x01);
+       //     m_MsgPkt.Data[ReqLen - 2] = CalculateCheckSum2 (( uint8_t*)pIPMIMsgHdr, ReqLen - Offset - 1);
+       //     pBMCInfo->BridgeMsgKCSIfc = *kcsifcnum;
+       // }
+
+        printf ("SendMsgCmd:Posting to interface ");
+        int y;
+        for(y=0;y<m_MsgPkt.Size;y++)
+       		printf("%#x ", m_MsgPkt.Data[y]);
+       	printf("\n");
+
+        m_MsgPkt.Cmd = PAYLOAD_IPMI_MSG;
+       /* Post the message to interface */
+       if (0 != PostMsg (m_MsgPkt.SrcQ, &m_MsgPkt))
+       {
+           printf ("SendMsg: Failed to post message to interface queue\n");
+       }
+
+       pSendMsgRes->CompletionCode = CC_NORMAL;
+   }
+   return ResLen;
+}
+
+
+///*---------------------------------------
+//* ReadEvtMsgBuffer
+//*---------------------------------------*/
+//int
+//ReadEvtMsgBuffer ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes, int BMCInst)
+//{
+//      ReadEvtMsgBufRes_T* pReadEvtMsgBufRes = ( ReadEvtMsgBufRes_T*)pRes;
+//#if GET_MSG_FLAGS != UNIMPLEMENTED
+//    GetMsgFlagsRes_T   GetMsgFlagsRes;
+//#endif
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
+//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->EventMutex,WAIT_INFINITE);
+//    if (-2 == GetMsg(&m_MsgPkt, EVT_MSG_Q, WAIT_NONE, BMCInst))
+//    {
+//        /*If queue is empty */
+//        pReadEvtMsgBufRes->CompletionCode = CC_EVT_MSG_QUEUE_EMPTY;/* Queue is empty    */
+//		OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
+//		OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
+//        return  sizeof (*pRes);
+//    }
+
+//    if (BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg == 0) 
+//    { 
+//        pReadEvtMsgBufRes->CompletionCode = CC_EVT_MSG_QUEUE_EMPTY; 
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
+//		OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
+//        return  sizeof (*pRes); 
+//    }
+
+//    BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg--;
+//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
+
+//#if GET_MSG_FLAGS != UNIMPLEMENTED
+//    // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
+//    GetMsgFlags (NULL, 0, (uint8_t *)&GetMsgFlagsRes,BMCInst);
+//    TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
+//            GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
+//    if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
+//#else
+//    if (0 == BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg)
+//#endif
+//    {
+//        /* if there is no messssage in buffer reset SMS/EVT ATN bit */
+//        //       CLEAR_SMS_ATN ();
+//        if (pBMCInfo->IpmiConfig.KCS1IfcSupport == 1)
+//        {
+//            CLEAR_SMS_ATN (0, BMCInst);
+//        }
+//        if (pBMCInfo->IpmiConfig.KCS2IfcSupport == 1)
+//        {
+//            CLEAR_SMS_ATN (1, BMCInst);
+//        }
+//        if (pBMCInfo->IpmiConfig.KCS3IfcSuppport == 1)
+//        {
+//            CLEAR_SMS_ATN (2, BMCInst);
+//        }
+//    }
+
+//    /* clear EventMessageBuffer full flag */
+//    BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x02;
+
+//    pReadEvtMsgBufRes->CompletionCode = CC_NORMAL; /* Completion Code   */
+
+//    /* copy the Message data */
+//    _fmemcpy (pReadEvtMsgBufRes->ResData, m_MsgPkt.Data, m_MsgPkt.Size);
+//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
+
+//    return sizeof (ReadEvtMsgBufRes_T);
+//}
+
+
+///*---------------------------------------
+//* GetBTIfcCap
+//*---------------------------------------*/
+//int
+//GetBTIfcCap ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes, int BMCInst)
+//{
+//      GetBTIfcCapRes_T* pGetBTIfcCapRes = ( GetBTIfcCapRes_T*)pRes;
+
+//    pGetBTIfcCapRes->CompletionCode     = CC_NORMAL;
+//    pGetBTIfcCapRes->NumReqSupported    = 2;
+//    pGetBTIfcCapRes->InputBufSize       = MAX_BT_PKT_LEN;
+//    pGetBTIfcCapRes->OutputBufSize      = MAX_BT_PKT_LEN;
+//    pGetBTIfcCapRes->RespTime           = 1;
+//    pGetBTIfcCapRes->Retries            = 0;
+
+//    return sizeof (GetBTIfcCapRes_T);
+//}
+
+
+///*---------------------------------------
+//* GetSystemGUID
+//*---------------------------------------*/
+//int
+//GetSystemGUID ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes, int BMCInst)
+//{
+//     GetSysGUIDRes_T* pGetSysGUIDRes = ( GetSysGUIDRes_T*)pRes;
+
+//    pGetSysGUIDRes->CompletionCode  = CC_NORMAL;
+//    LOCK_BMC_SHARED_MEM (BMCInst);
+//    _fmemcpy (&pGetSysGUIDRes->Node, BMC_GET_SHARED_MEM (BMCInst)->SystemGUID, 16);
+//    UNLOCK_BMC_SHARED_MEM (BMCInst);
+
+//    return sizeof (GetSysGUIDRes_T);
+//}
+
+
+#define SUPPORT_IPMI20  0x02
+#define SUPPORT_IPMI15  0x01
+/*---------------------------------------
+* GetChAuthCap
+*---------------------------------------*/
+int
+GetChAuthCap ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	//TODO: dummy data
+//    GetChAuthCapReq_T*   pGetChAuthCapReq = ( GetChAuthCapReq_T*)pReq;
+    GetChAuthCapRes_T*   pGetChAuthCapRes = ( GetChAuthCapRes_T*)pRes;
+
+	pGetChAuthCapRes->CompletionCode	=	CC_NORMAL;
+	pGetChAuthCapRes->ChannelNum		=	LAN_RMCP_CHANNEL;
+	pGetChAuthCapRes->AuthType			=	0x36;
+	pGetChAuthCapRes->PerMsgUserAuthLoginStatus	=	0x04;
+	pGetChAuthCapRes->ExtCap			=	0;
+	pGetChAuthCapRes->OEMID[0]			=	0;
+	pGetChAuthCapRes->OEMID[1]			=	0;
+	pGetChAuthCapRes->OEMID[2]			=	0;
+	pGetChAuthCapRes->OEMAuxData		=	0;
+	
+    return sizeof (GetChAuthCapRes_T);
+}
+
+
+/*---------------------------------------
+* GetSessionChallenge
+* Create session in this function
+*---------------------------------------*/
+int
+GetSessionChallenge ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	GetSesChallengeReq_T* pGetSesChalReq = ( GetSesChallengeReq_T*)pReq;
+	GetSesChallengeRes_T* pGetSesChalRes = ( GetSesChallengeRes_T*)pRes;
+    uint8_t                 Index;
+    uint8_t                 ChallengeString[CHALLENGE_STR_LEN];
+	UserInfo_T			*pUserInfo;
+	
+    // // Check for Reserved bits
+    // if((pGetSesChalReq->AuthType == AUTHTYPE_RESERVED) || (pGetSesChalReq->AuthType > AUTHTYPE_OEM_PROPRIETARY))
+    // {
+    //     pGetSesChalRes->CompletionCode = CC_INV_DATA_FIELD;
+    //     return sizeof (*pRes);
+    // }
+
+	if(pGetSesChalReq->UserName[0] == 0)
+	{
+		pGetSesChalRes->CompletionCode = 0x82;
+        return sizeof (*pRes);
+	}
+	
+	g_BMCInfo.pUserInfo = NULL;
+	pUserInfo = getUserNameInfo(pGetSesChalReq->UserName);
+	if(pUserInfo == NULL)
+	{
+		pGetSesChalRes->CompletionCode = 0x81;
+        return sizeof (*pRes);
+	}
+	
+	// if((pUserInfo->ID != USER_ID) || (pUserInfo->UserStatus == FALSE))
+	// {
+	// 	pGetSesChalRes->CompletionCode = 0x81;
+ //        return sizeof (*pRes);
+	// }
+	g_BMCInfo.pUserInfo = pUserInfo;
+	
+	g_BMCInfo.LanSession.AuthType	=	pGetSesChalReq->AuthType;
+	g_BMCInfo.LanSession.SessionID = 0x1234;//trng_get_true_random_data();
+	
+	pGetSesChalRes->CompletionCode = CC_NORMAL;
+    pGetSesChalRes->TempSessionID  = g_BMCInfo.LanSession.SessionID;
+
+	/* generate Randam Challenge String */
+    for(Index=0;Index < CHALLENGE_STR_LEN;Index++)
+    {
+        ChallengeString[Index] = 0x56;//trng_get_true_random_data()&0xff;
+    }
+    memcpy(pGetSesChalRes->ChallengeString, ChallengeString, CHALLENGE_STR_LEN);
+
+    return sizeof (GetSesChallengeRes_T);
+}
+
+/*---------------------------------------
+* ActivateSession
+*---------------------------------------*/
+int
+ActivateSession ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	//TODO: dummy data
+	ActivateSesReq_T*   pAcvtSesReq = ( ActivateSesReq_T*)pReq;
+	ActivateSesRes_T*   pAcvtSesRes = ( ActivateSesRes_T*)pRes;
+      
+
+    // /* Initial Outbound Sequence Number cannot be null */  
+    // if (pAcvtSesReq->OutboundSeq == 0)  
+    // {  
+    //     pAcvtSesRes->CompletionCode = CC_ACTIVATE_SESS_SEQ_OUT_OF_RANGE;  
+    //     return sizeof(*pRes);  
+    // }
+   
+    // // Check for Reserved bitss
+    // if((pAcvtSesReq->AuthType == AUTHTYPE_RESERVED) || (pAcvtSesReq->AuthType > AUTHTYPE_OEM_PROPRIETARY))
+    // {
+    //     pAcvtSesRes->CompletionCode = CC_INV_DATA_FIELD;
+    //     return sizeof (*pRes);
+    // }
+
+    // if ((pAcvtSesReq->Privilege == PRIV_LEVEL_RESERVED) || (pAcvtSesReq->Privilege > PRIV_LEVEL_PROPRIETARY))
+    // {
+    //    pAcvtSesRes->CompletionCode = CC_INV_DATA_FIELD;/* Privilege is Reserved */
+    //    return sizeof (*pRes);
+    // }
+
+    pAcvtSesRes->CompletionCode = CC_NORMAL;
+    pAcvtSesRes->AuthType = g_BMCInfo.LanSession.AuthType;
+    pAcvtSesRes->SessionID = g_BMCInfo.LanSession.SessionID;
+    pAcvtSesRes->InboundSeq = 0x78;//trng_get_true_random_data();
+    pAcvtSesRes->Privilege = 0x04;
+
+    return sizeof (ActivateSesRes_T);
+}
+
+
+/*---------------------------------------
+* SetSessionPrivLevel
+*---------------------------------------*/
+int
+SetSessionPrivLevel ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	SetSesPrivLevelReq_T*   pSetSesPrivLevelReq = ( SetSesPrivLevelReq_T*)pReq;
+	SetSesPrivLevelRes_T*   pSetSesPrivLevelRes = ( SetSesPrivLevelRes_T*)pRes;
+
+    //Check for Reserved bits
+    if((pSetSesPrivLevelReq->Privilege == PRIV_LEVEL_CALLBACK) || (pSetSesPrivLevelReq->Privilege > PRIV_LEVEL_PROPRIETARY))
+    {
+        pSetSesPrivLevelRes->CompletionCode = CC_INV_DATA_FIELD;
+        return sizeof(SetSesPrivLevelRes_T);
+    }
+ 
+    /* According to the IPMI 2.0 Priv Level =1 is reserved */
+    if((PRIV_USER      != pSetSesPrivLevelReq->Privilege) &&
+       (PRIV_OPERATOR  != pSetSesPrivLevelReq->Privilege) &&
+       (PRIV_ADMIN     != pSetSesPrivLevelReq->Privilege) &&
+       (PRIV_OEM     != pSetSesPrivLevelReq->Privilege))
+    {
+        /*Requested Privilege exceeds ChannelPrivilege Limit */
+        pSetSesPrivLevelRes->CompletionCode = CC_INV_DATA_FIELD;
+         return sizeof (*pRes);
+    }
+
+    pSetSesPrivLevelRes->CompletionCode = CC_NORMAL;
+    pSetSesPrivLevelRes->Privilege      = pSetSesPrivLevelReq->Privilege;
+
+    return sizeof (SetSesPrivLevelRes_T);
+}
+
+
+/*---------------------------------------
+* CloseSession
+*---------------------------------------*/
+int
+CloseSession ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	//TODO: dymmy data
+    *pRes = CC_NORMAL;
+    return sizeof (*pRes);
+}
+
+//#if GET_SESSION_INFO != UNIMPLEMENTED
+///*---------------------------------------
+//* GetSessionInfo
+//*---------------------------------------*/
+//int
+//GetSessionInfo ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes, int BMCInst)
+//{
+//      GetSesInfoReq_T* pGetSesInfoReq = ( GetSesInfoReq_T*)pReq;
+//      GetSesInfoRes_T* pGetSesInfoRes = ( GetSesInfoRes_T*)pRes;
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//    LANSesInfoRes_T     LANSesInfo;
+//    LANIPv6SesInfoRes_T     LANIPv6SesInfo;
+//       SessionInfo_T*   pSessInfo;
+//       ChannelInfo_T*   pChannelInfo;
+//       void*            SessionArg;
+//    uint8_t 	     SessionArgAlign[4];
+//    uint8_t            SessionArgType,EthIndex, netindex = 0xFF;
+//    char    IfcName[IFNAMSIZ];
+//    uint32_t *CurSesID,*curchannel;
+//    int i;
+
+//    *pRes = CC_REQ_INV_LEN;
+
+//    switch (pGetSesInfoReq->SessionIndex)
+//    {
+//        case 0:
+//            /* Get session information for this session */
+//            if (1 != ReqLen)
+//            {
+//                return sizeof (*pRes);
+//            }
+//            SessionArgType  = SESSION_ID_INFO;
+//            OS_THREAD_TLS_GET(g_tls.CurSessionID,CurSesID);
+//            SessionArg      = CurSesID;
+//            break;
+
+//        case 0xFF:
+//            if (5 != ReqLen)
+//            {
+//                return sizeof (*pRes);
+//            }
+//            SessionArgType  = SESSION_ID_INFO;
+
+//            SessionArgAlign[0]      = pGetSesInfoReq->SessionHandleOrID[0];
+//            SessionArgAlign[1]      = pGetSesInfoReq->SessionHandleOrID[1];
+//            SessionArgAlign[2]      = pGetSesInfoReq->SessionHandleOrID[2];
+//            SessionArgAlign[3]      = pGetSesInfoReq->SessionHandleOrID[3];
+//            SessionArg = SessionArgAlign;
+//            break;
+
+//        case 0xFE:
+//            if (2 != ReqLen)
+//            {
+//                return sizeof (*pRes);
+//            }
+//            if (pGetSesInfoReq->SessionHandleOrID[0] == 0)
+//            {
+//                *pRes=CC_INV_DATA_FIELD;
+//                return sizeof (*pRes);
+//            }
+//            SessionArgType  = SESSION_HANDLE_INFO;
+//            SessionArgAlign[0]      = pGetSesInfoReq->SessionHandleOrID[0];
+//            SessionArgAlign[1]      = pGetSesInfoReq->SessionHandleOrID[1];
+//            SessionArgAlign[2]      = pGetSesInfoReq->SessionHandleOrID[2];
+//            SessionArgAlign[3]      = pGetSesInfoReq->SessionHandleOrID[3];
+//            SessionArg = SessionArgAlign;
+//            break;
+
+//        default:
+//            if (1 != ReqLen)
+//            {
+//                return sizeof (*pRes);
+//            }
+//            SessionArgType  = SESSION_INDEX_INFO;
+//            SessionArg      = &pGetSesInfoReq->SessionIndex;
+//            break;
+//    }
+
+//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SessionTblMutex, WAIT_INFINITE);
+//    pSessInfo = getSessionInfo (SessionArgType, SessionArg, BMCInst);
+//    if (NULL == pSessInfo)
+//    {
+//        TDBG ("GetSessionInfo: pSessInfo is NULL\n");
+//        /* if there is no active channel for the current session Index
+//        * return the following bytes
+//        */
+
+//        OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
+//        pChannelInfo = getChannelInfo (*curchannel & 0xF, BMCInst);
+//        if(NULL == pChannelInfo)
+//        {
+//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+//            pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
+//            return	sizeof (*pRes);
+//        }
+
+//        pGetSesInfoRes->CompletionCode          = CC_NORMAL;
+//        pGetSesInfoRes->SessionHandle           = BMC_GET_SHARED_MEM (BMCInst)->SessionHandle;
+//        pGetSesInfoRes->NumPossibleActiveSession=  pBMCInfo->IpmiConfig.MaxSession;
+//        pGetSesInfoRes->NumActiveSession        = GetNumOfActiveSessions (BMCInst);
+
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+//        return (sizeof (GetSesInfoRes_T) - sizeof (ActiveSesInfo_T) - sizeof (SessionInfoRes_T));
+//    }
+
+//    memset (pGetSesInfoRes,0,sizeof(GetSesInfoRes_T));
+//    pChannelInfo = getChannelInfo (pSessInfo->Channel, BMCInst);
+//    if(NULL == pChannelInfo)
+//    {
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+//        pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
+//        return	sizeof (*pRes);
+//    }
+//    pGetSesInfoRes->CompletionCode              = CC_NORMAL;
+//    pGetSesInfoRes->SessionHandle               = pSessInfo->SessionHandle;
+//    pGetSesInfoRes->NumPossibleActiveSession    = pBMCInfo->IpmiConfig.MaxSession;
+//    pGetSesInfoRes->NumActiveSession            = GetNumOfActiveSessions (BMCInst);
+//    pGetSesInfoRes->ActiveSesinfo.UserID        = pSessInfo->UserId & 0x3F;
+//    pGetSesInfoRes->ActiveSesinfo.Privilege     = pSessInfo->Privilege & 0x0F;
+//    /* Set protocol bit as per Auth Type, bit4 must be 1 for IPMIv2.0 RMCP, 0 for IPMIv1.5 */
+//    if( AUTHTYPE_RMCP_PLUS_FORMAT == pSessInfo->AuthType )
+//    {
+//        pGetSesInfoRes->ActiveSesinfo.ChannelNum    = (pSessInfo->Channel & 0x0F) | 0x10;
+//    }else
+//    {
+//        pGetSesInfoRes->ActiveSesinfo.ChannelNum    = pSessInfo->Channel & 0x0F;
+//    }
+//    EthIndex= GetEthIndex(pSessInfo->Channel & 0x0F, BMCInst);
+//    if(0xff == EthIndex)
+//    {
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+//       *pRes = CC_INV_DATA_FIELD;
+//       DeleteSession (pSessInfo,BMCInst);
+//       return sizeof (uint8_t);
+//    }
+//    memset(IfcName,0,sizeof(IfcName));
+//    /*Get the EthIndex*/
+//    if(GetIfcName(EthIndex,IfcName, BMCInst) == -1)
+//    {
+//       TCRIT("Error in Getting Ifc name\n");
+//       OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+//       *pRes = CC_INV_DATA_FIELD;
+//       return sizeof (uint8_t);
+//    }
+
+//    for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
+//    {
+//       if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
+//       {
+//           netindex= Ifcnametable[i].Index;
+//           break;
+//       }
+//    }
+
+//    if(netindex == 0xFF)
+//    {
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+//       *pRes = CC_INV_DATA_FIELD;
+//       return sizeof (uint8_t);
+//    }
+//    if (IsLANChannel( pSessInfo->Channel, BMCInst))
+//    {
+//        if(g_corefeatures.global_ipv6  == ENABLED)
+//        {
+//            if(GetIPAdrressType(&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[0])==4) 
+//            {
+//                memset(&LANSesInfo,0,sizeof(LANSesInfo));
+//                /* IP Address */
+//                _fmemcpy (&(LANSesInfo.IPAddress),
+//                                    &pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[sizeof(struct in6_addr)-sizeof(struct in_addr)],
+//                                    sizeof(struct in_addr));
+//                /* MAC Address */
+//                if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
+//                nwGetSrcCacheMacAddr((uint8_t*)&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[12],
+//                                                        netindex, pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
+
+//                _fmemcpy(LANSesInfo.MACAddress, pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
+//                /* Port number */
+//                LANSesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
+
+//                _fmemcpy ((pRes+sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)),&LANSesInfo, sizeof (LANSesInfoRes_T));
+//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+//                return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)+sizeof (LANSesInfoRes_T));
+//                }
+//            else
+//            {
+//                /* IP Address */
+//                memset(&LANIPv6SesInfo,0,sizeof(LANIPv6SesInfo));
+//                _fmemcpy (&(LANIPv6SesInfo.IPv6Address),
+//                		pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr,
+//                		sizeof(struct in6_addr));
+//                /* MAC Address */
+//                if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
+//                    nwGetSrcMacAddr_IPV6((uint8_t*)&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr,
+//                                        pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
+
+//                _fmemcpy(LANIPv6SesInfo.MACAddress, pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
+//                /* Port number */
+//                LANIPv6SesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
+
+//                _fmemcpy ((pRes+sizeof (GetSesInfoRes_T) - sizeof(SessionInfoRes_T)),&LANIPv6SesInfo, sizeof (LANIPv6SesInfoRes_T));
+//                OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+//                return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)+sizeof (LANIPv6SesInfoRes_T));
+//                }
+//        }
+//        else
+//        {
+
+//            /* IP Address */
+//            _fmemcpy (pGetSesInfoRes->SesInfo.LANSesInfo.IPAddress,
+//            		pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr,
+//            		sizeof (pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr));
+//            /* MAC Address */
+//            if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
+//                nwGetSrcCacheMacAddr((uint8_t*)pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr, netindex, 
+//                                pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
+//            _fmemcpy(pGetSesInfoRes->SesInfo.LANSesInfo.MACAddress, 
+//                    pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
+//            /* Port number */
+//            pGetSesInfoRes->SesInfo.LANSesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
+//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+//            return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T) + sizeof (LANSesInfoRes_T));
+//        }
+//    }
+//    else if (pBMCInfo->IpmiConfig.SerialIfcSupport == 1 && pBMCInfo->SERIALch== pSessInfo->Channel)
+//    {
+
+//        pChannelInfo = getChannelInfo (pBMCInfo->SERIALch, BMCInst);
+//        if(NULL == pChannelInfo)
+//        {
+//            pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
+//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+//            return	sizeof (*pRes);
+//        }
+
+//        pGetSesInfoRes->SesInfo.SerialSesInfo.SessionActivityType = 0;
+//        pGetSesInfoRes->SesInfo.SerialSesInfo.DestinationSelector = 0;
+
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+//        return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T) + sizeof (SerialSesInfoRes_T));
+//    }
+//    else
+//    {
+//        pChannelInfo = getChannelInfo(pSessInfo->Channel, BMCInst);
+//        if(NULL == pChannelInfo)
+//        {
+//            pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
+//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+//            return sizeof (*pRes);
+//        }
+
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
+//        return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T));
+//    }
+//}
+//#endif
+
+
+///**
+// * @fn GetAuthCodeForTypeV15
+// * @brief This function will use the encryption technique supported 
+// * 			in IPMI V1.5 in order to produce Auth Code.
+// * @param[in] pUserInfo - Pointer to User info structure.
+// * @param[in] pGetAuthCodeReq - Pointer to the structure of request data
+// * @param[out] pGetAuthCodeRes - Pointer to the resultant data.
+// * @retval size of the result data.
+// */
+//static int
+//GetAuthCodeForTypeV15 (UserInfo_T* pUserInfo,
+//        GetAuthCodeReq_T* pGetAuthCodeReq,
+//        GetAuthCodeRes_T* pGetAuthCodeRes )
+//{
+//    uint8_t   AuthCode;
+//    uint8_t   InBuffer[2*IPMI15_MAX_PASSWORD_LEN + HASH_DATA_LENGTH];
+//    char    UserPswd[MAX_PASSWD_LEN];
+//    uint8_t   PwdEncKey[MAX_SIZE_KEY + 1] = {0};
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    memset(&(pGetAuthCodeRes->AuthCode), 0, AUTH_CODE_HASH_LEN);
+//    AuthCode = pGetAuthCodeReq->AuthType & AUTH_CODE_V15_MASK;
+//    if((pGetAuthCodeReq->AuthType & (BIT5 | BIT4)) ||
+//       (AuthCode == AUTHTYPE_RESERVED) || (AuthCode == AUTHTYPE_NONE) ||
+//       (AuthCode == AUTHTYPE_STRAIGHT_PASSWORD) ||
+//       (AuthCode > AUTHTYPE_OEM_PROPRIETARY))
+//    {
+//        pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
+//        return (sizeof (GetAuthCodeRes_T) - 4);
+//    }
+
+//    if (g_corefeatures.userpswd_encryption == ENABLED)
+//    {
+//        /* Get Encryption Key from the MBMCInfo_t structure */
+//        LOCK_BMC_SHARED_MEM(BMCInst);
+//            memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
+//        UNLOCK_BMC_SHARED_MEM(BMCInst);
+
+//        if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[pUserInfo->UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, UserPswd, MAX_PASSWORD_LEN, PwdEncKey))
+//        {
+//            TCRIT("Error in decrypting the IPMI User password for User ID:%d.\n", pUserInfo->UserId);
+//            pGetAuthCodeRes->CompletionCode = CC_UNSPECIFIED_ERR;
+//            return sizeof(*pGetAuthCodeRes);
+//        }
+//    	memcpy(&InBuffer[0],UserPswd,IPMI15_MAX_PASSWORD_LEN);
+//    }
+//    else
+//    {
+//    	memcpy(&InBuffer[0],pUserInfo->UserPassword,IPMI15_MAX_PASSWORD_LEN);
+//    }
+
+//    LOCK_BMC_SHARED_MEM(BMCInst);
+//    switch (AuthCode)
+//    {
+//        #if 0 // As per IPMIv2 Markup E4, Straight Password key is Reserved
+//        case AUTH_TYPE_PASSWORD: /* Straight password */
+//            if (0 == _fmemcmp (pUserInfo->UserPassword,pGetAuthCodeReq->HashData,IPMI15_MAX_PASSWORD_LEN))
+//            {
+//                _fmemcpy (pGetAuthCodeRes->AuthCode, "OK", 2);
+//            }
+//            else
+//            {
+//                pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
+//            }
+//            break;
+//        #endif
+
+//        case AUTH_TYPE_MD2: /* MD2 */
+//            _fmemcpy (&InBuffer[IPMI15_MAX_PASSWORD_LEN],
+//                    pGetAuthCodeReq->HashData, HASH_DATA_LENGTH);
+//            if (g_corefeatures.userpswd_encryption == ENABLED)
+//            {
+//            	_fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
+//                    UserPswd, IPMI15_MAX_PASSWORD_LEN);
+//            }
+//            else
+//            {
+//            	_fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
+//                    pUserInfo->UserPassword, IPMI15_MAX_PASSWORD_LEN);
+//            }
+
+//            AuthCodeCalMD2 (InBuffer, pGetAuthCodeRes->AuthCode, sizeof (InBuffer));
+//            break;
+
+//        case AUTH_TYPE_MD5: /* MD5 */
+//            _fmemcpy (&InBuffer[IPMI15_MAX_PASSWORD_LEN],
+//                    pGetAuthCodeReq->HashData, HASH_DATA_LENGTH);
+//            if (g_corefeatures.userpswd_encryption == ENABLED)
+//            {
+//            	_fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
+//                    UserPswd,IPMI15_MAX_PASSWORD_LEN);
+//            }
+//            else
+//            {
+//            	_fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
+//                    pUserInfo->UserPassword,IPMI15_MAX_PASSWORD_LEN);
+//            }
+//            AuthCodeCalMD5 (InBuffer, pGetAuthCodeRes->AuthCode, sizeof (InBuffer));
+//            break;
+
+//        default:
+//            pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
+//    }
+
+//    UNLOCK_BMC_SHARED_MEM(BMCInst);
+//    // IPMI V1.5 AuthCode is only 16 byte.
+//    return (sizeof (GetAuthCodeRes_T) - 4);
+//}
+
+///**
+// * @fn GetAuthCodeForTypeV20
+// * @brief This function will use the encryption technique supported 
+// * 			in IPMI V2.0 in order to produce Auth Code.
+// * @param[in] pUserInfo - Pointer to User info structure.
+// * @param[in] pGetAuthCodeReq - Pointer to the structure of request data
+// * @param[out] pGetAuthCodeRes - Pointer to the resultant data.
+// * @retval size of the result data.
+// */
+//static int
+//GetAuthCodeForTypeV20 (UserInfo_T* pUserInfo,
+//        GetAuthCodeReq_T* pGetAuthCodeReq,
+//        GetAuthCodeRes_T* pGetAuthCodeRes )
+//{
+//    uint8_t   AuthCode;
+//    uint8_t   UserPasswdLen=0;
+//    uint8_t   DecVal = 0;
+//     uint8_t m_SIK [SESSION_INTEGRITY_KEY_SIZE];
+//    char   UserPswd[MAX_PASSWD_LEN];
+//    unsigned char PwdEncKey[MAX_SIZE_KEY + 1] = {0};
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    if (g_corefeatures.userpswd_encryption == ENABLED)
+//    {
+//        /* Get Encryption Key from the MBMCInfo_t structure */
+//        LOCK_BMC_SHARED_MEM(BMCInst);
+//            memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
+//        UNLOCK_BMC_SHARED_MEM(BMCInst);
+
+//        if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[pUserInfo->UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, UserPswd, MAX_PASSWORD_LEN, PwdEncKey))
+//        {
+//            TCRIT("\nError in decrypting the IPMI User password for user with ID:%d.\n", pUserInfo->UserId);
+//            pGetAuthCodeRes->CompletionCode = CC_UNSPECIFIED_ERR;
+//            return sizeof (*pGetAuthCodeRes);
+//        }
+//    }
+//    else
+//    {
+//        memcpy(&UserPswd, pUserInfo->UserPassword, MAX_PASSWD_LEN);
+//    }
+
+//    /* Calculate password length */
+//    UserPasswdLen = _fstrlen (( char*)UserPswd);
+//    UserPasswdLen = (UserPasswdLen > MAX_PASSWORD_LEN) ?
+//            MAX_PASSWORD_LEN : UserPasswdLen;
+
+//    memset(&(pGetAuthCodeRes->AuthCode), 0, AUTH_CODE_HASH_LEN);
+//    AuthCode = pGetAuthCodeReq->AuthType & AUTH_CODE_V20_MASK;
+//    /* Validate the Auth Code */
+//    if ((AuthCode > MIN_AUTH_CODE_V20) && (AuthCode < MAX_AUTH_CODE_V20))
+//    {
+//        pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
+//        return sizeof(GetAuthCodeRes_T);
+//    }
+
+//    LOCK_BMC_SHARED_MEM(BMCInst);
+//    switch(AuthCode)
+//    {
+//        case AUTH_NONE: /* none */
+//            TDBG ("\nInside AUTH_NONE in GetAuthCode");
+//            pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
+//            break;
+
+//        case AUTH_HMAC_SHA1_96: /* HMAC-SHA1-96 */
+//            TDBG ("\nInside AUTH_HMAC_SHA1_96 in GetAuthCode");
+//            hmac_sha1 ((uint8_t *)UserPswd, UserPasswdLen,
+//                    (uint8_t *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
+//                    (uint8_t *)m_SIK, SESSION_INTEGRITY_KEY_SIZE);
+
+//            hmac_sha1 ((uint8_t *)m_SIK, SESSION_INTEGRITY_KEY_SIZE,
+//                    (uint8_t *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
+//                    (uint8_t *)&(pGetAuthCodeRes->AuthCode), HMAC_SHA1_96_LEN);
+
+//            DecVal = AUTH_CODE_HASH_LEN - HMAC_SHA1_96_LEN;
+//            break;
+
+//        case AUTH_HMAC_MD5_128: /* HMAC-MD5-128 */
+//            TDBG ("\nInside AUTH_HMAC_MD5_128 in GetAuthCode");
+//            hmac_md5 ((unsigned char*)UserPswd, UserPasswdLen,
+//                    pGetAuthCodeReq->HashData, HASH_DATA_LEN,
+//                    m_SIK, SESSION_HMAC_MD5_I_KEY_SIZE);
+
+//            hmac_md5 (m_SIK, SESSION_HMAC_MD5_I_KEY_SIZE,
+//                    pGetAuthCodeReq->HashData, HASH_DATA_LEN,
+//                    (unsigned char *)&(pGetAuthCodeRes->AuthCode), 
+//                    SESSION_HMAC_MD5_I_KEY_SIZE);
+//            DecVal = AUTH_CODE_HASH_LEN - SESSION_HMAC_MD5_I_KEY_SIZE;
+//            break;
+
+//        case AUTH_MD5_128: /* MD5-128 */
+//            TDBG ("\nInside AUTH_MD5_128 in GetAuthCode");
+//            MD5_128 ((char *)UserPswd, UserPasswdLen,
+//                    (char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
+//                    (char *)m_SIK, SESSION_MD5_KEY_SIZE);
+
+//            MD5_128 ((char *)m_SIK, SESSION_INTEGRITY_KEY_SIZE,
+//                    (char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
+//                    (char *)&(pGetAuthCodeRes->AuthCode), SESSION_MD5_KEY_SIZE);
+//            DecVal = AUTH_CODE_HASH_LEN - SESSION_MD5_KEY_SIZE;
+//            break;
+
+//        case AUTH_HMAC_SHA256_128: /* HMAC-SHA256-128 */
+//            TDBG ("\nInside AUTH_HMAC_SHA256_128 in GetAuthCode");
+//            hmac_sha256 ((unsigned char *)UserPswd, UserPasswdLen, 
+//    				(unsigned char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
+//    				(unsigned char *)m_SIK, SHA2_HASH_KEY_SIZE);
+
+//			hmac_sha256 (m_SIK, SHA2_HASH_KEY_SIZE,  
+//    				(unsigned char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
+//    				(unsigned char *)&(pGetAuthCodeRes->AuthCode), HMAC_SHA256_128_LEN);    		
+//            DecVal = AUTH_CODE_HASH_LEN - HMAC_SHA256_128_LEN;
+//            break;            
+
+//            //! TODO: Need support in openssl.
+//        default: /* OEM or Reserved */
+//            pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
+//    }
+
+//    UNLOCK_BMC_SHARED_MEM(BMCInst);
+//    if (DecVal > sizeof(GetAuthCodeRes_T))
+//        return sizeof(GetAuthCodeRes_T);
+//    else
+//        return (sizeof(GetAuthCodeRes_T) - DecVal);
+//}
+
+///**
+// * @fn GetAuthCode
+// * @brief This function will encrypt the given 16 byte data with
+// *          the algorithm given and return Auth Code.
+// * @param[in] pReq - Request data.
+// * @param[in] ReqLen - Length of the request data.
+// * @param[out] pRes - Result data
+// * @retval size of the result data.
+// */
+//int
+//GetAuthCode ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes )
+//{
+//      GetAuthCodeReq_T*   pGetAuthCodeReq = ( GetAuthCodeReq_T*)pReq;
+//      GetAuthCodeRes_T*   pGetAuthCodeRes = ( GetAuthCodeRes_T*)pRes;
+//    BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+//       UserInfo_T*         pUserInfo;
+//    uint8_t               AuthType,*curchannel;
+//       ChannelInfo_T*      pChannelInfo;
+//    int nRetSize = 0;
+
+//    /* Check for Reserved Bits */
+//    if((pGetAuthCodeReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4)) ||
+//            (pGetAuthCodeReq->UserID & (BIT7 | BIT6)))
+//    {
+//        pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
+//        return sizeof(*pRes);
+//    }
+
+//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
+//    /* Validate the channel number given */
+//    if (CURRENT_CHANNEL_NUM == pGetAuthCodeReq->ChannelNum)
+//    {
+//        OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
+//        pChannelInfo = getChannelInfo(*curchannel & 0xF,BMCInst);
+//    }
+//    else
+//        pChannelInfo = getChannelInfo(pGetAuthCodeReq->ChannelNum,BMCInst);
+
+//    if (NULL == pChannelInfo)
+//    {
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//        *pRes = CC_INV_DATA_FIELD;
+//        return sizeof(*pRes);
+//    }
+
+//    /* Get the user information for the given userID */
+//    pUserInfo = getUserIdInfo (pGetAuthCodeReq->UserID,BMCInst);
+//    if (NULL == pUserInfo)
+//    {
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//        TDBG ("AppDevice.c : GetAuthCode - Invalid user Id\n");
+//        pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
+//        return sizeof (*pRes);
+//    }
+
+//    AuthType = pGetAuthCodeReq->AuthType & GET_AUTH_TYPE_MASK;
+//    pGetAuthCodeRes->CompletionCode = CC_NORMAL;
+
+//    switch(AuthType)
+//    {
+//        case AUTH_TYPE_V15: /* IPMI v1.5 AuthCode Algorithms */
+//            nRetSize = GetAuthCodeForTypeV15(pUserInfo, pGetAuthCodeReq, pGetAuthCodeRes,BMCInst);
+//            break;
+
+//        case AUTH_TYPE_V20: /* IPMI v2.0/RMCP+ Algorithm Number */
+//            nRetSize = GetAuthCodeForTypeV20(pUserInfo, pGetAuthCodeReq, pGetAuthCodeRes,BMCInst);
+//            break;
+
+//        default:
+//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//            pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
+//            return sizeof(*pRes);
+//    }
+//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//    return nRetSize;
+//}
+
+
+///*---------------------------------------
+//* SetChAccess
+//*---------------------------------------*/
+//int
+//SetChAccess ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes, int BMCInst)
+//{
+//      SetChAccessReq_T*   pSetChAccessReq = ( SetChAccessReq_T*)pReq;
+//            uint8_t               ChannelNum, AccessMode;
+//       ChannelInfo_T*      pNvrChInfo;
+//       ChannelInfo_T*      pChannelInfo;
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//    uint8_t AccessFlags = 0,i=0,*curchannel;
+////    char ChFilename[MAX_CHFILE_NAME];
+
+//    /* Reserve Bit Checking for Set Channel Acces */
+//    for(i=0;i<ReqLen;i++)
+//    {
+//        if( 0 != (pReq[i] & m_Set_ChReserveBit[i]))
+//        {
+//            *pRes = CC_INV_DATA_FIELD;
+//            return	sizeof (*pRes);
+//        }
+//    }
+//    /* Reserve Value checking */
+
+//    if((pReq[1] & 0xC0)== 0xC0 || (pReq[2] & 0xC0) == 0xC0)
+//    {
+//        *pRes = CC_INV_DATA_FIELD;
+//        return	sizeof (*pRes);
+//    }
+
+//    ChannelNum = pSetChAccessReq->ChannelNum & 0x0F;
+//    if (CURRENT_CHANNEL_NUM == ChannelNum)
+//    {
+//        OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
+//        ChannelNum = *curchannel & 0xF;
+//    }
+
+//    if (((GetBits (pSetChAccessReq->Privilege, 0x0F)) < PRIV_LEVEL_CALLBACK) ||
+//        ((GetBits (pSetChAccessReq->Privilege, 0x0F)) > PRIV_LEVEL_PROPRIETARY))
+//    {
+//        IPMI_DBG_PRINT_1 ("Invalid Channel Privilege = 0x%x\n", pSetChAccessReq->Privilege);
+//        *pRes = CC_INV_DATA_FIELD;
+//        return  sizeof (*pRes);
+//    }
+
+//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
+//    pChannelInfo = getChannelInfo(ChannelNum, BMCInst);
+//    if (NULL == pChannelInfo)
+//    {
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//        *pRes = CC_INV_DATA_FIELD;
+//        return  sizeof (*pRes);
+//    }
+
+//    /*point to NVRAM ChannelInfo */
+//    pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
+
+//    if (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport)
+//    {
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//        /* Channel is sessionless channel this command is not supported */
+//        *pRes = CC_SET_CH_COMMAND_NOT_SUPPORTED;
+//        return  sizeof (*pRes);
+//    }
+
+
+//    AccessMode = pSetChAccessReq->ChannelAccess & 0x07;
+//    if(ChannelNum == pBMCInfo->SERIALch)
+//    {
+//        if( NULL != g_PDKHandle[PDK_SWITCHMUX])
+//        {
+//            ((void(*)(uint8_t, int))(g_PDKHandle[PDK_SWITCHMUX]))(AccessMode ,BMCInst);
+//        }
+//     }
+
+//    /* if the requested access mode is supported for the given channel */
+//    if (0 == (pChannelInfo->AccessModeSupported & (1 << AccessMode)))
+//    {
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//        *pRes = CC_SET_CH_ACCES_MODE_NOT_SUPPORTED;
+//        return  sizeof (*pRes);
+//    }
+
+//    AccessFlags = GetBits (pSetChAccessReq->ChannelAccess, 0xC0);
+
+//    switch (AccessFlags)
+//    {
+//        case 0:
+//            /* dont set channel access */
+//            break;
+
+//        case 1:
+//            /*set in  Non volatile Memory and in voatile Memory */
+//            pNvrChInfo->Alerting        = GetBits (pSetChAccessReq->ChannelAccess , 0x20);
+//            pNvrChInfo->PerMessageAuth  = GetBits (pSetChAccessReq->ChannelAccess , 0x10);
+//            pNvrChInfo->UserLevelAuth   = GetBits (pSetChAccessReq->ChannelAccess , 0x08);
+//            pNvrChInfo->AccessMode = AccessMode;
+//            /* write to NVRAM   */
+//            FlushChConfigs((uint8_t*)pNvrChInfo,pNvrChInfo->ChannelNumber,BMCInst);
+//            pChannelInfo->Alerting      = pNvrChInfo->Alerting;
+//            pChannelInfo->PerMessageAuth= pNvrChInfo->PerMessageAuth;
+//            pChannelInfo->UserLevelAuth = pNvrChInfo->UserLevelAuth;
+//            pChannelInfo->AccessMode = AccessMode;
+//            break;
+
+//        case 2:
+//            /*set in volatile Memmory only      */
+//            pChannelInfo->Alerting      = GetBits (pSetChAccessReq->ChannelAccess, 0x20);
+//            pChannelInfo->PerMessageAuth= GetBits (pSetChAccessReq->ChannelAccess, 0x10);
+//            pChannelInfo->UserLevelAuth = GetBits (pSetChAccessReq->ChannelAccess, 0x08);
+//            pChannelInfo->AccessMode = AccessMode;
+//    }
+
+//    switch (GetBits (pSetChAccessReq->Privilege, 0xC0))
+//    {
+//        case 0:
+//            /* dont set prilivege level */
+//            break;
+
+//        case 1:
+//            /* set in non volatile mem  and volatile  memeory*/ /*set privilege*/
+//            pNvrChInfo->MaxPrivilege = GetBits (pSetChAccessReq->Privilege, 0x0F);
+//            pChannelInfo->MaxPrivilege = pNvrChInfo->MaxPrivilege;
+//            break;
+
+//        case 2:
+//            /*set privilege*/
+//            /*  set in volatile memeory only    */
+//            pChannelInfo->MaxPrivilege = GetBits (pSetChAccessReq->Privilege, 0x0F);
+//    }
+
+//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//    *pRes = CC_NORMAL;
+
+//    return sizeof (*pRes);
+//}
+
+
+///*---------------------------------------
+//* GetChAccess
+//*---------------------------------------*/
+//int
+//GetChAccess ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes, int BMCInst)
+//{
+//      GetChAccessReq_T*   pGetChAccessReq = ( GetChAccessReq_T*)pReq;
+//      GetChAccessRes_T*   pGetChAccessRes = ( GetChAccessRes_T*)pRes;
+//       ChannelInfo_T*      pChannelInfo;
+//       ChannelInfo_T*      pNvrChInfo;
+//    uint8_t               ChannelNum,AccessFlag,*curchannel;
+//    BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    /* Check for reserved bits */
+//    if((0 != (pGetChAccessReq->ChannelNum & 0xf0)) ||
+//        (0 != (pGetChAccessReq->	AccessFlag & 0x3f)))
+//    {
+//        pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
+//        return  sizeof (*pRes);
+//    }
+
+//    ChannelNum = pGetChAccessReq->ChannelNum & 0x0F;
+//    if (CURRENT_CHANNEL_NUM == ChannelNum)
+//    {
+//        OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
+//        ChannelNum = *curchannel & 0xF;
+//    }
+
+//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
+//    pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
+
+//    if (NULL == pChannelInfo)
+//    {
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//        pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
+//        return  sizeof (*pRes);
+//    }
+
+//    if (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport)
+//    {
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//        /* Channel is sessionless channel this command is not supported */
+//        pGetChAccessRes->CompletionCode = CC_GET_CH_COMMAND_NOT_SUPPORTED;
+//        return  sizeof (*pRes);
+//    }
+
+//    AccessFlag = GetBits (pGetChAccessReq->AccessFlag, 0xC0);
+
+//    pGetChAccessRes->CompletionCode = CC_NORMAL;
+
+//    switch (AccessFlag)
+//    {
+//        case 1:
+//            /*  Get Channel Information from NVRAM */
+//            pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
+
+//            pGetChAccessRes->ChannelAccess  = SetBits (0x20, pNvrChInfo->Alerting);
+//            pGetChAccessRes->ChannelAccess |= SetBits (0x10, pNvrChInfo->PerMessageAuth);
+//            pGetChAccessRes->ChannelAccess |= SetBits (0x08, pNvrChInfo->UserLevelAuth);
+//            pGetChAccessRes->ChannelAccess |= SetBits (0x07, pNvrChInfo->AccessMode);
+//            pGetChAccessRes->Privilege      = SetBits (0x0F, pNvrChInfo->MaxPrivilege);
+//            break;
+
+//        case 2:
+//            /*  Get  Channel Information from  Volatile RAM */
+//            pGetChAccessRes->ChannelAccess  = SetBits (0x20, pChannelInfo->Alerting);
+//            pGetChAccessRes->ChannelAccess |= SetBits (0x10, pChannelInfo->PerMessageAuth);
+//            pGetChAccessRes->ChannelAccess |= SetBits (0x08, pChannelInfo->UserLevelAuth);
+//            pGetChAccessRes->ChannelAccess |= SetBits (0x07, pChannelInfo->AccessMode);
+//            pGetChAccessRes->Privilege      = SetBits (0x0F, pChannelInfo->MaxPrivilege);
+//            break;
+
+//        default:
+//            OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//            pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
+//            return  sizeof (*pRes);
+//    }
+
+//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//    return sizeof (GetChAccessRes_T);
+//}
+
+
+///*---------------------------------------
+//* GetChInfo
+//*---------------------------------------*/
+//int
+//GetChInfo ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes, int BMCInst)
+//{
+//      GetChInfoReq_T*     pGetChInfoReq = ( GetChInfoReq_T*)pReq;
+//      GetChInfoRes_T*     pGetChInfoRes = ( GetChInfoRes_T*)pRes;
+//    BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+//       ChannelInfo_T*      pChannelInfo;
+//    uint8_t               ChannelNum,*curchannel;
+
+//    if(pGetChInfoReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4)) //Check for Reserved bits
+//    {
+//        pGetChInfoRes->CompletionCode = CC_INV_DATA_FIELD;
+//        return sizeof(*pRes);
+//    }
+
+//    ChannelNum = pGetChInfoReq->ChannelNum;
+//    if (CURRENT_CHANNEL_NUM == ChannelNum)
+//    {
+//        OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
+//        ChannelNum = *curchannel & 0xF;
+//        
+//        /* UDS, not being a physical channel, will hold LAN properties */ 
+//        if(UDS_CHANNEL == ChannelNum)
+//        {
+//        	ChannelNum = LAN_RMCP_CHANNEL1_TYPE;
+//        }
+//    }
+
+//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
+//    pChannelInfo = getChannelInfo(ChannelNum, BMCInst);
+//    if (NULL == pChannelInfo)
+//    {
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//        pGetChInfoRes->CompletionCode = CC_INV_DATA_FIELD ;
+//        return  sizeof (*pRes);
+//    }
+
+//    pGetChInfoRes->CompletionCode        = CC_NORMAL;
+//    pGetChInfoRes->ChannelNum            = ChannelNum;
+//    pGetChInfoRes->ChannelMedium         = pChannelInfo->ChannelMedium;
+//    pGetChInfoRes->ChannelProtocol       = pChannelInfo->ChannelProtocol;
+//    pGetChInfoRes->SessionActiveSupport  = pChannelInfo->SessionSupport << 6;
+//    pGetChInfoRes->SessionActiveSupport |= pChannelInfo->ActiveSession;
+
+//    _fmemcpy (pGetChInfoRes->VendorID, pChannelInfo->ProtocolVendorId,
+//                sizeof (pGetChInfoRes->VendorID));
+//    _fmemcpy (pGetChInfoRes->AuxiliaryInfo, pChannelInfo->AuxiliaryInfo,
+//                sizeof (pGetChInfoRes->AuxiliaryInfo));
+
+//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+
+//    return sizeof (GetChInfoRes_T);
+//}
+
+///*---------------------------------------
+//* IsChannelSuppGroups
+//*---------------------------------------*/
+//uint8_t  IsChannelSuppGroups(uint8_t ChannelNum )
+//{
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//       ChannelInfo_T*          pChannelInfo;
+//    if(IsLANChannel(ChannelNum, BMCInst))
+//    {
+//        
+//        pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
+//        if(pChannelInfo==NULL)
+//            return 0;
+//        if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL1_TYPE) 
+//        {
+//           return pChannelInfo->ChannelType;
+//        }
+//        else
+//        {
+//            if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL2_TYPE)
+//            {
+//               return pChannelInfo->ChannelType;
+//            }
+//            else
+//            {
+//                if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL3_TYPE)
+//                {
+//                   return pChannelInfo->ChannelType;
+//                }
+//                else
+//                    return 0;
+//            }
+//        }
+//        return 0;
+//    }
+//    else
+//    {
+//        if (pBMCInfo->IpmiConfig.SerialIfcSupport == 1 && (pBMCInfo->SERIALch != CH_NOT_USED && ChannelNum == pBMCInfo->SERIALch))
+//        {
+//            pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
+//            if(pChannelInfo==NULL)
+//                return 0;
+//            return pChannelInfo->ChannelType;
+//        }
+//        else 
+//            return 0;
+//    }
+//}
+///*---------------------------------------
+//* ModifyUsrGRP
+//*---------------------------------------*/
+//int
+//ModifyUsrGrp(char * UserName,uint8_t ChannelNum,uint8_t OldAccessLimit, uint8_t NewAccessLimit )
+//{
+
+//    char oldgrp[20]="",newgrp[20]="";
+
+//    if(0 == NewAccessLimit)
+//    {
+//        DeleteUsrFromIPMIGrp(UserName);
+//    }
+
+//    if(PRIV_LEVEL_NO_ACCESS == OldAccessLimit)
+//    {
+//        strcpy(oldgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege].grpname);
+//    }
+//    else if(IGNORE_ADD_OR_REMOVE != OldAccessLimit)
+//    {
+//        strcpy(oldgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege+OldAccessLimit].grpname);
+//    }
+
+//    if(PRIV_LEVEL_NO_ACCESS == NewAccessLimit)
+//    {
+//        strcpy(newgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege].grpname);
+//    }
+//    else if(IGNORE_ADD_OR_REMOVE != NewAccessLimit)
+//    {
+//        strcpy(newgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege+NewAccessLimit].grpname);
+//    }
+
+//    AddIPMIUsrtoChGrp(UserName,(char *)oldgrp,(char *)newgrp);
+//    return 0;
+//}
+
+/*---------------------------------------
+* SetUserAccess
+*---------------------------------------*/
+int
+SetUserAccess ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	SetUserAccessReq_T*     pSetUserAccessReq = ( SetUserAccessReq_T*)pReq;
+	UserInfo_T*             pUserInfo;
+    
+    if (ReqLen == sizeof(SetUserAccessReq_T) - sizeof(pSetUserAccessReq->SessionLimit) )
+    {
+        pSetUserAccessReq->SessionLimit = 0;
+    }
+    else if(ReqLen == sizeof(SetUserAccessReq_T))
+    {
+        if(0 != pSetUserAccessReq->SessionLimit)
+        {
+            *pRes = CC_INV_DATA_FIELD;
+            return  sizeof (*pRes);
+        }
+    }
+    else
+    {
+        *pRes = CC_REQ_INV_LEN;
+        return  sizeof (*pRes);
+    }
+
+    pUserInfo = getUserIdInfo(pSetUserAccessReq->UserID);
+    if (NULL == pUserInfo)
+    {
+        printf ("AppDevice.c : SetUserAccess - Invalid user Id\n");
+        *pRes = CC_INV_DATA_FIELD;
+        return sizeof (*pRes);
+    }
+
+    // if (pUserInfo->ID != USER_ID)
+    // {
+    //     printf("Invalid data field\n");
+    //     *pRes = CC_INV_DATA_FIELD;
+    //     return  sizeof (*pRes);
+    // }
+	
+//	pUserInfo->ChannelAccess = (pSetUserAccessReq->ChannelNoUserAccess&0x70) | (pSetUserAccessReq->AccessLimit&0x0f);
+    *pRes = CC_NORMAL;
+
+    return sizeof (*pRes);
+}
+
+/*---------------------------------------
+* GetUserAccess
+*---------------------------------------*/
+int
+GetUserAccess ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	GetUserAccessReq_T*     pGetUserAccessReq = ( GetUserAccessReq_T*)pReq;
+	GetUserAccessRes_T*     pGetUserAccessRes = ( GetUserAccessRes_T*)pRes;
+	UserInfo_T*             pUserInfo;
+
+    pUserInfo = getUserIdInfo (pGetUserAccessReq->UserID);
+
+    if (NULL == pUserInfo)
+	{
+	   pGetUserAccessRes->CompletionCode = CC_INV_DATA_FIELD;
+	   return  sizeof (*pRes);
+	}
+
+    pGetUserAccessRes->CompletionCode = CC_NORMAL;
+    pGetUserAccessRes->MaxNoUserID    = MAX_USER_NUM;
+    pGetUserAccessRes->CurrentUserID  = g_BMCInfo.CurrentNoUser;
+    pGetUserAccessRes->FixedUserID    = 0;
+	//pGetUserAccessRes->ChannelAccess  = pUserInfo->ChannelAccess;
+
+    return sizeof (GetUserAccessRes_T);
+}
+
+
+/*---------------------------------------
+* SetUserName
+*---------------------------------------*/
+int
+SetUserName ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	// SetUserNameReq_T*       pSetUserNameReq = ( SetUserNameReq_T*)pReq;
+	// UserInfo_T*             pUserInfo;
+	// uint8_t                 i;
+	// uint8_t   	UserName[MAX_USERNAME_LEN + 1];   //plus 1 for null terminator
+	// uint8_t 	InvalidChar[]={  ' ' , ',' , '.' , '/' , ':' , ';' , '\\' , '(', ')' , 0x01 ,
+	// 				   0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09, 0x0A ,
+	// 				   0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x10 , 0x11 , 0x12, 0x13 ,
+	// 				   0x14 , 0x15 , 0x16 , 0x17 , 0x18 , 0x19 , 0x1A , 0x1B, 0x1C ,
+	// 				   0x1D , 0x1E , 0x1F , 0x7F} ;
+
+
+ //    // Check for Reserved bits
+ //    if(pSetUserNameReq->UserID & (BIT7 | BIT6) || (pSetUserNameReq->UserID == 0x00))
+ //    {
+ //        *pRes = CC_INV_DATA_FIELD;
+ //        return sizeof(*pRes);
+ //    }
+
+ //    /*User Id exceeded the limit or  Cant set NULL User */
+ //    if (pSetUserNameReq->UserID > MAX_USER_NUM )
+ //    {
+ //        *pRes = CC_INV_DATA_FIELD ;
+ //        return  sizeof (*pRes);
+ //    }
+
+ //    pUserInfo = getUserIdInfo(pSetUserNameReq->UserID);
+    
+ //    /* We should not set the NULL user */
+ //    if(0== pSetUserNameReq->UserName [0] )
+ //    {
+ //        printf("\n Setting the NULL user :%x",pSetUserNameReq->UserID);
+ //        *pRes = CC_INV_DATA_FIELD ;
+ //        return	sizeof (*pRes);
+ //    }
+
+ //    /* check for numeric first char and special chars */
+ //    if( (pSetUserNameReq->UserName[0] >= '0') && (pSetUserNameReq->UserName[0] <= '9')  )
+ //    {
+ //        *pRes = CC_INV_DATA_FIELD;
+ //        return sizeof(*pRes);
+ //    }
+ //    else
+ //    {
+	// 	strncpy((char *)UserName,(const char *) pSetUserNameReq->UserName, sizeof(pSetUserNameReq->UserName));
+	// 	UserName[MAX_USERNAME_LEN] = '\0';
+ //        for(i=0;i<sizeof(InvalidChar);i++)
+ //        {
+ //            if( NULL != strchr((const char *)UserName, InvalidChar[i] ))
+ //            {
+ //                *pRes = CC_INV_DATA_FIELD;
+ //                return sizeof(*pRes);
+ //            }
+ //        }
+ //    }
+    
+ //    //Don't check duplicated user names for 0xFF, this request is for deleting user
+ //    if(0xFF != pSetUserNameReq->UserName [0])
+ //    {
+ //        //checking for Duplicate user names
+ //        if(CheckForDuplicateUsers(pSetUserNameReq->UserName)==FALSE)
+ //        {
+ //            //setting user's name with same name
+ //            if(!strncmp((char *)pUserInfo->UserName,(char *)pSetUserNameReq->UserName, MAX_USERNAME_LEN))
+ //            {
+ //                *pRes = CC_NORMAL;
+ //                return sizeof (*pRes);
+ //            }
+ //            printf("Duplicate ipmi user!!\n");
+ //            *pRes = CC_INV_DATA_FIELD;
+ //            return	sizeof (*pRes);    		
+ //        }
+ //    }
+
+ //    /* If User[0] is 0xFF means the user is requested to delete */
+ //    if (0xFF == pSetUserNameReq->UserName [0])	//delete user 
+ //    {
+ //        if( (g_BMCInfo.IpmiConfig.CurrentNoUser > 1) && (USER_ID == pUserInfo->ID))
+ //        {
+	// 		if(pUserInfo->UserStatus == TRUE)
+	// 		{
+	// 			g_BMCInfo.IpmiConfig.CurrentNoUser--;
+	// 		}
+ //            /* Delete the user both in Volatile & Non Volatile memory*/
+ //            memset (pUserInfo,    0, sizeof (UserInfo_T));
+ //        }
+ //        else
+ //        {
+ //            *pRes = CC_INV_DATA_FIELD ;
+ //            return  sizeof (*pRes);
+ //        }
+ //    }
+ //    else if(USER_ID != pUserInfo->ID)	//add user
+ //    {
+ //        /* If First time-if user ID does not exist  */
+ //        /* if the user name is set for the first time */
+ //        pUserInfo->ID            = USER_ID;
+ //        pUserInfo->UserId        = pSetUserNameReq->UserID;
+ //        pUserInfo->UserStatus    = FALSE;
+	// 	memcpy(pUserInfo->UserName, pSetUserNameReq->UserName, MAX_USERNAME_LEN);
+
+ //        //g_BMCInfo.IpmiConfig.CurrentNoUser++;
+ //    }
+ //    else if (USER_ID == pUserInfo->ID)//modifying users
+ //    {
+ //        memcpy (pUserInfo->UserName, pSetUserNameReq->UserName, MAX_USERNAME_LEN);
+	// }
+
+	// UpdateFlash();
+	*pRes = CC_NORMAL;
+	return sizeof (*pRes);
+}
+
+
+/*---------------------------------------
+* GetUserName
+*---------------------------------------*/
+int
+GetUserName ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+      GetUserNameReq_T*       pGetUserNameReq = ( GetUserNameReq_T*)pReq;
+      GetUserNameRes_T*       pGetUserNameRes = ( GetUserNameRes_T*)pRes;
+       UserInfo_T*            pUserInfo;
+
+    // // Check for Reserved bits
+    // if(pGetUserNameReq->UserID & (BIT7 | BIT6) || (pGetUserNameReq->UserID == 0x00))
+    // {
+    //     pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
+    //     return sizeof(*pRes);
+    // }
+
+    if (pGetUserNameReq->UserID >= MAX_USER_NUM)
+    {
+        /*  if user ID exceeded the Max limit */
+        pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
+        return  sizeof (*pRes);/* Invalied user id */
+    }
+	pUserInfo = getUserIdInfo(pGetUserNameReq->UserID);
+
+    /* if User is disabled or if User is not created */
+
+    //if user is disabled we dont have to return invalid data field
+    //instead we return everything possible about the user
+    // if pUserInfo is NULL then nothing in the structure at all
+    // pUserInfo being NULL is probably not possible
+    // If the signature doesnt match then the useris not yet configured
+    // so reasonable to return an error
+    // if ((NULL == pUserInfo) || (pUserInfo->ID != USER_ID))
+    // {
+    //     /* User with given ID is disabled */
+    //     *pRes = CC_INV_DATA_FIELD;
+    //     return sizeof (*pRes);
+    // }
+
+    // //if we are here then the user is just disabled
+    // if(FALSE == pUserInfo->UserStatus)
+    // {
+    //     printf("user is just dissabled\n");
+    //     //user is just disabled!!
+    // }
+
+    //Err = 0;
+    pGetUserNameRes->CompletionCode = CC_NORMAL;
+    memcpy (pGetUserNameRes->UserName, pUserInfo->UserName, MAX_USERNAME_LEN);
+	return sizeof (GetUserNameRes_T);
+}
+
+
+/*---------------------------------------
+* SetUserPassword
+*---------------------------------------*/
+int
+SetUserPassword ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	// SetUserPswdReq_T*       pSetUserPswdReq = ( SetUserPswdReq_T*)pReq;
+	// UserInfo_T*             pUserInfo;
+	// uint8_t                 UserId=0, Operation;
+	// uint8_t          i;
+	// uint8_t          UserPassword[ MAX_PASSWORD_LEN + 1 ];
+ //    uint8_t InvalidChar[] = {  0x01 , 0x02 , 0x03 , 0x04 ,0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x0A, 
+ //                             0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x10 , 0x11 , 0x12 , 0x13 , 0x14,
+ //                             0x15 , 0x16 , 0x17 , 0x18 , 0x19 , 0x1A , 0x1B , 0x1C , 0x1D , 0x1E , 
+ //                             0x1F , 0x7F };
+
+
+ //    Operation = pSetUserPswdReq->Operation & 0x03;
+ //    UserId    = pSetUserPswdReq->UserID & 0x3F;
+
+ //    /* Reserved bits checking */
+ //    if((pSetUserPswdReq->UserID & BIT6) || (UserId == 0) || (pSetUserPswdReq->Operation & (BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)))
+ //    {
+ //        *pRes = CC_INV_DATA_FIELD;
+ //        return	sizeof (*pRes);
+ //    }
+
+ //    if (ReqLen == IPMI_15_PASSWORD_LEN)
+ //    {
+ //        memset (pSetUserPswdReq->Password + 16, 0, 4);
+ //    }
+ //    ReqLen -=2;
+
+ //    if (UserId > MAX_USER_NUM)
+ //    {
+ //        *pRes = CC_INV_DATA_FIELD;
+ //        return  sizeof (*pRes); /*User Id exceeded the limit*/
+ //    }
+
+ //    pUserInfo = getUserIdInfo (UserId);
+
+ //    if ( NULL ==  pUserInfo )
+ //    {
+ //        printf ("Invalid User Id \n");
+ //        *pRes = CC_INV_DATA_FIELD;
+ //        return  sizeof (*pRes);
+ //    }
+
+ //    *pRes = CC_NORMAL;
+
+ //    switch (Operation)
+ //    {
+
+ //        case DISABLE_USER:
+ //            /*disable user  */
+ //            if(pUserInfo == NULL)
+ //            {
+ //                //the user is already disabled!!
+ //                //no point in disabling him again
+ //            }
+ //            else
+ //            {
+ //                //here we can disable the user
+ //                if ((pUserInfo->UserStatus == TRUE) && (USER_ID == pUserInfo->ID) && (g_BMCInfo.IpmiConfig.CurrentNoUser > 1)) 	
+ //                {
+	// 				pUserInfo->UserStatus    = FALSE;
+	// 				pUserInfo->ChannelAccess &= 0x0f;
+ //                    g_BMCInfo.IpmiConfig.CurrentNoUser--;
+ //                    UpdateFlash(); 
+ //                }
+ //            }
+ //            break;
+ //        case ENABLE_USER:
+ //            /*enable user   */
+ //            if (USER_ID == pUserInfo->ID)
+ //            {
+ //                /* if for the first time then Increment the Current user No */
+ //                if ( pUserInfo->UserStatus == FALSE )
+ //                {
+	// 				pUserInfo->UserStatus    = TRUE;
+	// 				pUserInfo->ChannelAccess |= 0x70;
+ //                    g_BMCInfo.IpmiConfig.CurrentNoUser++;
+ //                    UpdateFlash();
+ //                }
+ //            }
+ //            else
+ //            {
+	// 			*pRes = CC_UNSPECIFIED_ERR;
+	// 			return	sizeof (*pRes);
+ //            }
+ //            break;
+
+ //        case SET_PASSWORD:
+ //            /*set password  */
+ //            if (USER_ID == pUserInfo->ID)
+ //            {
+ //            	/*check for special characters*/
+	// 			strncpy((char *)UserPassword,(const char *) pSetUserPswdReq->Password, sizeof(pSetUserPswdReq->Password));
+	// 			UserPassword[MAX_PASSWORD_LEN] = '\0';
+ //                for( i = 0 ; i < sizeof(InvalidChar) ; i++ )
+ //                {
+ //                     if( NULL != strchr((const char *)UserPassword, InvalidChar[i] ))
+ //                     {
+ //                         *pRes = CC_INV_DATA_FIELD;
+ //                         return sizeof(*pRes);
+ //                     }
+ //                }
+
+ //                pUserInfo->MaxPasswordSize = ReqLen;
+	// 			memcpy (pUserInfo->UserPassword, pSetUserPswdReq->Password, MAX_PASSWORD_LEN);
+	// 			UpdateFlash();
+ //            }
+ //            else
+ //            {
+ //                *pRes = CC_INV_DATA_FIELD;
+ //                return sizeof (*pRes);
+ //            }
+ //            break;
+
+ //        case TEST_PASSWORD:
+ //            memcpy (UserPassword, pUserInfo->UserPassword, MAX_PASSWORD_LEN);
+    		
+ //            /*Test Password */
+ //            if( ReqLen != pUserInfo->MaxPasswordSize  && (pUserInfo->MaxPasswordSize != 0))
+ //            {
+ //                *pRes = CC_PASSWORD_TEST_FAILED_WRONG_SIZE;
+ //            }
+ //            else if (((FALSE == pUserInfo->UserStatus) && (pUserInfo->ID != USER_ID)) ||
+ //            (0 != memcmp (UserPassword, pSetUserPswdReq->Password, MAX_PASSWORD_LEN)))
+ //            {
+ //                *pRes = CC_PASSWORD_TEST_FAILED;
+ //            }
+ //            break;
+ //    }
+    return sizeof (*pRes);
+}
+
+
+///*---------------------------------------
+//* MasterWriteRead
+//*---------------------------------------*/
+//int
+//MasterWriteRead ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes, int BMCInst)
+//{
+//     MasterWriteReadReq_T* pMasterWriteReadReq = ( MasterWriteReadReq_T*)pReq;
+//     MasterWriteReadRes_T* pMasterWriteReadRes = ( MasterWriteReadRes_T*)pRes;
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//     uint8_t*                OutBuffer;
+//     uint8_t*                InBuffer;
+//    uint8_t                 ChannelNum, BusID, BusType, SlaveAddr, ReadCount, WriteCount;
+//    INT8S	BusName[64];
+//    int retval = 0;
+//    uint8_t OrgReadCount;
+//    uint8_t	I2CBusId=0;
+//    uint8_t DevID = 0;            // This will be '0' by Default... /dev/peci0
+//    uint8_t Target = 0x30;        // This is the Client address. 30h = 48 is Default for CPU0
+//    uint8_t Domain = 0;           // Multi-Domain support. Default is '0'
+//    uint8_t Xmit_Feedback = 0;    // If full response is Desired, enable this. Default is '1'
+//    uint8_t AWFCS = 0;            // Enable AWFCS in the Transmitted packet by Hw. Default is '0'
+//    uint8_t Read_Len = 0;         // Number of bytes of read back Data from PECI Client
+//    uint8_t Write_Len = 0;        // Number of bytes of data, host is sending to client
+//    uint8_t *Write_Data = NULL;   // Pointer to the Data sent by User to the PECI Client
+//    uint8_t *Read_Data = NULL;    // Pointer to the Data received from PECI Client to be sent to user
+//    int ret_val = 0;
+
+//    if(pMasterWriteReadReq->SlaveAddress & BIT0)
+//    {
+//        *pRes = CC_INV_DATA_FIELD;
+//         return sizeof (*pRes);
+//    }
+
+//    ReadCount     = pMasterWriteReadReq->ReadCount;
+//    ChannelNum    = GetBits (pMasterWriteReadReq->BusTypeChNo, 0xF0);
+//    BusID         = GetBits (pMasterWriteReadReq->BusTypeChNo, 0x0E);
+//    BusType       = GetBits (pMasterWriteReadReq->BusTypeChNo, 0x01);
+//    SlaveAddr     = (pMasterWriteReadReq->SlaveAddress >> 1);
+
+//    if ((BusType == 0x00 && BusID != 0x00) || ((BusType == 0x01) && (BusID == 0x00)))
+//    {
+//        *pRes = CC_INV_DATA_FIELD;
+//        return  sizeof (*pRes);
+//    }
+//    // Command order:
+//    // ipmitool -H <IP> -I lan -U <Username> -P <Password> bus=7 <Slave_Addr> <Read_Len> <Write_Len> <AWFCS> <Domain> <Data>
+//    // <bus=7> : Bus# must be 0x07 for comunicating with PECI over IPMI. Other buses are not for this feature
+//    // <Slave_Addr> : This is the PECI Client target address.
+//    // <Read_Len> : Number of bytes of data to read from the PECI Response
+//    // <Write_Len> : Number of bytes of data being written, as per the PECI Spec. Number of Bytes after Domain.
+//    // <AWFCS> : 0x01 or 0x00 indicates enabling or disabling of AWFCS feature respectively
+//    // <Domain> : 0x01 or 0x00 indicates domain=1 or domain=0 for multi-domain commands respectively
+//    // <Data> : Rest of data like Command, and other params as per the PECI Spec.
+
+//    // If BusType is External (0x01) and BusID is 7, then we consider to communicate with PECI
+//    
+//    if(g_corefeatures.peci_over_ipmi == ENABLED )
+//    {
+//        if ((BusType & 0x01) && (BusID == 0x07))
+//        {
+//            DevID               = 0;
+//            Xmit_Feedback       = 0;
+//            Target              = pMasterWriteReadReq->SlaveAddress;
+//            Read_Len            = ReadCount;
+//            Write_Len           = pMasterWriteReadReq->Data[0];
+//            AWFCS               = pMasterWriteReadReq->Data[1];
+//            Domain              = pMasterWriteReadReq->Data[2];
+//            Write_Data          = &pMasterWriteReadReq->Data[3];
+//            Read_Data           = &pMasterWriteReadRes->Data[0];
+
+//            memset(&pMasterWriteReadRes->Data[0], 0, sizeof(pMasterWriteReadRes->Data));
+//            
+//            // Call the PECI Generic Handler for passing the command to the PECI Controller
+//            if(g_HALPECIHandle[HAL_PECI_COMMAND] != NULL)
+//            {
+//                ret_val = ((int(*)(char, char, char, char, char, char *, char, char *, char))g_HALPECIHandle[HAL_PECI_COMMAND]) (DevID, Target,
+//                                                                                                Domain, Xmit_Feedback, AWFCS,
+//                                                                                                (char *)Write_Data, Write_Len,
+//                                                                                                (char *)Read_Data, Read_Len );
+//            }
+//            else
+//            {
+//                pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                return sizeof (*pRes);
+//            }
+
+//            /* Check if peci issue command operation is success or not */
+//            if (ret_val == -1)
+//            {
+//                pMasterWriteReadRes->CompletionCode = CC_INV_DATA_FIELD;
+//                return sizeof (*pRes);
+//            }
+
+//            pMasterWriteReadRes->CompletionCode = CC_NORMAL;
+
+//            return (sizeof (*pRes) + ReadCount);
+//        }
+//    }
+
+//    if(0 ==BusType){
+//        if(PRIMARY_IPMB_CHANNEL == ChannelNum)
+//        {
+//            I2CBusId=pBMCInfo->IpmiConfig.PrimaryIPMBBusNumber;
+//        }
+//        else if((pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)&&(pBMCInfo->SecondaryIPMBCh == ChannelNum))
+//        {
+//            I2CBusId=pBMCInfo->IpmiConfig.SecondaryIPMBBusNumber;
+//        }else{
+//            *pRes = CC_INV_DATA_FIELD;
+//            return  sizeof (*pRes);
+//        }
+//    }
+//    else
+//    {
+//        if(BusID==pBMCInfo->IpmiConfig.PrimaryIPMBBusNumber)
+//        {
+//            *pRes = CC_INV_DATA_FIELD;
+//            return  sizeof (*pRes);
+//        }else if((pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)&&(BusID==pBMCInfo->IpmiConfig.SecondaryIPMBBusNumber))
+//        {
+//            *pRes = CC_INV_DATA_FIELD;
+//            return  sizeof (*pRes);
+//        }else{
+//            I2CBusId=BusID;
+//        }
+//    }
+
+//    if (ReqLen < 3)
+//    {
+//        *pRes = CC_REQ_INV_LEN;
+//        return  sizeof (*pRes);
+//    }
+
+//    /* number of bytes to write
+//    * = pMasterWriteReadReq length - 3 for  Request Data byte -
+//    * BusTypeChNo,SlaveAddr,Readcount + 1 byte for address
+//    */
+//    WriteCount = ReqLen - 3;
+
+//    OutBuffer = (pMasterWriteReadReq->Data);
+//    InBuffer = pMasterWriteReadRes->Data;
+//    sprintf(BusName,"/dev/i2c%d",I2CBusId);
+
+//    // Save original ReadCount in case we need to modify it
+//    OrgReadCount = ReadCount;
+
+//    // If both ReadCount and WriteCount are zero, then force a read of 1 byte.
+//    // If we do not do this, the write command will fail.
+//    // Having both counts 0 is a way of "pinging" the given device to see if it
+//    // is responding to its address.
+//    
+//    if (ReadCount == 0 && WriteCount == 0)
+//    {
+//        ReadCount = 1;
+//    }
+
+//    if (ReadCount > 0 && WriteCount == 0) 
+//    {
+//        if(g_HALI2CHandle[HAL_I2C_MR] != NULL)
+//        {
+//            retval = ((int(*)(char *,u8,u8 *,size_t))g_HALI2CHandle[HAL_I2C_MR]) (BusName, SlaveAddr, InBuffer, ReadCount);
+//            if (retval < 0)
+//            {
+//                 pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
+//                return sizeof (*pRes);
+//            }
+//        }
+//        else
+//        {
+//            pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//            return sizeof(*pRes);
+//        }
+
+//        ReadCount = OrgReadCount;
+
+//        /* copy the bytes read  to Response Data */
+//        _fmemcpy (pMasterWriteReadRes->Data, InBuffer, ReadCount);
+//    }
+//    else if(ReadCount > 0 && WriteCount > 0 )
+//    {
+//        if(g_HALI2CHandle[HAL_I2C_RW] != NULL)
+//        {
+//            retval = ((int(*)(char *,u8,u8 *,u8 *,size_t,size_t))g_HALI2CHandle[HAL_I2C_RW]) (BusName, SlaveAddr, OutBuffer, InBuffer, WriteCount, ReadCount);
+//            if (retval < 0)
+//            {
+//                 pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
+//                return sizeof (*pRes);
+//            }
+//        }
+//        else
+//        {
+//            pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//            return sizeof(*pRes);
+//        }
+
+//        ReadCount = OrgReadCount;
+
+//        /* copy the bytes read  to Response Data */
+//        _fmemcpy (pMasterWriteReadRes->Data, InBuffer, ReadCount);
+//    }
+//    else
+//    {
+//        /* No data to read so use master write instead,
+//         * otherwise some devices (EEPROM) that have not finished writing
+//         * will fail on the read transaction and possibly corrupt data
+//         */
+//        if(g_HALI2CHandle[HAL_I2C_MW] != NULL)
+//        {
+//            retval= ((ssize_t(*)(char *,u8,u8 *,size_t))g_HALI2CHandle[HAL_I2C_MW]) (BusName, SlaveAddr, OutBuffer, WriteCount);
+//            if(retval < 0)
+//            {
+//                pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
+//                return sizeof (*pRes);
+//            }
+//        }
+//        else
+//        {
+//            pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//            return sizeof(*pRes);
+//        }
+//    }
+
+//    pMasterWriteReadRes->CompletionCode = CC_NORMAL;
+
+//    return (sizeof (*pRes) + ReadCount);
+//}
+
+
+//#if 0
+///*-------------------------------------------
+//* ComputeAuthCode
+//*-------------------------------------------*/
+//void
+//ComputeAuthCode ( uint8_t* pPassword,  SessionHdr_T* pSessionHdr,
+//                 IPMIMsgHdr_T* pIPMIMsg,  uint8_t* pAuthCode,
+//                uint8_t ChannelType)
+//{
+//    if (AUTH_TYPE_PASSWORD == pSessionHdr->AuthType)
+//    {
+//        _fmemcpy (pAuthCode, pPassword, MAX_PASSWORD_LEN);
+//    }
+//    else
+//    {
+//        uint8_t   AuthBuf [MAX_AUTH_PARAM_SIZE];
+//        uint16_t  AuthBufLen = 0;
+//        uint8_t   IPMIMsgLen = *(( uint8_t*) pIPMIMsg - 1);
+
+//        /* Password */
+//        _fmemcpy (AuthBuf, pPassword, MAX_PASSWORD_LEN);
+//        AuthBufLen += MAX_PASSWORD_LEN;
+//        /* Session ID */
+//        _fmemcpy (AuthBuf + AuthBufLen, &pSessionHdr->SessionID, sizeof (uint32_t));
+//        AuthBufLen += sizeof (uint32_t);
+//        /* IPMI Response Message */
+//        _fmemcpy (AuthBuf + AuthBufLen, pIPMIMsg, IPMIMsgLen);
+//        AuthBufLen += IPMIMsgLen;
+
+//        if (ChannelType == MULTI_SESSION_CHANNEL)
+//        {
+//            /* Session Sequence Number */
+//            _fmemcpy (AuthBuf + AuthBufLen,
+//                    &pSessionHdr->SessionSeqNum, sizeof (uint32_t));
+//            AuthBufLen += sizeof (uint32_t);
+//        }
+//        /* Password */
+//        _fmemcpy (AuthBuf + AuthBufLen, pPassword, MAX_PASSWORD_LEN);
+//        AuthBufLen += MAX_PASSWORD_LEN;
+
+//        switch (pSessionHdr->AuthType)
+//        {
+//        case AUTH_TYPE_MD2 :
+//            AuthCodeCalMD2 (AuthBuf, pAuthCode, AuthBufLen);
+//            break;
+
+//        case AUTH_TYPE_MD5 :
+//            AuthCodeCalMD5 (AuthBuf, pAuthCode, AuthBufLen);
+//            break;
+
+//        default  :
+//            TDBG ("RMCP: Invalid Authentication Type \n");
+//        }
+//    }
+//}
+//#endif
+
+///*---------------------------------------
+//* GetSystemInfoParam
+//*---------------------------------------*/
+//int
+//GetSystemInfoParam ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes, int BMCInst)
+//{
+
+//     GetSystemInfoParamReq_T* pGetSysInfoReq = ( GetSystemInfoParamReq_T*)pReq;
+//     GetSystemInfoParamRes_T* pGetSysInfoRes = (  GetSystemInfoParamRes_T* ) pRes ;
+//     GetSystemInfoParamOEMRes_T* pGetSysInfoOEMRes = (  GetSystemInfoParamOEMRes_T* ) pRes ;
+//    BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+//       SystemInfoConfig_T*	pSysInfoCfg;
+//    uint8_t resSize = sizeof(pGetSysInfoRes->CompletionCode) + sizeof(pGetSysInfoRes->ParamRevision);
+//    uint8_t oem_len;
+//    unsigned long oem_addr;
+
+//    // Check for Reserved bits
+//    if(pGetSysInfoReq->ParamRev & (BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0))
+//    {
+//        pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
+//        return sizeof(pGetSysInfoRes->CompletionCode);
+//    }
+
+//    pGetSysInfoRes->CompletionCode   = CC_NORMAL;
+
+//    /* Fill the param's older Version and the present version */
+//    pGetSysInfoRes->ParamRevision    = ((PARAM_OLDER_REVISION << 4) & 0xF0 ) | PARAM_PRESENT_REVISION;
+
+//    /* Check for Revision only parameter */
+//    if (pGetSysInfoReq->ParamRev & GET_PARAM_REV_ONLY )
+//    {
+//        if((MAX_APP_CONF_PARAM >= pGetSysInfoReq->ParamSelector))
+//        {
+//            return resSize;
+//        }
+//        else if(( NULL != g_PDKHandle[PDK_GETSYSINFOPARAM]) && 
+//                    ((MIN_SYSINFO_OEM_CONF_PARAM <= pGetSysInfoReq->ParamSelector) && (MAX_SYSINFO_OEM_CONF_PARAM >= pGetSysInfoReq->ParamSelector)))
+//        {
+//            oem_len = ((int(*)(uint8_t, unsigned long*,int))(g_PDKHandle[PDK_GETSYSINFOPARAM]))(pGetSysInfoReq->ParamSelector, &oem_addr ,BMCInst);
+//            if( oem_len == 0)
+//            {
+//                pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
+//                return sizeof(uint8_t);
+//            }
+//            else
+//                return resSize;
+//        }
+//        else
+//        {
+//            *pRes = CC_PARAM_NOT_SUPPORTED;
+//            return sizeof (*pRes);  
+//        }
+//    }
+
+//    /* Get Systen Info parameters from NVRAM */
+//    pSysInfoCfg = &pBMCInfo->SystemInfoConfig;
+
+//    switch(pGetSysInfoReq->ParamSelector)
+//    {
+//        case SET_IN_PROGRESS_PARAM:		/*Parameter 0 volatile*/
+//            if( (0x00 != pGetSysInfoReq->SetSelector) || (0x00 != pGetSysInfoReq->BlockSelector) )
+//            {
+//                pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
+//                return sizeof(pGetSysInfoRes->CompletionCode);
+//            }
+
+//            LOCK_BMC_SHARED_MEM(BMCInst);
+//            pGetSysInfoRes->SysInfo.SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_Sys_SetInProgress;
+//            UNLOCK_BMC_SHARED_MEM(BMCInst);
+//            resSize++;
+//            break;
+
+//        case SYS_FW_VERSION_PARAM:
+//            _fmemset(&pGetSysInfoRes->SysInfo.SysVerInfo,0,sizeof(SysVerInfo_T));
+//            if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
+//            {
+//                pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
+//                return sizeof(pGetSysInfoRes->CompletionCode);
+//            }
+
+//            pGetSysInfoRes->SysInfo.SysVerInfo.SetSelector = pGetSysInfoReq->SetSelector;
+//            resSize++;
+//            if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
+//            {
+//                pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[0]=pSysInfoCfg->SysFWVersion.TypeOfEncoding;
+//                pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[1]=pSysInfoCfg->SysFWVersion.StringLength;
+//                _fmemcpy(&pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[2], pSysInfoCfg->SysFWVersion.SysFWVersionName,MAX_STRING_LENGTH_COPY);
+//                resSize += MAX_BLOCK_SIZE;
+//            }
+//            else
+//            {
+//               _fmemcpy(&pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[0],
+//                                        &pSysInfoCfg->SysFWVersion.SysFWVersionName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
+//                resSize += MAX_BLOCK_SIZE;
+//            }
+//            break;
+
+//        case SYS_NAME_PARAM:
+//            if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
+//            {
+//                pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
+//                return sizeof(pGetSysInfoRes->CompletionCode);
+//            }
+
+//            pGetSysInfoRes->SysInfo.SysNameInfo.SetSelector = pGetSysInfoReq->SetSelector;
+//            resSize++;
+//            if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
+//            {
+//                pGetSysInfoRes->SysInfo.SysNameInfo.SysName[0]=pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name;
+//                pGetSysInfoRes->SysInfo.SysNameInfo.SysName[1]=pSysInfoCfg->SysName.StringLength_Sys_Name;
+//                _fmemcpy(&pGetSysInfoRes->SysInfo.SysNameInfo.SysName[2],&pSysInfoCfg->SysName.SystemName,MAX_STRING_LENGTH_COPY);
+//                resSize += MAX_BLOCK_SIZE;
+//             }
+//            else
+//            {
+//                _fmemcpy(&pGetSysInfoRes->SysInfo.SysNameInfo.SysName[0],
+//                                &pSysInfoCfg->SysName.SystemName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2], MAX_BLOCK_SIZE);
+//                resSize += MAX_BLOCK_SIZE;
+//            }
+//            break;
+
+//        case PRIM_OS_NAME_PARAM:
+//            if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
+//            {
+//                pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
+//                return sizeof(pGetSysInfoRes->CompletionCode);
+//            }
+
+//            pGetSysInfoRes->SysInfo.PrimOSInfo.SetSelector  = pGetSysInfoReq->SetSelector;
+//            resSize++;
+//            if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
+//            {
+//                pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[0]=pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName;
+//                pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[1]=pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName;
+//                _fmemcpy(&pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[2], &pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName, MAX_STRING_LENGTH_COPY);
+//                resSize += MAX_BLOCK_SIZE;
+//             }
+//             else
+//             {
+//                 _fmemcpy(&pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[0],
+//                             &pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
+//                 resSize += MAX_BLOCK_SIZE;
+//              }
+//            break;
+
+//        case OS_NAME_PARAM:
+//            /*Parameter 4 volatile*/
+//            _fmemset(&pGetSysInfoRes->SysInfo.OSInfo,0,sizeof(OSInfo_T));
+//            if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)||(0x00 != pGetSysInfoReq->BlockSelector))
+//            {
+//                pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
+//                return sizeof(pGetSysInfoRes->CompletionCode);
+//            }
+//            pGetSysInfoRes->SysInfo.OSInfo.SetSelector  = pGetSysInfoReq->SetSelector;
+//            resSize++;
+//            if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
+//            {
+//                LOCK_BMC_SHARED_MEM(BMCInst);
+//                pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[0]=BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName;
+//                pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[1]=BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName;
+//                _fmemcpy(&pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[2], BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName, MAX_STRING_LENGTH_COPY);
+//                UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                resSize += MAX_BLOCK_SIZE;
+//            }
+//            else
+//            {
+//                LOCK_BMC_SHARED_MEM(BMCInst);
+//                _fmemcpy(&pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[0],
+//                    &BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
+//                UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                resSize += MAX_BLOCK_SIZE;
+//           }
+//            
+//            break;
+
+//        default:
+//            if(g_PDKHandle[PDK_GETSYSINFOPARAM] != NULL &&
+//            (pGetSysInfoReq->ParamSelector >= 192 && pGetSysInfoReq->ParamSelector <= 255))
+//            {
+//                oem_len = ((int(*)(uint8_t, unsigned long*,int))(g_PDKHandle[PDK_GETSYSINFOPARAM]))(pGetSysInfoReq->ParamSelector, &oem_addr ,BMCInst);
+//                if( oem_len == 0)
+//                {
+//                    pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
+//                    return sizeof(uint8_t);
+//                }
+//                else
+//                {
+//                    //Acquire the OEM parameters
+//                    if( oem_len < MSG_PAYLOAD_SIZE - sizeof(GetLanCCRev_T))
+//                    {
+//                        memcpy((char*)pGetSysInfoOEMRes + sizeof(GetSystemInfoParamOEMRes_T) ,\
+//                                    (unsigned int*)oem_addr , oem_len);
+//                    }
+//                    else
+//                    {
+//                        pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
+//                        return sizeof(uint8_t);
+//                    }
+//                    return sizeof(GetSystemInfoParamOEMRes_T) + oem_len;
+//                }
+//            }
+//            else
+//            {
+//                pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
+//                return sizeof(pGetSysInfoRes->CompletionCode);
+//            }
+//    }
+//    /* return the size of the response */
+//    return resSize;
+//}
+
+//int validatestring(uint8_t* String,int len,uint8_t TOE)
+//{
+//    int i,delimit = 0,strlen = 0;
+
+//    for(i=0;i<len;i++)
+//    {
+//        if(String[i] == 0)
+//        {
+//            delimit++;
+//        }
+//        else
+//        {
+//            if(delimit != 0)
+//            {
+//                if(TOE == UNICODE)
+//                {
+//                    if(delimit == 2)
+//                    {
+//                        strlen = strlen + 2;
+//                    }
+//                    else
+//                    {
+//                        return -1;
+//                    }
+//                }
+//                else
+//                {
+//                    if(delimit == 1)
+//                    {
+//                        strlen = strlen + 1;
+//                    }
+//                    else
+//                    {
+//                        return -1;
+//                    }
+//                }
+//                delimit = 0;
+//            }
+//            strlen++;
+//        }
+//    }
+
+//    return strlen;
+//}
+
+///*---------------------------------------
+//* SetSystemInfoParam
+//*---------------------------------------*/
+//int
+//SetSystemInfoParam ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes, int BMCInst)
+//{
+//     SetSystemInfoParamReq_T*	pSetSysInfoReq = ( SetSystemInfoParamReq_T*)pReq;
+//     SetSystemInfoParamOEMReq_T*	pSetSysInfoOEMReq = ( SetSystemInfoParamOEMReq_T*)pReq;
+//     SetSystemInfoParamRes_T*	pSetSysInfoRes = ( SetSystemInfoParamRes_T*)pRes;
+//    BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+//     SystemInfoConfig_T*	pSysInfoCfg;
+//    uint8_t *pSetInProgress;
+//    unsigned long oem_addr[2]={0};      // use oem_addr[1] as read-only/write-only flag
+//    int size,strlen,len;
+//    uint8_t OSName[MAX_OS_NAME_LENGTH] = {0};
+
+//    //If the OEM parameter is existing, then skip the length check.
+//    if(g_PDKHandle[PDK_SETSYSINFOPARAM] == NULL && (pSetSysInfoReq->ParamSelector < 192 )){
+//        if( !( (SET_IN_PROGRESS_PARAM == pSetSysInfoReq->ParamSelector && ( ReqLen == ( sizeof(pSetSysInfoReq->ParamSelector) + sizeof(uint8_t) /* for Data */ ) )) ||
+//    ( pSetSysInfoReq->ParamSelector < MAX_PARAM_SELECTOR && ReqLen == ( sizeof(pSetSysInfoReq->ParamSelector) + sizeof(uint8_t) /* for set Selector */ + MAX_BLOCK_SIZE))) )
+//        {
+//            pSetSysInfoRes->CompletionCode = CC_REQ_INV_LEN;
+//            return sizeof(pSetSysInfoRes->CompletionCode);
+//        }
+//    }
+
+//        pSetInProgress = &BMC_GET_SHARED_MEM(BMCInst)->m_Sys_SetInProgress;
+
+//        pSetSysInfoRes->CompletionCode = CC_NORMAL;
+
+//        /*Get NVRAM System Info Configuration parameters */
+//        pSysInfoCfg = &pBMCInfo->SystemInfoConfig;
+
+//    switch (pSetSysInfoReq->ParamSelector)
+//    {
+//        /*Parameter 0 volatile */
+//        case SET_IN_PROGRESS_PARAM:
+//            LOCK_BMC_SHARED_MEM(BMCInst);
+//            /* If Request for Set In progress */
+//            if(( SYS_INFO_SET_IN_PROGRESS == *pSetInProgress ) &&
+//            ( SYS_INFO_SET_IN_PROGRESS == pSetSysInfoReq->SysInfo.SetInProgress ))
+//            {
+//                UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                /* Trying to SetinProgress when already in set*/
+//                pSetSysInfoRes->CompletionCode = CC_SYS_INFO_SET_IN_PROGRESS ;
+//                return sizeof(pSetSysInfoRes->CompletionCode);
+//            } else if( SYS_INFO_COMMIT_WRITE == pSetSysInfoReq->SysInfo.SetInProgress )
+//            {
+//                /* Write SysInfoConfig to NVR */
+//                FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig,
+//                                  pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SystemInfoConfig_T),BMCInst);
+//                /* Write volatile data to the BMC Shared memory */
+//                
+//            } else if ( SYS_INFO_SET_COMPLETE == pSetSysInfoReq->SysInfo.SetInProgress )
+//            {
+//                //PMCONFIG_FILE(BMCInst,PMConfigFile);
+//                /* Set it to set Complete */
+//                *pSetInProgress = pSetSysInfoReq->SysInfo.SetInProgress;
+//                FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig,
+//                                  pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SystemInfoConfig_T),BMCInst);
+//            } else if ( SYS_INFO_SET_IN_PROGRESS != pSetSysInfoReq->SysInfo.SetInProgress )
+//            {
+//                UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
+//                return sizeof(pSetSysInfoRes->CompletionCode);
+//            }
+
+//            *pSetInProgress = pSetSysInfoReq->SysInfo.SetInProgress;
+//            UNLOCK_BMC_SHARED_MEM(BMCInst);
+//            break;
+
+//            case SYS_FW_VERSION_PARAM:
+//                
+//                if(pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector >= MAX_BLOCK_SIZE)
+//                {
+//                    pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
+//                    return sizeof(pSetSysInfoRes->CompletionCode);
+//                }
+//                if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector==ZERO_SETSELECTOR)
+//                {
+//                     if(pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]> MAX_FW_VER_LENGTH)
+//                     {
+//                        pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
+//                        return sizeof(pSetSysInfoRes->CompletionCode);
+//                     }
+//                     if(pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0] > MAX_TYPE_OF_ENCODING)
+//                     {
+//                         pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
+//                         return sizeof(pSetSysInfoRes->CompletionCode);
+//                     }
+//                     memset(&pSysInfoCfg->SysFWVersion,0,sizeof(pSysInfoCfg->SysFWVersion));
+//                     pSysInfoCfg->SysFWVersion.TypeOfEncoding=pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0];
+//                     pSysInfoCfg->SysFWVersion.StringLength=pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1];
+//                     /*First character should not be a delimiter*/
+//                     if(pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2] == 0x0 || ((pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0] == UNICODE) && (pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2] == 0x0 || pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[3] == 0x0)))
+//                    {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                    }
+//                     strlen = validatestring(&pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0]);
+//                     if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]) || ((pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]))
+//                     {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                     }
+//                     if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
+//                     {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                     }
+//                     _fmemcpy(&pSysInfoCfg->SysFWVersion.SysFWVersionName[0],&pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2], MAX_STRING_LENGTH_COPY);
+//                     FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig.SysFWVersion,
+//                                                 pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysFWVersion_T),BMCInst);
+//                }
+//                else
+//                {
+//                    _fmemcpy(&pSysInfoCfg->SysFWVersion.SysFWVersionName[(pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector* MAX_BLOCK_SIZE) - 2], 
+//                                                 &pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0],MAX_BLOCK_SIZE); 
+//                    len = ((pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
+//                    strlen = validatestring(&pSysInfoCfg->SysFWVersion.SysFWVersionName[0],len,pSysInfoCfg->SysFWVersion.TypeOfEncoding);
+//                    if(strlen == -1 || (strlen > pSysInfoCfg->SysFWVersion.StringLength))
+//                    {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                    }
+//                    /*Check the String length*/
+//                    if(((len < pSysInfoCfg->SysFWVersion.StringLength) && (len != strlen)) || ((len > pSysInfoCfg->SysFWVersion.StringLength) && (pSysInfoCfg->SysFWVersion.StringLength != strlen)))
+//                    {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                    }
+//                    if((len == pSysInfoCfg->SysFWVersion.StringLength) && (pSysInfoCfg->SysFWVersion.StringLength != strlen))
+//                    {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                    }
+
+//                    FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,
+//                                (uint8_t*)&pBMCInfo->SystemInfoConfig.SysFWVersion,pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysFWVersion_T),BMCInst);
+//                }
+//                break;
+
+//            case SYS_NAME_PARAM:
+//                if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector >= MAX_BLOCK_SIZE )
+//                {
+//                    pSetSysInfoRes->CompletionCode	= CC_INV_DATA_FIELD;
+//                    return sizeof(pSetSysInfoRes->CompletionCode);
+//                }
+//                if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector==ZERO_SETSELECTOR)
+//                {
+//                    if((pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1] > MAX_SYS_NAME_LENGTH))
+//                    {
+//                        pSetSysInfoRes->CompletionCode	= CC_INV_DATA_FIELD;
+//                        return sizeof(pSetSysInfoRes->CompletionCode);
+//                    }
+//                    if(pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0]>MAX_TYPE_OF_ENCODING)
+//                    {
+//                        pSetSysInfoRes->CompletionCode	= CC_INV_DATA_FIELD;
+//                        return sizeof(pSetSysInfoRes->CompletionCode);
+//                    }
+//                    memset(&pSysInfoCfg->SysName,0,sizeof(pSysInfoCfg->SysName));
+//                    pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name=pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0];
+//                    pSysInfoCfg->SysName.StringLength_Sys_Name=pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1];
+
+//                     /*First character should not be a delimiter*/
+//                     if(pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2] == 0x0 || ((pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0] == UNICODE) && (pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2] == 0x0 || pSetSysInfoReq->SysInfo.SysNameInfo.SysName[3] == 0x0)))
+//                    {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                    }
+
+//                    strlen = validatestring(&pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0]);
+//                    if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]) || ((pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]))
+//                    {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                    }
+//                     if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
+//                     {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                     }
+
+//                    _fmemcpy(&pSysInfoCfg->SysName.SystemName[0], &pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2],MAX_STRING_LENGTH_COPY);
+//                    FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig.SysName,
+//                                            pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysName_T),BMCInst);
+//                }
+//                else
+//                {
+//                    _fmemcpy(&pSysInfoCfg->SysName.SystemName[(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector* MAX_BLOCK_SIZE) - 2],
+//                                    &pSetSysInfoReq->SysInfo.SysNameInfo.SysName,MAX_BLOCK_SIZE);
+//                    len = ((pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
+//                    strlen = validatestring(&pSysInfoCfg->SysName.SystemName[0],len,pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name);
+//                    if(strlen == -1 || (strlen > pSysInfoCfg->SysName.StringLength_Sys_Name))
+//                    {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                    }
+//                    /*Check the String length*/
+//                    if(((len < pSysInfoCfg->SysName.StringLength_Sys_Name) && (len != strlen)) || ((len > pSysInfoCfg->SysName.StringLength_Sys_Name) && (pSysInfoCfg->SysName.StringLength_Sys_Name != strlen)))
+//                    {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                    }
+//                    if((len == pSysInfoCfg->SysName.StringLength_Sys_Name) && (pSysInfoCfg->SysName.StringLength_Sys_Name != strlen))
+//                    {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                    }
+
+//                    FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig.SysName, 
+//                                pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysName_T),BMCInst);
+//                }
+//                break;
+
+//            case PRIM_OS_NAME_PARAM:
+//                if(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector >= MAX_BLOCK_SIZE )
+//                {
+//                    pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
+//                    return sizeof(pSetSysInfoRes->CompletionCode);
+//                }
+//                if(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector==ZERO_SETSELECTOR)
+//                {
+//                    if((pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1] > MAX_PRIM_OS_NAME_LENGTH))
+//                    {
+//                        pSetSysInfoRes->CompletionCode	= CC_INV_DATA_FIELD;
+//                        return sizeof(pSetSysInfoRes->CompletionCode);
+//                        
+//                    }
+//                    if(pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0]>MAX_TYPE_OF_ENCODING)
+//                    {
+//                        pSetSysInfoRes->CompletionCode	= CC_INV_DATA_FIELD;
+//                        return sizeof(pSetSysInfoRes->CompletionCode);
+//                    }
+//                    memset(&pSysInfoCfg->PrimaryOSName,0,sizeof(pSysInfoCfg->PrimaryOSName));
+//                    pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName=pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0];
+//                    pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName=pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1];
+
+//                     /*First character should not be a delimiter*/
+//                     if(pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2] == 0x0 || ((pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0] == UNICODE) && (pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2] == 0x0 || pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[3] == 0x0)))
+//                    {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                    }
+
+//                    strlen = validatestring(&pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0]);
+//                    if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]) || ((pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]))
+//                    {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                    }
+//                     if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
+//                     {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                     }
+
+//                    _fmemcpy(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[0], &pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2], MAX_STRING_LENGTH_COPY);
+//                    FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig.PrimaryOSName,
+//                                                    pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(PrimaryOSName_T),BMCInst);
+//                }
+//                else
+//                {
+//                    _fmemcpy(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector * MAX_BLOCK_SIZE) - 2],
+//                                            &pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName, MAX_BLOCK_SIZE);
+//                    len = ((pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
+//                    strlen = validatestring(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[0],len,pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName);
+//                    if(strlen == -1 || (strlen > pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName))
+//                    {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                    }
+//                    /*Check the String length*/
+//                    if(((len < pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (len != strlen)) || ((len > pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName != strlen)))
+//                    {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                    }
+//                    if((len == pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName != strlen))
+//                    {
+//                        *pRes = CC_INV_DATA_FIELD;
+//                        return sizeof(uint8_t);
+//                    }
+
+//                    FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,
+//                                (uint8_t*)&pBMCInfo->SystemInfoConfig.PrimaryOSName,pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(PrimaryOSName_T),BMCInst);
+//                }
+//                break;
+
+//        case OS_NAME_PARAM:		
+//            /*Parameter 4 volatile*/
+//            if(pSetSysInfoReq->SysInfo.OSInfo.SetSelector >= MAX_BLOCK_SIZE )
+//            {
+//                pSetSysInfoRes->CompletionCode	= CC_INV_DATA_FIELD;
+//                return sizeof(pSetSysInfoRes->CompletionCode);
+//            }
+//            if(pSetSysInfoReq->SysInfo.OSInfo.SetSelector==ZERO_SETSELECTOR)
+//            {
+//                if(pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1] > MAX_OS_NAME_LENGTH)
+//                {
+//                    pSetSysInfoRes->CompletionCode	= CC_INV_DATA_FIELD;
+//                    return sizeof(pSetSysInfoRes->CompletionCode);
+//                }
+//                if(pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0] > MAX_TYPE_OF_ENCODING)
+//                {
+//                    pSetSysInfoRes->CompletionCode	= CC_INV_DATA_FIELD;
+//                    return sizeof(pSetSysInfoRes->CompletionCode);
+//                }
+
+//                 /*First character should not be a delimiter*/
+//                 if(pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2] == 0x0 || ((pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0] == UNICODE) && (pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2] == 0x0 || pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[3] == 0x0)))
+//                {
+//                    *pRes = CC_INV_DATA_FIELD;
+//                    return sizeof(uint8_t);
+//                }
+
+//                strlen = validatestring(&pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0]);
+//                if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]) || ((pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]))
+//                {
+//                    *pRes = CC_INV_DATA_FIELD;
+//                    return sizeof(uint8_t);
+//                }
+//                 if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
+//                 {
+//                    *pRes = CC_INV_DATA_FIELD;
+//                    return sizeof(uint8_t);
+//                 }
+
+//                memset(&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName,0,sizeof(OSName_T));
+//                LOCK_BMC_SHARED_MEM(BMCInst);
+//                BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName=pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0];
+//                BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName=pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1];
+//                _fmemcpy(&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName, &pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2], 
+//                                                      MAX_STRING_LENGTH_COPY);
+//                UNLOCK_BMC_SHARED_MEM (BMCInst);
+//            }
+//            else
+//            {
+//                LOCK_BMC_SHARED_MEM(BMCInst);
+//                _fmemcpy(&OSName[0],&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[0],MAX_OS_NAME_LENGTH);
+//                _fmemcpy(&OSName[(pSetSysInfoReq->SysInfo.OSInfo.SetSelector * MAX_BLOCK_SIZE) - 2],&pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName,MAX_BLOCK_SIZE);
+//                len = ((pSetSysInfoReq->SysInfo.OSInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
+//                strlen = validatestring(&OSName[0],len,BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName);
+//                if(strlen == -1 || (strlen > BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName))
+//                {
+//                    *pRes = CC_INV_DATA_FIELD;
+//                    UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                    return sizeof(uint8_t);
+//                }
+//                /*Check the String length*/
+//                if(((len < BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName) && (len != strlen)) || ((len > BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName) && (BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName != strlen)))
+//                {
+//                    *pRes = CC_INV_DATA_FIELD;
+//                    return sizeof(uint8_t);
+//                }
+//                if((len == BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName) && (BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName != strlen))
+//                {
+//                    *pRes = CC_INV_DATA_FIELD;
+//                    return sizeof(uint8_t);
+//                }
+
+//                _fmemcpy(&(BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[(pSetSysInfoReq->SysInfo.OSInfo.SetSelector * MAX_BLOCK_SIZE) - 2]),
+//                                                                &pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName,MAX_BLOCK_SIZE);
+//                UNLOCK_BMC_SHARED_MEM (BMCInst);
+//            }
+//            break;
+
+//        default:
+//            if(g_PDKHandle[PDK_SETSYSINFOPARAM] != NULL &&
+//               (pSetSysInfoReq->ParamSelector >= 192 && pSetSysInfoReq->ParamSelector <= 255))
+//            {
+//                oem_addr[0] = (unsigned long)((char*)pSetSysInfoOEMReq + sizeof(SetSystemInfoParamOEMReq_T));
+//                size = ((int(*)(uint8_t, unsigned long*,int))(g_PDKHandle[PDK_SETSYSINFOPARAM]))(pSetSysInfoReq->ParamSelector, oem_addr ,BMCInst);
+//                if(size <= 0)
+//               {
+//                    switch (oem_addr[1]) {
+//                    case CC_SYS_INFO_READ_ONLY_PARAM:
+//                        pSetSysInfoRes->CompletionCode = CC_SYS_INFO_READ_ONLY_PARAM;
+//                        break;
+//                    default:
+//                        pSetSysInfoRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//                    }
+//                }
+//                else
+//                {
+//                    pSetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
+//                    return sizeof(pSetSysInfoRes->CompletionCode);
+//                }
+//            }
+//    }
+//    return sizeof(pSetSysInfoRes->CompletionCode);
+//}
+
+#endif  /* APP_DEVICE */

+ 417 - 0
app/bmc/msghndlr/App/AppDevice/WDT.c

@@ -0,0 +1,417 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************/
+/*****************************************************************
+ *
+ * WDT.c
+ * WadtchDog TimeOut function
+ *
+ * Author: Govind Kothandapani <govindk@ami.com>
+ *       : Rama Bisa <ramab@ami.com>
+ *       : Basavaraj Astekar <basavaraja@ami.com>
+ *       : Bakka Ravinder Reddy <bakkar@ami.com>
+ *
+ *****************************************************************/
+
+#include "WDT.h"
+#include "com_IPMIDefs.h"
+#include "ChassisDevice.h"
+#include <stdio.h>
+
+
+/*** Local macro definitions ***/
+#define PRE_TIMEOUT             1
+#define WDT_TIMEOUT             2
+#define PRETIMEOUT_ACTION_TAKEN 0x08
+
+#define TIMEOUT_NO_ACTION_TAKEN         0x00
+#define TIMEOUT_ACTION_HARD_RESET       0x01
+#define TIMEOUT_ACTION_POWER_DOWN       0x02
+#define TIMEOUT_ACTION_POWER_CYCLE      0x03
+
+#define PRE_TIMEOUT_SMI                 0x10
+#define PRE_TIMEOUT_NMI_DIAG            0x20
+#define PRE_TIMEOUT_MESSAGING_INTR      0x30
+
+/*** Global variables **/
+ WDTTmrMgr_T   g_WDTTmrMgr;
+
+/*----------------------------------------------------------------
+ * WatchDog2 Event Offsets
+ *---------------------------------------------------------------*/
+#define IPMI_WDT_TIMER_EXPIRED			0x00   //Watch Dog Expired Status only offset 
+#define IPMI_WDT_HARD_RESET				0x01
+#define IPMI_WDT_POWER_DOWN				0x02
+#define IPMI_WDT_POWER_CYCLE			0x03
+#define IPMI_WDT_TIMER_INTERRUPT		0x08
+
+#define MAX_WDT_MS_VALUE(Hertz)     (0xFFFFFFFF * 1000)/Hertz
+
+/*** Function Prototypes ***/
+//static void WDTTmrAction (uint8_t TmrAction, int BMCInst);
+
+/* Declare Thread Mutex */
+//OS_THREAD_MUTEX_DECLARE(hWDTSharedMemMutex);
+
+
+/**
+ * WDTTimerTask
+ **/
+void WDTTimerTask (void *pArg)
+{
+//    int *inst = (int*) pArg;
+//    int BMCInst = *inst;
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//    uint32_t WDTInterval = 0,WDTPreInterval = 0,jiffycmp = 0;
+//    long long jiffyvalue=0,jiffystart = 0;
+//    unsigned long Hertz = sysconf(_SC_CLK_TCK);
+//    prctl(PR_SET_NAME,__FUNCTION__,0,0,0);
+
+//    /* Get the Shared memory mutex handle */
+//    OS_THREAD_MUTEX_INIT(pBMCInfo->hWDTSharedMemMutex, PTHREAD_MUTEX_RECURSIVE);
+
+//    while(TRUE)
+//    {
+//        /* Will be waiting till the Watchdog timer is armed*/
+//        sem_wait(&pBMCInfo->WDTSem);
+
+//        /* If no timer to process return */
+//        if (FALSE == BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent)
+//        {
+//            continue;
+//        }
+
+//        WDTInterval = pBMCInfo->WDTConfig.InitCountDown * WDT_COUNT_MS;
+//        if ((pBMCInfo->WDTConfig.TmrActions & 0x70) == 0)
+//        {
+//            WDTPreInterval = WDTInterval+1;
+//        }
+//        else
+//        {
+//            WDTPreInterval = 1000 * pBMCInfo->WDTConfig.PreTimeOutInterval;
+//        }
+
+//        if(GetJiffySysCtlvalue(JIFFY_VALUE,&jiffyvalue) == 1)
+//        {
+//            IPMI_ERROR("Error in getting Jiffy value \n");
+//            return 0;
+//        }
+
+//        jiffystart = jiffyvalue;
+
+//        while(1)
+//        {
+
+//            if(GetJiffySysCtlvalue(JIFFY_VALUE,&jiffyvalue) == 1)
+//            {
+//                IPMI_ERROR("Error in getting Jiffy value \n");
+//                return 0;
+//            }
+
+//            if (pBMCInfo->HostOFFStopWDT == TRUE)
+//            {
+//                pBMCInfo->HostOFFStopWDT = FALSE;			
+//                break;
+//            }
+
+//            if(pBMCInfo->SetWDTUpdated == TRUE && (TRUE == BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent))
+//            {
+//                jiffystart = jiffyvalue;
+//                WDTInterval = pBMCInfo->WDTConfig.InitCountDown * WDT_COUNT_MS;
+//                if ((pBMCInfo->WDTConfig.TmrActions & 0x70) == 0)
+//                {
+//                    WDTPreInterval = WDTInterval+1;
+//                    
+//                }
+//                else
+//                {
+//                    WDTPreInterval = 1000 * pBMCInfo->WDTConfig.PreTimeOutInterval;
+//                }
+//                pBMCInfo->SetWDTUpdated = FALSE;
+//            }
+//            else if(pBMCInfo->SetWDTUpdated == TRUE && (FALSE== BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent))
+//            {
+//                /* Restore Initial countdown value */
+//                g_WDTTmrMgr.TmrInterval = pBMCInfo->WDTConfig.InitCountDown;
+//                break;
+//            }
+
+//            if(jiffyvalue < jiffystart)
+//            {
+//                /* To handle Jiffy Overflow condition */
+//                jiffycmp = (MAX_WDT_MS_VALUE(Hertz) -jiffystart) + jiffyvalue;
+//            }
+//            else
+//            {
+//                jiffycmp = jiffyvalue - jiffystart;
+//            }
+
+//            if((jiffycmp > WDTInterval) ||(jiffycmp > (WDTInterval-WDTPreInterval)))
+//            {
+//                if((jiffycmp > (WDTInterval-WDTPreInterval)) && (pBMCInfo->WDTPreTmtStat == FALSE)
+//                    && ((pBMCInfo->WDTConfig.TmrActions & 0x70) != 0))
+//                {
+//                    /* take pretimeout actions */
+//                    if(pBMCInfo->TriggerEvent.WDTTimeExpire)
+//                    {
+//                        if(0 == send_signal_by_name("Adviserd",SIGUSR2))
+//                        {
+//                             TDBG("Signal Sent successfully to adviser to start recording video\n");
+//                        }
+//                        else
+//                        {
+//                             TDBG("Cannot Send Signal to adviser to start recording video\n");
+//                        }
+//                    }
+//                    WDTTmrAction (g_WDTTmrMgr.WDTTmr.TmrActions & 0x70, BMCInst);
+//                    pBMCInfo->WDTPreTmtStat = TRUE;
+//                }
+//                else if(jiffycmp > WDTInterval)
+//                {
+//                    g_WDTTmrMgr.TmrPresent = FALSE;
+//                    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->hWDTSharedMemMutex, WAIT_INFINITE)
+//                    BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning=FALSE;
+//                    BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent =FALSE;
+//                    // Modify ARP status to resume the thread
+//                    // after receiving set Watchdog Timer command
+//                    //BMC_GET_SHARED_MEM(BMCInst)->GratArpStatus = RESUME_ARPS;
+//                    
+//                    uint8_t i = 0;
+
+//                    for (i = 0; i < MAX_LAN_CHANNELS; i++)
+//                    {
+//                        if((pBMCInfo->LanIfcConfig[i].Enabled == TRUE)
+//                            && (pBMCInfo->LanIfcConfig[i].Up_Status == LAN_IFC_UP))
+//                        {
+//                            BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[i] = RESUME_ARPS;
+//                            UpdateArpStatus(pBMCInfo->LanIfcConfig[i].Ethindex, BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning, BMCInst);
+//                        }
+//                    }
+//                    
+//                    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->hWDTSharedMemMutex);
+//                    /* Take WDT timeout Actions */
+//                    pBMCInfo->WDTPreTmtStat = FALSE;
+//                    g_WDTTmrMgr.TmrInterval = 0;
+//                    if(pBMCInfo->TriggerEvent.WDTTimeExpire)
+//                    {
+//                        if(0 == send_signal_by_name("Adviserd",SIGUSR2))
+//                        {
+//                            TDBG("Signal Sent successfully to adviser to start recording video\n");
+//                        }
+//                        else
+//                        {
+//                            TDBG("Cannot Send Signal to adviser to start recording video\n");
+//                        }
+//                    }
+//                    WDTTmrAction (g_WDTTmrMgr.WDTTmr.TmrActions & 0x07, BMCInst);
+//                    break;
+//                 }
+//                
+//            }
+
+//            if((jiffycmp -WDTInterval) > 20)
+//            {
+//                /* Made to sleep for 100ms to reduce CPU Usage */
+//                usleep(WDT_SLEEP_TIME);
+//                g_WDTTmrMgr.TmrInterval = pBMCInfo->WDTConfig.InitCountDown - (jiffycmp/WDT_COUNT_MS);
+//            }
+//        }
+//    }
+
+}
+
+///**
+// * @brief Takes action depending on the argument.
+// * @param TmrAction Timeout action.
+// **/
+//static void
+//WDTTmrAction (uint8_t TmrAction, int BMCInst)
+//{
+//	log("WDTTmrAction not implement\r\n");
+//    int i = 0;
+//    uint8_t  u8EventOffset;
+//    uint8_t  readFlags = 0;
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo;
+//     SensorInfo_T*        pSensorInfo;    
+//    SensorSharedMem_T*    pSMSharedMem;
+
+//    if(IsCardInFlashMode()){    	
+//    	return;
+//    }
+//    
+//    if (TmrAction & 0x70)
+//    {
+//        pBMCInfo->WDTConfig.PreTimeoutActionTaken = g_WDTTmrMgr.WDTTmr.PreTimeoutActionTaken = PRETIMEOUT_ACTION_TAKEN;
+//        if (pBMCInfo->IpmiConfig.KCS1IfcSupport == 1)
+//        {
+//            SET_SMS_ATN (0, BMCInst);
+//            if(g_corefeatures.kcs_obf_bit == ENABLED)
+//            {
+//                SET_OBF (0, BMCInst);
+//            }
+//        }
+
+//        if (pBMCInfo->IpmiConfig.KCS2IfcSupport == 1)
+//        {
+//            SET_SMS_ATN (1, BMCInst);
+//            if(g_corefeatures.kcs_obf_bit == ENABLED)
+//            {
+//                SET_OBF (1, BMCInst);
+//            }
+//        }
+
+//        if (pBMCInfo->IpmiConfig.KCS3IfcSuppport == 1)
+//        {
+//            SET_SMS_ATN (2, BMCInst);
+//            if(g_corefeatures.kcs_obf_bit == ENABLED)
+//            {
+//                SET_OBF (2, BMCInst);
+//            }
+//        }
+//    }
+//    else
+//    {
+//        pBMCInfo->WDTConfig.ExpirationFlag |=  0x1 << (pBMCInfo->WDTConfig.TmrUse & 0x07);
+
+//        // Based on the IPMI spec 27.7, the WDT expiration flag should not be preserved on any AC cycle.
+//        // update the WDT expiration flag in the global memory pool, not persistant in the flash
+//        g_WDTTmrMgr.WDTTmr.ExpirationFlag |=  0x1 << (pBMCInfo->WDTConfig.TmrUse & 0x07);
+//    }
+//    // setup sensor event offset
+//    u8EventOffset = TmrAction;
+
+//    if(g_corefeatures.wdt_flush_support == ENABLED )
+//    {
+//        FlushIPMI((uint8_t*)&pBMCInfo->WDTConfig,(uint8_t*)&pBMCInfo->WDTConfig,pBMCInfo->IPMIConfLoc.WDTDATAddr,
+//                       sizeof(WDTConfig_T),BMCInst);
+//    }
+
+//    if(g_PDKHandle[PDK_BEFOREWATCHDOGACTION] != NULL)
+//    {
+//        if( (((int(*)(uint8_t,WDTTmrMgr_T*,int))g_PDKHandle[PDK_BEFOREWATCHDOGACTION]) (TmrAction, &g_WDTTmrMgr,BMCInst)) != 0)
+//        {
+//            return;
+//        }
+//    }
+//    else
+//    {
+//    	if (g_PDKHandle[PDK_PREWATCHDOGACTION] != NULL)
+//	{
+//        	if( (((int(*)(uint8_t*, WDTTmrMgr_T*, int))g_PDKHandle[PDK_PREWATCHDOGACTION]) (&TmrAction, &g_WDTTmrMgr,BMCInst)) != 0)
+//        	{
+//            		return;
+//        	}
+//    	}
+//    }
+
+//    switch (TmrAction)
+//    {
+//        case TIMEOUT_NO_ACTION_TAKEN:
+//            break;
+
+//        case TIMEOUT_ACTION_HARD_RESET:
+//            //Added for GetSystem RestartCause //
+//            pBMCInfo->ChassisConfig.SysRestartCause = RESTART_CAUSE_WDT_EXPIRATION;
+//            //API_OnSetRestartCause(RESTART_CAUSE_WDT_EXPIRATION, TRUE);
+//            OnSetRestartCause(pBMCInfo->ChassisConfig.SysRestartCause, TRUE,BMCInst);
+
+//            // perform the chassis control action
+//            Platform_HostColdReset (BMCInst);
+//            break;
+
+//        case TIMEOUT_ACTION_POWER_DOWN:
+//            //Added for GetSystem RestartCause //
+//            pBMCInfo->ChassisConfig.SysRestartCause = RESTART_CAUSE_WDT_EXPIRATION;
+//            //API_OnSetRestartCause(RESTART_CAUSE_WDT_EXPIRATION, TRUE);
+//            OnSetRestartCause(pBMCInfo->ChassisConfig.SysRestartCause, TRUE,BMCInst);
+
+//            // perform the chassis control action
+//            Platform_HostPowerOff (BMCInst);
+//            break;
+
+//        case TIMEOUT_ACTION_POWER_CYCLE:
+//            //Added for GetSystem RestartCause //
+//            pBMCInfo->ChassisConfig.SysRestartCause = RESTART_CAUSE_WDT_EXPIRATION;
+//            //API_OnSetRestartCause(RESTART_CAUSE_WDT_EXPIRATION, TRUE);
+//            OnSetRestartCause(pBMCInfo->ChassisConfig.SysRestartCause, TRUE,BMCInst);
+
+//            // perform the chassis control action
+//            Platform_HostPowerCycle (BMCInst);
+//            break;
+
+//        case PRE_TIMEOUT_NMI_DIAG:
+//            // perform the NMI
+//            Platform_HostDiagInt (BMCInst);
+
+//            // fall through
+
+//        case PRE_TIMEOUT_SMI:
+//        case PRE_TIMEOUT_MESSAGING_INTR:
+//            // setup sensor event offset to be the timer interrupt (08h)
+//            u8EventOffset = IPMI_WDT_TIMER_INTERRUPT;				
+//            break;
+//        default:
+//            IPMI_ERROR("Invalid Timer Action for watchdog.\n");
+//            break;
+//    }
+//    // save the system restart cause even if there is no change
+//    FlushIPMI((uint8_t*)&pBMCInfo->ChassisConfig,(uint8_t*)&pBMCInfo->ChassisConfig,pBMCInfo->IPMIConfLoc.ChassisConfigAddr,sizeof(ChassisConfig_T),BMCInst);
+//    // pass the WDT event offset
+//    if(g_corefeatures.internal_sensor == ENABLED)
+//    {
+//        SetWD2SensorReading((1 << u8EventOffset), g_WDTTmrMgr.WDTTmr.TmrUse,g_WDTTmrMgr.WDTTmr.TmrActions,BMCInst);
+//	
+//	/* Get the Sensor Shared Memory */
+//	pSMSharedMem = ( SensorSharedMem_T*)&pBMCInfo->SensorSharedMem;
+//	for (i = 0; i < pBMCInfo->SenConfig.ValidSensorCnt; i++)
+//	{	
+//	    /* When the SensorType is WatchDog, calling WD2EventLog here to create EventLog instead through SensorMonitor */    
+//	    if(pSMSharedMem->SensorInfo[pBMCInfo->SenConfig.ValidSensorList [i]].SensorTypeCode == SENSOR_TYPE_WATCHDOG2)
+//	    {
+//		pSensorInfo = (SensorInfo_T*)&pSMSharedMem->SensorInfo[pBMCInfo->SenConfig.ValidSensorList [i]];
+//		WD2EventLog(pSensorInfo,&readFlags,BMCInst);
+//	    }
+//	}
+//    }
+
+//    if(g_PDKHandle[PDK_WATCHDOGACTION] != NULL)
+//    {
+//        ((void(*)(uint8_t,WDTTmrMgr_T*,int))g_PDKHandle[PDK_WATCHDOGACTION]) (TmrAction,&g_WDTTmrMgr,BMCInst);
+//    }
+
+//    /* Clearing don't log bit after Watchdog timeout */
+//    g_WDTTmrMgr.WDTTmr.TmrUse &= 0x7F;
+
+//}
+
+
+/*-----------------------------------------------------------------
+ * @fn StopWDTTimer
+ *
+ * @brief This is provided to stop Watchdog Timer.
+ *
+ * @return None.
+ *-----------------------------------------------------------------*/
+void
+StopWDTTimer ()
+{
+	printf("StopWDTTimer not implement\r\n");
+//    BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    g_WDTTmrMgr.TmrPresent = FALSE;
+//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->hWDTSharedMemMutex, WAIT_INFINITE);
+//    BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning = FALSE;
+//    BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent = FALSE;
+//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->hWDTSharedMemMutex);
+}
+

+ 304 - 0
app/bmc/msghndlr/App/IPMDevice/Firewall.c

@@ -0,0 +1,304 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************/
+/*****************************************************************
+ *
+ * Firewall.c
+ * Firewall Commands Handler
+ *
+ * Author: Basavaraj Astekar <basavaraja@ami.com>
+ *       : Bakka Ravinder Reddy <bakkar@ami.com>
+ *
+ *****************************************************************/
+
+#include "Firewall.h"
+#include "MsgHndlrTask.h"
+#include "Support.h"
+#include "com_IPMIDefs.h"
+#include "com_IPMI_Firewall.h"
+
+/* Reserved bit macro definitions */
+#define RESERVED_BITS_GETNETFNSUP                       0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
+
+#define RESERVED_BITS_GETCMDSUP_CH                      0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
+#define RESERVED_BITS_GETCMDSUP_LUN                     0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
+#define RESERVED_BITS_GETCMDSUP_NETFUN					0x80 //BIT7 \BIT6 (11 and 10 are reserved as per IPMI spec)
+
+#define RESERVED_BITS_GETSUBFNSUP_CH                    0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+#define RESERVED_BITS_GETSUBFNSUP_NETFN                 0xC0 //(BIT7 | BIT6)
+#define RESERVED_BITS_GETSUBFNSUP_LUN                   0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
+
+#define RESERVED_BITS_GETCFGCMDS_CH                     0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
+#define RESERVED_BITS_GETCFGCMDS_LUN                    0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
+#define RESERVED_BITS_GETCFGCMDS_NETFUN					0x80 //BIT7 \BIT6 (11 and 10 are reserved as per IPMI spec)
+
+#define RESERVED_BITS_GETCFGSUBFNS_CH                   0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
+#define RESERVED_BITS_GETCFGSUBFNS_NETFN                0xC0 //(BIT7 | BIT6)
+#define RESERVED_BITS_GETCFGSUBFNS_LUN                  0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
+
+#define RESERVED_BITS_SETCMDEN_CH                       0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
+#define RESERVED_BITS_SETCMDEN_LUN                      0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
+#define RESERVED_BITS_SETCMDEN_NETFUN                	0x80 //BIT7 \BIT6 (11 and 10 are reserved as per IPMI spec)
+
+#define RESERVED_BITS_GETCMDEN_CH                       0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
+#define RESERVED_BITS_GETCMDEN_LUN                      0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
+#define RESERVED_BITS_GETCMDEN_NETFUN                	0x80 //BIT7 \BIT6 (11 and 10 are reserved as per IPMI spec)
+
+#define RESERVED_BITS_SETSUBFNEN_CH                     0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+#define RESERVED_BITS_SETSUBFNEN_NETFN                  0xC0 //(BIT7 | BIT6)
+#define RESERVED_BITS_SETSUBFNEN_LUN                    0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
+
+#define RESERVED_BITS_GETSUBFNEN_CH                     0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+#define RESERVED_BITS_GETSUBFNEN_NETFN                  0xC0 //(BIT7 | BIT6)
+#define RESERVED_BITS_GETSUBFNEN_LUN                    0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
+
+#define RESERVED_BITS_GETOEMNETFNIANASUPPORT_CH         0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+#define RESERVED_BITS_GETOEMNETFNIANASUPPORT_NETFN      0xC0 //(BIT7 | BIT6)
+#define RESERVED_BITS_GETOEMNETFNIANASUPPORT_LISTINDEX  0xC0 //(BIT7 | BIT6)
+#if IPM_DEVICE == 1
+
+//static int GetRequiredLength (uint8_t NetFn, uint8_t CmdReqSize);
+//static int ValidateFFNetFnData (uint8_t NetFn, NetFnParams_T* pNetFnParams ,BMCInfo_t *pBMCInfo);
+/*** Local Macro definitions ***/
+#define LUN_NO_CMD_SUPPORT          0x00
+#define LUN_NO_RESTRICTION_SUPPORT  0x01
+#define LUN_RESTRICTION_SUPPORT     0x02
+
+#define LUN_00                      LUN_RESTRICTION_SUPPORT
+#define LUN_01                      LUN_NO_CMD_SUPPORT << 2
+#define LUN_10                      LUN_NO_CMD_SUPPORT << 4
+#define LUN_11                      LUN_NO_CMD_SUPPORT << 6
+
+#define DMTF_DEFINING_BODY    0x01
+
+//Group Extension codes
+#define GROUPEXTNCODE_PICMG     0x00
+#define GROUPEXTNCODE_DMTF      0x01
+#define GROUPEXTNCODE_SSI       0x02
+#define GROUPEXTNCODE_VSO       0x03
+#define GROUPEXTNCODE_DCMI      0xDC
+#define Max_GROUPEXTNCODE        5
+
+
+/* Add IANA No's to the Array */
+IANA_T m_IANAList[] = {			/* LS byte first */
+   {{0xFF,0xFF,0xFF}}, /* Reserved Oem IANA */
+#ifdef IANA_OEM_LIST
+   IANA_OEM_LIST
+#endif   
+};
+uint8_t GroupExtnCode[Max_GROUPEXTNCODE]={
+    GROUPEXTNCODE_PICMG,
+    GROUPEXTNCODE_DMTF,
+    GROUPEXTNCODE_SSI,
+    GROUPEXTNCODE_VSO,
+    GROUPEXTNCODE_DCMI,
+    };
+
+
+#if GET_NETFN_SUP != UNIMPLEMENTED
+/*---------------------------------------
+ * GetNetFnSup
+ *---------------------------------------*/
+int
+GetNetFnSup ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    printf("GetNetFnSup not implement\r\n");
+        *pRes = CC_INV_CMD;
+        return sizeof(*pRes);
+}
+#endif  /* GET_NETFN_SUP != UNIMPLEMENTED */
+
+
+#if GET_CMD_SUP != UNIMPLEMENTED
+/*---------------------------------------
+ * GetCmdSup
+ *---------------------------------------*/
+int
+GetCmdSup ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+   printf("GetCmdSup not implement\r\n");
+        *pRes = CC_INV_CMD;
+        return sizeof(*pRes);
+}
+#endif  /* GET_CMD_SUP != UNIMPLEMENTED */
+
+
+#if GET_SUBFN_SUP != UNIMPLEMENTED
+/*---------------------------------------
+ * GetSubFnSup
+ *---------------------------------------*/
+int
+GetSubFnSup ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+     printf("GetSubFnSup not implement\r\n");
+        *pRes = CC_INV_CMD;
+        return sizeof(*pRes);
+}
+#endif  /* GET_SUBFN_SUP != UNIMPLEMENTED */
+
+
+#if GET_CONFIG_CMDS != UNIMPLEMENTED
+/*---------------------------------------
+ * GetConfigCmds
+ *---------------------------------------*/
+int
+GetConfigCmds ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+     printf("GetConfigCmds not implement\r\n");
+        *pRes = CC_INV_CMD;
+        return sizeof(*pRes);
+}
+#endif  /* GET_CONFIG_CMDS != UNIMPLEMENTED */
+
+
+#if GET_CONFIG_SUB_FNS != UNIMPLEMENTED
+/*---------------------------------------
+ * GetConfigSubFns
+ *---------------------------------------*/
+int
+GetConfigSubFns ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	printf("GetConfigSubFns not implement\r\n");
+        *pRes = CC_INV_CMD;
+        return sizeof(*pRes);
+}
+#endif  /* GET_CONFIG_SUB_FNS != UNIMPLEMENTED */
+
+
+#if SET_CMD_ENABLES != UNIMPLEMENTED
+/*---------------------------------------
+ * SetCmdEnables
+ *---------------------------------------*/
+int
+SetCmdEnables ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+     printf("SetCmdEnables not implement\r\n");
+        *pRes = CC_INV_CMD;
+        return sizeof(*pRes);
+}
+#endif  /* SET_CMD_ENABLES != UNIMPLEMENTED */
+
+
+#if GET_CMD_ENABLES != UNIMPLEMENTED
+/*---------------------------------------
+ * GetCmdEnables
+ *---------------------------------------*/
+int
+GetCmdEnables ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    printf("GetCmdEnables not implement\r\n");
+        *pRes = CC_INV_CMD;
+        return sizeof(*pRes);
+}
+#endif  /* GET_CMD_ENABLES != UNIMPLEMENTED */
+
+
+#if SET_SUBFN_ENABLES != UNIMPLEMENTED
+/*---------------------------------------
+ * SetSubFnEnables
+ *---------------------------------------*/
+int
+SetSubFnEnables ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+     printf("SetSubFnEnables not implement\r\n");
+        *pRes = CC_INV_CMD;
+        return sizeof(*pRes);
+}
+#endif  /* SET_SUBFN_ENABLES != UNIMPLEMENTED */
+
+
+#if GET_SUBFN_ENABLES != UNIMPLEMENTED
+/*---------------------------------------
+ * GetSubFnEnables
+ *---------------------------------------*/
+int
+GetSubFnEnables ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+     printf("GetSubFnEnables not implement\r\n");
+        *pRes = CC_INV_CMD;
+        return sizeof(*pRes);
+}
+
+#endif  /* GET_SUBFN_ENABLES != UNIMPLEMENTED */
+
+#if GET_OEM_NETFN_IANA_SUPPORT != UNIMPLEMENTED
+/*---------------------------------------
+ * GetOEMNetFnIANASupport
+ *---------------------------------------*/
+int
+GetOEMNetFnIANASupport ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+     printf("GetOEMNetFnIANASupport not implement\r\n");
+        *pRes = CC_INV_CMD;
+        return sizeof(*pRes);
+}
+
+#endif	//GET_OEM_NETFN_IANA_SUPPORT != UNIMPLEMENTED
+
+//static int GetRequiredLength(uint8_t NetFn, uint8_t CmdReqSize)
+//{
+//    uint8_t    RequiredLength;
+
+//    switch (NetFn)
+//    {
+//        case NETFN_OEM:
+//            RequiredLength = CmdReqSize;
+//            break;
+//        case NETFN_AMI:
+//            RequiredLength = CmdReqSize - sizeof(NetFnParams_T) + 1;
+//            break;
+//        case NETFN_PICMG:
+//            RequiredLength = CmdReqSize - sizeof(NetFnParams_T) + 1;
+//            break;
+//        default:
+//            RequiredLength = CmdReqSize - sizeof(NetFnParams_T);
+//            break;
+//    }
+
+//    return RequiredLength;
+//}
+
+//static int ValidateFFNetFnData (uint8_t NetFn, NetFnParams_T* pNetFnParams , BMCInfo_t *pBMCInfo)
+//{
+//    uint8_t i;
+//    
+//    // If NetFn is 0x2C, check for Defining Body code
+//    if (NETFN_PICMG == NetFn )
+//    {
+//        for (i = 0; i < sizeof (pBMCInfo->GroupExtnMsgHndlrTbl) / sizeof (pBMCInfo->GroupExtnMsgHndlrTbl [0]); i++)
+//        {
+//            if (pBMCInfo->GroupExtnMsgHndlrTbl [i].NetFn == NetFn) 
+//                return (pBMCInfo->GroupExtnMsgHndlrTbl [i].GroupExtnCode != pNetFnParams->DefBodyCode);
+//        }
+//    }
+//    else if (NETFN_OEM == NetFn) 	// If NetFn is 0x2E, check for OEM IANA
+//    {
+//        for (i=0; i <(sizeof(m_IANAList)/ sizeof(m_IANAList[0])); i++)
+//        {
+//            if (0 == _fmemcmp( pNetFnParams->IANA, m_IANAList[i].IANA, sizeof(IANA_T)))
+//            {
+//                break;
+//            }
+//        }
+
+//        if (i >= (sizeof(m_IANAList)/ sizeof(m_IANAList[0])))
+//        {
+//            // Given IANA in Req is not matching any of the IANA in the IANA list
+//            return  1;
+//        }
+//    }
+//    return 0;
+//}
+
+#endif  /* IPM_DEVICE */

+ 53 - 0
app/bmc/msghndlr/App/IPMDevice/Firewall.h

@@ -0,0 +1,53 @@
+/*****************************************************************
+ *****************************************************************
+ ***                                                            **
+ ***    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ ***                                                            **
+ ***            All Rights Reserved.                            **
+ ***                                                            **
+ ***        6145-F, Northbelt Parkway, Norcross,                **
+ ***                                                            **
+ ***        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ ***                                                            **
+ *****************************************************************
+ ******************************************************************
+ * 
+ * Firewall.h
+ * IPMI firmware firewall commands
+ *
+ *  Author: Ravinder Reddy <bakkar@ami.com>
+ *          Basavaraj Astekar <basavaraja@ami.com>
+ *          
+ ******************************************************************/
+#ifndef FIREWALL_H
+#define FIREWALL_H
+#include "com_BmcType.h"
+#include "com_IPMIDefs.h"
+
+#pragma pack(1)
+typedef struct{
+  uint8_t IANA[3];
+} IANA_T;
+#pragma pack()
+/*** Function Prototypes ***/
+
+// /**
+//  * @defgroup apcf5 Firmware Firewall Commands
+//  * @ingroup apcf
+//  * IPMI IPM Device Command Handlers. Invoked by the message handler
+//  * (IPMI 2.0 feature)
+//  * @{
+//  **/
+// extern int GetNetFnSup      ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+// extern int GetCmdSup        ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+// extern int GetSubFnSup      ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+// extern int GetConfigCmds    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+// extern int GetConfigSubFns  ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+// extern int SetCmdEnables    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+// extern int GetCmdEnables    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+// extern int SetSubFnEnables  ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+// extern int GetSubFnEnables  ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+// extern int GetOEMNetFnIANASupport  ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+// /** @} */
+
+#endif /* FIREWALL_H */

+ 222 - 0
app/bmc/msghndlr/App/IPMDevice/IPMDevice.c

@@ -0,0 +1,222 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+*****************************************************************
+ *
+ * IPMdevice.c
+ * IPMDevice Commands Handler
+ *
+ * Author: Govind Kothandapani <govindk@ami.com>
+ *       : Rama Bisa <ramab@ami.com>
+ *       : Basavaraj Astekar <basavaraja@ami.com>
+ *       : Bakka Ravinder Reddy <bakkar@ami.com>
+ *
+ *****************************************************************/
+
+#include <string.h>
+#include <stdio.h>
+#include "IPMDevice.h"
+#include "MsgHndlr.h"
+#include "Support.h"
+#include "com_IPMIDefs.h"
+#include "com_IPMI_IPM.h"
+#include "Sensor.h"
+#include "main.h"
+#include "WDT.h"
+//#include "IPMIDef.h"
+#include "ChassisTimerTask.h"
+#include "com_IPMI_App.h"
+
+
+#if IPM_DEVICE == 1
+
+/*** Local macro definitions ***/
+#define ACPI_SET_SYS_PWR_STATE          0x80
+#define ACPI_SET_DEV_PWR_STATE          0x80
+#define ACPI_SYS_PWR_STATE_MASK         0x7F
+#define ACPI_DEV_PWR_STATE_MASK         0x7F
+#define ACPI_MAX_SYS_PWR_STATE			16
+#define ACPI_MAX_DEV_PWR_STATE			7
+#define ACPI_FLAG_SET					1
+#define ACPI_FLAG_UNSET					0
+
+
+/*** Global Variables ***/
+
+extern  WDTTmrMgr_T   g_WDTTmrMgr;
+
+
+
+//To get the data across the processes added in Shared memory structure in SharedMem.h
+// uint8_t     g_ACPISysPwrState;
+// uint8_t     g_ACPIDevPwrState;
+
+/*** Module Variables ***/
+
+#define WORKING_STATE 0x0
+#define S1_SLEEPING_STATE  0x1
+
+//notice
+static uint8_t  MfgID[]       = {0x12,0x34,0x56};//     /**< Contains Manufacturer ID */
+static uint16_t g_ProdID      = 0xaabb;
+
+
+static void GetFirmwareVersion(unsigned int* Major,unsigned int* Minor,unsigned int* Rev)
+{
+	*Major = g_BMCInfo.FwMajorVer;
+	*Minor = g_BMCInfo.FwMinorVer;
+	*Rev	= 0;
+}
+
+/*---------------------------------------
+ * GetDevID
+ *---------------------------------------*/
+int
+GetDevID ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+     GetDevIDRes_T*  pGetDevIDRes = ( GetDevIDRes_T*) pRes;
+    static unsigned int Major,Minor,Rev;
+    static unsigned char MinorBCD;
+    static int firsttime = 1;
+
+    if(firsttime == 1)
+    {
+        //	printf("Calling get firmware version only for first time\n");
+        GetFirmwareVersion(&Major,&Minor,&Rev);
+        MinorBCD = ((Minor/10)<<4)+(Minor%10);
+        firsttime = 0;
+    }
+
+    pGetDevIDRes->CompletionCode      = CC_NORMAL;
+    pGetDevIDRes->DeviceID            = DEVICE_ID;
+    pGetDevIDRes->DevRevision         = IPMI_DEV_REVISION;
+    pGetDevIDRes->FirmwareRevision1   = Major ;
+    pGetDevIDRes->FirmwareRevision2   = MinorBCD;  //DO NOT CHANGE THIS ASSIGNMENT. INSTEAD SET THE VALUE OF THE VARIABLE Minor IN THE FIRSTTIME LOOP
+    pGetDevIDRes->IPMIVersion         = IPMI_VERSION;
+    pGetDevIDRes->DevSupport          = DEV_SUPPORT;
+    pGetDevIDRes->ProdID              =  (g_ProdID);
+    pGetDevIDRes->AuxFirmwareRevision = Rev;
+    memcpy (pGetDevIDRes->MfgID, MfgID, sizeof (MfgID));
+
+    return sizeof (GetDevIDRes_T);
+}
+
+
+/*---------------------------------------
+ * ColdReset
+ *---------------------------------------*/
+int
+ColdReset ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	MsgPkt_T MsgPkt;
+	MsgPkt.Param = PARAM_MC;
+	MsgPkt.NetFnLUN = NETFN_APP<<2; 
+	MsgPkt.Cmd = CMD_COLD_RESET;
+	
+	PostMsg(gFd_ChassisPwrHndlrQue, &MsgPkt);
+    *pRes = CC_NORMAL;
+    return sizeof (*pRes);
+}
+
+
+/*---------------------------------------
+ * WarmReset
+ *---------------------------------------*/
+int
+WarmReset ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	MsgPkt_T MsgPkt;
+	MsgPkt.Param = PARAM_MC;
+	MsgPkt.NetFnLUN = NETFN_APP<<2; 
+	MsgPkt.Cmd = CMD_WARM_RESET;
+	
+	PostMsg(gFd_ChassisPwrHndlrQue, &MsgPkt);
+	*pRes = CC_NORMAL;
+	return sizeof (*pRes);
+}
+
+
+/*---------------------------------------
+ * GetSelfTestResults
+ *---------------------------------------*/
+int
+GetSelfTestResults ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+     GetSelfTestRes_T*  pGetSelfTest = ( GetSelfTestRes_T*) pRes;
+
+    pGetSelfTest->CompletionCode  = CC_NORMAL;
+    pGetSelfTest->TestResultByte1 = ( 0 == g_BMCInfo.SelfTestByte ) ?
+                                     GST_NO_ERROR: GST_CORRUPTED_DEVICES;
+    pGetSelfTest->TestResultByte2 = g_BMCInfo.SelfTestByte;
+
+    return sizeof (GetSelfTestRes_T);
+}
+
+
+/*---------------------------------------
+ * MfgTestOn
+ *---------------------------------------*/
+int
+MfgTestOn ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	printf("MfgTestOn not implement\r\n");
+
+    *pRes = CC_NORMAL;
+    return sizeof (*pRes);
+}
+
+
+/*---------------------------------------
+ * SetACPIPwrState
+ *---------------------------------------*/
+int
+SetACPIPwrState ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    printf("SetACPIPwrState not implement\r\n");
+
+    *pRes = CC_NORMAL;
+    return sizeof (*pRes);
+}
+
+
+/*---------------------------------------
+ * GetACPIPwrState
+ *---------------------------------------*/
+int
+GetACPIPwrState ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    GetACPIPwrStateRes_T*  pGetACPIRes = ( GetACPIPwrStateRes_T*) pRes;
+
+	printf("GetACPIPwrState not implement\r\n");
+    pGetACPIRes->CompletionCode  = CC_NORMAL;
+    pGetACPIRes->ACPISysPwrState = 0;//BMC_GET_SHARED_MEM (BMCInst)-> m_ACPISysPwrState;
+    pGetACPIRes->ACPIDevPwrState = 0;//BMC_GET_SHARED_MEM (BMCInst)->m_ACPIDevPwrState;
+  
+    return sizeof (GetACPIPwrStateRes_T);
+}
+
+
+/*---------------------------------------
+ * GetDevGUID
+ *---------------------------------------*/
+int
+GetDevGUID ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    GetDevGUIDRes_T*  pGetDevGUIDRes = ( GetDevGUIDRes_T*) pRes;
+
+    pGetDevGUIDRes->CompletionCode  = CC_NORMAL;
+    memcpy (pGetDevGUIDRes->Node, g_BMCInfo.DeviceGUID, 16);
+  
+    return sizeof (GetDevGUIDRes_T);
+}
+
+#endif  /* IPM_DEVICE */

+ 13 - 13
app/bmc_server/ipmi_dev/IPMDevice.h → app/bmc/msghndlr/App/IPMDevice/IPMDevice.h

@@ -23,7 +23,7 @@
  *****************************************************************/
 #ifndef IPMDEVICE_H
 #define IPMDEVICE_H
-#include "Types.h"
+#include "com_BmcType.h"
 
 /*** Extern Declaration ***/
 
@@ -31,7 +31,7 @@
 
 
 /**
- * @var _FAR_ INT8U g_ACPISysPwrState
+ * @var _FAR_ uint8_t g_ACPISysPwrState
  * @brief Contains System ACPI state.
  * @warning Should not be accessed from task other than Message Handler
  **/
@@ -39,10 +39,10 @@
  /*Commented it inorder to access the data across the processes and moved it to the
  shared memory structure BMCSharedMem_T in SharedMem.h file*/
 
-//extern _FAR_ INT8U      g_ACPISysPwrState;
+//extern _FAR_ uint8_t      g_ACPISysPwrState;
 
 /**
- * @var _FAR_ INT8U g_ACPIDevPwrState
+ * @var _FAR_ uint8_t g_ACPIDevPwrState
  * @brief Contains Device ACPI state.
  * @warning Should not be accessed from task other than Message Handler
  **/
@@ -50,7 +50,7 @@
  /*Commented it inorder to access the data across the processes and moved it to the
  shared memory structure BMCSharedMem_T in SharedMem.h file*/
 
-//	extern _FAR_ INT8U      g_ACPIDevPwrState;
+//	extern _FAR_ uint8_t      g_ACPIDevPwrState;
 
 /*** Function Prototypes ***/
 /**
@@ -59,14 +59,14 @@
  * IPMI IPM Device Command Handlers. Invoked by the message handler
  * @{
  **/
-extern int GetDevID             (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int ColdReset            (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int WarmReset            (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetSelfTestResults   (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int MfgTestOn            (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int SetACPIPwrState      (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetACPIPwrState      (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetDevGUID           (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
+extern int GetDevID             ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int ColdReset            ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int WarmReset            ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetSelfTestResults   ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int MfgTestOn            ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SetACPIPwrState      ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetACPIPwrState      ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetDevGUID           ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
 /** @} */
 
 #endif  /* IPMDEVICE_H */

+ 14 - 15
app/bmc_server/ipmi_dev/WDT.h → app/bmc/msghndlr/App/WDT.h

@@ -25,19 +25,18 @@
 #ifndef WDTMGR_H
 #define WDTMGR_H
 
-#include "Types.h"
+#include "com_BmcType.h"
+#include "com_IPMIDefs.h"
 #include "PMConfig.h"
-#include <features.h>
 
 #pragma pack( 1 )
 
 /*** Type definitions ***/
 // Resume ARP Thread 
 #define RESUME_ARPS     0x00 
-#define JIFFY_VALUE "/proc/sys/ractrends/Helper/Jiffies"
-#define WDT_SLEEP_TIME 100000
-#define WDT_COUNT_MS 100
-#define SEC_TO_MS 1000
+#define WDT_SLEEP_TIME 	100000
+#define WDT_COUNT_MS 	100
+#define SEC_TO_MS 		1000
 
 /**
  * @struct  WDTTmrMgr_T
@@ -45,26 +44,26 @@
 **/
 typedef struct
 {
-    INT8U       TmrPresent;         /**< Flag to indicate timer is present or not */
-    INT16U      TmrInterval;        /**< Timer interval */
-    INT16U      PreTimeOutInterval; /**< Pre Timeout interval */
-    WDTConfig_T WDTTmr;             /**< Watchdog timer configurations */
+    uint8_t       TmrPresent;         /**< Flag to indicate timer is present or not */
+    uint16_t      TmrInterval;        /**< Timer interval */
+    uint16_t      PreTimeOutInterval; /**< Pre Timeout interval */
+    WDTConfig_T   WDTTmr;             /**< Watchdog timer configurations */
 
-} PACKED  WDTTmrMgr_T;
+}   WDTTmrMgr_T;
 
 #pragma pack( )
 
 /**
- * @var _FAR_ WDTTmrMgr_T g_WDTTmrMgr
+ * @var  WDTTmrMgr_T g_WDTTmrMgr
  * @brief   Watchdog Timer table
  * @warning Should not be used from task other than Message Handler
 **/
-extern _FAR_ WDTTmrMgr_T g_WDTTmrMgr;
+extern  WDTTmrMgr_T g_WDTTmrMgr;
 
 /**
  * @brief Watchdog timer task invoked every second from timer task
  **/
-extern void* WDTTimerTask (void*Arg);
+extern void WDTTimerTask (void*Arg);
 
  /*-----------------------------------------------------------------
  * @fn StopWDTTimer
@@ -73,6 +72,6 @@ extern void* WDTTimerTask (void*Arg);
  *
  * @return None.
  *-----------------------------------------------------------------*/
-extern void StopWDTTimer (int BMCInst);
+extern void StopWDTTimer (void);
 
 #endif /* WDTMGR_H */

+ 73 - 0
app/bmc/msghndlr/Bridge/Bridge.c

@@ -0,0 +1,73 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+*****************************************************************
+ *
+ * Bridge.c
+ * Bridge Command Handler
+ *
+ * Author: Gowtham.M.S <gowthamms@amiindia.co.in>
+ *
+ *****************************************************************/
+#define UNIMPLEMENTED_AS_FUNC
+//#include "Support.h"
+//#include "Bridge.h"
+//#include "BridgeMgmt.h"
+//#include "Bridging.h"
+//#include "BridgeDiscovery.h"
+//#include "BridgeEvt.h"
+//#include "Storlead_BMC_LIb.h"
+#include "Support.h"
+#include "MsgHndlr.h"
+/**
+ * @brief Bridge Command Handler Map.
+**/
+const CmdHndlrMap_T g_Bridge_CmdHndlr [] =
+{
+#if BRIDGE_DEVICE == 1
+/*----------------------- Bridge Management Commands --------------------------------*/
+    { CMD_GET_BRIDGE_STATE,     PRIV_USER,      GET_BRIDGE_STATE,       0x00,   0xAAAA  ,0xFFFF},
+    { CMD_SET_BRIDGE_STATE,     PRIV_OPERATOR,  SET_BRIDGE_STATE,       sizeof(SetBridgeStateReq_T),    0xAAAA  ,0xFFFF},
+    { CMD_GET_ICMB_ADDR,        PRIV_USER,      GET_ICMB_ADDR,          0x00,   0xAAAA  ,0xFFFF},
+    { CMD_SET_ICMB_ADDR,        PRIV_OPERATOR,  SET_ICMB_ADDR,          sizeof(SetICMBAddrReq_T),   0xAAAA  ,0xFFFF},
+    { CMD_SET_BRIDGE_PROXY_ADDR,PRIV_OPERATOR,  SET_BRIDGE_PROXY_ADDR,      0xff,   0xAAAA  ,0xFFFF}, //sizeof(SetBrProxyAddrReq_T)
+    { CMD_GET_BRIDGE_STATISTICS,PRIV_USER,      GET_BRIDGE_STATISTICS,      sizeof(GetBrStatisticsReq_T),   0xAAAA  ,0xFFFF},
+    { CMD_GET_ICMB_CAPABILITIES,PRIV_USER,      GET_ICMB_CAPABILITIES,      0x00,   0xAAAA  ,0xFFFF},
+    { CMD_CLEAR_BRIDGE_STATISTICS,PRIV_OPERATOR,CLEAR_BRIDGE_STATISTICS,    0x00,   0xAAAA  ,0xFFFF},
+    { CMD_GET_BRIDGE_PROXY_ADDR,PRIV_USER,      GET_BRIDGE_PROXY_ADDR,      0x00,   0xAAAA  ,0xFFFF},
+    { CMD_GET_ICMB_CONNECTOR_INFO,PRIV_USER,    GET_ICMB_CONNECTOR_INFO,    sizeof(GetICMBConnInfoReq_T),   0xAAAA  ,0xFFFF},
+    { CMD_GET_ICMB_CONNECTION_ID,PRIV_USER,     GET_ICMB_CONNECTION_ID,     0xff,   0xAAAA  ,0xFFFF},
+    { CMD_SEND_ICMB_CONNECTION_ID,PRIV_USER,    SEND_ICMB_CONNECTION_ID,    0x00,   0xAAAA  ,0xFFFF},
+
+/*---------------------- Bridge Discovery Commands -----------------------------------*/
+    { CMD_PREPARE_FOR_DISCOVERY,  PRIV_OPERATOR, PREPARE_FOR_DISCOVERY, 0x00,   0xAAAA  ,0xFFFF},
+    { CMD_GET_ADDRESSES,          PRIV_USER,     GET_ADDRESSES,         0x00,   0xAAAA  ,0xFFFF},
+    { CMD_SET_DISCOVERED,         PRIV_OPERATOR, SET_DISCOVERED,        0x00,   0xAAAA  ,0xFFFF},
+    { CMD_GET_CHASSIS_DEVICE_ID,  PRIV_USER,     GET_CHASSIS_DEVICE_ID, 0x00,   0xAAAA  ,0xFFFF},
+    { CMD_SET_CHASSIS_DEVICE_ID,  PRIV_OPERATOR, SET_CHASSIS_DEVICE_ID, sizeof(INT8U),  0xAAAA  ,0xFFFF},
+
+/*----------------------- Bridging Commands ------------------------------------------*/
+    { CMD_BRIDGE_REQUEST,       PRIV_OPERATOR,  BRIDGE_REQUEST,         0xff,   0xAAAA  ,0xFFFF},
+    { CMD_BRIDGE_MESSAGE,       PRIV_OPERATOR,  BRIDGE_MESSAGE,         0xff,   0xAAAA  ,0xFFFF},
+
+/*---------------------- Bridge Event Commands ---------------------------------------*/
+    { CMD_GET_EVENT_COUNT,          PRIV_USER,      GET_EVENT_COUNT,            0x00,   0xAAAA  ,0xFFFF},
+    { CMD_SET_EVENT_DESTINATION,    PRIV_OPERATOR,  SET_EVENT_DESTINATION,      sizeof(SetEvtDestReq_T),    0xAAAA  ,0xFFFF},
+    { CMD_SET_EVENT_RECEPTION_STATE,PRIV_OPERATOR,  SET_EVENT_RECEPTION_STATE,  sizeof(SetEvtRecpStateReq_T),   0xAAAA  ,0xFFFF},
+    { CMD_SEND_ICMB_EVENT_MESSAGE,  PRIV_OPERATOR,  SEND_ICMB_EVENT_MESSAGE,    0xff,   0xAAAA  ,0xFFFF}, //sizeof(SendICMBEvtMsgReq_T)
+    { CMD_GET_EVENT_DESTINATION,    PRIV_USER,      GET_EVENT_DESTINATION,      0x00,   0xAAAA  ,0xFFFF},
+    { CMD_GET_EVENT_RECEPTION_STATE,PRIV_USER,      GET_EVENT_RECEPTION_STATE,  0x00,   0xAAAA  ,0xFFFF},
+#endif  /*BRIDGE_DEVICE*/
+
+    { 0x00,                     0x00,           0x00,                 0x00, 0x0000           ,0x0000}   
+};
+

+ 20 - 0
app/bmc/msghndlr/Bridge/Bridge.h

@@ -0,0 +1,20 @@
+/*
+* Brief:	The header file of MsgHndlr_Bridge packet.
+* Author:	Jimbo_Zhang@outlook.com
+* Date:		2019-9-16
+*/
+
+#ifndef __MSG_HNDLR_BRIDGE_H__
+#define __MSG_HNDLR_BRIDGE_H__
+
+#include "com_BmcType.h"
+#include "MsgHndlr.h"
+
+
+/**
+ * @var g_Bridge_CmdHndlr
+ * @brief Bridge Command Hanlder Map.
+**/
+extern const CmdHndlrMap_T  g_Bridge_CmdHndlr [];
+
+#endif /* __MSG_HNDLR_BRIDGE_H__ */

+ 51 - 0
app/bmc/msghndlr/Chassis/Chassis.c

@@ -0,0 +1,51 @@
+/*****************************************************************
+ *****************************************************************
+ ***                                                            **
+ ***    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ ***                                                            **
+ ***            All Rights Reserved.                            **
+ ***                                                            **
+ ***        6145-F, Northbelt Parkway, Norcross,                **
+ ***                                                            **
+ ***        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ ***                                                            **
+ *****************************************************************
+ *****************************************************************
+ ******************************************************************
+ * 
+ * chassis.c
+ * Chassis commands
+ *
+ *  Author: Rama Bisa <ramab@ami.com>
+ *          
+ ******************************************************************/
+
+#include "MsgHndlr.h"
+#include "com_IPMI_Chassis.h"
+#include "Support.h"
+#include "com_IPMI_ChassisDevice.h"
+
+/*** Global Variables ***/
+
+const CmdHndlrMap_T g_Chassis_CmdHndlr [] = 
+{
+    /*--------------------- Chassis Commands ---------------------------------*/
+#if CHASSIS_DEVICE == 1
+    { CMD_GET_CHASSIS_CAPABILITIES,     PRIV_USER,      GET_CHASSIS_CAPABILITIES,       0x00,                               0xAAAA ,0xFFFF},
+    { CMD_GET_CHASSIS_STATUS,           PRIV_USER,      GET_CHASSIS_STATUS,             0x00,                               0xAAAA ,0xFFFF},
+    { CMD_CHASSIS_CONTROL,              PRIV_OPERATOR,  CHASSIS_CONTROL,                sizeof(ChassisControlReq_T),        0xAAAA ,0xFFFF},
+    // { CMD_CHASSIS_RESET,                PRIV_OPERATOR,  CHASSIS_RESET_CMD,              0x00,                               0xAAAA ,0xFFFF},
+    { CMD_CHASSIS_IDENTIFY,             PRIV_OPERATOR,  CHASSIS_IDENTIFY_CMD,           0xFF,                               0xAAAA ,0xFFFF},
+    { CMD_SET_CHASSIS_CAPABILITIES,     PRIV_ADMIN,     SET_CHASSIS_CAPABILITIES,       0xFF,                               0xAAAA ,0xFFFF},
+    { CMD_SET_POWER_RESTORE_POLICY,     PRIV_OPERATOR,  SET_POWER_RESTORE_POLICY,       sizeof(SetPowerRestorePolicyReq_T), 0xAAAA ,0xFFFF},
+    { CMD_GET_SYSTEM_RESTART_CAUSE,     PRIV_USER,      GET_SYSTEM_RESTART_CAUSE,       0x00,                               0xAAAA ,0xFFFF},
+    { CMD_SET_SYSTEM_BOOT_OPTIONS,      PRIV_OPERATOR,  SET_SYSTEM_BOOT_OPTIONS,        0xFF,                               0xAAAA ,0xFFFF},
+    { CMD_GET_SYSTEM_BOOT_OPTIONS,      PRIV_OPERATOR,  GET_SYSTEM_BOOT_OPTIONS,        sizeof (GetBootOptionsReq_T),       0xAAAA ,0xFFFF},
+    { CMD_GET_POH_COUNTER,              PRIV_USER,      GET_POH_COUNTER,                0x00,                               0xAAAA ,0xFFFF},
+    { CMD_SET_FP_BTN_ENABLES,           PRIV_ADMIN,     SET_FP_BTN_ENABLES,             sizeof(SetFPBtnEnablesReq_T),		0xAAAA ,0xFFFF},
+    { CMD_SET_POWER_CYCLE_INTERVAL, 	PRIV_ADMIN,		SET_POWER_CYCLE_INTERVAL,		sizeof(SetPowerCycleIntervalReq_T),		0xAAAA ,0xFFFF},
+#endif  /* CHASSIS_DEVICE */
+    { 0x00,                             0x00,           0x00,                           0x00,                               0x0000 ,           0x0000}
+    
+};
+

+ 18 - 0
app/bmc/msghndlr/Chassis/Chassis.h

@@ -0,0 +1,18 @@
+/*
+* Brief:	The header file of MsgHndlr_Chassis packet.
+* Author:	Jimbo_Zhang@outlook.com
+* Date:		2019-9-16
+*/
+
+#ifndef __MSG_HNDLR_CHASSIS_H__
+#define __MSG_HNDLR_CHASSIS_H__
+
+#include "com_BmcType.h"
+#include "MsgHndlr.h"
+
+
+/*** Extern Definitions ***/
+extern const CmdHndlrMap_T g_Chassis_CmdHndlr []; /**< Chassis command handler table. */
+
+
+#endif /* __MSG_HNDLR_CHASSIS_H__ */

+ 1119 - 0
app/bmc/msghndlr/Chassis/ChassisDevice.c

@@ -0,0 +1,1119 @@
+/*****************************************************************
+ *****************************************************************
+ ***                                                            **
+ ***    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ ***                                                            **
+ ***            All Rights Reserved.                            **
+ ***                                                            **
+ ***        6145-F, Northbelt Parkway, Norcross,                **
+ ***                                                            **
+ ***        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ ***                                                            **
+ *****************************************************************
+ *****************************************************************
+ ******************************************************************
+ *
+ * ChassisDevice.c
+ * Chassis commands
+ *
+ *  Author: Rama Bisa <ramab@ami.com>
+ *
+ ******************************************************************/
+
+#include <string.h>
+#include "com_IPMI_ChassisDevice.h"
+#include "ChassisDevice.h"
+#include "ChassisTimerTask.h"
+
+#include "Support.h"
+#include "main.h"
+#include "message.h"
+
+/* Reserved bit macro definitions */
+#define RESERVED_BITS_CHASSISCONTROL                    0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
+#define RESERVED_BITS_GETCHASSISIDENTIFY                0xFE //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0)
+#define RESERVED_BITS_SETCHASSISCAPS                    0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
+#define RESERVED_BITS_SETPOWERRESTOREPOLICY             0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
+#define RESERVED_BITS_SETFPBUTTONENABLES                0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+
+#if CHASSIS_DEVICE == 1
+
+/*** Local Definitions ***/
+#define PRP_ALWAYS_POWEROFF_SUPPORT             0x01
+#define PRP_LAST_STATE_SUPPORT                  0x02
+#define PRP_ALWAYS_POWERON_SUPPORT              0x04
+
+
+#define CHASSIS_AMI_OEM_PARAM                   96
+#define CHASSIS_SET_INPROG                      0x00
+#define CHASSIS_SERVICE_PART_SEL                0x01
+#define CHASSIS_SERVICE_PART_SCAN               0x02
+#define CHASSIS_BOOT_FLAG_VALID_BIT_CLEAR       0x03
+#define CHASSIS_BOOT_INFO_ACK                   0x04
+#define CHASSIS_BOOT_FLAGS                      0x05
+#define CHASSIS_BOOT_INITIATOR_INFO             0x06
+#define CHASSIS_BOOT_INITIATOR_MBOX             0x07
+#define CHASSIS_AMI_OEM_PARAM                   96
+#define SSICB_OEM_PARAM_BLK_SIZE_TBL            0x78
+#define SSICB_BOOT_ORDER_TBL                    0x7D
+#define SSICB_BOOT_DEV_SELECTOR                 0x7E
+#define SSICB_SLOT_CONFIG_TBL                   0x7F
+
+#define ROLLBACK_OPTION                         0x00
+
+/* Mask Bits */
+#define BIT5_BIT2_MASK				0x3C
+#define BIT6_BIT5_MASK				0x60
+#define BIT1_BIT0_MASK				0x03
+       
+/* Reserved Bits */
+#define RESERVED_VALUE_03			0x03
+#define RESERVED_VALUE_10			0x10
+#define RESERVED_VALUE_20			0x20
+#define RESERVED_VALUE_28			0x28
+#define RESERVED_VALUE_30			0x30
+#define RESERVED_VALUE_34			0x34
+#define RESERVED_VALUE_38			0x38
+#define RESERVED_VALUE_40			0x40
+#define RESERVED_VALUE_60			0x60
+#define RESERVED_VALUE_80			0x80
+
+///*** Module Varibales ***/
+//static const uint8_t            m_BootOptParamLen [] = /**< Boot Options parameter length */
+//{   
+//    0x01,                           /**< Set in progress byte length */
+//    0x01,                           /**< Service Partition selector length */
+//    0x01,                           /**< Service Partition scan length */
+//    0x01,                           /**< Boot flag valid bit length */
+//    sizeof(BootInfoAck_T),          /**< Boot info ack length */
+//    sizeof(BootFlags_T),            /**< Boot Flags valid length */ 
+//    sizeof(BootInitiatorInfo_T),    /**< Boot init info length */   
+//    sizeof(BootInitiatorMboxReq_T), /**< Boot init info length */   
+//};
+
+//static const uint8_t            m_SSIBootOptParamLen [] = /**< SSI Boot Options parameter length */
+//{
+//    sizeof(OemParamBlkSizeTbl_T), /* OEM Parameter Block Size Table length */
+//    0x0,                          /* Reserved */
+//    0x0,                          /* Reserved */
+//    0x0,                          /* Reserved */
+//    0x0,                          /* Reserved */
+//    sizeof(BootOrderTblReq_T),    /* Boot Order Table length */
+//    sizeof(uint8_t),                /* SSI Boot Device Selector length*/
+//    sizeof(SlotConfigTbl_T)       /* Slot Configuration Table length */
+//};
+
+#define MAX_BOOT_PARAMS_DATA  20
+typedef struct
+{
+    uint8_t	Params;
+    uint8_t	ReservedBits [MAX_BOOT_PARAMS_DATA];
+    uint8_t	DataLen;
+
+} BootCfgRsvdBits_T;
+
+//static BootCfgRsvdBits_T m_RsvdBitsCheck [] = {
+
+//        /* Param        Reserved Bits      Data Size   */
+//        { 0,	     		{ 0xFC }, 				    				 0x1 },	/* Set In progress  */
+//        { 2,				{ 0xFC }, 					 				 0x1 },
+//        { 3,				{ 0xE0 },									 0x1 },
+//        { 5,				{ 0x1F,0x00,0x00,0xF0,0xE0},			  	 0x5 },
+//        { 6,				{ 0xF0 },					 				 0x1 }
+//};
+
+/*-------------------------------------
+ * GetChassisCaps
+ *-------------------------------------*/
+int
+GetChassisCaps ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+      GetChassisCapabilitiesRes_T* pGetChassisCapsRes = ( GetChassisCapabilitiesRes_T*) pRes;
+
+    
+    printf("GetChassisCaps not implement\r\n");
+    pGetChassisCapsRes->CompletionCode = CC_NORMAL;
+
+   memcpy ( ( uint8_t*)&pGetChassisCapsRes->ChassisCapabilities,
+               ( uint8_t*)&g_BMCInfo.IpmiConfig.ChassisCapabilities,
+                                            sizeof(ChassisCapabilities_T) );
+    
+    return sizeof(GetChassisCapabilitiesRes_T);
+}
+
+
+/*-------------------------------------
+ * GetChassisStatus
+ *-------------------------------------*/
+int
+GetChassisStatus ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    GetChassisStatusRes_T*  pGetChassisStatusRes =
+        ( GetChassisStatusRes_T*) pRes;
+
+    pGetChassisStatusRes->CompletionCode = CC_NORMAL;
+
+
+    memcpy ( ( uint8_t*)&pGetChassisStatusRes->ChassisPowerState,
+                    ( uint8_t*)&g_BMCInfo.IpmiConfig.ChassisPowerState,
+                                    sizeof(ChassisPowerState_T));
+    
+    return sizeof (GetChassisStatusRes_T) ; 
+
+}
+
+
+/*-------------------------------------
+ * ChassisControl
+ *-------------------------------------*/
+int
+ChassisControl (  uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes )
+{
+      ChassisControlReq_T*    pChassisControlReq = 
+        (  ChassisControlReq_T*) pReq;
+      ChassisControlRes_T*    pChassisControlRes = 
+        (  ChassisControlRes_T*) pRes;
+	MsgPkt_T	MsgPkt;
+
+    pChassisControlRes->CompletionCode = CC_NORMAL;
+
+    /* Check for the reserved bytes should b zero */
+
+    if  ( 0 !=  (pChassisControlReq->ChassisControl & RESERVED_BITS_CHASSISCONTROL ) )
+    {
+        pChassisControlRes->CompletionCode = CC_INV_DATA_FIELD;
+        return sizeof(uint8_t);	
+    }
+
+    switch (pChassisControlReq->ChassisControl & 0x0F  )
+    {
+
+        case CHASSIS_POWER_DOWN:
+            //printf ("Chassis IS GOING FOR POWER_DOWN\n");
+			MsgPkt.Param 	= 	PARAM_CHASSIS;
+			MsgPkt.NetFnLUN	=	0x00<<2;
+			MsgPkt.Cmd		=	0x02;
+			MsgPkt.Data[0]	=	CHASSIS_POWER_DOWN;
+			PostMsg(gFd_ChassisPwrHndlrQue, &MsgPkt);	
+//            g_BMCInfo.HostOFFStopWDT = TRUE ;
+            g_BMCInfo.IpmiConfig.SysRestartCause = RESTART_CAUSE_CHASSIS_CTRL;
+//            OnSetRestartCause(g_BMCInfo.ChassisConfig.SysRestartCause, TRUE,BMCInst);
+//            g_BMCInfo.Msghndlr.ChassisControl= CHASSIS_POWER_DOWN;
+            break;
+
+        case CHASSIS_POWER_UP:
+            //printf ("Chassis IS GOING FOR POWER UP\n");
+			MsgPkt.Param 	= 	PARAM_CHASSIS;
+			MsgPkt.NetFnLUN	=	0x00<<2;
+			MsgPkt.Cmd		=	0x02;
+			MsgPkt.Data[0]	=	CHASSIS_POWER_UP;
+			PostMsg(gFd_ChassisPwrHndlrQue, &MsgPkt);
+            g_BMCInfo.IpmiConfig.SysRestartCause = RESTART_CAUSE_CHASSIS_CTRL;
+//            OnSetRestartCause(g_BMCInfo.ChassisConfig.SysRestartCause, TRUE,BMCInst);
+//            g_BMCInfo.Msghndlr.ChassisControl = CHASSIS_POWER_UP;
+
+//            /* Set Last Power Event through IPMI Command */
+//            if(g_PDKHandle[PDK_SETLASTPOWEREVENT] != NULL)
+//				{
+//					((void(*)(uint8_t,int))g_PDKHandle[PDK_SETLASTPOWEREVENT]) (PDK_LAST_POWER_ON_VIA_IPMI,BMCInst);
+//				}
+            break;
+
+    case CHASSIS_POWER_CYCLE:
+		//printf ("Chassis IS GOING FOR POWER CYCLE\n");
+		MsgPkt.Param 	= 	PARAM_CHASSIS;
+		MsgPkt.NetFnLUN	=	0x00<<2;
+		MsgPkt.Cmd		=	0x02;
+		MsgPkt.Data[0]	=	CHASSIS_POWER_CYCLE;
+		PostMsg(gFd_ChassisPwrHndlrQue, &MsgPkt);
+	
+        g_BMCInfo.IpmiConfig.SysRestartCause = RESTART_CAUSE_CHASSIS_CTRL;
+//        OnSetRestartCause(g_BMCInfo.ChassisConfig.SysRestartCause, TRUE,BMCInst);
+//        g_BMCInfo.Msghndlr.ChassisControl = CHASSIS_POWER_CYCLE;
+
+//        /* Set Last Power Event through IPMI Command */
+//        if(g_PDKHandle[PDK_SETLASTPOWEREVENT] != NULL)
+//			{
+//				((void(*)(uint8_t,int))g_PDKHandle[PDK_SETLASTPOWEREVENT]) (PDK_LAST_POWER_ON_VIA_IPMI,BMCInst);
+//			}
+        break;
+
+    case CHASSIS_HARD_RESET:
+        //printf ("Chassis IS GOING FOR HARD RESET");
+		MsgPkt.Param 	= 	PARAM_CHASSIS;
+		MsgPkt.NetFnLUN	=	0x00<<2;
+		MsgPkt.Cmd		=	0x02;
+		MsgPkt.Data[0]	=	CHASSIS_HARD_RESET;
+		PostMsg(gFd_ChassisPwrHndlrQue, &MsgPkt);	
+        g_BMCInfo.IpmiConfig.SysRestartCause = RESTART_CAUSE_CHASSIS_CTRL;
+//        OnSetRestartCause(g_BMCInfo.ChassisConfig.SysRestartCause, TRUE,BMCInst);
+//        g_BMCInfo.Msghndlr.ChassisControl = CHASSIS_HARD_RESET;
+        break;
+
+    case CHASSIS_PULSE_DIAGNOSTIC_INTERRUPT:
+        //printf ("Chassis IS GOING FOR DIAG INT\n");
+		MsgPkt.Param 	= 	PARAM_CHASSIS;
+		MsgPkt.NetFnLUN	=	0x00<<2;
+		MsgPkt.Cmd		=	0x02;
+		MsgPkt.Data[0]	=	CHASSIS_PULSE_DIAGNOSTIC_INTERRUPT;
+		PostMsg(gFd_ChassisPwrHndlrQue, &MsgPkt);
+        //Platform_HostDiagInt ();
+        break;
+
+    case CHASSIS_SOFT_SHUTDOWN:
+        //printf ("Chassis IS GOING FOR SOFT SHUTDOWN\n");
+		MsgPkt.Param 	= 	PARAM_CHASSIS;
+		MsgPkt.NetFnLUN	=	0x00<<2;
+		MsgPkt.Cmd		=	0x02;
+		MsgPkt.Data[0]	=	CHASSIS_SOFT_SHUTDOWN;
+		PostMsg(gFd_ChassisPwrHndlrQue, &MsgPkt);
+        //Platform_HostSoftShutDown (BMCInst);
+        break;
+
+    default:
+        printf ("UNKNOWN Chassis CONTROL REQUEST \r\n");
+        pChassisControlRes->CompletionCode = CC_INV_DATA_FIELD;
+        break;
+    }
+    UpdateFlash();
+    return sizeof (ChassisControlRes_T);
+}
+
+
+/*-------------------------------------
+ * GetChassisIdentify
+ *-------------------------------------*/
+int
+GetChassisIdentify ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+     ChassisIdentifyReq_T*    pChassisIdentifyReq =
+        ( ChassisIdentifyReq_T*) pReq;
+     ChassisIdentifyRes_T*    pChassisIdentifyRes =
+        ( ChassisIdentifyRes_T*) pRes;
+
+    if (ReqLen <= sizeof(ChassisIdentifyReq_T)) 
+    {
+       if (0 != ReqLen) 
+        {    
+            g_BMCInfo.ChassisIdentifyForce = 0;
+            g_BMCInfo.ChassisIdentifyTimeout = pChassisIdentifyReq->IdentifyInterval; 
+        }
+        else
+        {    
+             g_BMCInfo.ChassisIdentifyForce = 0;
+             g_BMCInfo.ChassisIdentifyTimeout = 15;
+        }
+
+        if (ReqLen == 2)
+        {
+            /* Check for the reserved bytes should b zero */
+            if  ( 0 !=  (pChassisIdentifyReq->ForceIdentify & RESERVED_BITS_GETCHASSISIDENTIFY ) )
+            {
+                pChassisIdentifyRes->CompletionCode = CC_INV_DATA_FIELD;
+                return sizeof(uint8_t);	
+            }
+
+            if(pChassisIdentifyReq->ForceIdentify & 1)
+            {
+                g_BMCInfo.ChassisIdentifyTimeout = 0;
+                g_BMCInfo.ChassisIdentifyForce = 1;
+            }
+            else
+            {
+                g_BMCInfo.ChassisIdentifyForce = 0;
+            }
+        }
+        g_BMCInfo.ChassisIdentify = TRUE;
+
+        pChassisIdentifyRes->CompletionCode = CC_NORMAL;
+    }    	
+    else 
+    {
+        pChassisIdentifyRes->CompletionCode = CC_REQ_INV_LEN;
+    }
+    
+    return sizeof(ChassisIdentifyRes_T);
+}
+
+
+/*-------------------------------------
+ * SetChassisCaps
+ *-------------------------------------*/
+int
+SetChassisCaps ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+      SetChassisCapabilitiesReq_T*    pSetChassisCapsReq =
+        ( SetChassisCapabilitiesReq_T*) pReq;
+      SetChassisCapabilitiesRes_T*    pSetChassisCapsRes =
+        ( SetChassisCapabilitiesRes_T*) pRes;
+
+    //printf ("SET Chassis CAPABILITIES\n");
+
+    /* Check for the reserved bytes should b zero */
+    if  ( 0 !=  (pSetChassisCapsReq->ChassisCaps.CapabilitiesFlags & RESERVED_BITS_SETCHASSISCAPS ) )
+    {
+        pSetChassisCapsRes->CompletionCode = CC_INV_DATA_FIELD;
+        return sizeof(uint8_t);	
+    }
+    
+    if ((ReqLen != 5) &&
+        (ReqLen != sizeof(SetChassisCapabilitiesReq_T)))
+    {
+        pSetChassisCapsRes->CompletionCode= CC_REQ_INV_LEN;
+        return sizeof(SetChassisCapabilitiesRes_T); 
+    }
+
+    if((pSetChassisCapsReq->ChassisCaps.CapabilitiesFlags & 0xFC ) != 0)
+    {
+        pSetChassisCapsRes->CompletionCode= CC_INV_DATA_FIELD;
+        return sizeof(SetChassisCapabilitiesRes_T);   
+    }
+
+   memcpy (( uint8_t*) &g_BMCInfo.IpmiConfig.ChassisCapabilities,
+              ( uint8_t*) &pSetChassisCapsReq->ChassisCaps,
+              sizeof(ChassisCapabilities_T));
+   
+    UpdateFlash();
+    pSetChassisCapsRes->CompletionCode = CC_NORMAL;
+    
+    return sizeof (SetChassisCapabilitiesRes_T);
+}
+
+
+/*-------------------------------------
+ * SetPowerRestorePolicy
+ *-------------------------------------*/
+int
+SetPowerRestorePolicy ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    
+      SetPowerRestorePolicyReq_T* pSetPowerRestorePolicyReq =
+        ( SetPowerRestorePolicyReq_T*) pReq;
+      SetPowerRestorePolicyRes_T* pSetPowerRestorePolicyRes =
+        ( SetPowerRestorePolicyRes_T*) pRes;  
+    
+    printf ("\nSET POWER RESORE POLICY\r\n");
+    
+    /* Check for the reserved bytes should b zero */
+    if ( 0 != ( pSetPowerRestorePolicyReq->PowerRestorePolicy & RESERVED_BITS_SETPOWERRESTOREPOLICY ))
+    {
+        pSetPowerRestorePolicyRes->CompletionCode = CC_INV_DATA_FIELD;
+        return sizeof (uint8_t);
+    }
+
+    // 011b = no change to the current power restore policy
+   if (pSetPowerRestorePolicyReq->PowerRestorePolicy != 0x03)
+   {
+        g_BMCInfo.IpmiConfig.PowerRestorePolicy =
+        pSetPowerRestorePolicyReq->PowerRestorePolicy & 0x07;
+        g_BMCInfo.IpmiConfig.ChassisPowerState.PowerState &= ~0x60;
+        g_BMCInfo.IpmiConfig.ChassisPowerState.PowerState |= (pSetPowerRestorePolicyReq->PowerRestorePolicy << 5); 
+        UpdateFlash();
+   }
+
+    pSetPowerRestorePolicyRes->CompletionCode = CC_NORMAL;
+    pSetPowerRestorePolicyRes->PowerRestorePolicy = PRP_ALWAYS_POWEROFF_SUPPORT |
+                                                    PRP_LAST_STATE_SUPPORT      |
+                                                    PRP_ALWAYS_POWERON_SUPPORT;
+    return  sizeof(SetPowerRestorePolicyRes_T);
+}
+
+
+/*-------------------------------------
+ * GetSysRestartCause
+ *-------------------------------------*/
+int
+GetSysRestartCause ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{    
+      GetSystemRestartCauseRes_T* pGetSysRestartCauseRes =
+        ( GetSystemRestartCauseRes_T*) pRes;
+    uint8_t *curchannel = 0;
+
+    //printf ("GET SYSTEM RESTART CAUSE\n");
+
+    pGetSysRestartCauseRes->CompletionCode  = CC_NORMAL;
+    pGetSysRestartCauseRes->SysRestartCause = g_BMCInfo.IpmiConfig.SysRestartCause;
+    pGetSysRestartCauseRes->ChannelID       = *curchannel & 0xF;
+ 
+    return sizeof(GetSystemRestartCauseRes_T);
+}
+
+
+
+/*-------------------------------------
+ * GetPOHCounter
+ *-------------------------------------*/
+int
+GetPOHCounter ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	//TODO: POHCounterReading unit is hour or minutes or second?
+    GetPOHCounterRes_T* pGetPOHCounterRes = ( GetPOHCounterRes_T*) pRes;
+
+    //printf ("GET POH COUNTER\r\n");
+
+    pGetPOHCounterRes->CompletionCode    = CC_NORMAL;
+    pGetPOHCounterRes->MinutesPerCount   = POH_MINS_PER_COUNT;
+    pGetPOHCounterRes->POHCounterReading = (g_BMCInfo.BootValidMinutes/60);
+   
+    return sizeof(GetPOHCounterRes_T);
+}
+
+
+/*-------------------------------------
+ * SetSysBOOTOptions
+ *-------------------------------------*/
+int
+SetSysBOOTOptions ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	printf("SetSysBOOTOptions not implement\r\n");
+//     SetBootOptionsReq_T* pBootOptReq = ( SetBootOptionsReq_T*) pReq;
+//     SetBootOptionsRes_T* pBootOptRes = ( SetBootOptionsRes_T*) pRes;
+//    BMCInfo_t *pBMCInfo = &g_BMCInfo;
+//    uint8_t                Parameter;
+//    BootOptions_T*       pBootOptions;
+//    uint8_t				u8SetInProgress;
+//    uint8_t				u8TempData,SSIComputeBladeSupport;
+//    int i,j=0;
+
+//    Parameter = pBootOptReq->ParamValidCumParam & 0x7F;
+
+//     SSIComputeBladeSupport = g_corefeatures.ssi_support;
+
+//    /*Check for validity of parameter */
+//    if(SSIComputeBladeSupport)
+//    {
+//        if ((Parameter >= sizeof (m_BootOptParamLen)) && (Parameter != CHASSIS_AMI_OEM_PARAM) &&
+//            (Parameter != SSICB_OEM_PARAM_BLK_SIZE_TBL) && (Parameter < SSICB_BOOT_ORDER_TBL || Parameter > SSICB_SLOT_CONFIG_TBL))
+//        {
+//            pBootOptRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//            return sizeof (SetBootOptionsRes_T);
+//        }
+//    }
+//    else
+//   {
+//        if ((Parameter >= sizeof (m_BootOptParamLen)) && (Parameter != CHASSIS_AMI_OEM_PARAM))
+//        {
+//            pBootOptRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//            return sizeof (SetBootOptionsRes_T);
+//        }
+//    }
+//    /*Check if ReqLen valid for OEM Parameter */
+//    if (CHASSIS_AMI_OEM_PARAM == Parameter)
+//    {
+//        if ((ReqLen - 1) != sizeof (AMI_BootOpt_T))
+//        {
+//            pBootOptRes->CompletionCode= CC_REQ_INV_LEN;
+//            return sizeof (uint8_t);  
+//        }
+//    }
+//    else if (Parameter >= SSICB_OEM_PARAM_BLK_SIZE_TBL && Parameter <= SSICB_SLOT_CONFIG_TBL)
+//    {
+//      if(SSIComputeBladeSupport)
+//      {
+//        if ((ReqLen - 1) != m_SSIBootOptParamLen[Parameter-SSICB_OEM_PARAM_BLK_SIZE_TBL])
+//        {
+//            pBootOptRes->CompletionCode= CC_REQ_INV_LEN;
+//            return sizeof (uint8_t);
+//        }
+//      }
+//    }
+//    else
+//    {
+//        /*Check if valid message length */
+//        //if ( ((ReqLen - 1) != m_BootOptParamLen[Parameter]) && (ReqLen != sizeof (Parameter)))
+//        if ((ReqLen - 1) != m_BootOptParamLen[Parameter])
+//        {
+//            pBootOptRes->CompletionCode= CC_REQ_INV_LEN;
+//            return sizeof (uint8_t);  
+//        }
+//    }
+//#if 0  
+//   Bit is 1 - Parameter is locked 
+//   Bit is 0 - Parameter is unlocked 
+
+//if locked 
+//	if no req to unlock then  return invalid 
+//	if req to unlock    then  unlock and procced 
+//else 
+//	Proceed
+//#endif
+//    /* Check for Reserved Bits */
+//    for (i = 0; i < sizeof (m_RsvdBitsCheck)/ sizeof (m_RsvdBitsCheck[0]); i++)
+//    {
+//        /* Check if this Parameter Selector needs Reserved bit checking !! */
+//        if (m_RsvdBitsCheck[i].Params == Parameter)
+//        {
+//            //IPMI_DBG_PRINT_2 ("Param - %x, DataLen - %x\n", pSetLanReq->ParameterSelect, m_RsvdBitsCheck[i].DataLen);
+
+//            for (j = 0; j < m_RsvdBitsCheck[i].DataLen; j++)
+//            {
+//                //	IPMI_DBG_PRINT_2 ("Cmp  %x,  %x\n", pReq[2+j], m_RsvdBitsCheck[i].ReservedBits[j]);
+//                if ( 0 != (pReq[1+j] & m_RsvdBitsCheck[i].ReservedBits[j]))
+//                {
+//                    /* Alarm !!! Somebody is trying to set Reseved Bits */
+//                    *pRes = CC_INV_DATA_FIELD;
+//                    return sizeof (*pRes);
+//                }
+//            }
+//        }
+//     }
+
+//    OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo.ChassisMutex, WAIT_INFINITE);
+//    pBootOptions = &(BMC_GET_SHARED_MEM(BMCInst)->sBootOptions);
+//    u8SetInProgress = pBootOptions->u8SetInProgress;
+//    /* if locked */
+//    if (pBootOptions->ParameterValid &  (1 << Parameter) )
+//    {
+//        /*if not req to unlock */
+//        if (0 != (pBootOptReq->ParamValidCumParam & 0x80))
+//        {
+//            pBootOptRes->CompletionCode = CC_INV_DATA_FIELD;
+//            OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.ChassisMutex);
+//            return sizeof (uint8_t);
+//        }
+//    }
+// 
+
+//    /*Check for valid bit settings */
+//    if (0 != (pBootOptReq->ParamValidCumParam & 0x80))
+//    {
+//        /* The valid bit for parameters 0 - 7  are SET/RESET to 
+//         *  corresponding bits 0-7 in ParameterValid field
+//         */ 
+//        pBootOptions->ParameterValid |= (1 << Parameter);
+//    }
+//    else
+//    {
+//        pBootOptions->ParameterValid &= ~(1 << Parameter);
+//    }
+
+//    /*if only the parameter byte is provided then exit */
+//    if (ReqLen == sizeof (Parameter))
+//    {
+//        pBootOptRes->CompletionCode = CC_NORMAL;
+//        OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.ChassisMutex);
+//        return sizeof (SetBootOptionsRes_T);
+//    }
+
+//    switch (Parameter)
+//    {
+//        case CHASSIS_SET_INPROG:
+//            /* Commit Write is optional and supported
+//             * only if rollback is supported */
+//            if ( (BMC_BOOT_OPTION_SET_IN_PROGRESS != pBootOptReq->BootParam.SetInProgress) &&
+//                (BMC_BOOT_OPTION_SET_COMPLETE != pBootOptReq->BootParam.SetInProgress) )
+//            {
+//                pBootOptRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//                OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.ChassisMutex);
+//                return sizeof(SetBootOptionsRes_T);
+//            }
+//            else if ((BMC_BOOT_OPTION_SET_IN_PROGRESS == (u8SetInProgress & 0x03)) &&
+//                (BMC_BOOT_OPTION_SET_IN_PROGRESS == pBootOptReq->BootParam.SetInProgress))
+//            {
+//                IPMI_DBG_PRINT ("\nSET IN PROGRESS ALREADY SET \n");
+
+//                pBootOptRes->CompletionCode = CC_SET_IN_PROGRESS;
+//                OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.ChassisMutex);
+//                return sizeof(SetBootOptionsRes_T); 
+//            }
+
+//            /*Set the new setinpogress byte */
+//            pBootOptions->u8SetInProgress = pBootOptReq->BootParam.SetInProgress;
+//            break;       
+//            
+//        case CHASSIS_SERVICE_PART_SEL:
+//            pBootOptions->ServicePartitionSelector =
+//                pBootOptReq->BootParam.ServicePartitionSelector;
+//            break;
+//            
+//        case CHASSIS_SERVICE_PART_SCAN:
+//            pBootOptions->ServicePartitionScan = 
+//                pBootOptReq->BootParam.ServicePartitionScan;
+//            /*Update in NVRAM*/
+//            g_BMCInfo.ChassisConfig.SysPartitionScan = pBootOptReq->BootParam.ServicePartitionScan;
+//            FlushIPMI((uint8_t*)&g_BMCInfo.ChassisConfig,(uint8_t*)&g_BMCInfo.ChassisConfig.SysPartitionScan,g_BMCInfo.IPMIConfLoc.ChassisConfigAddr,sizeof(uint8_t),BMCInst);
+//            break;
+//            
+//        case CHASSIS_BOOT_FLAG_VALID_BIT_CLEAR:
+//            pBootOptions->BootFlagValidBitClearing =
+//                pBootOptReq->BootParam.BootFlagValidBitClearing;
+//            break;
+
+//        case CHASSIS_BOOT_INFO_ACK:
+//            _fmemcpy (( uint8_t*)&pBootOptions->BootInfoAck,
+//                      ( uint8_t*)&pBootOptReq->BootParam.BootInfoAck,
+//                       sizeof (BootInfoAck_T));
+//            break;
+
+//        case CHASSIS_BOOT_FLAGS:
+//            u8TempData = (pBootOptReq->BootParam.BootFlags.Data2 & BIT5_BIT2_MASK);        	
+//            if((u8TempData == RESERVED_VALUE_28) ||(u8TempData == RESERVED_VALUE_30) ||(u8TempData == RESERVED_VALUE_34)||(u8TempData == RESERVED_VALUE_38))
+//            {
+//                /* Alarm !!! Somebody is trying to set Reseved Bits */
+//                *pRes = CC_INV_DATA_FIELD;
+//                OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.ChassisMutex);
+//                return sizeof (*pRes);
+//            }
+//            u8TempData = (pBootOptReq->BootParam.BootFlags.Data3 & BIT6_BIT5_MASK);
+//            if((u8TempData  == RESERVED_VALUE_60))
+//            {
+//                /* Alarm !!! Somebody is trying to set Reseved Bits */
+//                *pRes = CC_INV_DATA_FIELD;
+//                OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.ChassisMutex);
+//                return sizeof (*pRes);
+//            }
+//            u8TempData = (pBootOptReq->BootParam.BootFlags.Data3 & BIT1_BIT0_MASK);
+//            if((u8TempData  == RESERVED_VALUE_03))
+//            {
+//                /* Alarm !!! Somebody is trying to set Reseved Bits */
+//                *pRes = CC_INV_DATA_FIELD;
+//                OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.ChassisMutex);
+//                return sizeof (*pRes);
+//            }
+//            if((pBootOptReq->BootParam.BootFlags.Data5 == RESERVED_VALUE_20)||(pBootOptReq->BootParam.BootFlags.Data5 == RESERVED_VALUE_40)||(pBootOptReq->BootParam.BootFlags.Data5 == RESERVED_VALUE_80))
+//            {
+//                /* Alarm !!! Somebody is trying to set Reseved Bits */
+//                *pRes = CC_INV_DATA_FIELD;
+//                OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.ChassisMutex);
+//                return sizeof (*pRes);
+//            }
+//            _fmemcpy (( uint8_t*)&pBootOptions->BootFlags,
+//            ( uint8_t*)&pBootOptReq->BootParam.BootFlags,
+//            sizeof (BootFlags_T));
+//            break;
+
+//        case CHASSIS_BOOT_INITIATOR_INFO:
+//            _fmemcpy (( uint8_t*)&pBootOptions->BootInitiatorInfo,
+//                      ( uint8_t*)&pBootOptReq->BootParam.BootInitiatorInfo,
+//                      sizeof (BootInitiatorInfo_T));
+//            break;
+//            
+//        case CHASSIS_BOOT_INITIATOR_MBOX:
+//            if (pBootOptReq->BootParam.BootMailBox.BlockSel >= MAX_BOOT_INIT_MAILBOX_BLOCKS)
+//            {
+//                IPMI_DBG_PRINT ("\n ONLY FIVE BLOCKS ARE USED \n");
+
+//                pBootOptRes->CompletionCode = CC_INV_DATA_FIELD;
+//                OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.ChassisMutex);
+//                return sizeof(SetBootOptionsRes_T); 
+//                
+//            }
+
+//            _fmemcpy (( uint8_t*)&pBootOptions->BootMailBox[pBootOptReq->BootParam.BootMailBox.BlockSel], 
+//                      ( uint8_t*) &pBootOptReq->BootParam.BootMailBox.BootMBox,
+//                      sizeof (BootInitiatorMailbox_T));
+//            break;
+
+
+//        case CHASSIS_AMI_OEM_PARAM:
+//            _fmemcpy (( uint8_t*)&g_BMCInfo.ChassisConfig.OemBootOpt,
+//                      ( uint8_t*) &pBootOptReq->BootParam.Oem,
+//                      sizeof (AMI_BootOpt_T));
+//            FlushIPMI((uint8_t*)&g_BMCInfo.ChassisConfig,(uint8_t*)&g_BMCInfo.ChassisConfig,g_BMCInfo.IPMIConfLoc.ChassisConfigAddr,sizeof(ChassisConfig_T),BMCInst);
+//            break;
+
+//        case SSICB_OEM_PARAM_BLK_SIZE_TBL:
+//            if(SSIComputeBladeSupport)
+//            {
+//                    _fmemcpy (( uint8_t*)&pBootOptions->OemParamBlkSizeTbl,
+//                    ( uint8_t*)&pBootOptReq->BootParam.OemParamBlkSizeTbl,
+//                    sizeof(OemParamBlkSizeTbl_T));
+//                    break;
+//            }
+//            else
+//            {
+//                    pBootOptRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//                    OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.ChassisMutex);
+//                    return sizeof (SetBootOptionsRes_T);
+//            }
+//        case SSICB_BOOT_ORDER_TBL:
+//            if(SSIComputeBladeSupport)
+//            {
+//            if (pBootOptReq->BootParam.BootOrderTbl.BlockSel >= g_coremacros.ssi_bot_dev_num)
+//            {
+//                pBootOptRes->CompletionCode = CC_INV_DATA_FIELD;
+//                OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.ChassisMutex);
+//                return sizeof(uint8_t); 
+//            }
+//            _fmemcpy (( uint8_t*)&pBootOptions->BootOrderTbl[(pBootOptReq->BootParam.BootOrderTbl.BlockSel) * sizeof(BootOrderTbl_T)],
+//                        ( uint8_t*)&pBootOptReq->BootParam.BootOrderTbl,
+//                      sizeof(BootOrderTbl_T));
+//            break;
+//            }
+//            else
+//            {
+//                pBootOptRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//                OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.ChassisMutex);
+//                return sizeof (SetBootOptionsRes_T);
+//            }
+//        case SSICB_BOOT_DEV_SELECTOR:
+//            if(SSIComputeBladeSupport)
+//            {
+//                pBootOptions->BootDevSelector = pBootOptReq->BootParam.BootDevSelector;
+//                break;
+//            }
+//            else
+//            {
+//                pBootOptRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//                OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.ChassisMutex);
+//                return sizeof (SetBootOptionsRes_T);
+//            }
+//        case SSICB_SLOT_CONFIG_TBL:
+//            if(SSIComputeBladeSupport)
+//            {
+//                _fmemcpy (( uint8_t*)&pBootOptions->SlotConfigTbl,
+//                ( uint8_t*)&pBootOptReq->BootParam.SlotConfigTbl,
+//                sizeof(SlotConfigTbl_T));
+//                break;
+//            }
+//            else
+//            {
+//                pBootOptRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//                OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.ChassisMutex);
+//                return sizeof (SetBootOptionsRes_T);
+//            }
+//     default:
+//            pBootOptRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//            OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.ChassisMutex);
+//        return sizeof (SetBootOptionsRes_T);
+
+//    }
+
+//    if (0 != ROLLBACK_OPTION)
+//    {
+//        if (BMC_BOOT_OPTION_COMMIT_WRITE == (u8SetInProgress & 0x03))
+//        {
+//            /* Writing to nvRAM when "commit write" is given */
+//            FlushIPMI((uint8_t*)&g_BMCInfo.ChassisConfig,(uint8_t*)&g_BMCInfo.ChassisConfig,g_BMCInfo.IPMIConfLoc.ChassisConfigAddr,sizeof(ChassisConfig_T),BMCInst);
+//            /* Setting  this to "set complete", don't need mutex protection */
+//            pBootOptions->u8SetInProgress  = BMC_BOOT_OPTION_SET_COMPLETE;
+//        }
+//        
+//    }
+//    else
+//    {
+//        /* Since roll back feature is not provided
+//           the data is  written to nvram */
+//        FlushIPMI((uint8_t*)&g_BMCInfo.ChassisConfig,(uint8_t*)&g_BMCInfo.ChassisConfig,g_BMCInfo.IPMIConfLoc.ChassisConfigAddr,sizeof(ChassisConfig_T),BMCInst);
+//    }
+//    OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.ChassisMutex);
+
+//    pBootOptRes->CompletionCode = CC_NORMAL;
+    return sizeof(SetBootOptionsRes_T);
+}
+
+
+/*-------------------------------------
+ * GetSysBOOTOptions
+ *-------------------------------------*/
+int 
+GetSysBOOTOptions ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	printf("GetSysBOOTOptions not implement\r\n");
+//      GetBootOptionsReq_T* pGetBootOptReq = ( GetBootOptionsReq_T*) pReq;
+//      GetBootOptionsRes_T* pGetBootOptRes = ( GetBootOptionsRes_T*) pRes;
+//    BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+//    uint8_t                ParamSel,SSIComputeBladeSupport;
+//    int                  ResponseLength;
+//    BootOptions_T        sBootOptions;
+
+
+//    IPMI_DBG_PRINT ("GET SYSTEM BOOT OPTIONS\n");
+
+//    if(pGetBootOptReq->ParamSel & RESERVED_VALUE_80)
+//    {
+//        /* Alarm !!! Somebody is trying to set Reseved Bits */
+//        *pRes = CC_INV_DATA_FIELD;
+//        return sizeof (*pRes);
+//    }
+
+//    ParamSel = pGetBootOptReq->ParamSel & 0x7F;
+
+//    SSIComputeBladeSupport = g_corefeatures.ssi_support;
+
+//    /*Check for validity of parameter */
+//    if(SSIComputeBladeSupport)
+//    {
+//    if ((ParamSel >= sizeof (m_BootOptParamLen)) && (ParamSel != CHASSIS_AMI_OEM_PARAM) &&
+//        (ParamSel != SSICB_OEM_PARAM_BLK_SIZE_TBL) && (ParamSel < SSICB_BOOT_ORDER_TBL || ParamSel > SSICB_SLOT_CONFIG_TBL))
+//        {
+//            pGetBootOptRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//            return sizeof(uint8_t);
+//        }
+//    }
+//    else
+//    {
+//        if ((ParamSel >= sizeof (m_BootOptParamLen)) && (ParamSel != CHASSIS_AMI_OEM_PARAM))
+//        {
+//            pGetBootOptRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//            return sizeof(uint8_t);
+//        }
+//    }
+
+//    /*Check the validity of Setselector & Blockselector */
+//    if(SSIComputeBladeSupport)
+//    {
+//        if (((0 != pGetBootOptReq->SetSel) && (ParamSel != CHASSIS_BOOT_INITIATOR_MBOX || ParamSel != SSICB_BOOT_ORDER_TBL)) ||
+//            (ParamSel == CHASSIS_BOOT_INITIATOR_MBOX && pGetBootOptReq->SetSel >= MAX_BOOT_INIT_MAILBOX_BLOCKS) ||
+//            (ParamSel == SSICB_BOOT_ORDER_TBL && pGetBootOptReq->SetSel >= g_coremacros.ssi_bot_dev_num) ||
+//            (0 != pGetBootOptReq->BlockSel))
+//        {
+//            IPMI_DBG_PRINT ("Set Selector or Block Selector is invalid\n") ;
+//            pGetBootOptRes->CompletionCode = CC_INV_DATA_FIELD;
+//            return sizeof(uint8_t);
+//        }
+//    }
+//    else
+//    {
+//        if (((0 != pGetBootOptReq->SetSel) && (ParamSel != CHASSIS_BOOT_INITIATOR_MBOX)) ||
+//            (pGetBootOptReq->SetSel >= MAX_BOOT_INIT_MAILBOX_BLOCKS)                      ||
+//            (0 != pGetBootOptReq->BlockSel))
+//        {
+//            IPMI_DBG_PRINT ("Set Selector or Block Selector is invalid\n") ;
+//            pGetBootOptRes->CompletionCode = CC_INV_DATA_FIELD;
+//            return sizeof(uint8_t);
+//        }
+//   }
+//    pGetBootOptRes->CompletionCode  = CC_NORMAL;
+//    pGetBootOptRes->ParamVersion    = CHASSIS_PARAMETER_VERSION;
+//    pGetBootOptRes->ParameterValid  = ParamSel;
+
+//    OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo.ChassisMutex, WAIT_INFINITE);
+//    // get a local copy of the boot option from the shared memory
+//    sBootOptions = BMC_GET_SHARED_MEM(BMCInst)->sBootOptions;
+//    /*Set the Parameter valid bit if needed */
+//    if (sBootOptions.ParameterValid & (1 << ParamSel))
+//    {
+//        pGetBootOptRes->ParameterValid |= 0x80;
+//    }
+
+//    /*Set initial length of Completion code,Param revision & Paramvalid */
+//    ResponseLength = 0x03;
+
+//    /*Load the specific parameter */
+//    switch (ParamSel)
+//    {
+//        case CHASSIS_SET_INPROG :
+//            pGetBootOptRes->BootParams.SetInProgress = sBootOptions.u8SetInProgress;
+//            ResponseLength += sizeof (sBootOptions.u8SetInProgress); 
+//            break;
+
+//        case CHASSIS_SERVICE_PART_SEL:
+//            pGetBootOptRes->BootParams.ServicePartitionSelector =
+//                sBootOptions.ServicePartitionSelector;
+//            ResponseLength += sizeof (sBootOptions.ServicePartitionScan); 
+//            break;
+//    
+//        case CHASSIS_SERVICE_PART_SCAN:
+//            pGetBootOptRes->BootParams.ServicePartitionScan = g_BMCInfo.ChassisConfig.SysPartitionScan;
+//            ResponseLength += sizeof (sBootOptions.ServicePartitionScan); 
+//            break;
+//        
+//        case CHASSIS_BOOT_FLAG_VALID_BIT_CLEAR:
+//            pGetBootOptRes->BootParams.BootFlagValidBitClearing =
+//                sBootOptions.BootFlagValidBitClearing;
+//            ResponseLength += sizeof (sBootOptions.BootFlagValidBitClearing); 
+//            break;
+//    
+//        case CHASSIS_BOOT_INFO_ACK:
+//            _fmemcpy (( uint8_t*)&pGetBootOptRes->BootParams.BootInfoAck,
+//                      ( uint8_t*)&sBootOptions.BootInfoAck,
+//                      sizeof (BootInfoAck_T));
+//            pGetBootOptRes->BootParams.BootInfoAck.WriteMask = 0;
+//            ResponseLength += sizeof (BootInfoAck_T); 
+//            break;
+//               
+//        case CHASSIS_BOOT_FLAGS:
+//            _fmemcpy (( uint8_t*)&pGetBootOptRes->BootParams.BootFlags,
+//                      ( uint8_t*)&sBootOptions.BootFlags,
+//                      sizeof (BootFlags_T));
+//            ResponseLength += sizeof (BootFlags_T); 
+//            break;
+
+//        case CHASSIS_BOOT_INITIATOR_INFO:
+//            _fmemcpy (( uint8_t*)&pGetBootOptRes->BootParams.BootInitiatorInfo,
+//                      ( uint8_t*)&sBootOptions.BootInitiatorInfo,
+//                      sizeof (BootInitiatorInfo_T));
+//            ResponseLength += sizeof (BootInitiatorInfo_T); 
+//            break;
+//        
+//        case CHASSIS_BOOT_INITIATOR_MBOX:
+//			pGetBootOptRes->BootParams.BootMailBox.BlockSel = pGetBootOptReq->SetSel;
+//            _fmemcpy (( uint8_t*)&pGetBootOptRes->BootParams.BootMailBox.BootMBox,
+//                      ( uint8_t*)&sBootOptions.BootMailBox[pGetBootOptReq->SetSel],
+//                      sizeof (BootInitiatorMailbox_T));
+//            ResponseLength += sizeof (BootInitiatorMboxReq_T); 
+//            break;
+
+//        case CHASSIS_AMI_OEM_PARAM:
+//            _fmemcpy (( uint8_t*)&pGetBootOptRes->BootParams.Oem,
+//                      ( uint8_t*)&g_BMCInfo.ChassisConfig.OemBootOpt, 
+//                      sizeof (AMI_BootOpt_T));
+//            ResponseLength += sizeof (AMI_BootOpt_T); 
+//            break;
+
+//        case SSICB_OEM_PARAM_BLK_SIZE_TBL:
+//            if(SSIComputeBladeSupport)
+//            {
+//                _fmemcpy (( uint8_t*)&pGetBootOptRes->BootParams.OemParamBlkSizeTbl,
+//                          ( uint8_t*)&sBootOptions.OemParamBlkSizeTbl,
+//                          sizeof(OemParamBlkSizeTbl_T));
+//                ResponseLength += sizeof(OemParamBlkSizeTbl_T);
+//                break;
+//            }
+//            else
+//            {
+//                pGetBootOptRes->CompletionCode  = CC_PARAM_NOT_SUPPORTED ;
+//                ResponseLength  = 1 ; 
+//                break;
+//            }
+
+//        case SSICB_BOOT_ORDER_TBL:
+//            if(SSIComputeBladeSupport)
+//             {
+//            _fmemcpy (( uint8_t*)&pGetBootOptRes->BootParams.BootOrderTbl,
+//                      ( uint8_t*)&sBootOptions.BootOrderTbl[pGetBootOptReq->SetSel * sizeof(BootOrderTbl_T)],
+//                      sizeof(BootOrderTbl_T));
+//            ResponseLength += sizeof(BootOrderTbl_T);
+//            break;
+//            }
+//            else
+//            {
+//                pGetBootOptRes->CompletionCode  = CC_PARAM_NOT_SUPPORTED ;
+//                ResponseLength  = 1 ; 
+//                break;
+//            }
+
+//        case SSICB_BOOT_DEV_SELECTOR:
+//            if(SSIComputeBladeSupport)
+//            {
+//                pGetBootOptRes->BootParams.BootDevSelector = sBootOptions.BootDevSelector; 
+//                ResponseLength += sizeof(sBootOptions.BootDevSelector);
+//                break;
+//            }
+//            else
+//            {
+//                pGetBootOptRes->CompletionCode  = CC_PARAM_NOT_SUPPORTED ;
+//                ResponseLength  = 1 ; 
+//                break;
+//            }
+
+//        case SSICB_SLOT_CONFIG_TBL:
+//            if(SSIComputeBladeSupport)
+//            {
+//            _fmemcpy (( uint8_t*)&pGetBootOptRes->BootParams.SlotConfigTbl,
+//                      ( uint8_t*)&sBootOptions.SlotConfigTbl,
+//                      sizeof(SlotConfigTbl_T));
+//            ResponseLength += sizeof(SlotConfigTbl_T);
+//            break;
+//            }
+//            else
+//            {
+//                pGetBootOptRes->CompletionCode  = CC_PARAM_NOT_SUPPORTED ;
+//                ResponseLength  = 1 ; 
+//                break;
+//            }
+
+//        default :
+//        pGetBootOptRes->CompletionCode  = CC_PARAM_NOT_SUPPORTED ;
+//         ResponseLength  = 1 ; 
+//    }
+
+//    OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.ChassisMutex);
+//    return ResponseLength; 
+	return 1;
+}
+
+/*-------------------------------------
+ * SetFPButtonEnables
+ *-------------------------------------*/
+int
+SetFPButtonEnables ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	printf("SetFPButtonEnables not implement\r\n");
+//#if 0 //FQLI
+//       PMConfig_T*          pPMConfig;
+//    bool                         bRet;
+//    SetFPBtnEnablesRes_T*        pFPBtnEnablesRes = (SetFPBtnEnablesRes_T*)pRes;
+//    SetFPBtnEnablesReq_T*   pFPBtnEnablesReq = (SetFPBtnEnablesReq_T*)pReq;
+
+//    IPMI_DBG_PRINT ("PwrCtrl - SetFrontPanelEnables\n");
+//    pFPBtnEnablesRes->CompletionCode = CC_INV_CMD;
+
+//    if (pReq)
+//    {
+//        pFPBtnEnablesRes->CompletionCode = CC_NORMAL;
+
+//        // retrieve chassis status from the NVStore
+//        pPMConfig = ( PMConfig_T*)GetNVRAddr(NVRH_PMCONFIG);
+
+//        // store the front panel enables to the NVStore
+//        pPMConfig->ChassisConfig.ChassisPowerState.FPBtnEnables = pFPBtnEnablesReq->ButtonEnables;
+
+//        // enable / disable front panel buttons. do the set before store the value in case the
+//        // action fails. if failed to set the passthrough buttons, the current reading will be
+//        // used to be the current settings.
+//        bRet = PDK_SetFPEnable(&pFPBtnEnablesReq->ButtonEnables);
+//        if (bRet != TRUE)
+//        {
+//            pFPBtnEnablesRes->CompletionCode = CC_UNSPECIFIED_ERR;
+//        }
+
+//      	FlushPMC(&pPMConfig->ChassisConfig.ChassisPowerState.sFrontPanelButton, sizeof(ChassisPowerState_T));
+//    }
+
+//    return sizeof (SetFPBtnEnablesRes_T);
+
+//#else //AMI
+
+//      SetFPBtnEnablesReq_T* pFPBtnEnablesReq = ( SetFPBtnEnablesReq_T*)pReq;
+//      SetFPBtnEnablesRes_T* pFPBtnEnablesRes = ( SetFPBtnEnablesRes_T*)pRes;
+//    BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    IPMI_DBG_PRINT ("Set FP Button Enables\n");
+
+//    /* Check for the reserved bytes should b zero */
+
+//    if  ( 0 !=  (pFPBtnEnablesReq->ButtonEnables & RESERVED_BITS_SETFPBUTTONENABLES ) )
+//    {
+//        pFPBtnEnablesRes->CompletionCode = CC_INV_DATA_FIELD;
+//        return sizeof(uint8_t);	
+//    }
+
+//    OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo.ChassisMutex, WAIT_INFINITE);
+//    g_BMCInfo.ChassisConfig.ChassisPowerState.FPBtnEnables = pFPBtnEnablesReq->ButtonEnables;
+
+//    if(g_PDKHandle[PDK_FPENABLE] != NULL)
+//    {
+//        ((int(*)(uint8_t,int))g_PDKHandle[PDK_FPENABLE]) (pFPBtnEnablesReq->ButtonEnables,BMCInst);
+//    }
+
+//    /* Save in NVR */
+//    FlushIPMI((uint8_t*)&g_BMCInfo.IpmiConfig,sizeof(IPMIConfig_T));
+//    pFPBtnEnablesRes->CompletionCode = 0x00;
+
+//    return sizeof (SetFPBtnEnablesRes_T);
+//#endif //FQLI
+	return 1;
+}
+
+
+/*-------------------------------------
+ * SetPowerCycleInterval
+ *-------------------------------------*/
+int
+SetPowerCycleInterval ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{    
+    SetPowerCycleIntervalReq_T* pSetPowerCycleInterval = (SetPowerCycleIntervalReq_T*) pReq;
+    SetPowerCycleIntervalRes_T* pSetPowerCycleIntervalRes = (SetPowerCycleIntervalRes_T*) pRes;
+
+
+    g_BMCInfo.IpmiConfig.PowerCycleInterval = pSetPowerCycleInterval->PowerCycleInterval;
+
+    pSetPowerCycleIntervalRes->CompletionCode  = CC_NORMAL;
+
+    UpdateFlash();
+    return sizeof(SetPowerCycleIntervalRes_T);
+}
+
+#endif /* CHASSIS_DEVICE */

+ 14 - 14
app/bmc_server/ipmi_dev/ChassisDevice.h → app/bmc/msghndlr/Chassis/ChassisDevice.h

@@ -22,7 +22,7 @@
 #ifndef CHASSIS_DEVICE_H
 #define CHASSIS_DEVICE_H
 
-#include "Types.h"
+#include "com_BmcType.h"
 
 /*** Definitions and Macros ***/
 #define  CHASSIS_POWER_DOWN                        0x00
@@ -114,19 +114,19 @@
  * IPMI Chassis Device Command Handlers. Invoked by the message handler
  * @{
  **/
-extern int GetChassisCaps       (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetChassisStatus     (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int ChassisControl       (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int SetChassisCaps       (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int SetPowerRestorePolicy(_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetChassisIdentify   (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetSysRestartCause   (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetPOHCounter        (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int SetSysBOOTOptions    (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetSysBOOTOptions    (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int SetFPButtonEnables (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int SetPowerCycleInterval (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern void SetACPIState(INT8U State, int BMCInst);
+extern int GetChassisCaps       ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetChassisStatus     ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int ChassisControl       ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SetChassisCaps       ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SetPowerRestorePolicy( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetChassisIdentify   ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetSysRestartCause   ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetPOHCounter        ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SetSysBOOTOptions    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetSysBOOTOptions    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SetFPButtonEnables ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SetPowerCycleInterval ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern void SetACPIState(uint8_t State);
 
 
 /** @} */

+ 337 - 0
app/bmc/msghndlr/MsgHndlr.h

@@ -0,0 +1,337 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************/
+/*****************************************************************
+ *
+ * MsgHndlr.h
+ * Message Handler.
+ *
+ * Author: Govind Kothandapani <govindk@ami.com>
+ * 		 : Rama Bisa <ramab@ami.com>
+ *       : Basavaraj Astekar <basavaraja@ami.com>
+ *       : Bakka Ravinder Reddy <bakkar@ami.com>
+ *
+ *****************************************************************/
+#ifndef MSG_HNDLR_H
+#define MSG_HNDLR_H
+
+#include "com_Message.h"
+#include "com_IPMIDefs.h"
+
+#pragma pack( 1 )
+
+#define BMC_LUN_00                      0
+#define BMC_LUN_01                      1
+#define BMC_LUN_10                      2
+#define BMC_LUN_11                      3
+
+#define LOOP_BACK_REQ                     0x10
+
+#define LAN_IFC_SUP 0x0001
+#define SOL_IFC_SUP 0x0002
+#define SERIAL_IFC_SUP 0x0004
+#define AMI_DEVICE_SUP 0x0008
+#define USER_LOCKED                    1
+#define USER_UNLOCKED                0
+#define MAX_NETFN                        64
+
+// /*FLASH TYPE*/
+// #define YAFU_FLASH   1
+// #define TFTP_FLASH   2
+// #define HPM_FLASH    3
+
+
+/*Get the current cmd channel for OBSM*/
+//#define GetCurCmdChannel(BMCInst)	g_BMCInfo[BMCInst].Msghndlr.CurChannel
+
+/*-----------------------
+ * Command Handler Type
+ *----------------------*/
+typedef int (*pCmdHndlr_T) (  uint8_t* pReq, uint8_t ReqLen,   uint8_t* pRes);
+
+/*----------------------
+ * Command Handler map
+ *----------------------*/
+typedef struct
+{
+    uint8_t		Cmd;
+    uint8_t		Privilege;
+    pCmdHndlr_T	CmdHndlr;
+    uint8_t		ReqLen;		/* 0xFF - Any Length */
+    uint16_t		FFConfig;
+    uint16_t            IfcSupport;
+
+}  CmdHndlrMap_T;
+
+/*-------------------------------
+ * Extended Command Handler Type
+ *-------------------------------*/
+typedef int (*pExCmdHndlr_T) (  uint8_t* pReq, uint32_t ReqLen,   uint8_t* pRes);
+
+/*------------------------------
+ * Extended Command Handler map
+ *------------------------------*/
+typedef struct
+{
+    uint8_t		Cmd;
+    uint8_t		Privilege;
+    pExCmdHndlr_T	CmdHndlr;
+    uint8_t		ReqLen;		/* 0xFF - Any Length */
+    uint16_t		FFConfig;
+    uint16_t            IfcSupport;
+
+} ExCmdHndlrMap_T;
+
+
+
+/*-------------------------
+ * Message Handler Table
+ *-------------------------*/
+typedef struct
+{
+    uint8_t						NetFn;
+      const CmdHndlrMap_T*	CmdHndlrMap;
+
+}  MsgHndlrTbl_T;
+
+typedef struct
+{
+    uint8_t			NetFn;
+    uint8_t			GroupExtnCode;
+    const CmdHndlrMap_T*	CmdHndlrMap;
+
+} GroupExtnMsgHndlrTbl_T;
+
+
+
+
+/*-------------------------------------------------------------
+ * Pending Bridged Response Tbl Size
+ * 
+ * Do not increase beyond 60 as maximum sequence number is 64
+ *------------------------------------------------------------*/
+#define MAX_PENDING_BRIDGE_RES    64
+#define MAX_PENDING_BRIDGE_TBL    2
+#define PRIMARY_PB_TBL    0
+#define SECONDARY_PB_TBL    1
+
+typedef union
+{
+    IPMIMsgHdr_T        IPMIMsgHdr;
+    IPMIUDSMsg_T        UDSMsgHdr;
+
+}  ResMsgHdr_T;
+
+typedef struct
+{
+    uint8_t               Used;
+    uint8_t               TimeOut;
+    uint8_t               SeqNum;
+    uint8_t               ChannelNum;
+    uint8_t               DstSessionHandle;
+    uint8_t               SrcSessionHandle;
+    uint32_t              SrcSessionID;
+    int                   DestQ;
+    uint8_t               OriginSrc;
+    IPMIMsgHdr_T        ReqMsgHdr;
+    ResMsgHdr_T         ResMsgHdr;
+}    PendingBridgedResTbl_T;
+
+/*------------------------------
+ * Pending Sequence Number
+ *-----------------------------*/
+//#define		NO_IPMB_PROTOCOL_CHANNEL	3
+#define		MAX_PENDING_SEQ_NO			50
+#define		SEQ_NO_EXPIRATION_TIME		5
+
+typedef struct
+{
+    uint8_t			Used;
+    uint8_t			TimeOut;
+    uint8_t			SeqNum;
+    uint8_t			NetFn;
+    uint8_t			Cmd;
+}    PendingSeqNoTbl_T;
+
+#define MAX_IPMI_CMD_BLOCKS         3
+// typedef struct
+// {
+//     uint8_t			Channel;		/**< Originator's channel number 		*/
+//     HQueue_T		hSrcQ;			/**< Originator Queue 					*/
+//     uint8_t			Param;			/**< Parameter							*/
+//     uint8_t			Cmd;			/**< Command that needs to be processed */
+//     uint8_t			NetFnLUN;		/**< Net function and LUN of command    */
+//     uint8_t			Privilege;		/**< Current privilege level			*/
+//     uint32_t			SessionID;		/**< Session ID if any					*/
+//     uint8_t			RequestSize;						/**< Size of the Request	*/
+//     uint8_t			Request	 [MSG_PAYLOAD_SIZE];		/**< Request Data	buffer	*/
+//     uint8_t			ResponseSize;						/**< Size of the response	*/
+//     uint8_t			Response [MSG_PAYLOAD_SIZE];		/**< Response Data buffer	*/
+//       uint8_t*    pRequest;                   /**< Pointer to Request data    */
+//       uint8_t*    pResponse;                  /**< Pointer to Response data   */
+
+// }    IPMICmdMsg_T;
+
+typedef struct
+{
+    uint8_t    NetFnLUN;
+    uint32_t   SessionID;
+    int    SrcQ ;
+}   KCSBridgeResInfo_T;
+
+#pragma pack( )
+
+/*------------------ Timer Task Table --------------------------*/
+typedef void (*pTimerFn_T) (void);
+typedef struct
+{
+    uint8_t           NumSecs;
+    pTimerFn_T      TimerFn;
+
+} TimerTaskTbl_T;
+
+/*-----------------------------------------------------------
+ * Bridge Status
+ *---------------------------------------------------------*/
+#define STATUS_OK        0x0
+#define STATUS_FAIL      0x1
+
+
+/* Extern declaration */
+extern int GetCmdHndlr(MsgPkt_T* pReq,MsgPkt_T* pRes,CmdHndlrMap_T* pCmdHndlrMap,
+                                uint32_t HdrOffset,uint8_t CmdOverride,CmdHndlrMap_T** CmdHndrl );
+extern int	  GetMsgHndlrMap (uint8_t NetFn,   CmdHndlrMap_T ** pCmdHndlrMap);
+
+/**
+*@fn GroupExtnGetMsgHndlrMap
+*@brief Gets the exact command Handler by comparing NetFn
+*@param Netfn -NetFunction of the Cmd to execute
+*@GroupExtnCode - Group Extension code
+*@param pCmdHndlrMap Pointer to the Command Handler
+*/
+extern int 	  GroupExtnGetMsgHndlrMap (uint8_t NetFn, uint8_t GroupExtnCode, CmdHndlrMap_T ** pCmdHndlrMap);
+
+//extern PendingBridgedResTbl_T	m_PendingBridgedResTbl[MAX_PENDING_BRIDGE_TBL][MAX_PENDING_BRIDGE_RES];
+extern uint8_t CalculateCheckSum2 (  uint8_t* Pkt, uint32_t Len);
+extern void  SwapIPMIMsgHdr (  IPMIMsgHdr_T* pIPMIMsgReq,   IPMIMsgHdr_T* pIPMIMsgRes);
+extern void  SwapUDSIPMIMsg (  MsgPkt_T* pIPMIMsgReq,   MsgPkt_T* pIPMIMsgRes);
+
+/**
+* @fn GetIfcSupport
+* @brief This function checks the support of Interface before 
+*            Interface specific commands are executed
+* @param IfcSupt - Interface support variable to be verified
+* @param IfcSupport - Gives the Interface presence support
+*/
+//extern int GetIfcSupport(uint16_t IfcSupt,uint8_t *IfcSupport);
+
+/*------------------------
+ * Privilege Levels
+ *------------------------*/
+#define PRIV_NONE		0x00
+#define PRIV_CALLBACK	0x01
+#define PRIV_USER		0x02
+#define PRIV_OPERATOR	0x03
+#define PRIV_ADMIN		0x04
+#define PRIV_OEM		0x05
+#define PRIV_LOCAL		0x81
+#define PRIV_SYS_IFC	0x82
+
+/*------------------------------
+* Channel type used for BadPassword
+*------------------------------*/
+#define LAN_CHANNEL_BADP       0x1
+#define SERIAL_CHANNEL_BADP  0x2
+
+/*----------------------------
+ * Command Handler Example (app.c)
+ *----------------------------*/
+/*
+#ifdef	APP_DEVICE
+
+ .... Code ....
+
+const CmdHndlrMap_T	g_APP_CmdHndlr [] =
+{
+	{ CMD_GET_DEV_ID,			PRIV_USER,		GET_DEV_ID,			  0x00 },
+	{ CMD_BROADCAST_GET_DEV_ID, PRIV_LOCAL,		BROADCAST_GET_DEV_ID, 0x00 },
+	...
+	...
+	{ 0x00, 					0x00, 			0x00,				  0x00 }
+};
+
+#else
+const CmdHndlrMap_T	g_APP_CmdHndlr [] = { 0x00, 0x00, 0x00, 0x00 };
+#endif	// APP_DEVICE
+*/
+
+/*---------------------------
+ * app.h
+ *---------------------------*/
+/*
+#ifndef APP_H
+#define APP_H
+#include "MsgHndlr.h"
+
+extern const CmdHndlrMap_T g_APP_CmdHndlr [];
+
+#endif
+*/
+
+/*---------------------------------------------------
+ * Parameters passed by through the message handler Q.
+ *---------------------------------------------------*/
+// #define PARAM_IFC			        0x01
+// #define PARAM_TIMER			        0x02
+// #define PARAM_EXECUTE_SP	        0x03
+// #define PARAM_SENSOR_MONITOR        0x04
+// #define PARAM_SENSOR_MONITOR_DONE   0x05
+// #define PARAM_IFC_READY				0x06
+#define RCVMSGQ_LENGTH              100
+
+
+#define NO_RESPONSE			        0x10
+#define NORMAL_RESPONSE		        0x11
+//#define BRIDGING_REQUEST	        0x12
+
+
+/*----------------------------------------------------
+ * Receive Message Queue Names
+ *----------------------------------------------------*/
+extern   char g_RcvMsgQ [3][RCVMSGQ_LENGTH];
+
+/*------------------------------------------------------------------
+ *@fn RespondSendMessage
+ *@brief Frames the Response packet when a IPMB destination is
+ *       unavialable
+ *
+ *@param pReq:    Request Message Packet address
+ *@param Status   Status of SendIPMBPkt method
+ *@param BMCInst: BMC Instance Number
+ *
+ *@return none
+ *-----------------------------------------------------------------*/
+extern void RespondSendMessage (   MsgPkt_T* pReq, uint8_t Status);
+
+/**
+*@fn ValidateMsgHdr
+*@brief Validates the Message header and keeps track of the messages that has been bridged
+*@param pReq Request packet of the command to be executed
+*@return Returns -1 in case of the response to the bridged message
+*            Returns 0 otherwise
+*/
+extern int  ValidateMsgHdr (  MsgPkt_T* pReq);
+
+
+#endif  /* MSG_HNDLR_H */
+

+ 743 - 0
app/bmc/msghndlr/MsgHndlrTask.c

@@ -0,0 +1,743 @@
+/*
+* Brief:	Receive message from Interface and send response to original interface.
+			Process all IPMI standard command and oem command.
+* Author:	Jimbo_Zhang@outlook.com
+* Date:		2019-9-13, the Mid-autumn Festival;
+*/
+
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/prctl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <pthread.h>
+#include "MsgHndlr.h"
+#include "PDKCmds.h"
+#include "App.h"
+#include "PICMG.h"
+#include "Bridge.h"
+#include "SensorEvent.h"
+#include "Chassis.h"
+#include "Storage.h"
+#include "cmdselect.h"
+#include "com_IPMI_App.h"
+#include "com_IPMI_Storage.h"
+#include "com_IPMI_SDR.h"
+
+//#include "main.h"
+#include <string.h>
+#include "main.h"
+
+static void ProcessIPMIReq (MsgPkt_T* pReq, MsgPkt_T* pRes);
+static void PendingBridgeResTimerTask (void);
+static void PendingSeqNoTimerTask (void);
+
+
+MsgHndlrTbl_T m_MsgHndlrTbl [] =	//notice!
+{
+	{ NETFN_APP,                    g_App_CmdHndlr                  },
+	{ NETFN_CHASSIS,                g_Chassis_CmdHndlr              },
+	{ NETFN_BRIDGE,                 g_Bridge_CmdHndlr               },
+	{ NETFN_SENSOR,                 g_SensorEvent_CmdHndlr          },
+	{ NETFN_STORAGE,                g_Storage_CmdHndlr              },
+//	{ NETFN_TRANSPORT,              g_Config_CmdHndlr               },
+//	{ NETFN_AMI,                    (CmdHndlrMap_T*)g_AMI_CmdHndlr  },
+	{	0,							0	},
+};
+
+
+GroupExtnMsgHndlrTbl_T m_GroupExtnMsgHndlrTbl [] =		//jimbo add
+{
+	{0,		0},
+};
+
+
+TimerTaskTbl_T    m_TimerTaskTbl [20] =
+{
+//	{ 1,    PEFTimerTask	},
+//	{ 1,    PETAckTimerTask },
+//	{ 1,    PEFStartDlyTimerTask },
+	{ 1,    SessionTimerTask },
+	{ 1,    PendingBridgeResTimerTask },
+	{ 1,    PendingSeqNoTimerTask },
+//	{ 1,    FlashTimerTask },
+
+//	#if FRB_SUPPORT == 1
+//	{ 1,    FRB3TimerTask   },
+//	#endif /* #if FRB_SUPPORT == 1 */
+//
+//	#if SERIAL_MODEM_CONNECTION_ACTIVITY  != UNIMPLEMENTED
+//	{ 2,    SerialModemPingTask },
+//	#endif /* SERIAL_MODEM_CONNECTION_ACTIVITY */
+//
+//	{ 1,    MonitorPassword },
+	{ 1,    UDSSessionTimerTask },
+
+};
+
+//PendingBridgedResTbl_T	m_PendingBridgedResTbl[MAX_PENDING_BRIDGE_RES];
+
+PendingBridgedResTbl_T	m_PendingBridgedResTbl[MAX_PENDING_BRIDGE_TBL][MAX_PENDING_BRIDGE_RES];
+PendingSeqNoTbl_T	m_PendingSeqNoTbl[16][MAX_PENDING_SEQ_NO];
+KCSBridgeResInfo_T       m_KCSBridgeResInfo;
+int gFd_MsgHndlrIfc;
+TLS_T g_tls;
+/*!
+    \brief      Message handler Task. Process all standard and oem ipmi message form interface, and send response back.
+    \param[in]  none
+    \param[out] none
+    \retval     none
+*/
+void *MsgHndlrTask( void *pArg )
+{
+	MsgPkt_T reqMsgPkt;
+	MsgPkt_T resMsgPkt;
+	uint8_t channelinit = 0xF;
+
+	printf("MsgHndlrTask start...\r\n");
+
+	prctl(PR_SET_NAME,__FUNCTION__,0,0,0);
+
+ 	//create 
+    if(-1 != access(MSG_HNDLR_Q, F_OK))
+    {
+        remove(MSG_HNDLR_Q);
+    }
+    if(0 != mkfifo (MSG_HNDLR_Q, 0777))
+    {
+        printf("%s: Create %s fifo failed! %s\n", __FUNCTION__, MSG_HNDLR_Q, strerror(errno));
+        return (void*)-1;
+    }
+    gFd_MsgHndlrIfc = open (MSG_HNDLR_Q, O_RDWR);
+    if(-1 == gFd_MsgHndlrIfc)
+    {
+        printf("%s: Open %s fifo failed! %s\n", __FUNCTION__, MSG_HNDLR_Q, strerror(errno));
+        return (void*)-1;
+    }
+	
+	pthread_key_create(&g_tls.CurSessionID,NULL);
+	pthread_key_create(&g_tls.CurPrivLevel,NULL);
+	pthread_key_create(&g_tls.CurChannel,NULL);
+	pthread_key_create(&g_tls.CurKCSIfcNum,NULL);
+	pthread_key_create(&g_tls.CurSessionType,NULL);
+	pthread_key_create(&g_tls.OwnerLUN,NULL);
+
+	pthread_setspecific(g_tls.CurChannel,&channelinit);
+	while(1)
+	{
+		while(GetMsg(gFd_MsgHndlrIfc, &reqMsgPkt, WAIT_INFINITE) != 0);
+		printf("Mrx: ");
+		int i;
+		for(i=0;i<reqMsgPkt.Size;i++)
+			printf("%#x ", reqMsgPkt.Data[i]);
+		printf("\n");
+
+		pthread_setspecific(g_tls.CurChannel,&reqMsgPkt.Channel);
+		pthread_setspecific(g_tls.CurPrivLevel,&reqMsgPkt.Privilege);
+		pthread_setspecific(g_tls.CurSessionID,&reqMsgPkt.SessionID);
+		pthread_setspecific(g_tls.CurSessionType,&reqMsgPkt.SessionType);
+		pthread_setspecific(g_tls.OwnerLUN,&reqMsgPkt.NetFnLUN);
+
+		ProcessIPMIReq(&reqMsgPkt, &resMsgPkt);
+		
+		//update checksum2
+		resMsgPkt.Data[resMsgPkt.Size-1]	=	CalculateCheckSum2(resMsgPkt.Data, resMsgPkt.Size-1);
+		
+		//send response pkt to source queue.
+		PostMsg(resMsgPkt.SrcQ, &resMsgPkt);
+		printf("Mtx: ");
+		for(i=0;i<reqMsgPkt.Size;i++)
+			printf("%#x ", reqMsgPkt.Data[i]);
+		printf("\n");
+	}
+}
+
+/**
+*@fn ProcessIPMIReq
+*@brief Processes the requested IPMI command
+*@param pReq Request of the command
+*@param pRes Response for the requested command
+*@return none
+*/
+static void
+ProcessIPMIReq (MsgPkt_T* pReq, MsgPkt_T* pRes)
+{
+	CmdHndlrMap_T *    	pCmdHndlrMap;
+	uint32_t            HdrOffset = 0;
+	uint8_t				CmdOverride = 1;
+	int8_t 				MsgHndlrMapGot=0;
+	uint8_t              PBTbl = PRIMARY_PB_TBL;
+	
+//	msgHndlr_dbg_printf ("Processing IPMI Packet.\r\n");
+
+	/* Set the Cmd and Net function in response packet */
+	pRes->Cmd		= 	pReq->Cmd;
+	pRes->NetFnLUN	= 	pReq->NetFnLUN;
+	pRes->Channel	=	pReq->Channel;
+	pRes->SrcQ		=	pReq->SrcQ;
+	/* Normal IPMI Command response */
+	pRes->Param 	= 	PARAM_NORMAL_RESPONSE;
+	
+	HdrOffset = sizeof (IPMIMsgHdr_T);
+	pReq->Size  = pReq->Size - HdrOffset - 1;
+	
+	SwapIPMIMsgHdr((IPMIMsgHdr_T*)pReq->Data, (IPMIMsgHdr_T*)pRes->Data);
+	pRes->Size  = HdrOffset;
+
+	if(IsCommandEnabled(NET_FN(pReq->NetFnLUN), &pReq->Data[HdrOffset], pReq->Cmd) != 0)
+	{
+		pRes->Data [HdrOffset] = CC_INV_CMD;
+		printf ("Invalid Net Function 0x%x or Invalid Command 0x%x\n",NET_FN(pReq->NetFnLUN), pReq->Cmd);
+		pRes->Size	+= 2;
+		return;
+	}
+	
+	//Get oem command map
+	MsgHndlrMapGot = PDKGetOEMMsgHndlrMap(NET_FN(pReq->NetFnLUN),&pCmdHndlrMap);
+	if(MsgHndlrMapGot == 0)
+	{
+		CmdOverride = GetCmdHndlr(pReq,pRes,pCmdHndlrMap,HdrOffset,CmdOverride,&pCmdHndlrMap);
+	}	
+	//get standard ipmi command map
+	if((CmdOverride == 0 || MsgHndlrMapGot == -1) )	//OEM commands have no command map.
+    {
+		if (0 != GetMsgHndlrMap (NET_FN (pReq->NetFnLUN), &pCmdHndlrMap))
+		{
+			// if(pBMCInfo->IpmiConfig.GrpExtnSupport == 1)
+			// {
+				if (0 != GroupExtnGetMsgHndlrMap (NET_FN (pReq->NetFnLUN), pReq->Data [HdrOffset], &pCmdHndlrMap) )
+				{
+					pRes->Data [HdrOffset] = CC_INV_CMD;
+					printf ("MsgHndlr.c : Invalid Net Function 0x%x or Invalid Command 0x%x\n",NET_FN(pReq->NetFnLUN), pReq->Cmd);
+					pRes->Size	+= 2;
+					return;
+				}
+			// }
+			// else
+			// {
+			// 	pRes->Data [HdrOffset] = CC_INV_CMD;
+			// 	printf ("MsgHndlr.c : Invalid Net Function 0x%x\n",NET_FN(pReq->NetFnLUN));
+			// 	pRes->Size	+= 2;
+			// 	return;
+			// }
+		}
+
+		if(GetCmdHndlr(pReq,pRes,pCmdHndlrMap,HdrOffset,CmdOverride,&pCmdHndlrMap) == FALSE)
+		{
+			pRes->Data [HdrOffset] = CC_INV_CMD;
+			pRes->Size	+= 2;
+			return;
+		}
+   }
+   
+	/* Check for the request size */
+	if (0xff != pCmdHndlrMap->ReqLen)
+	{
+		/* Check for invalid request size */
+		if (pCmdHndlrMap->ReqLen != pReq->Size)
+		{	
+			printf("Warning: Request data len error, require %d\n", pCmdHndlrMap->ReqLen);
+			pRes->Data [HdrOffset] = CC_REQ_INV_LEN;
+			pRes->Size	+= 2;
+			return;
+		}
+	}
+	
+	pRes->Size 	= 	pCmdHndlrMap->CmdHndlr (&pReq->Data [HdrOffset], pReq->Size, &pRes->Data [HdrOffset]) + HdrOffset + 1;
+	
+	// //Patch for sensor Owner ID not equal IPMB address bug.
+	// if((NET_FN(pReq->NetFnLUN) == NETFN_STORAGE) && (pReq->Cmd == CMD_GET_SDR) 
+	// 	&& (((GetSDRReq_T*)&pReq->Data[6])->Offset == 5) && (pRes->Data [HdrOffset] == CC_NORMAL))
+	// {
+	// 	pRes->Data [HdrOffset+3] = ((IPMIMsgHdr_T*)(pReq->Data))->ResAddr;	//modify sensor owner id
+	// }
+	
+	//send message command
+	if( (CMD_SEND_MSG == pReq->Cmd) && (NETFN_APP == pReq->NetFnLUN >> 2))
+	{
+		int Offset = 0;
+		uint8_t SeqNum = g_BMCInfo.SendMsgSeqNum;
+		if ((0 == pRes->Size) &&
+			((g_BMCInfo.IpmiConfig.PrimaryIPMBSupport == 0x01  && PRIMARY_IPMB_CHANNEL == pRes->Channel) || 
+			 (g_BMCInfo.IpmiConfig.SecondaryIPMBSupport == 0x01 && SECONDARY_IPMB_CHANNEL == pRes->Channel)) )
+		{
+			pRes->Param = PARAM_NO_RESPONSE;
+			Offset = HdrOffset + 2;
+		}
+		else if (HdrOffset == pRes->Size)
+		{
+			Offset = HdrOffset + 1;
+		}
+
+	    PBTbl = ( ((pReq->Data[sizeof (IPMIMsgHdr_T)] & 0x0F) == SECONDARY_IPMB_CHANNEL) ? SECONDARY_PB_TBL : PRIMARY_PB_TBL );
+		while(TRUE)
+		{ 
+			if ( (TRUE == m_PendingBridgedResTbl[PBTbl][SeqNum].Used) &&
+				(0 == memcmp (&m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr, &pReq->Data[Offset], sizeof (IPMIMsgHdr_T))) )
+			{
+				 memcpy (&m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr, pRes->Data, sizeof (IPMIMsgHdr_T));
+				 break;    
+			}
+			else
+			{
+				SeqNum = (SeqNum - 1) & 0x3F;
+				if(SeqNum == g_BMCInfo.SendMsgSeqNum)
+				{
+					break; 
+				}
+			}
+		}
+	}
+	
+	return;
+}
+
+/**
+*@fn CalculateChecksum2
+*@brief Calculates the checksum
+*@param Pkt Pointer to the data for the checksum to be calculated
+*@param Len Size of data for checksum calculation
+*@return Returns the checksum value
+*/
+uint8_t CalculateCheckSum2 (uint8_t* Pkt, uint32_t Len)
+{
+	uint8_t	Sum;
+	uint32_t	i;
+
+	/* Get Checksum 2 */
+	Sum = 0;
+	for (i = 3; i < Len; i++)
+	{
+		Sum += Pkt [i];
+	}
+	return (uint8_t)(0xFF & (0x100 - Sum));
+}
+
+
+/**
+*@fn GetMsgHndlrMap
+*@brief Gets the exact command Handler by comparing NetFn
+*@param Netfn -NetFunction of the Cmd to execute
+*@param pCmdHndlrMap Pointer to the Command Handler
+*@return Returns 0 on success
+*            Returns -1 on failure
+*/
+int
+GetMsgHndlrMap (uint8_t NetFn, CmdHndlrMap_T ** pCmdHndlrMap)
+{
+	int i;
+
+	/* Get the command handler corresponding to the net function */
+	for (i = 0; i <  sizeof(m_MsgHndlrTbl)/sizeof(m_MsgHndlrTbl[0]); i++)		//pBMCInfo->MsgHndlrTblSize 
+	{
+		if (m_MsgHndlrTbl [i].NetFn == NetFn) { break; }
+	}
+
+	/* Check if we have not found our net function */
+	if (i ==  sizeof(m_MsgHndlrTbl)/sizeof(m_MsgHndlrTbl[0]) )
+	{
+		return -1;
+	}
+
+	/* Get the handler corresponding to the command */
+	*pCmdHndlrMap = (CmdHndlrMap_T*)m_MsgHndlrTbl [i].CmdHndlrMap;
+	return 0;
+}
+
+/**
+*@fn GetCmdHndlr
+*@brief Picks up the exact command to execute by comparing Cmd no.
+*@param pReq Request buffer for the command
+*@param pRes Response buffer for the command
+*@param pCmdHndlrMap
+*@param HdrOffset
+*@param CmdOverride
+*@param CmdHndlr
+*@return Returns TRUE on success
+*            Returns FALSE on failure
+*/
+int GetCmdHndlr(MsgPkt_T* pReq,MsgPkt_T* pRes,CmdHndlrMap_T* pCmdHndlrMap,
+								uint32_t HdrOffset,uint8_t CmdOverride,CmdHndlrMap_T** CmdHndrl )
+{
+	int i=0;
+	while (1)
+	{
+		/**
+		* If we reached the end of the Command Handler map - invalid command
+		**/
+		if (0 == pCmdHndlrMap->CmdHndlr)
+		{
+			if(CmdOverride == FALSE)
+			{
+				pRes->Data [HdrOffset] = CC_INV_CMD;
+				printf( "Warning: MsgHndlr.c : Invalid Command %#x\r\n", pReq->Cmd );
+			}
+			return FALSE;
+		}
+
+		if (pCmdHndlrMap->Cmd == pReq->Cmd)
+		{
+			break;
+		}
+		
+		i++;
+		pCmdHndlrMap++;
+
+	}
+	*CmdHndrl = pCmdHndlrMap;
+	return TRUE;
+}
+
+/**
+*@fn GroupExtnGetMsgHndlrMap
+*@brief Gets the exact command Handler by comparing NetFn
+*@param Netfn -NetFunction of the Cmd to execute
+*@GroupExtnCode - Group Extension code
+*@param pCmdHndlrMap Pointer to the Command Handler
+*@return Returns 0 on success
+*            Returns -1 on failure
+*/
+int
+GroupExtnGetMsgHndlrMap (uint8_t NetFn, uint8_t GroupExtnCode, CmdHndlrMap_T ** pCmdHndlrMap)
+{
+	int i;
+
+	/* Get the command handler corresponding to the net function */
+	for (i = 0; i < sizeof (m_GroupExtnMsgHndlrTbl) / sizeof (m_GroupExtnMsgHndlrTbl [0]); i++)
+	{
+		if ((m_GroupExtnMsgHndlrTbl [i].NetFn == NetFn) && (m_GroupExtnMsgHndlrTbl [i].GroupExtnCode == GroupExtnCode)) 
+		{
+			break; 
+		}
+	}
+
+	/* Check if we have not found our net function */
+	if (i == sizeof (m_GroupExtnMsgHndlrTbl) / sizeof (m_GroupExtnMsgHndlrTbl[0]))
+	{
+		return -1;
+	}
+
+//	printf("---> GroupExtnGetMsgHndlrMap successful, i=%d\n",i);
+	/* Get the handler corresponding to the command */
+	*pCmdHndlrMap = (CmdHndlrMap_T*)m_GroupExtnMsgHndlrTbl [i].CmdHndlrMap;
+	return 0;
+}
+
+/*------------------------------------------------------------------
+ *@fn RespondSendMessage
+ *@brief Frames the Response packet when a IPMB destination is
+ *       unavialable
+ *
+ *@param pReq:    Request Message Packet address
+ *@param Status   Status of SendIPMBPkt method
+ *@param BMCInst: BMC Instance Number
+ *
+ *@return none
+ *-----------------------------------------------------------------*/
+void RespondSendMessage ( MsgPkt_T* pReq, uint8_t Status)
+{
+	uint8_t PBTbl = PRIMARY_PB_TBL;
+
+	MsgPkt_T   ResPkt;
+	IPMIMsgHdr_T*  pIPMIResHdr = ( IPMIMsgHdr_T*)ResPkt.Data;
+	IPMIMsgHdr_T*  pIPMIReqHdr = ( IPMIMsgHdr_T*)pReq->Data;
+	uint8_t SeqNum = NET_FN(pIPMIReqHdr->RqSeqLUN);
+	int QueueFd;
+	
+  /* Check for pending responses */
+	PBTbl = ( (pReq->Channel == SECONDARY_IPMB_CHANNEL) ? SECONDARY_PB_TBL : PRIMARY_PB_TBL );
+	if ( (TRUE == m_PendingBridgedResTbl[PBTbl][SeqNum].Used) &&
+		 (NET_FN(pIPMIReqHdr->RqSeqLUN)  == SeqNum) &&
+		 (NET_FN(pIPMIReqHdr->NetFnLUN)  == NET_FN(m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.NetFnLUN )) &&
+		 (pIPMIReqHdr->Cmd               == m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.Cmd) &&
+		 (pIPMIReqHdr->ResAddr           == m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.ResAddr)  )
+	{
+		
+		memcpy (pIPMIResHdr, &m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr.IPMIMsgHdr, sizeof (IPMIMsgHdr_T));
+		 
+			
+		 if (STATUS_OK == Status)
+		 {
+			if ( ( m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFd_PrimaryIpmbIfcQ) ||
+				 (m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFd_SecondaryIpmbIfcQ) ||
+				 (ORIGIN_SENDMSG != m_PendingBridgedResTbl[PBTbl][SeqNum].OriginSrc) )
+			{    
+				 return;
+			}
+				
+			ResPkt.Data [sizeof(IPMIMsgHdr_T)] = CC_NORMAL;
+		 }
+		 else if (STATUS_FAIL == Status)
+		 {
+			ResPkt.Data [sizeof(IPMIMsgHdr_T)] = CC_NO_ACK_FROM_SLAVE;
+		 }
+		 else
+		 {
+			ResPkt.Data [sizeof(IPMIMsgHdr_T)] = CC_UNSPECIFIED_ERR;
+		 }
+
+		 ResPkt.Size = sizeof (IPMIMsgHdr_T) + 1 + 1; // IPMI Header + Completion Code + Second Checksum
+		 ResPkt.Cmd = pIPMIResHdr->Cmd;
+		 ResPkt.NetFnLUN = pIPMIReqHdr->NetFnLUN;
+		 ResPkt.Channel = pReq->Channel;
+
+		 /* Calculate the Second CheckSum */
+		 ResPkt.Data[ResPkt.Size - 1] = CalculateCheckSum2 (ResPkt.Data, ResPkt.Size-1);
+
+		 ResPkt.Param = BRIDGING_REQUEST;
+
+		 if (m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFd_LanIfcQ)
+		 {
+			 QueueFd = gFd_LanResQ;
+		 }
+		 // else if (0 == strcmp ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ, SerialQueueName))
+		 // {
+			//  //ResPkt.SessionID = m_PendingBridgedResTbl[i].ResMsgHdr.RqSeqLUN;
+			//  strcpy (QueueName, SERIAL_RES_Q);
+		 // }
+		 else if ( (m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFd_PrimaryIpmbIfcQ) ||
+				   (m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFd_SecondaryIpmbIfcQ) )
+		 {
+		 	QueueFd = m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ;
+		 }
+		 else
+		 {
+			 /* PDK Hook to format Pending Bridge Response Packet for other destinations */
+			// if(g_PDKHandle[PDK_FORMATBRIDGERESPKT] != NULL)
+			 {
+				  SwapIPMIMsgHdr ( pIPMIReqHdr, pIPMIResHdr);
+				  
+			//	  ( (void (*)(MsgPkt_T *, int) ) g_PDKHandle[PDK_FORMATBRIDGERESPKT]) ( &ResPkt, BMCInst);
+			 }     
+		   
+		   	QueueFd = m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ;
+		 }
+
+		 if (STATUS_OK != Status)
+		 {
+			 m_PendingBridgedResTbl[PBTbl][SeqNum].Used = FALSE;
+		 }
+		 
+		 /* Post the data to Destination Interface queue */
+		 PostMsg (QueueFd, &ResPkt);
+
+	}
+}
+
+
+/**
+*@fn PendingBridgeResTimerTask
+*@brief Sends the timeout message to response queue
+*          if the message does not turn out within send message timeout
+*@return none
+*/
+static void
+PendingBridgeResTimerTask (void)
+{
+	uint8_t		i;
+	uint8_t     PBTbl = PRIMARY_PB_TBL;
+	int 		QueueFd = 0;
+	printf("-> PendingBridgeResTimerTask\n");
+	/* Check for any pending responses */
+	for( PBTbl=0; PBTbl < MAX_PENDING_BRIDGE_TBL; PBTbl++)
+	{
+		for (i = 0; i < sizeof (m_PendingBridgedResTbl[0])/sizeof (m_PendingBridgedResTbl[0][0]); i++)
+		{
+			if (TRUE == m_PendingBridgedResTbl[PBTbl][i].Used)
+			{
+				m_PendingBridgedResTbl[PBTbl][i].TimeOut--;
+				if (0 == m_PendingBridgedResTbl[PBTbl][i].TimeOut)
+				{
+				   MsgPkt_T		Timeout;
+				   IPMIMsgHdr_T*   pIPMIMsgHdr  = (IPMIMsgHdr_T*) Timeout.Data;
+
+				   /* Fill the response packet */
+				   SwapIPMIMsgHdr (&m_PendingBridgedResTbl[PBTbl][i].ReqMsgHdr, pIPMIMsgHdr);
+
+				   // slog(LANQueueName,"%s%d",LAN_IFC_Q,BMCInst);
+				   // sprintf(PrimaryIPMBQueueName,"%s%d",IPMB_PRIMARY_IFC_Q,BMCInst);
+				   // sprintf(SecondaryIPMBQueueName,"%s%d",IPMB_SECONDARY_IFC_Q,BMCInst);
+				   // sprintf(SerialQueueName,"%s%d",SERIAL_IFC_Q,BMCInst);
+
+				   if(PBTbl == PRIMARY_PB_TBL)
+				   {
+					   pIPMIMsgHdr->ReqAddr = g_BMCInfo.IpmiConfig.PrimaryIPMBAddr;
+				   }
+				   else if(PBTbl == SECONDARY_PB_TBL)
+				   {
+					   pIPMIMsgHdr->ReqAddr = g_BMCInfo.IpmiConfig.SecondaryIPMBAddr;
+				   }
+				   else
+				   {
+					   printf("Invalid PBTbl\n");;//pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
+				   }
+
+				   Timeout.Data [sizeof(IPMIMsgHdr_T)] = CC_TIMEOUT;
+
+				   Timeout.Size = sizeof (IPMIMsgHdr_T) + 1 + 1; // IPMI Header + Completion Code + Second Checksum
+
+				   /* Calculate the Second CheckSum */
+				   Timeout.Data[Timeout.Size - 1] = CalculateCheckSum2 (Timeout.Data, Timeout.Size-1);
+
+				   Timeout.Param = BRIDGING_REQUEST;
+
+				   if (m_PendingBridgedResTbl[PBTbl][i].DestQ == gFd_LanIfcQ)
+				   {
+					   int j;
+					   for (j = Timeout.Size - 1; j >= 0; --j)
+					   {
+						   Timeout.Data [j+1] = Timeout.Data [j];
+					   }
+
+					   Timeout.Data[0] = m_PendingBridgedResTbl[PBTbl][i].SrcSessionHandle;
+					   Timeout.Size++;
+					   Timeout.Cmd = PAYLOAD_IPMI_MSG;
+					   QueueFd = gFd_LanIfcQ;
+					}
+				   // else if (0 == strcmp ((char *)m_PendingBridgedResTbl[PBTbl][i].DestQ, SerialQueueName))
+				   // {
+					  //  int j;
+					  //  for (j = Timeout.Size - 1; j >= 0; --j)
+					  //  {
+						 //   Timeout.Data [j+1] = Timeout.Data [j];
+					  //  }
+
+					  //  Timeout.Data[0] = m_PendingBridgedResTbl[PBTbl][i].SrcSessionHandle;
+					  //  Timeout.Size++;
+					  //  Timeout.Cmd = PAYLOAD_IPMI_MSG;
+					  //  strcpy(QueueName, SERIAL_IFC_Q);
+				   // }
+				   else if (g_BMCInfo.IpmiConfig.PrimaryIPMBSupport == 1 && m_PendingBridgedResTbl[PBTbl][i].DestQ == gFd_PrimaryIpmbIfcQ)
+					{
+					   int j;
+					   for (j = Timeout.Size - 1; j >= 0; --j)
+					   {
+						   Timeout.Data [j + sizeof (IPMIMsgHdr_T) + 1] = Timeout.Data [j];
+					   }
+					   memcpy (Timeout.Data, &m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr, sizeof (IPMIMsgHdr_T));
+					   Timeout.Data[sizeof (IPMIMsgHdr_T)] = CC_NORMAL;
+					   Timeout.Size++;
+					   QueueFd = gFd_PrimaryIpmbIfcQ;
+
+					 }
+					 else if (g_BMCInfo.IpmiConfig.SecondaryIPMBSupport == 1 && m_PendingBridgedResTbl[PBTbl][i].DestQ == gFd_SecondaryIpmbIfcQ)
+					 {
+						int j;
+						for (j = Timeout.Size - 1; j >= 0; --j)
+						{
+							Timeout.Data [j + sizeof (IPMIMsgHdr_T) + 1] = Timeout.Data [j];
+						}
+						memcpy (Timeout.Data, &m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.IPMIMsgHdr, sizeof (IPMIMsgHdr_T));
+						Timeout.Data[sizeof (IPMIMsgHdr_T)] = CC_NORMAL;
+						Timeout.Size++;
+						QueueFd = gFd_SecondaryIpmbIfcQ;
+					 }
+					 else if (m_PendingBridgedResTbl[PBTbl][i].DestQ = gFdUdsIfc)
+					 {
+						 int j;
+						 UDSSessionTbl_T *pUDSSessionInfo = NULL;
+						 for (j = sizeof (IPMIMsgHdr_T); j < Timeout.Size ;j++)
+						 {
+							Timeout.Data [j + sizeof (IPMIUDSMsg_T)-sizeof (IPMIMsgHdr_T)] = Timeout.Data [j];
+						 }
+						 Timeout.Size = Timeout.Size + sizeof (IPMIUDSMsg_T)- sizeof (IPMIMsgHdr_T);
+						 
+						 m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.UDSMsgHdr.IPMIMsgLen = Timeout.Size;
+						 memcpy (Timeout.Data, &m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.UDSMsgHdr, sizeof (IPMIUDSMsg_T));
+						 Timeout.NetFnLUN = m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.UDSMsgHdr.NetFnLUN;
+						 Timeout.SessionID = m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.UDSMsgHdr.SessionID;
+						 Timeout.Cmd = m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.UDSMsgHdr.Cmd;
+						 
+						 pUDSSessionInfo = GetUDSSessionInfo (UDS_SESSION_ID_INFO,&Timeout.SessionID);
+						 if(pUDSSessionInfo != NULL)
+						 {
+							 Timeout.Socket = pUDSSessionInfo->UDSSocket;
+						 }
+						 QueueFd = m_PendingBridgedResTbl[PBTbl][i].DestQ;
+					 }
+					 else 
+					 {
+						int j;
+						for (j = Timeout.Size - 1; j >= 0; --j)
+						{
+						   Timeout.Data [j + sizeof (IPMIMsgHdr_T) + 1] = Timeout.Data [j];
+						}
+						memcpy (Timeout.Data, &m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.IPMIMsgHdr, sizeof (IPMIMsgHdr_T));
+						Timeout.Data[sizeof (IPMIMsgHdr_T)] = CC_TIMEOUT;
+						QueueFd = m_PendingBridgedResTbl[PBTbl][i].DestQ;
+					 }
+
+					  /* Post the data to Destination Interface queue */
+					  PostMsg (QueueFd, &Timeout);
+
+					  m_PendingBridgedResTbl[PBTbl][i].Used = FALSE;
+					  printf( "MsgHndlr: clean pending index = %d.\n", i );
+				}
+		   }
+		}
+	}
+}
+
+
+/**
+*@fn PendingSeqNoTimerTask
+*@brief Timertask which helpful in IPMB sequence number validation
+*@return none
+*/
+static void
+PendingSeqNoTimerTask (void)
+{
+	uint8_t	i,j;
+	printf("-> PendingSeqNoTimerTask\n");
+	/* Check for any Sequence Number expiraied */
+	for (i = 0; i < sizeof (m_PendingSeqNoTbl)/sizeof (m_PendingSeqNoTbl[0]); i++)
+	{
+		for (j = 0; j < sizeof (m_PendingSeqNoTbl[0])/sizeof (m_PendingSeqNoTbl[0][0]); j++)
+		{
+			if (TRUE == m_PendingSeqNoTbl[i][j].Used)
+			{
+				m_PendingSeqNoTbl[i][j].TimeOut--;
+				if (0 == m_PendingSeqNoTbl[i][j].TimeOut)
+				{
+					m_PendingSeqNoTbl[i][j].Used = FALSE;
+				}
+			}
+		}
+	}
+}
+
+
+/**
+*@fn SwapIPMIMsgHdr
+*@brief Swaps the header and copies into response
+*@param pIPMIMsgReq Header of the Request
+*@param pIPMIMsgRes Header of the response
+*@return none
+*/
+void
+SwapIPMIMsgHdr (IPMIMsgHdr_T* pIPMIMsgReq, IPMIMsgHdr_T* pIPMIMsgRes)
+{
+	pIPMIMsgRes->ResAddr   = pIPMIMsgReq->ReqAddr;
+	pIPMIMsgRes->NetFnLUN  = (pIPMIMsgReq->NetFnLUN & 0xFC) + 0x04;
+	pIPMIMsgRes->NetFnLUN |= pIPMIMsgReq->RqSeqLUN & 0x03;
+
+	/* Calculate the Checksum for above two bytes */
+	pIPMIMsgRes->ChkSum   = (~(pIPMIMsgRes->ResAddr + pIPMIMsgRes->NetFnLUN) + 1);
+
+	pIPMIMsgRes->ReqAddr  = pIPMIMsgReq->ResAddr;
+
+	pIPMIMsgRes->RqSeqLUN = (pIPMIMsgReq->RqSeqLUN & 0xFC);
+	pIPMIMsgRes->RqSeqLUN |= (pIPMIMsgReq->NetFnLUN & 0x03);
+
+	pIPMIMsgRes->Cmd = pIPMIMsgReq->Cmd;
+
+	return;
+}
+
+

+ 10 - 0
app/bmc/msghndlr/MsgHndlrTask.h

@@ -0,0 +1,10 @@
+
+#ifndef __MSG_HNDLR_TASK_H__
+#define __MSG_HNDLR_TASK_H__
+
+
+void *MsgHndlrTask( void *pArg );
+
+
+
+#endif /* __MSG_HNDLR_TASK_H__ */

+ 1711 - 0
app/bmc/msghndlr/OemSMMCmds/OemSMMCmds.c

@@ -0,0 +1,1711 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2008, American Megatrends Inc.             **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ *
+ * OemCmdhndlr.c
+ * Oem Commands used  by SMM Channel
+ *
+ * Author: Anurag Bhatia <anuragb@ami.com>
+ *         Vinesh Chirstopher <vineshc@ami.com>
+ *
+ *****************************************************************/
+
+#include <string.h>
+#include "OemSMMCmds.h"
+#include "com_BmcType.h"
+#include "main.h"
+
+int  SMMExample_0h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	printf("SMMExample_0h\n" );
+	return 	1;
+}
+
+int  SMMExample_1h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	printf("SMMExample_1h\n" );
+	return 	1;
+}
+
+
+int SMMExample_2h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	printf("SMMExample_2h\n" );
+	return 1;
+
+}
+
+int SMMExample_3h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{	
+	*pRes= CC_NORMAL;
+	printf("SMMExample_3h\n" );
+	return 	1;
+}
+
+
+int SMMExample_4h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+
+int SMMExample_5h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;										
+}
+
+
+int SMMExample_6h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;											
+}
+ 
+
+int SMMExample_7h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+ 
+
+int SMMExample_8h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;
+}
+
+
+int SMMExample_9h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int SMMExample_ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{							
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+
+int SMMExample_bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;		
+}
+
+
+int SMMExample_fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int  SMMExample_10h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int  SMMExample_11h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_12h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 1;
+
+}
+
+int SMMExample_13h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{	
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_14h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+
+int SMMExample_15h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;										
+}
+
+
+int SMMExample_16h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;											
+}
+ 
+
+int SMMExample_17h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+ 
+
+int SMMExample_18h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;
+}
+
+
+int SMMExample_19h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int SMMExample_1ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{							
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+
+int SMMExample_1bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_1ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_1dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_1eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;		
+}
+
+
+int SMMExample_1fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int  SMMExample_20h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int  SMMExample_21h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_22h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 1;
+
+}
+
+int SMMExample_23h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{	
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_24h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+
+int SMMExample_25h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;										
+}
+
+
+int SMMExample_26h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;											
+}
+ 
+
+int SMMExample_27h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+ 
+
+int SMMExample_28h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;
+}
+
+
+int SMMExample_29h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int SMMExample_2ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{							
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+
+int SMMExample_2bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_2ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_2dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_2eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;		
+}
+
+
+int SMMExample_2fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int  SMMExample_30h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int  SMMExample_31h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_32h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 1;
+
+}
+
+int SMMExample_33h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{	
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_34h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int SMMExample_35h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;										
+}
+
+
+int SMMExample_36h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;											
+}
+ 
+
+int SMMExample_37h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+ 
+
+int SMMExample_38h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;
+}
+
+
+int SMMExample_39h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int SMMExample_3ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{							
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+
+int SMMExample_3bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_3ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_3dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_3eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;		
+}
+
+
+int SMMExample_3fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int  SMMExample_40h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int  SMMExample_41h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_42h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 1;
+
+}
+
+int SMMExample_43h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{	
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_44h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+
+int SMMExample_45h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;										
+}
+
+
+int SMMExample_46h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;											
+}
+ 
+
+int SMMExample_47h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+ 
+
+int SMMExample_48h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;
+}
+
+
+int SMMExample_49h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int SMMExample_4ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{							
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+
+int SMMExample_4bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_4ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_4dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_4eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;		
+}
+
+
+int SMMExample_4fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int  SMMExample_50h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int  SMMExample_51h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_52h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 1;
+
+}
+
+int SMMExample_53h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{	
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_54h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+
+int SMMExample_55h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;										
+}
+
+
+int SMMExample_56h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;											
+}
+ 
+
+int SMMExample_57h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+ 
+
+int SMMExample_58h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;
+}
+
+
+int SMMExample_59h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int SMMExample_5ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{							
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+
+int SMMExample_5bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_5ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_5dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_5eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;		
+}
+
+
+int SMMExample_5fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int  SMMExample_60h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int  SMMExample_61h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_62h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 1;
+
+}
+
+int SMMExample_63h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{	
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_64h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+
+int SMMExample_65h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;										
+}
+
+
+int SMMExample_66h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;											
+}
+ 
+
+int SMMExample_67h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+ 
+
+int SMMExample_68h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;
+}
+
+
+int SMMExample_69h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int SMMExample_6ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{							
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+
+int SMMExample_6bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_6ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_6dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_6eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;		
+}
+
+
+int SMMExample_6fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int  SMMExample_70h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int  SMMExample_71h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_72h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 1;
+
+}
+
+int SMMExample_73h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{	
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_74h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+
+int SMMExample_75h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;										
+}
+
+
+int SMMExample_76h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;											
+}
+ 
+
+int SMMExample_77h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+ 
+
+int SMMExample_78h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;
+}
+
+
+int SMMExample_79h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int SMMExample_7ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{							
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+
+int SMMExample_7bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_7ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_7dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_7eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;		
+}
+
+
+int SMMExample_7fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+/********************** storlead oem command ********************************/
+//
+int SMMExample_80h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	return 1;
+} 
+
+//
+int SMMExample_81h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+
+	return 1;
+} 
+
+//GetIPMCCapability
+int SMMExample_82h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{	
+	return 1;
+} 
+
+int SMMExample_83h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+			
+	return 1;	
+} 
+
+
+//reserved
+int SMMExample_84h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	pRes[0] = CC_NORMAL;
+	return 1;	
+} 
+
+//
+int SMMExample_85h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	
+	return 1;	
+} 
+//
+int SMMExample_86h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	
+	return 1;	
+} 
+//
+int SMMExample_87h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	return 1;	
+} 
+
+int SMMExample_88h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	return 1;
+} 
+
+int SMMExample_89h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	return 1;
+} 
+
+int SMMExample_8ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	return 1;	
+} 
+
+int SMMExample_8bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{	
+	return 1;	
+} 
+
+//
+int SMMExample_8ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes) 
+{
+
+ return 1;    
+} 
+
+int SMMExample_8dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes) 
+{
+	return 1;
+} 
+
+int SMMExample_8eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	*pRes= CC_NORMAL;
+	return sizeof (*pRes);	
+} 
+
+
+int SMMExample_8fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+
+	return 1;	
+} 
+
+
+int SMMExample_90h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+
+	return 1;	
+} 
+
+
+int SMMExample_91h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+
+	return 1;	
+}
+
+
+int SMMExample_92h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	
+	return 1;
+} 
+
+int SMMExample_93h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+
+	return 1;
+} 
+
+
+int SMMExample_94h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+
+	return 1;	
+} 
+
+int SMMExample_95h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	*pRes= CC_NORMAL;
+	return sizeof (*pRes);	
+} 
+
+int SMMExample_96h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	*pRes= CC_NORMAL;
+	return sizeof (*pRes);	
+} 
+
+int SMMExample_97h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	*pRes= CC_NORMAL;
+	return sizeof (*pRes);	
+} 
+
+int SMMExample_98h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	*pRes= CC_NORMAL;
+	return sizeof (*pRes);	
+} 
+
+int SMMExample_99h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	*pRes= CC_NORMAL;
+	return sizeof (*pRes);	
+} 
+
+int SMMExample_9ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	*pRes= CC_NORMAL;
+	return sizeof (*pRes);	
+} 
+
+int SMMExample_9bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	*pRes= CC_NORMAL;
+	return sizeof (*pRes);	
+} 
+
+int SMMExample_9ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	*pRes= CC_NORMAL;
+	return sizeof (*pRes);	
+} 
+
+int SMMExample_9dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	*pRes= CC_NORMAL;
+	return sizeof (*pRes);	
+} 
+
+int SMMExample_9eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+	*pRes= CC_NORMAL;
+	return 1;	
+} 
+
+int SMMExample_9fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{
+
+	return 1;	
+} 
+
+/******************************************************************************/
+
+int  SMMExample_a0h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int  SMMExample_a1h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_a2h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 1;
+
+}
+
+int SMMExample_a3h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{	
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_a4h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+
+int SMMExample_a5h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;										
+}
+
+
+int SMMExample_a6h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;											
+}
+ 
+
+int SMMExample_a7h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+ 
+
+int SMMExample_a8h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;
+}
+
+
+int SMMExample_a9h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int SMMExample_aah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{							
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+
+int SMMExample_abh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_ach( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_adh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_aeh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;		
+}
+
+
+int SMMExample_afh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int  SMMExample_b0h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int  SMMExample_b1h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_b2h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 1;
+
+}
+
+int SMMExample_b3h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{	
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_b4h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+
+int SMMExample_b5h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;										
+}
+
+
+int SMMExample_b6h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;											
+}
+ 
+
+int SMMExample_b7h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+ 
+
+int SMMExample_b8h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;
+}
+
+
+int SMMExample_b9h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int SMMExample_bah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{							
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+
+int SMMExample_bbh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_bch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_bdh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_beh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;		
+}
+
+
+int SMMExample_bfh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int  SMMExample_c0h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int  SMMExample_c1h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_c2h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 1;
+
+}
+
+int SMMExample_c3h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{	
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_c4h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+
+int SMMExample_c5h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;										
+}
+
+
+int SMMExample_c6h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;											
+}
+ 
+
+int SMMExample_c7h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+ 
+
+int SMMExample_c8h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;
+}
+
+
+int SMMExample_c9h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int SMMExample_cah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{							
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+
+int SMMExample_cbh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_cch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_cdh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_ceh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;		
+}
+
+
+int SMMExample_cfh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int  SMMExample_d0h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int  SMMExample_d1h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_d2h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 1;
+
+}
+
+int SMMExample_d3h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{	
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_d4h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+
+int SMMExample_d5h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;										
+}
+
+
+int SMMExample_d6h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;											
+}
+ 
+
+int SMMExample_d7h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+ 
+
+int SMMExample_d8h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;
+}
+
+
+int SMMExample_d9h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int SMMExample_dah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{							
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+
+int SMMExample_dbh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_dch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_ddh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_deh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;		
+}
+
+
+int SMMExample_dfh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int  SMMExample_e0h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int  SMMExample_e1h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_e2h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 1;
+
+}
+
+int SMMExample_e3h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{	
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_e4h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+
+int SMMExample_e5h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;										
+}
+
+
+int SMMExample_e6h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;											
+}
+ 
+
+int SMMExample_e7h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+ 
+
+int SMMExample_e8h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;
+}
+
+
+int SMMExample_e9h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int SMMExample_eah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{							
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+
+int SMMExample_ebh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_ech( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_edh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_eeh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;		
+}
+
+
+int SMMExample_efh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int  SMMExample_f0h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int  SMMExample_f1h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_f2h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 1;
+
+}
+
+int SMMExample_f3h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
+{	
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+int SMMExample_f4h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+
+
+int SMMExample_f5h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;										
+}
+
+
+int SMMExample_f6h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	*pRes= CC_NORMAL;
+	return 	1;											
+}
+ 
+
+int SMMExample_f7h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+ 
+
+int SMMExample_f8h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 1;
+}
+
+
+int SMMExample_f9h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;
+}
+
+int SMMExample_fah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{							
+	*pRes= CC_NORMAL;
+	return 1;	
+}
+
+int SMMExample_fbh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_fch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_fdh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+
+int SMMExample_feh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;		
+}
+
+
+int SMMExample_ffh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)		
+{
+	*pRes= CC_NORMAL;
+	return 	1;	
+}
+

+ 541 - 0
app/bmc/msghndlr/OemSMMCmds/OemSMMCmds.h

@@ -0,0 +1,541 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2008, American Megatrends Inc.             **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ *
+ * OemSMMCmds.h
+ * OemSMMCmds.h used by SMM  channel
+ *
+ * Author: Anurag Bhatia <anuragb@ami.com>
+ *         Vinesh Chirstopher <vineshc@ami.com>
+ *
+ *****************************************************************/
+
+#include "com_BmcType.h"
+
+#define CMD_EXAMPLE_0h   0x0
+#define CMD_EXAMPLE_1h   0x1
+#define CMD_EXAMPLE_2h   0x2
+#define CMD_EXAMPLE_3h   0x3
+#define CMD_EXAMPLE_4h   0x4
+#define CMD_EXAMPLE_5h   0x5
+#define CMD_EXAMPLE_6h   0x6
+#define CMD_EXAMPLE_7h   0x7
+#define CMD_EXAMPLE_8h   0x8
+#define CMD_EXAMPLE_9h   0x9
+#define CMD_EXAMPLE_ah   0xa
+#define CMD_EXAMPLE_bh   0xb
+#define CMD_EXAMPLE_ch   0xc
+#define CMD_EXAMPLE_dh   0xd
+#define CMD_EXAMPLE_eh   0xe
+#define CMD_EXAMPLE_fh   0xf
+#define CMD_EXAMPLE_10h   0x10
+#define CMD_EXAMPLE_11h   0x11
+#define CMD_EXAMPLE_12h   0x12
+#define CMD_EXAMPLE_13h   0x13
+#define CMD_EXAMPLE_14h   0x14
+#define CMD_EXAMPLE_15h   0x15
+#define CMD_EXAMPLE_16h   0x16
+#define CMD_EXAMPLE_17h   0x17
+#define CMD_EXAMPLE_18h   0x18
+#define CMD_EXAMPLE_19h   0x19
+#define CMD_EXAMPLE_1ah   0x1a
+#define CMD_EXAMPLE_1bh   0x1b
+#define CMD_EXAMPLE_1ch   0x1c
+#define CMD_EXAMPLE_1dh   0x1d
+#define CMD_EXAMPLE_1eh   0x1e
+#define CMD_EXAMPLE_1fh   0x1f
+#define CMD_EXAMPLE_20h   0x20
+#define CMD_EXAMPLE_21h   0x21
+#define CMD_EXAMPLE_22h   0x22
+#define CMD_EXAMPLE_23h   0x23
+#define CMD_EXAMPLE_24h   0x24
+#define CMD_EXAMPLE_25h   0x25
+#define CMD_EXAMPLE_26h   0x26
+#define CMD_EXAMPLE_27h   0x27
+#define CMD_EXAMPLE_28h   0x28
+#define CMD_EXAMPLE_29h   0x29
+#define CMD_EXAMPLE_2ah   0x2a
+#define CMD_EXAMPLE_2bh   0x2b
+#define CMD_EXAMPLE_2ch   0x2c
+#define CMD_EXAMPLE_2dh   0x2d
+#define CMD_EXAMPLE_2eh   0x2e
+#define CMD_EXAMPLE_2fh   0x2f
+#define CMD_EXAMPLE_30h   0x30
+#define CMD_EXAMPLE_31h   0x31
+#define CMD_EXAMPLE_32h   0x32
+#define CMD_EXAMPLE_33h   0x33
+#define CMD_EXAMPLE_34h   0x34
+#define CMD_EXAMPLE_35h   0x35
+#define CMD_EXAMPLE_36h   0x36
+#define CMD_EXAMPLE_37h   0x37
+#define CMD_EXAMPLE_38h   0x38
+#define CMD_EXAMPLE_39h   0x39
+#define CMD_EXAMPLE_3ah   0x3a
+#define CMD_EXAMPLE_3bh   0x3b
+#define CMD_EXAMPLE_3ch   0x3c
+#define CMD_EXAMPLE_3dh   0x3d
+#define CMD_EXAMPLE_3eh   0x3e
+#define CMD_EXAMPLE_3fh   0x3f
+#define CMD_EXAMPLE_40h   0x40
+#define CMD_EXAMPLE_41h   0x41
+#define CMD_EXAMPLE_42h   0x42
+#define CMD_EXAMPLE_43h   0x43
+#define CMD_EXAMPLE_44h   0x44
+#define CMD_EXAMPLE_45h   0x45
+#define CMD_EXAMPLE_46h   0x46
+#define CMD_EXAMPLE_47h   0x47
+#define CMD_EXAMPLE_48h   0x48
+#define CMD_EXAMPLE_49h   0x49
+#define CMD_EXAMPLE_4ah   0x4a
+#define CMD_EXAMPLE_4bh   0x4b
+#define CMD_EXAMPLE_4ch   0x4c
+#define CMD_EXAMPLE_4dh   0x4d
+#define CMD_EXAMPLE_4eh   0x4e
+#define CMD_EXAMPLE_4fh   0x4f
+#define CMD_EXAMPLE_50h   0x50
+#define CMD_EXAMPLE_51h   0x51
+#define CMD_EXAMPLE_52h   0x52
+#define CMD_EXAMPLE_53h   0x53
+#define CMD_EXAMPLE_54h   0x54
+#define CMD_EXAMPLE_55h   0x55
+#define CMD_EXAMPLE_56h   0x56
+#define CMD_EXAMPLE_57h   0x57
+#define CMD_EXAMPLE_58h   0x58
+#define CMD_EXAMPLE_59h   0x59
+#define CMD_EXAMPLE_5ah   0x5a
+#define CMD_EXAMPLE_5bh   0x5b
+#define CMD_EXAMPLE_5ch   0x5c
+#define CMD_EXAMPLE_5dh   0x5d
+#define CMD_EXAMPLE_5eh   0x5e
+#define CMD_EXAMPLE_5fh   0x5f
+#define CMD_EXAMPLE_60h   0x60
+#define CMD_EXAMPLE_61h   0x61
+#define CMD_EXAMPLE_62h   0x62
+#define CMD_EXAMPLE_63h   0x63
+#define CMD_EXAMPLE_64h   0x64
+#define CMD_EXAMPLE_65h   0x65
+#define CMD_EXAMPLE_66h   0x66
+#define CMD_EXAMPLE_67h   0x67
+#define CMD_EXAMPLE_68h   0x68
+#define CMD_EXAMPLE_69h   0x69
+#define CMD_EXAMPLE_6ah   0x6a
+#define CMD_EXAMPLE_6bh   0x6b
+#define CMD_EXAMPLE_6ch   0x6c
+#define CMD_EXAMPLE_6dh   0x6d
+#define CMD_EXAMPLE_6eh   0x6e
+#define CMD_EXAMPLE_6fh   0x6f
+#define CMD_EXAMPLE_70h   0x70
+#define CMD_EXAMPLE_71h   0x71
+#define CMD_EXAMPLE_72h   0x72
+#define CMD_EXAMPLE_73h   0x73
+#define CMD_EXAMPLE_74h   0x74
+#define CMD_EXAMPLE_75h   0x75
+#define CMD_EXAMPLE_76h   0x76
+#define CMD_EXAMPLE_77h   0x77
+#define CMD_EXAMPLE_78h   0x78
+#define CMD_EXAMPLE_79h   0x79
+#define CMD_EXAMPLE_7ah   0x7a
+#define CMD_EXAMPLE_7bh   0x7b
+#define CMD_EXAMPLE_7ch   0x7c
+#define CMD_EXAMPLE_7dh   0x7d
+#define CMD_EXAMPLE_7eh   0x7e
+#define CMD_EXAMPLE_7fh   0x7f
+/********* storlead oem command ***********/
+#define CMD_EXAMPLE_80h   0x80
+#define CMD_EXAMPLE_81h   0x81
+#define CMD_EXAMPLE_82h   0x82
+#define CMD_EXAMPLE_83h   0x83
+#define CMD_EXAMPLE_84h   0x84
+#define CMD_EXAMPLE_85h   0x85
+#define CMD_EXAMPLE_86h   0x86
+#define CMD_EXAMPLE_87h   0x87
+#define CMD_EXAMPLE_88h   0x88
+#define CMD_EXAMPLE_89h   0x89
+#define CMD_EXAMPLE_8ah   0x8a
+#define CMD_EXAMPLE_8bh   0x8b
+#define CMD_EXAMPLE_8ch   0x8c
+#define CMD_EXAMPLE_8dh   0x8d
+#define CMD_EXAMPLE_8eh   0x8e
+#define CMD_EXAMPLE_8fh   0x8f
+#define CMD_EXAMPLE_90h   0x90
+#define CMD_EXAMPLE_91h   0x91
+#define CMD_EXAMPLE_92h   0x92
+#define CMD_EXAMPLE_93h   0x93
+#define CMD_EXAMPLE_94h   0x94
+#define CMD_EXAMPLE_95h   0x95
+#define CMD_EXAMPLE_96h   0x96
+#define CMD_EXAMPLE_97h   0x97
+#define CMD_EXAMPLE_98h   0x98
+#define CMD_EXAMPLE_99h   0x99
+#define CMD_EXAMPLE_9ah   0x9a
+#define CMD_EXAMPLE_9bh   0x9b
+#define CMD_EXAMPLE_9ch   0x9c
+#define CMD_EXAMPLE_9dh   0x9d
+#define CMD_EXAMPLE_9eh   0x9e
+#define CMD_EXAMPLE_9fh   0x9f
+/************************************************************/
+#define CMD_EXAMPLE_a0h   0xa0
+#define CMD_EXAMPLE_a1h   0xa1
+#define CMD_EXAMPLE_a2h   0xa2
+#define CMD_EXAMPLE_a3h   0xa3
+#define CMD_EXAMPLE_a4h   0xa4
+#define CMD_EXAMPLE_a5h   0xa5
+#define CMD_EXAMPLE_a6h   0xa6
+#define CMD_EXAMPLE_a7h   0xa7
+#define CMD_EXAMPLE_a8h   0xa8
+#define CMD_EXAMPLE_a9h   0xa9
+#define CMD_EXAMPLE_aah   0xaa
+#define CMD_EXAMPLE_abh   0xab
+#define CMD_EXAMPLE_ach   0xac
+#define CMD_EXAMPLE_adh   0xad
+#define CMD_EXAMPLE_aeh   0xae
+#define CMD_EXAMPLE_afh   0xaf
+#define CMD_EXAMPLE_b0h   0xb0
+#define CMD_EXAMPLE_b1h   0xb1
+#define CMD_EXAMPLE_b2h   0xb2
+#define CMD_EXAMPLE_b3h   0xb3
+#define CMD_EXAMPLE_b4h   0xb4
+#define CMD_EXAMPLE_b5h   0xb5
+#define CMD_EXAMPLE_b6h   0xb6
+#define CMD_EXAMPLE_b7h   0xb7
+#define CMD_EXAMPLE_b8h   0xb8
+#define CMD_EXAMPLE_b9h   0xb9
+#define CMD_EXAMPLE_bah   0xba
+#define CMD_EXAMPLE_bbh   0xbb
+#define CMD_EXAMPLE_bch   0xbc
+#define CMD_EXAMPLE_bdh   0xbd
+#define CMD_EXAMPLE_beh   0xbe
+#define CMD_EXAMPLE_bfh   0xbf
+#define CMD_EXAMPLE_c0h   0xc0
+#define CMD_EXAMPLE_c1h   0xc1
+#define CMD_EXAMPLE_c2h   0xc2
+#define CMD_EXAMPLE_c3h   0xc3
+#define CMD_EXAMPLE_c4h   0xc4
+#define CMD_EXAMPLE_c5h   0xc5
+#define CMD_EXAMPLE_c6h   0xc6
+#define CMD_EXAMPLE_c7h   0xc7
+#define CMD_EXAMPLE_c8h   0xc8
+#define CMD_EXAMPLE_c9h   0xc9
+#define CMD_EXAMPLE_cah   0xca
+#define CMD_EXAMPLE_cbh   0xcb
+#define CMD_EXAMPLE_cch   0xcc
+#define CMD_EXAMPLE_cdh   0xcd
+#define CMD_EXAMPLE_ceh   0xce
+#define CMD_EXAMPLE_cfh   0xcf
+#define CMD_EXAMPLE_d0h   0xd0
+#define CMD_EXAMPLE_d1h   0xd1
+#define CMD_EXAMPLE_d2h   0xd2
+#define CMD_EXAMPLE_d3h   0xd3
+#define CMD_EXAMPLE_d4h   0xd4
+#define CMD_EXAMPLE_d5h   0xd5
+#define CMD_EXAMPLE_d6h   0xd6
+#define CMD_EXAMPLE_d7h   0xd7
+#define CMD_EXAMPLE_d8h   0xd8
+#define CMD_EXAMPLE_d9h   0xd9
+#define CMD_EXAMPLE_dah   0xda
+#define CMD_EXAMPLE_dbh   0xdb
+#define CMD_EXAMPLE_dch   0xdc
+#define CMD_EXAMPLE_ddh   0xdd
+#define CMD_EXAMPLE_deh   0xde
+#define CMD_EXAMPLE_dfh   0xdf
+#define CMD_EXAMPLE_e0h   0xe0
+#define CMD_EXAMPLE_e1h   0xe1
+#define CMD_EXAMPLE_e2h   0xe2
+#define CMD_EXAMPLE_e3h   0xe3
+#define CMD_EXAMPLE_e4h   0xe4
+#define CMD_EXAMPLE_e5h   0xe5
+#define CMD_EXAMPLE_e6h   0xe6
+#define CMD_EXAMPLE_e7h   0xe7
+#define CMD_EXAMPLE_e8h   0xe8
+#define CMD_EXAMPLE_e9h   0xe9
+#define CMD_EXAMPLE_eah   0xea
+#define CMD_EXAMPLE_ebh   0xeb
+#define CMD_EXAMPLE_ech   0xec
+#define CMD_EXAMPLE_edh   0xed
+#define CMD_EXAMPLE_eeh   0xee
+#define CMD_EXAMPLE_efh   0xef
+#define CMD_EXAMPLE_f0h   0xf0
+#define CMD_EXAMPLE_f1h   0xf1
+#define CMD_EXAMPLE_f2h   0xf2
+#define CMD_EXAMPLE_f3h   0xf3
+#define CMD_EXAMPLE_f4h   0xf4
+#define CMD_EXAMPLE_f5h   0xf5
+#define CMD_EXAMPLE_f6h   0xf6
+#define CMD_EXAMPLE_f7h   0xf7
+#define CMD_EXAMPLE_f8h   0xf8
+#define CMD_EXAMPLE_f9h   0xf9
+#define CMD_EXAMPLE_fah   0xfa
+#define CMD_EXAMPLE_fbh   0xfb
+#define CMD_EXAMPLE_fch   0xfc
+#define CMD_EXAMPLE_fdh   0xfd
+#define CMD_EXAMPLE_feh   0xfe
+#define CMD_EXAMPLE_ffh   0xff
+
+extern int SMMExample_0h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_1h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_2h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_3h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_4h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_5h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_6h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_7h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_8h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_9h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_10h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_11h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_12h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_13h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_14h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_15h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_16h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_17h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_18h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_19h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_1ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_1bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_1ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_1dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_1eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_1fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_20h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_21h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_22h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_23h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_24h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_25h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_26h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_27h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_28h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_29h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_2ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_2bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_2ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_2dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_2eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_2fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_30h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_31h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_32h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_33h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_34h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_35h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_36h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_37h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_38h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_39h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_3ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_3bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_3ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_3dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_3eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_3fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_40h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_41h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_42h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_43h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_44h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_45h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_46h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_47h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_48h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_49h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_4ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_4bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_4ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_4dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_4eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_4fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_50h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_51h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_52h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_53h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_54h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_55h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_56h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_57h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_58h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_59h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_5ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_5bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_5ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_5dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_5eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_5fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_60h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_61h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_62h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_63h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_64h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_65h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_66h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_67h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_68h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_69h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_6ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_6bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_6ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_6dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_6eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_6fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_70h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_71h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_72h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_73h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_74h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_75h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_76h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_77h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_78h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_79h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_7ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_7bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_7ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_7dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_7eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_7fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+
+/**************** storlead oem command **********************/
+extern int SMMExample_80h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_81h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_82h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_83h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_84h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_85h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_86h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_87h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_88h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_89h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_8ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_8bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_8ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_8dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_8eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_8fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_90h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_91h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_92h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_93h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_94h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_95h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_96h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_97h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_98h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_99h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_9ah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_9bh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_9ch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_9dh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_9eh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_9fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+/**********************************************************************************/
+extern int SMMExample_a0h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_a1h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_a2h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_a3h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_a4h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_a5h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_a6h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_a7h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_a8h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_a9h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_aah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_abh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_ach( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_adh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_aeh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_afh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_b0h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_b1h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_b2h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_b3h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_b4h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_b5h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_b6h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_b7h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_b8h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_b9h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_bah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_bbh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_bch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_bdh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_beh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_bfh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_c0h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_c1h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_c2h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_c3h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_c4h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_c5h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_c6h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_c7h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_c8h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_c9h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_cah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_cbh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_cch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_cdh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_ceh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_cfh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_d0h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_d1h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_d2h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_d3h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_d4h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_d5h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_d6h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_d7h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_d8h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_d9h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_dah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_dbh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_dch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_ddh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_deh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_dfh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_e0h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_e1h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_e2h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_e3h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_e4h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_e5h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_e6h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_e7h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_e8h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_e9h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_eah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_ebh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_ech( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_edh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_eeh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_efh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_f0h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_f1h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_f2h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_f3h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_f4h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_f5h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_f6h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_f7h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_f8h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_f9h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_fah( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_fbh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_fch( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_fdh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_feh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SMMExample_ffh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);

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

@@ -0,0 +1,383 @@
+/*****************************************************************
+ *****************************************************************
+ ***                                                            **
+ ***    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ ***                                                            **
+ ***            All Rights Reserved.                            **
+ ***                                                            **
+ ***        6145-F, Northbelt Parkway, Norcross,                **
+ ***                                                            **
+ ***        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ ***                                                            **
+ *****************************************************************
+ *****************************************************************
+ ******************************************************************
+ *
+ * PDKCmds.c
+ * Hooks that are invoked at different points of the Firmware
+ * execution.
+ *
+ *  Author: Govind Kothandapani <govindk@ami.com>
+ ******************************************************************/
+
+#include "PDKCmds.h"
+#include "OemSMMCmds.h"
+#include "com_IPMIDefs.h"
+
+
+/*NetFn -Application OEM Command Handler to override generic IPMI cmd 
+   Commands can be added to the Handler as explained below 
+  { CMD_GET_DEV_ID, PRIV_USER, GETDEV_ID,  0x00,  0xAAAA },
+  where CMD_GET_DEV_ID - Command no.
+            PRIV_USER            - Privilege level like administrator,user
+            GETDEV_ID           -  Function for the command to override
+            0x00                     -  Request length for the command
+            0xAAAA                -   Firewall settings 
+  GETDEV_ID function definition can be as shown below   
+  int  GETDEV_ID (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes)
+  {
+		*pRes= CC_NORMAL;
+		return 	sizeof (*pRes);
+  }   
+*/
+const CmdHndlrMap_T	g_Oem_App_CmdHndlr [] =
+{
+    { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
+};
+
+/*Netfn - Chasiss OEM Command Handler to override generic IPMI cmd */
+const CmdHndlrMap_T	g_Oem_Chassis_CmdHndlr [] =
+{
+    { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
+};
+
+/*Netfn - Bridging OEM Command Handler to override generic  IPMI cmd */
+const CmdHndlrMap_T	g_Oem_Bridge_CmdHndlr [] =
+{
+    { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
+};
+
+/*Netfn - Sensor OEM Command Handler to override generic IPMI cmd */
+const CmdHndlrMap_T	g_Oem_SensorEvent_CmdHndlr [] =
+{
+    { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
+};
+
+/*Netfn - Storage OEM Command Handler to override generic IPMI cmd */
+const CmdHndlrMap_T	g_Oem_Storage_CmdHndlr [] =
+{
+    { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
+};
+
+/*Netfn - Transport OEM Command Handler to override generic IPMI cmd */
+const CmdHndlrMap_T	g_Oem_Config_CmdHndlr [] =
+{
+    { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
+};
+
+/*Netfn - OEM cmd */
+const CmdHndlrMap_T	g_Oem_CmdHndlr [] =	//jimbo add
+{
+    { CMD_EXAMPLE_1h,     PRIV_USER,       SMMExample_1h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_2h,     PRIV_USER,       SMMExample_2h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_3h,     PRIV_USER,       SMMExample_3h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_4h,     PRIV_USER,       SMMExample_4h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_5h,     PRIV_USER,       SMMExample_5h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_6h,     PRIV_USER,       SMMExample_6h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_7h,     PRIV_USER,       SMMExample_7h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_8h,     PRIV_USER,       SMMExample_8h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_9h,     PRIV_USER,       SMMExample_9h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_ah,     PRIV_USER,       SMMExample_ah,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_bh,     PRIV_USER,       SMMExample_bh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_ch,     PRIV_USER,       SMMExample_ch,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_dh,     PRIV_USER,       SMMExample_dh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_eh,     PRIV_USER,       SMMExample_eh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_fh,     PRIV_USER,       SMMExample_fh,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_10h,     PRIV_USER,       SMMExample_10h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_11h,     PRIV_USER,       SMMExample_11h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_12h,     PRIV_USER,       SMMExample_12h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_13h,     PRIV_USER,       SMMExample_13h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_14h,     PRIV_USER,       SMMExample_14h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_15h,     PRIV_USER,       SMMExample_15h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_16h,     PRIV_USER,       SMMExample_16h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_17h,     PRIV_USER,       SMMExample_17h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_18h,     PRIV_USER,       SMMExample_18h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_19h,     PRIV_USER,       SMMExample_19h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_20h,     PRIV_USER,       SMMExample_20h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_21h,     PRIV_USER,       SMMExample_21h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_22h,     PRIV_USER,       SMMExample_22h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_23h,     PRIV_USER,       SMMExample_23h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_24h,     PRIV_USER,       SMMExample_24h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_25h,     PRIV_USER,       SMMExample_25h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_26h,     PRIV_USER,       SMMExample_26h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_27h,     PRIV_USER,       SMMExample_27h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_28h,     PRIV_USER,       SMMExample_28h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_29h,     PRIV_USER,       SMMExample_29h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_2ah,     PRIV_USER,       SMMExample_2ah,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_2bh,     PRIV_USER,       SMMExample_2bh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_2ch,     PRIV_USER,       SMMExample_2ch,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_2dh,     PRIV_USER,       SMMExample_2dh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_2eh,     PRIV_USER,       SMMExample_2eh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_2fh,     PRIV_USER,       SMMExample_2fh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_30h,     PRIV_USER,       SMMExample_30h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_31h,     PRIV_USER,       SMMExample_31h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_32h,     PRIV_USER,       SMMExample_32h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_33h,     PRIV_USER,       SMMExample_33h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_34h,     PRIV_USER,       SMMExample_34h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_35h,     PRIV_USER,       SMMExample_35h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_36h,     PRIV_USER,       SMMExample_36h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_37h,     PRIV_USER,       SMMExample_37h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_38h,     PRIV_USER,       SMMExample_38h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_39h,     PRIV_USER,       SMMExample_39h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_3ah,     PRIV_USER,       SMMExample_3ah,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_3bh,     PRIV_USER,       SMMExample_3bh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_3ch,     PRIV_USER,       SMMExample_3ch,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_3dh,     PRIV_USER,       SMMExample_3dh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_3eh,     PRIV_USER,       SMMExample_3eh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_3fh,     PRIV_USER,       SMMExample_3fh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_40h,     PRIV_USER,       SMMExample_40h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_41h,     PRIV_USER,       SMMExample_41h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_42h,     PRIV_USER,       SMMExample_42h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_43h,     PRIV_USER,       SMMExample_43h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_44h,     PRIV_USER,       SMMExample_44h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_45h,     PRIV_USER,       SMMExample_45h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_46h,     PRIV_USER,       SMMExample_46h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_47h,     PRIV_USER,       SMMExample_47h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_48h,     PRIV_USER,       SMMExample_48h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_49h,     PRIV_USER,       SMMExample_49h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_4ah,     PRIV_USER,       SMMExample_4ah,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_4bh,     PRIV_USER,       SMMExample_4bh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_4ch,     PRIV_USER,       SMMExample_4ch,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_4dh,     PRIV_USER,       SMMExample_4dh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_4eh,     PRIV_USER,       SMMExample_4eh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_4fh,     PRIV_USER,       SMMExample_4fh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_50h,     PRIV_USER,       SMMExample_50h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_51h,     PRIV_USER,       SMMExample_51h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_52h,     PRIV_USER,       SMMExample_52h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_53h,     PRIV_USER,       SMMExample_53h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_54h,     PRIV_USER,       SMMExample_54h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_55h,     PRIV_USER,       SMMExample_55h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_56h,     PRIV_USER,       SMMExample_56h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_57h,     PRIV_USER,       SMMExample_57h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_58h,     PRIV_USER,       SMMExample_58h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_59h,     PRIV_USER,       SMMExample_59h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_5ah,     PRIV_USER,       SMMExample_5ah,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_5bh,     PRIV_USER,       SMMExample_5bh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_5ch,     PRIV_USER,       SMMExample_5ch,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_5dh,     PRIV_USER,       SMMExample_5dh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_5eh,     PRIV_USER,       SMMExample_5eh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_5fh,     PRIV_USER,       SMMExample_5fh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_60h,     PRIV_USER,       SMMExample_60h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_61h,     PRIV_USER,       SMMExample_61h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_62h,     PRIV_USER,       SMMExample_62h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_63h,     PRIV_USER,       SMMExample_63h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_64h,     PRIV_USER,       SMMExample_64h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_65h,     PRIV_USER,       SMMExample_65h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_66h,     PRIV_USER,       SMMExample_66h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_67h,     PRIV_USER,       SMMExample_67h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_68h,     PRIV_USER,       SMMExample_68h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_69h,     PRIV_USER,       SMMExample_69h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_6ah,     PRIV_USER,       SMMExample_6ah,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_6bh,     PRIV_USER,       SMMExample_6bh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_6ch,     PRIV_USER,       SMMExample_6ch,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_6dh,     PRIV_USER,       SMMExample_6dh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_6eh,     PRIV_USER,       SMMExample_6eh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_6fh,     PRIV_USER,       SMMExample_6fh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_70h,     PRIV_USER,       SMMExample_70h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_71h,     PRIV_USER,       SMMExample_71h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_72h,     PRIV_USER,       SMMExample_72h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_73h,     PRIV_USER,       SMMExample_73h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_74h,     PRIV_USER,       SMMExample_74h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_75h,     PRIV_USER,       SMMExample_75h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_76h,     PRIV_USER,       SMMExample_76h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_77h,     PRIV_USER,       SMMExample_77h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_78h,     PRIV_USER,       SMMExample_78h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_79h,     PRIV_USER,       SMMExample_79h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_7ah,     PRIV_USER,       SMMExample_7ah,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_7bh,     PRIV_USER,       SMMExample_7bh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_7ch,     PRIV_USER,       SMMExample_7ch,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_7dh,     PRIV_USER,       SMMExample_7dh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_7eh,     PRIV_USER,       SMMExample_7eh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_7fh,     PRIV_USER,       SMMExample_7fh,      0xff,     0xAAAA,	0xFFFF },
+    
+    /*************************** storlead oem command *********************************/
+    { CMD_EXAMPLE_80h,     PRIV_USER,       SMMExample_80h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_81h,     PRIV_USER,       SMMExample_81h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_82h,     PRIV_USER,       SMMExample_82h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_83h,     PRIV_USER,       SMMExample_83h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_84h,     PRIV_USER,       SMMExample_84h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_85h,     PRIV_USER,       SMMExample_85h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_86h,     PRIV_USER,       SMMExample_86h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_87h,     PRIV_USER,       SMMExample_87h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_88h,     PRIV_USER,       SMMExample_88h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_89h,     PRIV_USER,       SMMExample_89h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_8ah,     PRIV_USER,       SMMExample_8ah,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_8bh,     PRIV_USER,       SMMExample_8bh,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_8ch,     PRIV_USER,       SMMExample_8ch,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_8dh,     PRIV_USER,       SMMExample_8dh,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_8eh,     PRIV_USER,       SMMExample_8eh,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_8fh,     PRIV_USER,       SMMExample_8fh,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_90h,     PRIV_USER,       SMMExample_90h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_91h,     PRIV_USER,       SMMExample_91h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_92h,     PRIV_USER,       SMMExample_92h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_93h,     PRIV_USER,       SMMExample_93h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_94h,     PRIV_USER,       SMMExample_94h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_95h,     PRIV_USER,       SMMExample_95h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_96h,     PRIV_USER,       SMMExample_96h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_97h,     PRIV_USER,       SMMExample_97h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_98h,     PRIV_USER,       SMMExample_98h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_99h,     PRIV_USER,       SMMExample_99h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_9ah,     PRIV_USER,       SMMExample_9ah,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_9bh,     PRIV_USER,       SMMExample_9bh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_9ch,     PRIV_USER,       SMMExample_9ch,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_9dh,     PRIV_USER,       SMMExample_9dh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_9eh,     PRIV_USER,       SMMExample_9eh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_9fh,     PRIV_USER,       SMMExample_9fh,      0xff,     0xAAAA,	0xFFFF },
+	/*************************** storlead oem command end *********************************/
+	{ CMD_EXAMPLE_a0h,     PRIV_USER,       SMMExample_a0h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_a1h,     PRIV_USER,       SMMExample_a1h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_a2h,     PRIV_USER,       SMMExample_a2h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_a3h,     PRIV_USER,       SMMExample_a3h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_a4h,     PRIV_USER,       SMMExample_a4h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_a5h,     PRIV_USER,       SMMExample_a5h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_a6h,     PRIV_USER,       SMMExample_a6h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_a7h,     PRIV_USER,       SMMExample_a7h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_a8h,     PRIV_USER,       SMMExample_a8h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_a9h,     PRIV_USER,       SMMExample_a9h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_aah,     PRIV_USER,       SMMExample_aah,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_abh,     PRIV_USER,       SMMExample_abh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_ach,     PRIV_USER,       SMMExample_ach,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_adh,     PRIV_USER,       SMMExample_adh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_aeh,     PRIV_USER,       SMMExample_aeh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_afh,     PRIV_USER,       SMMExample_afh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_b0h,     PRIV_USER,       SMMExample_b0h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_b1h,     PRIV_USER,       SMMExample_b1h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_b2h,     PRIV_USER,       SMMExample_b2h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_b3h,     PRIV_USER,       SMMExample_b3h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_b4h,     PRIV_USER,       SMMExample_b4h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_b5h,     PRIV_USER,       SMMExample_b5h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_b6h,     PRIV_USER,       SMMExample_b6h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_b7h,     PRIV_USER,       SMMExample_b7h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_b8h,     PRIV_USER,       SMMExample_b8h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_b9h,     PRIV_USER,       SMMExample_b9h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_bah,     PRIV_USER,       SMMExample_bah,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_bbh,     PRIV_USER,       SMMExample_bbh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_bch,     PRIV_USER,       SMMExample_bch,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_bdh,     PRIV_USER,       SMMExample_bdh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_beh,     PRIV_USER,       SMMExample_beh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_bfh,     PRIV_USER,       SMMExample_bfh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_c0h,     PRIV_USER,       SMMExample_c0h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_c1h,     PRIV_USER,       SMMExample_c1h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_c2h,     PRIV_USER,       SMMExample_c2h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_c3h,     PRIV_USER,       SMMExample_c3h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_c4h,     PRIV_USER,       SMMExample_c4h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_c5h,     PRIV_USER,       SMMExample_c5h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_c6h,     PRIV_USER,       SMMExample_c6h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_c7h,     PRIV_USER,       SMMExample_c7h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_c8h,     PRIV_USER,       SMMExample_c8h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_c9h,     PRIV_USER,       SMMExample_c9h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_cah,     PRIV_USER,       SMMExample_cah,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_cbh,     PRIV_USER,       SMMExample_cbh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_cch,     PRIV_USER,       SMMExample_cch,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_cdh,     PRIV_USER,       SMMExample_cdh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_ceh,     PRIV_USER,       SMMExample_ceh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_cfh,     PRIV_USER,       SMMExample_cfh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_d0h,     PRIV_USER,       SMMExample_d0h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_d1h,     PRIV_USER,       SMMExample_d1h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_d2h,     PRIV_USER,       SMMExample_d2h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_d3h,     PRIV_USER,       SMMExample_d3h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_d4h,     PRIV_USER,       SMMExample_d4h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_d5h,     PRIV_USER,       SMMExample_d5h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_d6h,     PRIV_USER,       SMMExample_d6h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_d7h,     PRIV_USER,       SMMExample_d7h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_d8h,     PRIV_USER,       SMMExample_d8h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_d9h,     PRIV_USER,       SMMExample_d9h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_dah,     PRIV_USER,       SMMExample_dah,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_dbh,     PRIV_USER,       SMMExample_dbh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_dch,     PRIV_USER,       SMMExample_dch,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_ddh,     PRIV_USER,       SMMExample_ddh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_deh,     PRIV_USER,       SMMExample_deh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_dfh,     PRIV_USER,       SMMExample_dfh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_e0h,     PRIV_USER,       SMMExample_e0h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_e1h,     PRIV_USER,       SMMExample_e1h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_e2h,     PRIV_USER,       SMMExample_e2h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_e3h,     PRIV_USER,       SMMExample_e3h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_e4h,     PRIV_USER,       SMMExample_e4h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_e5h,     PRIV_USER,       SMMExample_e5h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_e6h,     PRIV_USER,       SMMExample_e6h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_e7h,     PRIV_USER,       SMMExample_e7h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_e8h,     PRIV_USER,       SMMExample_e8h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_e9h,     PRIV_USER,       SMMExample_e9h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_eah,     PRIV_USER,       SMMExample_eah,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_ebh,     PRIV_USER,       SMMExample_ebh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_ech,     PRIV_USER,       SMMExample_ech,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_edh,     PRIV_USER,       SMMExample_edh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_eeh,     PRIV_USER,       SMMExample_eeh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_efh,     PRIV_USER,       SMMExample_efh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_f0h,     PRIV_USER,       SMMExample_f0h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_f1h,     PRIV_USER,       SMMExample_f1h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_f2h,     PRIV_USER,       SMMExample_f2h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_f3h,     PRIV_USER,       SMMExample_f3h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_f4h,     PRIV_USER,       SMMExample_f4h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_f5h,     PRIV_USER,       SMMExample_f5h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_f6h,     PRIV_USER,       SMMExample_f6h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_f7h,     PRIV_USER,       SMMExample_f7h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_f8h,     PRIV_USER,       SMMExample_f8h,      0xff,     0xAAAA,	0xFFFF },
+    { CMD_EXAMPLE_f9h,     PRIV_USER,       SMMExample_f9h,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_fah,     PRIV_USER,       SMMExample_fah,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_fbh,     PRIV_USER,       SMMExample_fbh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_fch,     PRIV_USER,       SMMExample_fch,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_fdh,     PRIV_USER,       SMMExample_fdh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_feh,     PRIV_USER,       SMMExample_feh,      0xff,     0xAAAA,	0xFFFF },
+	{ CMD_EXAMPLE_ffh,     PRIV_USER,       SMMExample_ffh,      0xff,     0xAAAA,	0xFFFF },
+};
+
+/*OEM Message Handler table to override generic IPMI cmd
+  Any OEM specific Netfn and Command Handler can also be
+  added here*/
+const MsgHndlrTbl_T oem_MsgHndlrTbl [] =	
+{
+    // { NETFN_APP,                     g_Oem_App_CmdHndlr             },
+    // { NETFN_CHASSIS,                 g_Oem_Chassis_CmdHndlr         },
+    // { NETFN_BRIDGE,                  g_Oem_Bridge_CmdHndlr          },
+    // { NETFN_SENSOR,                  g_Oem_SensorEvent_CmdHndlr     },
+    // { NETFN_STORAGE,                 g_Oem_Storage_CmdHndlr         },
+    // { NETFN_TRANSPORT,               g_Oem_Config_CmdHndlr          },
+    { NETFN_OEM,               		 g_Oem_CmdHndlr      		     },
+};
+
+/**
+*@fn PDKGetOEMMsgHndlrMap 
+*@brief Helps in getting command handler for specific NetFn
+*@parm NetFn -NetFunction
+*@param pCmdHndlrMap - Command Handler for the given NetFn
+*@return Returns 0 on success and -1 on failure
+*/
+int
+PDKGetOEMMsgHndlrMap (uint8_t NetFn, CmdHndlrMap_T ** pCmdHndlrMap)
+{
+    int i;
+
+    /* Get the command handler corresponding to the net function */
+    for (i = 0; i < sizeof (oem_MsgHndlrTbl) / sizeof (oem_MsgHndlrTbl [0]); i++)
+    {
+        if (oem_MsgHndlrTbl [i].NetFn == NetFn) 
+        {
+            break; 
+        }
+    }
+
+    /* Check if we have not found our net function */
+    if (i == sizeof (oem_MsgHndlrTbl) / sizeof (oem_MsgHndlrTbl [0]))
+    {
+        return -1;
+    }
+
+    /* Get the handler corresponding to the command */
+    *pCmdHndlrMap = (CmdHndlrMap_T*)oem_MsgHndlrTbl [i].CmdHndlrMap;
+    
+    return 0;
+}
+
+
+

+ 60 - 50
app/bmc_server/ipmi_dev/NVRData.h → app/bmc/msghndlr/PDKCmds.h

@@ -1,50 +1,60 @@
-/*****************************************************************
- *****************************************************************
- ***                                                            **
- ***    (C)Copyright 2005-2006, American Megatrends Inc.        **
- ***                                                            **
- ***            All Rights Reserved.                            **
- ***                                                            **
- ***        6145-F, Northbelt Parkway, Norcross,                **
- ***                                                            **
- ***        Georgia - 30071, USA. Phone-(770)-246-8600.         **
- ***                                                            **
- *****************************************************************
- ******************************************************************
- * 
- * nvrdata.h
- * NVRAM Data
- *
- *  Author: Govind Kothandapani <govindk@ami.com>
- *
- ******************************************************************/
-#ifndef NVR_DATA_H
-#define NVR_DATA_H
-
-#include "PMConfig.h"
-
-/**
- * NVRAM Handles
-**/
-#define NVRH_USERCONFIG 0
-#define NVRH_CHCONFIG     0
-#define NVRH_SDR		0
-
-
-#if 0
-/*** Extern Definitions ***/
-extern _FAR_ const ChcfgInfo_T g_IPMBChcfg;
-extern _FAR_ const ChcfgInfo_T g_SysChcfg;
-extern _FAR_ const ChcfgInfo_T g_LanChcfg1;
-extern _FAR_ const ChcfgInfo_T g_LanChcfg2;
-extern _FAR_ const ChcfgInfo_T g_LanChcfg3;
-extern _FAR_ const ChcfgInfo_T g_SerialChcfg;
-extern _FAR_ const ChcfgInfo_T g_IcmbChcfg;
-extern _FAR_ const ChcfgInfo_T g_SMBChcfg;
-extern _FAR_ const ChcfgInfo_T g_SMMChcfg;
-extern _FAR_ const ChcfgInfo_T g_SmlinkipmbChcfg;
-#endif
-
-#endif	/* NVR_DATA_H */
-
-
+/*****************************************************************
+ *****************************************************************
+ ***                                                            **
+ ***    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ ***                                                            **
+ ***            All Rights Reserved.                            **
+ ***                                                            **
+ ***        6145-F, Northbelt Parkway, Norcross,                **
+ ***                                                            **
+ ***        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ ***                                                            **
+ *****************************************************************
+ ******************************************************************
+ *
+ * pdkhooks.h
+ * Hooks that are invoked at different points of the Firmware
+ * execution.
+ *
+ *  Author: Govind Kothandapani <govindk@ami.com>
+ ******************************************************************/
+#ifndef PDKCMDS_H
+#define PDKCMDS_H
+#include "MsgHndlr.h"
+
+
+#define PDK_CMD_LENGTH_UNKNOWN 0xFFFFFFFF
+
+typedef uint32_t (*pOEMCmdHndlr_T) ( uint8_t* pReq, uint32_t ReqLen,  uint8_t* pRes);
+
+typedef struct
+{
+
+    uint8_t  			NetFn;
+    uint8_t  			Cmd;
+    uint8_t  			Privilege;
+    pOEMCmdHndlr_T	CmdHndlr;
+    uint32_t			ReqLen;		/* 0xFF - Any Length */
+    uint16_t			FFConfig;
+
+} OEMCmdHndlrMap_T;
+
+typedef struct
+{
+    uint8_t    OwnerID;
+    uint8_t    ChannelNum;
+
+} OwnerIDMap_T;
+
+/**
+*@fn PDKGetOEMMsgHndlrMap 
+*@brief Helps in getting command handler for particular NetFn
+*@parm NetFn -NetFunction
+*@param pCmdHndlrMap - Command Handler for the given NetFn
+*@param BMCInst - BMC instances
+*@return Returns 0 on success and -1 for failure
+*/
+extern int	  PDKGetOEMMsgHndlrMap (uint8_t NetFn, CmdHndlrMap_T ** pCmdHndlrMap);
+
+#endif	/* PDKCMDS_H */
+

+ 20 - 0
app/bmc/msghndlr/PICMG/PICMG.h

@@ -0,0 +1,20 @@
+/*
+* Brief:	The header file of MsgHndlr_PICMG packet.
+* Author:	Jimbo_Zhang@outlook.com
+* Date:		2019-9-16
+*/
+
+#ifndef __MSG_HNDLR_PICMG_H__
+#define __MSG_HNDLR_PICMG_H__
+
+#include "com_BmcType.h"
+#include "MsgHndlr.h"
+
+
+
+extern int Get_IPMC_Properties ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int Get_Address_Info ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int Get_Shelf_Addr_Info ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int Get_Dev_Locator_Rec_ID ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+
+#endif /* __MSG_HNDLR_PICMG_H__ */

+ 63 - 0
app/bmc/msghndlr/PICMG/PICMGDevice.c

@@ -0,0 +1,63 @@
+/* 
+ * Brief:	PICMG command define.
+ * Author:	jimbo_zhang@outlook.com
+ * Date:	2019-4-11
+ */
+
+#include "com_BmcType.h"
+#include "MsgHndlr.h"
+
+/*---------------------------------------
+* get IPMC Properties
+*---------------------------------------*/
+//netfn = 0x2c, cmd = 0, subfn = 0x00
+int Get_IPMC_Properties ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    *pRes = CC_NORMAL;
+    *(pRes+1)	=	0x00;
+    *(pRes+2)	=	0x00;
+    *(pRes+3)	=	0x01;
+    *(pRes+4)	=	0x00;
+    
+    return 5;
+}
+
+/*---------------------------------------
+* get address information
+*---------------------------------------*/
+//netfn = 0x2c, cmd = 0x01, subfn = 0x00
+int Get_Address_Info ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	 
+    return 1;
+}
+
+/*---------------------------------------
+* get shelf address infomation
+*---------------------------------------*/
+int
+Get_Shelf_Addr_Info ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    *pRes = CC_NORMAL;
+    *(pRes+1)	=	0x00;
+    *(pRes+2)	=	0x01;
+    *(pRes+3)	=	0x02;
+    *(pRes+4)	=	0x03;
+    
+    return 5;
+}
+
+/*---------------------------------------
+* get device locator record id
+*---------------------------------------*/
+//netfn = 0x2c, cmd = 0x0d, subfn = 0x00.
+int Get_Dev_Locator_Rec_ID ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    *pRes = CC_NORMAL;
+    pRes[1] = 0;
+    pRes[2] = 0;	//Device locator ID MS
+    pRes[3] = 0;	//Device locator ID LS
+    
+    return 4;
+}
+

+ 874 - 0
app/bmc/msghndlr/PMConfig.h

@@ -0,0 +1,874 @@
+/*****************************************************************
+ *****************************************************************
+ ***                                                            **
+ ***    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ ***                                                            **
+ ***            All Rights Reserved.                            **
+ ***                                                            **
+ ***        6145-F, Northbelt Parkway, Norcross,                **
+ ***                                                            **
+ ***        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ ***                                                            **
+ *****************************************************************
+ *****************************************************************
+ ******************************************************************
+ *
+ * PMConfig.h
+ * Platform management configuration structures
+ *
+ *  Author: Govind Kothandapani <govindk@ami.com>
+ *          Basavaraj Astekar   <basavaraja@ami.com>
+ *          Ravinder Reddy      <bakkar@ami.com>
+ ******************************************************************/
+#ifndef PMCONFIG_H
+#define PMCONFIG_H
+//#include "Support.h"
+//#include "IPMI_PEF.h"
+#include "com_IPMI_AppDevice.h"
+//#include "OemDefs.h"
+//#include "IPMI_LANConfig.h"
+//#include "IPMI_ChassisDevice.h"
+#include <stdint.h>
+
+/*** External Definitions ***/
+#define MAX_PRIVILEGE_TYPES                 7
+#define MAX_CHFILE_NAME                         50
+
+#define MAX_EVT_FILTER_ENTRIES              40
+#define ALERT_POLICY_SET_SIZE		    4
+#define ALERT_POLICY_PER_CHANNEL	    15
+#define LAN_DESTINATIONS_PER_CHANNEL	    15
+#define NUM_LAN_DESTINATION                 LAN_DESTINATIONS_PER_CHANNEL
+#define MAX_ALERT_POLICY_ENTRIES            (ALERT_POLICY_PER_CHANNEL * 4)
+
+//Added to Support 20 Alert Strings in Set/Get Pef Config.Parms ../
+/* It should equal to number of Event filter entries */
+#define MAX_ALERT_STRINGS                  MAX_EVT_FILTER_ENTRIES
+#define PEF_MAX_OEM_PARAMETERS              0x20
+#define MAX_SIZE_PET_GUID                   0x11
+#define MAX_PLD_ENABLES_TYPES               4
+#define MAX_FF_CMD_CFGS                     255
+/* RMCP+ Definitions */
+#define MAX_ALGORITHMS						2
+#define MAX_PAYLOADS						3
+#define HASH_KEY_LEN						20
+#define MAX_ID_PAIRS 7
+
+
+#define IPMI_CONFIG_VERSION     17
+
+#define MAX_ENCRYPTED_PSWD_LEN 24
+
+/* The maximum no. of users that can be configured
+     via MDS */
+#define MAX_USER_CFG_MDS 0x10
+
+/* The maximum no. of channel users that can be configured
+     via MDS */
+#define MAX_NUM_CH_USERS_MDS 0x10
+
+/*  The IPMI configuration version is maintained in IPMI_CONFIG_VERSION macro and the version 
+      number should be incremented in counts of '1' whenever there are changes in CDF files used in 
+      MDS and in CDF related structures used in this file.One should make sure that the version number incremented
+      in IPMI_CONFIG_VERSION and version number maintained in libipmipar package should be same.
+      The CDF version number for libipmipar should be configured using MDS. The IPMI Config version check
+      will be done only when CONFIG_SPX_FEATURE_IPMI_CONFIG_VER_CHECK feature is enabled 
+      in PRJ file*/
+#pragma pack( 1 )
+
+/**
+ * @struct WDTConfig_T
+ * @brief Watchdog Timer configuration information.
+**/
+typedef struct
+{
+    uint8_t   TmrUse;
+    uint8_t   TmrActions;
+    uint8_t   PreTimeOutInterval;
+    uint8_t   ExpirationFlag;
+    uint16_t InitCountDown;
+    uint8_t   PreTimeoutActionTaken;
+
+}   WDTConfig_T;
+
+
+
+///**
+// * @struct PEFConfig_T
+// * PEF Configuration structure.
+//**/
+//typedef struct
+//{
+//    uint8_t                   PEFControl;
+//    uint8_t                   PEFActionGblControl;
+//    uint8_t                   PEFStartupDly;
+//    uint8_t                   PEFAlertStartupDly;
+//    EvtFilterTblEntry_T     EvtFilterTblEntry [MAX_EVT_FILTER_ENTRIES];
+//    AlertPolicyTblEntry_T   AlertPolicyTblEntry [MAX_ALERT_POLICY_ENTRIES];
+//    uint8_t                   SystemGUID [MAX_SIZE_PET_GUID];
+//    AlertStringTbl_T        AlertStringEntry [MAX_ALERT_STRINGS];
+//    uint8_t                   OEMParams [PEF_MAX_OEM_PARAMETERS];
+//    uint8_t                   NumAlertPolicyEntries;
+
+//}   PEFConfig_T;
+
+
+///**
+// * @struct PEFRecordDetailsConfig_T
+// * Record ID Configuration structure.
+//**/
+//typedef struct
+//{
+//    uint16_t                  LastBMCProcessedEventID;
+//    uint16_t                  LastSWProcessedEventID;
+//    uint16_t                  LastSELRecordID;
+//    uint32_t                  LastProcessedTimestamp;
+//    uint8_t                   LastActionDone;
+
+//}   PEFRecordDetailsConfig_T;
+
+/**
+* @struct ChannelUserInfo_T
+* Structure for user information per channel.
+**/
+typedef struct
+{
+   uint32_t  ID;
+   uint8_t   UserId;
+   uint32_t    AccessLimit:4;
+   uint32_t    LinkAuth:1;
+   uint32_t    UserAccessCallback:1;
+   uint32_t    UserAccessCBCPCallback:1;
+   uint8_t   UserCallbackCapabilities;
+   uint8_t   CBCPNegOptions;
+   uint8_t   CallBack1;
+   uint8_t   CallBack2;
+   uint8_t   CallBack3;
+   uint8_t   FailureAttempts;
+   uint8_t   Lock;
+   uint32_t LockedTime;
+   uint8_t  PayloadEnables [MAX_PLD_ENABLES_TYPES];
+
+   uint8_t  IPMIMessaging;
+   uint8_t  ActivatingSOL;
+
+}   ChannelUserInfo_T;
+
+
+/**
+ * @struct UserInfo_T
+ * Structure for user information.
+**/
+typedef struct
+{
+//    uint32_t  ID;
+    uint8_t   UserId;
+    uint8_t   UserName [MAX_USERNAME_LEN];
+    uint8_t   UserPassword [MAX_PASSWORD_LEN];
+//    uint8_t   MaxPasswordSize;				/**< Maximum password size					*/
+//	uint8_t	  ChannelAccess;				/** reserve,Call back, Link Auth, Ipmi Msg, Priv[3:0]. **/
+//    uint8_t   UserShell;	                    /**< user shell type	                    */		
+//    uint8_t	UserEMailID [EMAIL_ADDR_SIZE];	/**< Email-ID registered for the user		*/
+//    uint8_t   MaxSession;             		/**< max No of session allowed for User.    */
+//    uint8_t   CurrentSession;         		/**< No Current session for the User.       */
+//   uint8_t    UserStatus;           		/**< User Enabled/Disabled Status.          */
+//    uint32_t    FixedUser:1;            		/**< Is this user name fixed                */
+//    uint8_t  EmailFormat[EMAIL_FORMAT_SIZE]; /** Email Alert format                       */
+//    uint32_t  ExtendedPrivilege;                       /** User Enhanced Privilege Flags           */
+//    uint8_t   UserPasswdConfigured;			/*  Flag to allow default Empty Password  */
+}   UserInfo_T;
+
+
+/**
+* @struct DefaultChCfg_T
+* Structure of channel Information.
+**/
+typedef struct
+{
+   uint32_t          ID;
+   uint32_t            ChannelIndex;
+   uint32_t            ChannelNumber:4;
+   uint32_t            ChannelType:7;     /* Channel Type */
+   uint32_t            ChannelMedium:7;
+   uint32_t            ChannelProtocol:5;
+   uint32_t            SessionSupport:2;               /**< session support. */
+   uint32_t            ActiveSession:6;                /**< No of active session in this channel. */
+   uint8_t           AuthType [MAX_PRIVILEGE_TYPES]; /**< Authentication according to privilege. */
+   uint8_t           ProtocolVendorId [3];
+   uint8_t           AuxiliaryInfo [2];
+   uint32_t            ReceiveMsgQ:1;            /**< enable/disable  message to Receive Message Queue. */
+   uint32_t            AccessMode:4;             /**< channel access mode - disabled/perboot/always/shared. */
+   uint32_t            AccessModeSupported:4;    /**< access mode supported by this channel. */
+   uint32_t            Alerting:1;               /**< enable/disable alerting through this channel. */
+   uint32_t            PerMessageAuth:1;         /**< enable/disable per message Auth through this channel. */
+   uint32_t            UserLevelAuth:1;          /**< enable/disable userlevel Auth through this channel. */
+   uint32_t            MaxPrivilege:4;           /**< max privilage level allowed by this channel. */
+   uint32_t            reserved:1;
+   uint32_t            SetUserAccess:1;          /**< set user access command not allowed. */
+   uint32_t            SetChPrivilege:2;
+   uint32_t            SessionLimit:6;
+   uint32_t            LoginStatusNUP:1;
+   uint32_t            LoginStatusNUNP:1;
+   uint32_t            LoginStatusNNU:1;
+   uint32_t            MaxUser:6;
+   uint32_t            NoCurrentUser:6;
+   uint32_t            NoFixedUser:6;
+   uint32_t            ChannelIndexRam:4;
+   uint32_t            ChannelIndexNvRam:4;
+ ChannelUserInfo_T ChannelUserInfo [MAX_NUM_CH_USERS_MDS];
+
+}   ChannelInfo_T;
+
+
+///**
+// * @struct ChassisConfig_T
+// * Chassis Configuration.
+//**/
+//typedef struct
+//{
+//   uint8_t                        SysRestartCause;
+//   uint8_t                        PowerRestorePolicy;
+//   ChassisPowerState_T          ChassisPowerState;
+//   ChassisCapabilities_T        ChassisCapabilities;
+//   uint8_t						PowerCycleInterval;
+//   AMI_BootOpt_T                OemBootOpt;  /**< AMI OEM BootOptions */
+//   uint8_t                        SysPartitionScan;
+
+//}   ChassisConfig_T;
+
+
+///**
+// * @struct VLANDestTags_T
+// * VLAN Destination Tags.
+//**/
+//typedef struct
+//{
+//    uint8_t   AddressFormat;
+//    uint16_t  VLANTag;
+
+//}   VLANDestTags_T;
+
+
+///**
+// * @struct LANConfig_T
+// * LAN Configuration.
+//**/
+//typedef struct {
+
+//    uint8_t               AuthTypeSupport;
+//    AuthTypeEnables_T   AuthTypeEnables;
+//    uint8_t               IPAddr [IP_ADDR_LEN];
+//    uint8_t               IPAddrSrc;
+//    uint8_t               MACAddr [MAC_ADDR_LEN];
+//    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 [NUM_LAN_DESTINATION];
+//    LANDestAddr_T       DestAddr [NUM_LAN_DESTINATION];
+//    LANDestv6Addr_T       Destv6Addr [NUM_LAN_DESTINATION];
+//    uint16_t              VLANID;
+//    uint8_t               VLANPriority;
+//    uint8_t               CipherSuitePrivLevels [MAX_NUM_CIPHER_SUITE_PRIV_LEVELS];
+//    VLANDestTags_T      VLANDestTags [NUM_LAN_DESTINATION];
+//    BadPassword_T BadPasswd;
+//    uint8_t               IPv6_Enable;
+//    uint8_t               IPv6_IPAddrSrc;
+//    uint8_t               IPv6_IPAddr [16][IP6_ADDR_LEN];
+//    uint8_t               IPv6_PrefixLen[16];
+//    uint8_t               IPv6_GatewayIPAddr[IP6_ADDR_LEN];
+//    uint8_t               IPv4_Enable;
+//    uint8_t               AutoNegotiationEnable;
+//    uint16_t              Speed;
+//    uint8_t               Duplex;
+//    uint16_t              MTU_size;
+//}   LANConfig_T;
+
+
+///**
+// * @struct PayloadSupport_T
+// * Payload support.
+//**/
+//typedef struct
+//{
+//    uint8_t   StandPldtype1;
+//    uint8_t   StandPldtype2;
+//    uint8_t   SessStpPldtype1;
+//    uint8_t   SessStpPldtype2;
+//    uint8_t   OemPldtype1;
+//    uint8_t   OemPldtype2;
+
+//}   PayloadSupport_T;
+
+
+///**
+// * @struct PayloadInfo_T
+// * Payload information.
+//**/
+//typedef struct
+//{
+//    uint8_t   Type;
+//    uint8_t   OemPldIANA [3];
+//    uint8_t   OemPldID [2];
+//    uint8_t   Version;
+
+//}   PayloadInfo_T;
+
+
+///**
+// * @struct RMCPPlus_T
+// * RMCP+ information.
+//**/
+//typedef struct
+//{
+//    bool                LockKey [2];
+//    uint8_t               KGHashKey [HASH_KEY_LEN];
+//    uint8_t               PseudoGenKey [HASH_KEY_LEN];
+//    uint8_t               Algorithm [MAX_PAYLOADS] [MAX_PRIVILEGE_TYPES];
+//    PayloadSupport_T    PayloadSupport;
+//    PayloadInfo_T       PayloadInfo [MAX_PYLDS_SUPPORT];
+
+//}   RMCPPlus_T;
+
+
+///**
+// * @struct FFCmdConfigTbl_T
+// * Firmware Firewall Command Configuration Tbl.
+//**/
+//typedef struct
+//{
+//    uint8_t   NetFn;
+//    uint8_t   Cmd;
+//    uint8_t   Config;
+
+//}   FFCmdConfigTbl_T;
+
+
+///**
+// * @struct SOLConfig_T
+// * SOL Configuration.
+//**/
+//typedef struct
+//{
+//    uint8_t   SOLEnable;
+//    uint8_t   SOLAuth;
+//    uint16_t  CharAccThresh;
+//    uint8_t   SOLRetryCount;
+//    uint8_t   SOLRetryInterval;
+//    uint8_t   NVBitRate;
+//    uint8_t   VBitRate;
+//    uint8_t   PayldChannel;
+//    uint16_t  PayldPortNum;
+
+//}   SOLConfig_T;
+
+
+///**
+// * @struct SystemInfoConfig_T
+// * Get / Set System Info Parameters info.
+//**/
+//typedef struct
+//{
+//    SysFWVersion_T SysFWVersion;
+//    SysName_T SysName;
+//    PrimaryOSName_T PrimaryOSName;
+//} SystemInfoConfig_T;
+
+///**
+// * @struct DCMIThermalCfg_T
+// * brief Temperature limit for inlet sensors
+//**/
+//typedef struct
+//{
+//    uint8_t   Valid;
+//    uint8_t   ExceptionAction;
+//    uint8_t   TemperatureLimit;
+//    uint16_t  ExceptionTime;
+//} DCMIThermalCfg_T;
+
+//typedef struct
+//{
+//    bool	IsValid;
+//    uint8_t	ActivePowerLimit;
+//    uint8_t	ExceptionAction;
+//    uint16_t	PwrLimitInWatts;
+//    uint32_t	CorrectionTimeLimitInMsec;
+//    uint16_t	MangSamplingTimeInSecs;
+//    DCMIThermalCfg_T    ThermalCfg[MAX_TEMP_INSTANCE];
+
+//}  DCMICfg_T;
+
+
+//typedef struct
+//{
+//    uint8_t    CurrentNoUser;
+//    uint32_t    POHCounterReading;
+//    /* SEL Time UTC Offset information */
+//    uint16_t    SELTimeUTCOffset;
+//    uint32_t    SDREraseTime;
+//    /*Location of time (asia/calcutta)*/
+//    uint8_t      TimeZone[64];
+//} GENConfig_T;
+
+
+///**
+// * @struct ChcfgInfo_T
+// * Channel Configuration Information taken from respective channel .i files.
+//**/
+//typedef struct
+//{
+//    uint8_t ChType;
+//    ChannelInfo_T ChannelInfo;
+//}  ChcfgInfo_T;
+
+///**
+// * @struct AuthTypeEnable_T
+// * @brief Authentication Enables.
+//**/
+//typedef struct
+//{
+//    uint8_t Callback;
+//    uint8_t User;
+//    uint8_t Operator;
+//    uint8_t Admin;
+//    uint8_t oem;
+
+//}   AuthTypeEnable_T;
+
+
+///**
+// * @struct ChannelCallbackCtrl_T
+// * @brief Channel Callback Control.
+//**/
+//typedef struct 
+//{
+//    uint8_t CallBackEnable;
+//    uint8_t CBCPnegopt;
+//    uint8_t CallBackDes1;
+//    uint8_t CallBackDes2;
+//    uint8_t CallBackDes3;
+
+//}   ChannelCallbackCtrl_T;
+
+
+///**
+// * @struct IpmiMsgCommSettings_T
+// * @brief Communication Settings.
+//**/
+//typedef struct 
+//{
+//    uint8_t  FlowCtrl;
+//    uint8_t  BitRate;
+
+//}   IpmiMsgCommSettings_T;
+
+
+///** 
+// * @struct MuxSwitchCtrl_T
+// * @brief MUX Switch Control.
+//**/
+//typedef struct 
+//{
+//    uint8_t Data1;
+//    uint8_t Data2;
+
+//}   MuxSwitchCtrl_T;
+
+
+///**
+// * @struct ModemRingTime_T
+// * @brief Modem Ring Time.
+//**/
+//typedef struct 
+//{
+//    uint8_t RingDuration;
+//    uint8_t RingDeadTime;
+
+//}   ModemRingTime_T;
+
+
+///**
+// * @struct DestInfo_T
+// * @brief Destination Information.
+//**/
+//typedef struct 
+//{
+//    uint8_t DesType;
+//    uint8_t AlertAckTimeout;
+//    uint8_t Retries;
+//    uint8_t DesTypeSpecific;
+
+//}   DestInfo_T;
+
+
+///**
+// * @struct ModemDestCommSettings_T
+// * @brief Modem Destination Communication Settings.
+//**/
+//typedef struct 
+//{
+//    uint8_t FlowControl;
+//    uint8_t BitRate;
+
+//}   ModemDestCommSettings_T;
+
+
+///**
+// * @struct DestIPAddr_T
+// * @brief Destination IP Address.
+//**/
+//typedef struct 
+//{
+//    uint8_t ip [IP_ADDR_LEN];
+
+//}   DestIPAddr_T;
+
+
+///**
+// * @struct TAPServiceSettings_T
+// * @brief TAP Service Settings.
+//**/
+//typedef struct 
+//{
+//    uint8_t   TAPConfirmation;
+//    uint8_t   TAPServiceTypeChars [3];
+//    uint32_t  TAPCtrlESCMask;
+//    uint8_t   TimeOutParam1;
+//    uint8_t   TimeOutParam2;
+//    uint8_t   TimeOutParam3;
+//    uint8_t   RetryParam1;
+//    uint8_t   RetryParam2;
+
+//}   TAPServiceSettings_T;
+
+
+///**
+// * @struct TermConfig_T
+// * @brief Terminal Configuration Data.
+//**/
+//typedef struct 
+//{
+//    uint8_t Data1;    /* Config Data1 deals with feature configuration */
+//    uint8_t Data2;    /* Config Data2 deals with i/o termination sequence */
+
+//}   TermConfig_T;
+
+
+///**
+// * @struct PPPProtocolOptions_T
+// * @brief PPP Protocol Options.
+//**/
+//typedef struct 
+//{
+//    uint8_t  SnoopControl;
+//    uint8_t  NegControl;
+//    uint8_t  NegConfig;
+
+//}   PPPProtocolOptions_T;
+
+
+///**
+// * @struct PPPAccm_T
+// * @brief PPP ACCM.
+//**/
+//typedef struct 
+//{
+//    uint32_t  ReceiveACCM;
+//    uint32_t  TransmitACCM;
+
+//}   PPPAccm_T;
+
+
+///**
+// * @struct PPPSnoopAccm_T
+// * @brief PPP Snoop ACCM
+//**/
+//typedef struct 
+//{
+//    uint32_t  ReceiveACCM;
+
+//}   PPPSnoopAccm_T;
+
+
+///**
+// * @struct PPPUDPProxyIPHeaderData_T
+// * @brief PPP UDP Proxy Header Data.
+//**/
+//typedef struct 
+//{
+//    uint8_t SrcIPAddress [IP_ADDR_LEN];
+//    uint8_t DestIPAddress [IP_ADDR_LEN];
+
+//}   PPPUDPProxyIPHeaderData_T;
+
+
+///**
+// * @struct SMConfig_T
+// * @brief Serial/Modem Configuration.
+//**/
+//typedef struct
+//{
+//    uint8_t                       SetInProgress;
+//    uint8_t                       AuthTypeSupport;
+//    AuthTypeEnable_T            AuthTypeEnable;
+//    uint8_t                       ConnectionMode;
+//    uint8_t                       SessionInactivity;
+//    ChannelCallbackCtrl_T       ChannelCallBackCtrl;
+//    uint8_t                       SessionTermination;
+//    IpmiMsgCommSettings_T       IpmiMsgCommSet;
+//    MuxSwitchCtrl_T             MUXSwitchCtrl;
+//    ModemRingTime_T             RingTime;
+//    uint8_t                       ModemInitString [4] [16];
+//    uint8_t                       ModemEscapeSeq [MAX_MODEM_ESC_SEQ_SIZE + 1];   /*+1 for NULL Termination when */
+//    uint8_t                       ModemHangup [MAX_MODEM_HANG_UP_SEQ_SIZE + 1];  /*full non null chars are provided*/
+//    uint8_t                       ModemDialCmd [MAX_MODEM_DIAL_CMD_SIZE + 1];
+//    uint8_t                       PageBlockOut;
+//    uint8_t                       CommunityString [MAX_COMM_STRING_SIZE + 1];
+//    uint8_t                       TotalAlertDest;
+//    DestInfo_T                  DestinationInfo [MAX_SERIAL_ALERT_DESTINATIONS];
+//    uint8_t                       CallRetryInterval;
+//    ModemDestCommSettings_T     DestComSet [MAX_SERIAL_ALERT_DESTINATIONS];
+//    uint8_t                       TotalDialStr;
+//    uint8_t                       DestDialStrings [MAX_MODEM_DIAL_STRS] [MAX_MODEM_DIAL_STR_BLOCKS] [MAX_MODEM_DIAL_STR_BLOCK_SIZE];
+//    uint8_t                       TotalDestIP;
+//    DestIPAddr_T                DestAddr [MAX_MODEM_ALERT_DEST_IP_ADDRS];
+//    uint8_t                       TotalTAPAcc;
+//    uint8_t                       TAPAccountSelector [MAX_MODEM_TAP_ACCOUNTS];
+//    uint8_t                       TAPPasswd [MAX_MODEM_TAP_ACCOUNTS] [TAP_PASSWORD_SIZE + 1];
+//    uint8_t                       TAPPagerIDStrings [MAX_MODEM_TAP_ACCOUNTS] [TAP_PAGER_ID_STRING_SIZE + 1];
+//    TAPServiceSettings_T        TAPServiceSettings [MAX_MODEM_TAP_ACCOUNTS];
+//    TermConfig_T                Termconfig;
+//    PPPProtocolOptions_T        PPPProtocolOptions;
+//    uint16_t                      PPPPrimaryRMCPPort;
+//    uint16_t                      PPPSecondaryRMCPPort;
+//    uint8_t                       PPPLinkAuth;
+//    uint8_t                       CHAPName [MAX_MODEM_CHAP_NAME_SIZE];
+//    PPPAccm_T                   PPPACCM;
+//    PPPSnoopAccm_T              PPPSnoopACCM;
+//    uint8_t                       TotalPPPAcc;
+//    uint8_t                       PPPAccDialStrSel [MAX_MODEM_PPP_ACCOUNTS];
+//    uint8_t                       PPPAccIPAddress [MAX_MODEM_PPP_ACCOUNTS] [IP_ADDR_LEN];
+//    uint8_t                       PPPAccUserNames [MAX_MODEM_PPP_ACCOUNTS] [PPP_ACC_USER_NAME_DOMAIN_PASSWD_SIZE + 1 ];
+//    uint8_t                       PPPAccUserDomain [MAX_MODEM_PPP_ACCOUNTS] [PPP_ACC_USER_NAME_DOMAIN_PASSWD_SIZE + 1];
+//    uint8_t                       PPPAccUserPasswd [MAX_MODEM_PPP_ACCOUNTS] [PPP_ACC_USER_NAME_DOMAIN_PASSWD_SIZE + 1];
+//    uint8_t                       PPPAccAuthSettings [MAX_MODEM_PPP_ACCOUNTS];
+//    uint8_t                       PPPAccConnHoldTimes [MAX_MODEM_PPP_ACCOUNTS];
+//    PPPUDPProxyIPHeaderData_T   PPPUDPProxyIPHeadData;
+//    uint16_t                      PPPUDPProxyTransmitBuffSize;
+//    uint16_t                      PPPUDPProxyReceiveBuffSize;
+//    uint8_t                       PPPRemoteConsoleIPAdd [IP_ADDR_LEN];
+//    BadPassword_T               BadPasswd;
+
+//}   SMConfig_T;
+
+/*
+* SensorOffsetInfo_T Structure
+*/
+typedef struct {
+
+    uint8_t SensorLUN;
+    uint8_t SensorNo;
+    int8_t Offset;
+    uint8_t valid;
+
+}  SensorOffsetInfo_T;
+
+
+/*
+* OPMA_IDPair_T Structure
+*/
+typedef struct
+{
+    uint16_t OemId;
+    uint16_t ImplementationId;
+
+}  OPMA_IDPair_T;
+
+
+///*
+// * OPMA Config Structure
+// * The OPMA specific Data are stored in this Structure
+// */
+//typedef struct
+//{
+//    SensorOffsetInfo_T SensorOffsetInfo [256];
+//    uint8_t         SupportedSysCount;
+//    OPMA_IDPair_T OPMA_IdPairs [ MAX_ID_PAIRS ];
+//    OPMA_IDPair_T SystemIdentifier ;
+//    uint8_t SysLocalAccessLockout;
+//    uint16_t OPMASpecComplaince;
+
+//}  OPMA_Config_T;
+
+
+//typedef struct
+//{
+//    uint8_t EnableDisableSMTP;
+//    uint8_t EnableDisableSmtpAuth;
+//    uint8_t ServerAddr [ IP_ADDR_LEN ];
+//    uint8_t IP6_ServerAddr [ IP6_ADDR_LEN ];
+//    uint8_t UserName [ MAX_SMTP_USERNAME_LEN ];
+//    uint8_t Passwd   [MAX_SMTP_PASSWD_LEN];
+//    uint8_t NoofDestinations;
+//    uint8_t Subject	 [MAX_EMAIL_DESTINATIONS+1][MAX_SUB_BLOCK_SIZE * MAX_SUB_BLOCKS];
+//    uint8_t Msg	 [MAX_EMAIL_DESTINATIONS+1][MAX_MSG_BLOCK_SIZE * MAX_MSG_BLOCKS];
+//    uint8_t SenderAddr[MAX_EMAIL_BLOCK_SIZE * MAX_EMAIL_ADDR_BLOCKS];
+//    uint8_t  Servername[MAX_SRV_NAME_BLOCK_SIZE * MAX_SRV_NAME_BLOCKS];
+//    uint16_t SmtpPort;
+//    uint8_t UserID[MAX_EMAIL_DESTINATIONS+1];
+//    uint8_t EnableDisableSMTP2;
+//    uint8_t EnableDisableSmtp2Auth;
+//    uint8_t Server2Addr [ IP_ADDR_LEN ];
+//    uint8_t IP6_Server2Addr [ IP6_ADDR_LEN ];
+//    uint8_t UserName2 [ MAX_SMTP_USERNAME_LEN ];
+//    uint8_t Passwd2 [MAX_SMTP_PASSWD_LEN];
+//    uint8_t Sender2Addr[MAX_EMAIL_BLOCK_SIZE * MAX_EMAIL_ADDR_BLOCKS];
+//    uint8_t  Server2name[MAX_SRV_NAME_BLOCK_SIZE * MAX_SRV_NAME_BLOCKS];
+//    uint16_t Smtp2Port;
+//}  Smtp_Config_T;
+
+
+/**
+ * @struct TriggerEventCfg_T
+ * Trigger Event Configuration.
+**/
+typedef struct
+{
+   uint8_t CriticalFlag;
+   uint8_t NONCriticalFlag;
+   uint8_t NONRecoverableFlag;
+   uint8_t FanTroubled;
+   uint8_t WDTTimeExpire;
+   uint8_t SysDConFlag;
+   uint8_t SysDCoffFlag;
+   uint8_t SysResetFlag;
+   uint8_t LPCResetFlag;
+   uint8_t SpecDateTime;
+   uint32_t Time;
+} TriggerEventCfg_T;
+
+/**
+ * @struct LoginAuditConfig_T
+ * Login Audit Configuration.
+**/
+typedef struct
+{
+   uint8_t WebEventMask;
+   uint8_t IPMIEventMask;
+   uint8_t TelnetEventMask;
+   uint8_t SSHEventMask;
+   uint8_t KVMEventMask;
+} LoginAuditConfig_T;
+
+/**
+ * @struct AMIConfig_T
+ * @brief AMI Specific Configuration.
+**/
+typedef struct
+{
+    uint8_t CircularSEL;
+    uint8_t  CircularSELFlag;
+
+}  AMIConfig_T;
+
+///**
+// * @struct SSIConfig_T
+// * @brief SSI Configuration.
+//**/
+//typedef struct
+//{
+//    OpState CurrentState;
+//    uint32_t  CurrentConditions;
+//    uint8_t   CurrentPowerLevel;
+//    uint8_t   CMMIPAddr[IP_ADDR_LEN];
+
+//}  SSIConfig_T; 
+
+typedef struct
+{
+    uint32_t Version;
+}  VersionConfig_T;
+
+typedef struct
+{
+    uint8_t Host[200];
+    uint8_t Path[200];
+    uint8_t Retry;
+}  ConnectionInfo_T;
+
+typedef struct
+{
+    uint8_t ProtocolType;
+    ConnectionInfo_T ConnectionInfo;
+}  FWConfig_T;
+
+typedef struct
+{
+    char  EncryptedPswd[MAX_ENCRYPTED_PSWD_LEN];
+}  EncryptedUserInfo_T;
+#pragma pack( )
+
+/**
+ * @brief Initialize PM configuration information.
+ * @return 0 if success, -1 if error.
+**/
+extern int InitPMConfig (int BMCInst);
+
+
+/**
+*@fn InitChannelConfigs
+*@brief This function is Initialize to load all Channel Configs from NVRAM to RAM
+*/
+extern int InitChannelConfigs(int BMCInst);
+
+/**
+*@fn InitDCMIConfig
+*@brief This function is invoked to Initialize all DCMI Configs from NVRAM to RAM
+*/
+extern int initDCMIConfig(int BMCInst);
+
+/**
+*@fn InitUserConfig
+*@brief This function is invoked to Initialize UserConfigs from NVRAM to RAM
+*/
+extern int InitUserConfig(int BMCInst);
+
+/**
+*@fn InitTriggerEventConfig
+*@brief This function is invoked to Initialize TriggerEventConfig from NVRAM to RAM
+*/
+extern int InitTriggerEventConfig(int BMCInst);
+
+/**
+*@fn InitLoginAuditConfig
+*@brief This function is invoked to Initialize the login audit configuration from NVRAM to RAM
+*/
+extern int InitLoginAuditConfig(int BMCInst);
+
+/**
+*@fn InitEncUserPswdConfig
+*@brief This function is invoked to Initialize EncUserPasswordsConfigs from NVRAM to RAM
+*/
+extern int InitEncUserPswdConfig(int BMCInst);
+
+/**
+*@fn InitChannelPriv
+*@brief Add Channel Groups
+**/
+extern void InitChannelPrivtbl(int BMCInst);
+
+/**
+*@fn AddUserToChGroups
+*@brief Add users to Channel Groups
+**/
+extern void AddUserToChGroups(int BMCInst);
+#endif /* PMCONFIG_H */
+

+ 37 - 36
app/bmc_server/ipmi_dev/Sensor.h → app/bmc/msghndlr/SensorEvent/Sensor.h

@@ -22,18 +22,17 @@
 #ifndef SENSOR_H
 #define SENSOR_H
 
-#include "Types.h"
-#include "IPMI_Sensor.h"
-#include "SDRRecord.h"
-//#include "SensorMonitor.h"
+#include "com_IPMI_Sensor.h"
+#include "com_IPMI_SDRRecord.h"
+#include "SensorMonitor.h"
 
 /**
  * @brief Sensor Types
  */
 #define PROCESSOR				0x07
-#define POWER_SUPPLY				0x08
+#define POWER_SUPPLY			0x08
 #define MEMORY					0x0c
-#define ENTITY_PRESENCE				0x25
+#define ENTITY_PRESENCE			0x25
 #define BATTERY					0x29
 
 
@@ -141,27 +140,29 @@
  * @brief Initialize Sensor information.
  * @return 0 if success, -1 if error
 **/
-extern int InitSensor (int BMCInst);
+extern int InitSensorInfo (void);
+
+extern int InitSensorDev (void);
 
 /**
  * @brief Initialize the scanning bit of each sensor
  * @return 0 if success, -1 if error
  */
-extern int InitSensorScanningBit (int BMCInst);
+extern int InitSensorScanningBit (void);
 
 /**
  * @brief Get sensor's SDR record.
  * @param SensorNum - Sensor number.
  * @return the sensor's SDR record.
 **/
-extern _FAR_ SDRRecHdr_T* SR_GetSensorSDR (INT8U SensorNum,int BMCInst);
+extern SDRRecHdr_T* SR_GetSensorSDR (uint8_t SensorNum);
 
 
-extern int GetRecordIdsforDCMISensor (INT8U EntityID,INT8U SensorType,INT8U EntityInstance, 
-		INT8U StartingEntityInstance, INT16U* pBuf, INT8U* pTotalValidInstances,int BMCInst);
+extern int GetRecordIdsforDCMISensor (uint8_t EntityID,uint8_t SensorType,uint8_t EntityInstance, 
+		uint8_t StartingEntityInstance, uint16_t* pBuf, uint8_t* pTotalValidInstances);
 
-extern int GetDCMITempReading(INT8U EntityID, INT8U SensorType,INT8U EntityInstance,
-                            INT8U StartingEntityInstance, INT8U* pBuf, INT8U* pTotalValidInstances,int BMCInst);
+extern int GetDCMITempReading(uint8_t EntityID, uint8_t SensorType,uint8_t EntityInstance,
+                            uint8_t StartingEntityInstance, uint8_t* pBuf, uint8_t* pTotalValidInstances);
 
 /**
  * @defgroup sdc Sensor Device Commands
@@ -171,23 +172,23 @@ extern int GetDCMITempReading(INT8U EntityID, INT8U SensorType,INT8U EntityInsta
  * sensor values.
  * @{
 **/
-extern int GetDevSDRInfo (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetDevSDR (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int ReserveDevSDRRepository (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int SetSensorType (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetSensorType (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int ReArmSensor (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetSensorEventStatus (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int SetSensorHysterisis (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetSensorHysterisis (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int SetSensorThresholds (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetSensorThresholds (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetSensorReadingFactors (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int SetSensorEventEnable (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetSensorEventEnable (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetSensorReading (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int SetSensorReading (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-int CompareValues(BOOL isSigned, INT8U val1, INT8U val2);
+extern int GetDevSDRInfo ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetDevSDR ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int ReserveDevSDRRepository ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SetSensorType ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetSensorType ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int ReArmSensor ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetSensorEventStatus ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SetSensorHysterisis ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetSensorHysterisis ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SetSensorThresholds ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetSensorThresholds ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetSensorReadingFactors ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SetSensorEventEnable ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetSensorEventEnable ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetSensorReading ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SetSensorReading ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+int CompareValues(uint8_t isSigned, uint8_t val1, uint8_t val2);
 /** @} */
 
 /**
@@ -196,7 +197,7 @@ int CompareValues(BOOL isSigned, INT8U val1, INT8U val2);
  * @param Res       - Response data.
  * @return 0 if success, -1 if error.
 **/
-extern int SR_GetSensorHysterisis  (INT8U SensorNum, _NEAR_ GetSensorHysterisisRes_T* Res);
+extern int SR_GetSensorHysterisis  (uint8_t SensorNum,  GetSensorHysterisisRes_T* Res);
 
 /**
  * @brief Get Sensor Threshold.
@@ -204,7 +205,7 @@ extern int SR_GetSensorHysterisis  (INT8U SensorNum, _NEAR_ GetSensorHysterisisR
  * @param Res       - Response data.
  * @return 0 if success, -1 if error.
 **/
-extern int SR_GetSensorThreshold   (INT8U SensorNum, _NEAR_ GetSensorThresholdRes_T* Res);
+extern int SR_GetSensorThreshold   (uint8_t SensorNum,  GetSensorThresholdRes_T* Res);
 
 /**
  * @brief Get Sensor Event Enables.
@@ -212,14 +213,14 @@ extern int SR_GetSensorThreshold   (INT8U SensorNum, _NEAR_ GetSensorThresholdRe
  * @param Res       - Response data.
  * @return 0 if success, -1 if error.
 **/
-//extern int SR_GetSensorEventEnable (INT8U  SensorNum, _NEAR_ GetSensorEventEnableRes_T* Res);
+extern int SR_GetSensorEventEnable (uint8_t  SensorNum,  GetSensorEventEnableRes_T* Res);
 
 /**
  * @brief Get Sensor Reading.
  * @param SensorNum - Sensor number.
  * @return the Sensor reading.
 **/
-extern INT16U SM_GetSensorReading (INT8U SensorNum, INT16U *pSensorReading);
+extern uint16_t SM_GetSensorReading (uint8_t SensorNum, uint16_t *pSensorReading);
 
 /**
  * @brief SR_LoadSDRDefaults.
@@ -227,7 +228,7 @@ extern INT16U SM_GetSensorReading (INT8U SensorNum, INT16U *pSensorReading);
  * @return none.
 **/
 
-extern void SR_LoadSDRDefaults (SDRRecHdr_T* sr, SensorInfo_T* pSensorInfo,int BMCInst);
+extern void SR_LoadSDRDefaults (SDRRecHdr_T* sr, SensorInfo_T* pSensorInfo);
 
 
 /**
@@ -236,7 +237,7 @@ extern void SR_LoadSDRDefaults (SDRRecHdr_T* sr, SensorInfo_T* pSensorInfo,int B
  * @return none.
 **/
 
-extern SDRRecHdr_T* SR_FindSDR (INT8U SensorNum, INT8U SensorOwnerLUN, int BMCInst);
+extern SDRRecHdr_T* SR_FindSDR (uint8_t SensorNum);
 
 
 #endif  /* SENSOR_H */

+ 2114 - 0
app/bmc/msghndlr/SensorEvent/SensorDevice/Sensor.c

@@ -0,0 +1,2114 @@
+/*****************************************************************
+ *****************************************************************
+ ***                                                            **
+ ***    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ ***                                                            **
+ ***            All Rights Reserved.                            **
+ ***                                                            **
+ ***        6145-F, Northbelt Parkway, Norcross,                **
+ ***                                                            **
+ ***        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ ***                                                            **
+ *****************************************************************
+ *****************************************************************
+ ******************************************************************
+ *
+ * sensor.c
+ * Sensor functions.
+ *
+ *  Author: Govind Kothandapani <govindk@ami.com>
+ *          Bakka Ravinder Reddy <bakkar@ami.com>
+ ******************************************************************/
+
+#include "MsgHndlr.h"
+#include "sensor_tbl.h"
+#include "com_IPMI_Sensor.h"
+#include "Support.h"
+#include "Sensor.h"
+#include "SDRFunc.h"
+#include "SensorEvent.h"
+#include <string.h>
+#include "main.h"
+
+/* Reserved bit macro definitions */
+#define RESERVED_BITS_SETSENSORTYPE                     0X80 //(BIT7)
+#define RESERVED_BITS_REARMSENSOR_REARMALLEVENTS        0X7F //(BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0)
+#define RESERVED_BITS_REARMSENSOR_REARMASSEVT2_1        0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+#define RESERVED_BITS_REARMSENSOR_REARMDEASSEVT2_1      0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+#define RESERVED_BITS_REARMSENSOR_REARMASSEVT2_2        0X80 //(BIT7)
+#define RESERVED_BITS_REARMSENSOR_REARMDEASSEVT2_2      0X80 //(BIT7)
+#define RESERVED_BITS_SETSENSORTHRESHOLDS               0XC0 //(BIT7 | BIT6)
+#define RESERVED_BITS_SETSENEVTEN_FLAGS                 0X0F //(BIT3 | BIT2 | BIT1 | BIT0)
+#define RESERVED_BITS_SETSENEVTEN_ASSERTIONMASK         0X8000
+#define RESERVED_BITS_SETSENEVTEN_DEASSERTIONMASK       0X8000
+#define RESERVED_BITS_SETSENRD_ASSEVTOCCBYTE_1          0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+#define RESERVED_BITS_SETSENRD_DEASSEVTOCCBYTE_1        0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+#define RESERVED_BITS_SETSENRD_ASSEVTOCCBYTE_2          0x80 //(BIT7)
+#define RESERVED_BITS_SETSENRD_DEASSEVTOCCBYTE_2        0x80 //(BIT7)
+
+#define SENSOR_THRESOLD_ACCESS_BITS        0x0c //(BIT2 | BIT3)
+#define SENSOR_HYSTERESIS_ACCESS_BITS      0x30 //(BIT4 | BIT5)
+
+#if SENSOR_DEVICE == 1
+
+
+/*** Local Definitions ***/
+//#define NUM_SENSORS()         (g_BMCInfo.SenConfig.NumThreshSensors + g_BMCInfo.SenConfig.NumNonThreshSensors)
+
+#define FULL_SDR_REC                0x01
+#define COMPACT_SDR_REC             0x02
+#define OEM_SDR_FRU_REC             0xf1
+#define OEM_SDR_NM_REC             0x0D
+
+#define FL_STATIC_SENSOR            0x00
+#define FL_NUM_LUN(NUM_LUN)         NUM_LUN
+
+#define LWR_NON_CRIT                0x01
+#define LWR_CRIT                    0x02
+#define LWR_NON_REC                 0x04
+#define UPR_NON_CRIT                0x08
+#define UPR_CRIT                    0x10
+#define UPR_NON_REC                 0x20
+
+#define EVENT_MSG_MASK              0x80
+#define SCAN_MASK                   0x40
+#define ENABLE_DISABLE_EVENT_MASK   0x30
+#define DO_NOT_CHANGE               0x00
+#define ENABLE_SELECTED_EVENT_MSG   0x10
+#define DISABLE_SELECTED_EVENT_MSG  0x20
+
+
+#define CC_INVALID_ATTEMPT_TO_SET   0x80
+#define MIN_SET_SEN_READING_CMD_LEN  3
+#define LEN_FOR_EVT_DATA             10
+#define MAX_SET_SEN_READ_LEN         10
+#define LEN_FOR_ASSERT_DATA          5
+#define LEN_FOR_DEASSERT_DATA        7
+#define LEN_FOR_SETSENSOR_DATA       3
+
+#define NOT_FOUND_SCAN_DISABLED		-1
+#define NOT_FOUND_SCAN_ENABLED		-2
+#define ENTITY_FOUND				1
+#define ENTITY_NOT_FOUND			0
+
+#define DCMI_TEMP_READING    0x0
+#define DCMI_INST_NUMBER      0x1
+
+/*** Local typedefs ***/
+
+/**
+ * @struct SR_SensorInfo_T
+ * @brief Sensor Information.
+**/
+typedef struct
+{
+    /* CAUTION Order of members dependent on Response structures */
+    uint8_t   M_LSB;
+    uint8_t   M_MSB_Tolerance;
+    uint8_t   B_LSB;
+    uint8_t   B_MSB_Accuracy;
+    uint8_t   Accuracy_MSB_Exp;
+    uint8_t   RExp_BExp;
+
+    uint8_t   PositiveHysterisis;
+    uint8_t   NegativeHysterisis;
+
+    uint8_t   LowerNonCritical;
+    uint8_t   LowerCritical;
+    uint8_t   LowerNonRecoverable;
+    uint8_t   UpperNonCritical;
+    uint8_t   UpperCritical;
+    uint8_t   UpperNonRecoverable;
+
+    uint8_t   EventFlags;
+    uint16_t  AssertionMask;
+    uint16_t  DeAssertionMask;
+
+    uint8_t   EventTypeCode;
+
+    uint16_t  ReadWriteThreshMask;
+    uint8_t   SensorInit;
+    uint8_t   SensorNum;
+
+} SR_SensorInfo_T;
+
+
+/*** Global Variables ***/
+// uint8_t g_NumThreshSensors;
+// uint8_t g_NumNonThreshSensors;
+//  uint8_t g_FRUInfo[MAX_PDK_FRU_SUPPORTED];
+//FRUInfo_T   *m_FRUInfo[MAX_PDK_FRU_SUPPORTED];
+//uint8_t m_total_frus=0;
+
+//Sensor-Type  Sensor-specific-offset
+static const uint8_t sensor_presence [][2] = {
+    {PROCESSOR, PROCESSOR_PRESENCE_DETECTED},
+    {POWER_SUPPLY, POWER_SUPPLY_PRESENCE_DETECTED},
+    {POWER_SUPPLY, POWER_SUPPLY_OUT_OF_RANGE_PRESENT},
+    {MEMORY, MEMORY_PRESENCE_DETECTED},
+    {ENTITY_PRESENCE, ENTITY_PRESENCE_ENTITY_PRESENT},
+    {BATTERY, BATTERY_PRESENCE_DETECTED}
+};
+#define SENSOR_PRESENCE_COUNT	(sizeof(sensor_presence)/ sizeof(sensor_presence[0]))
+
+
+/*** Prototype Declaration ***/
+//static void FindNumSensors (void);
+
+
+/*---------------------------------------
+ * InitSensor
+ *---------------------------------------*/
+int
+InitSensorInfo ()
+{
+	SensorInfo_T*        	pSensorInfo;
+	SensorSharedMem_T*    	pSMSharedMem;
+	SDRRecHdr_T*			pSDRRec;
+	int i;
+	
+	pSMSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem;
+	/* Update Sensor Properties & Get SDR & initialize sensors */
+	for (i = 0; i < g_BMCInfo.SenConfig.ValidSensorCnt; i++)
+	{
+		pSensorInfo = (SensorInfo_T*)&pSMSharedMem->SensorInfo [i];
+		
+		g_BMCInfo.SenConfig.ValidSensorList[i]	=	sensor_tbl[i].sensor_number;
+		
+		pSensorInfo->SensorNumber	= 	sensor_tbl[i].sensor_number;
+		pSensorInfo->SensorReading	=	0;
+		pSensorInfo->SensorMonitorInterval	=	sensor_tbl[i].monitor_interval;
+		pSensorInfo->SensorState			=	sensor_tbl[i].monitor_state;
+		pSensorInfo->PowerOnDelay			=	sensor_tbl[i].poweron_delay;
+		pSensorInfo->SysResetDelay			=	sensor_tbl[i].reset_delay;
+		
+		pSDRRec		=	SR_FindSDR(pSensorInfo->SensorNumber);
+		
+		SR_LoadSDRDefaults(pSDRRec, pSensorInfo);
+		
+		pSensorInfo->SDRRec		=	(SDRRecHdr_T*)pSDRRec;
+	}
+    return 0;
+}
+
+/*---------------------------------------
+ * InitSensor
+ *---------------------------------------*/
+int
+InitSensorDev ()
+{
+	int i;
+	sensor_tbl_t*	pSensorDev	=	NULL;
+	for(i=0;i<g_BMCInfo.SenConfig.ValidSensorCnt;i++)
+	{
+		pSensorDev = (sensor_tbl_t*)getSensorDev(g_BMCInfo.SenConfig.ValidSensorList[i]);
+		pSensorDev->device_init();
+	}
+	return 0;
+}
+
+/*-----------------------------------------
+ * SR_FindSDR
+ *-----------------------------------------*/
+SDRRecHdr_T* SR_FindSDR (uint8_t SensorNum)	
+{
+	SDRRecHdr_T*	sr = SDR_GetFirstSDRRec ();
+	FullSensorRec_T*      sfs = NULL;
+    CompactSensorRec_T*   scs = NULL;
+	
+	while(sr != 0)
+	{
+		if (sr->Type == FULL_SDR_REC)
+		{
+			sfs = (FullSensorRec_T*) sr;
+			if (sfs->SensorNum == SensorNum) { return sr; }
+		}
+		else if (sr->Type == COMPACT_SDR_REC)
+		{
+			scs = (CompactSensorRec_T*) sr;
+			if (scs->SensorNum == SensorNum) { return sr; }
+		}
+
+		/* Get the next record */
+		sr = SDR_GetNextSDRRec (sr);
+	}
+
+	return NULL;
+}
+
+/*-----------------------------------------
+ * SR_LoadSDRDefaults
+ * CAUTION !! this function has to be called
+ * after acquiring a sensor shared memory mutex
+ *-----------------------------------------*/
+extern void
+SR_LoadSDRDefaults (SDRRecHdr_T* sr, SensorInfo_T* pSensorInfo)
+{
+    FullSensorRec_T*      sfs;
+    CompactSensorRec_T*   scs;
+
+    // Populater sensor information for Threshold sensors
+    if (sr->Type == FULL_SDR_REC)
+    {
+        sfs = ( FullSensorRec_T*) sr;
+
+        pSensorInfo->SensorOwnerLun     = sfs->OwnerLUN;		/* Multi-LUN support */
+        pSensorInfo->SensorNumber       = sfs->SensorNum;
+        pSensorInfo->M_LSB              = sfs->M;
+        pSensorInfo->M_MSB_Tolerance    = sfs->M_Tolerance;
+        pSensorInfo->B_LSB              = sfs->B;
+        pSensorInfo->B_MSB_Accuracy     = sfs->B_Accuracy;
+        pSensorInfo->Accuracy_MSB_Exp   = sfs->Accuracy;
+        pSensorInfo->RExp_BExp          = sfs->R_B_Exp;
+        pSensorInfo->Units1             = sfs->Units1;
+        pSensorInfo->Units2             = sfs->Units2;
+        pSensorInfo->Units3             = sfs->Units3;
+        pSensorInfo->RecordID           = sfs->hdr.ID;
+
+        pSensorInfo->PosHysteresis      = sfs->PositiveHysterisis;
+        pSensorInfo->NegHysteresis      =  sfs->NegativeHysterisis;
+
+        pSensorInfo->SensorInit         = sfs->SensorInit;
+        pSensorInfo->SettableThreshMask = (sfs->DiscreteReadingMask);
+        pSensorInfo->SensorCaps 		= sfs->SensorCaps;
+        pSensorInfo->SensorTypeCode     = sfs->SensorType;
+        pSensorInfo->OEMField 			= sfs->OEMField ;
+
+        if (pSensorInfo->SensorInit & BIT4)
+        {
+            if (pSensorInfo->SettableThreshMask & BIT8)
+            {
+                pSensorInfo->LowerNonCritical = sfs->LowerNonCritical;
+            }
+            if (pSensorInfo->SettableThreshMask & BIT9)
+            {
+                pSensorInfo->LowerCritical = sfs->LowerCritical;
+            }
+            if (pSensorInfo->SettableThreshMask & BIT10)
+            {
+                pSensorInfo->LowerNonRecoverable = sfs->LowerNonRecoverable;
+            }
+            if (pSensorInfo->SettableThreshMask & BIT11)
+            {
+                pSensorInfo->UpperNonCritical = sfs->UpperNonCritical;
+            }
+            if (pSensorInfo->SettableThreshMask & BIT12)
+            {
+                pSensorInfo->UpperCritical = sfs->UpperCritical;
+            }
+            if (pSensorInfo->SettableThreshMask & BIT13)
+            {
+                pSensorInfo->UpperNonRecoverable = sfs->UpperNonRecoverable;
+            }
+        }
+
+        pSensorInfo->EventFlags					 = 0;
+        pSensorInfo->EventFlags		     		 |= sfs->SensorInit & BIT6;
+        pSensorInfo->EventFlags		     		 |= (sfs->SensorInit & BIT5) << 2;
+        pSensorInfo->EventFlags                  |= sfs->SensorInit & BIT5;
+        pSensorInfo->AssertionEventEnablesByte1  = (sfs->AssertionEventMask) & 0xFF;
+        pSensorInfo->AssertionEventEnablesByte2  = ((sfs->AssertionEventMask) >> 8) & 0xFF;
+
+        pSensorInfo->DeassertionEventEnablesByte1= (sfs->DeAssertionEventMask) & 0xFF;
+        pSensorInfo->DeassertionEventEnablesByte2= ((sfs->DeAssertionEventMask) >> 8) & 0xFF;
+
+        pSensorInfo->EventTypeCode  	= sfs->EventTypeCode;
+        pSensorInfo->SensorReadType		= sfs->EventTypeCode;
+    }
+	else if (sr->Type == COMPACT_SDR_REC)
+	{
+		scs = ( CompactSensorRec_T*) sr;
+
+		pSensorInfo->SensorOwnerLun     		= scs->OwnerLUN;		/* Multi-LUN support */
+		pSensorInfo->SensorNumber       		= scs->SensorNum;
+		pSensorInfo->EventFlags					= 0;
+		pSensorInfo->EventFlags		     		 |= scs->SensorInit & BIT6;
+		pSensorInfo->EventFlags		     		 |= (scs->SensorInit & BIT5) << 2;
+		pSensorInfo->EventFlags                  |= scs->SensorInit & BIT5;
+		pSensorInfo->AssertionEventEnablesByte1  = (scs->AssertionEventMask) & 0xFF;
+		pSensorInfo->AssertionEventEnablesByte2  = ((scs->AssertionEventMask) >> 8) & 0xFF;
+
+		pSensorInfo->DeassertionEventEnablesByte1= (scs->DeAssertionEventMask) & 0xFF;
+
+		pSensorInfo->DeassertionEventEnablesByte2= ((scs->DeAssertionEventMask) >> 8) & 0xFF;
+		pSensorInfo->SensorInit         	= scs->SensorInit;
+		pSensorInfo->SettableThreshMask 	= (scs->DiscreteReadingMask);
+		pSensorInfo->PosHysteresis 		= scs->PositiveHysteris;
+		pSensorInfo->NegHysteresis 		= scs->NegativeHysterisis;
+		pSensorInfo->EventTypeCode      	= scs->EventTypeCode;
+		pSensorInfo->SensorReadType			= scs->EventTypeCode;
+		pSensorInfo->SensorTypeCode     	= scs->SensorType;
+		pSensorInfo->SensorCaps = scs->SensorCaps;
+
+		pSensorInfo->Units1                 = scs->Units1;
+		pSensorInfo->Units2                 = scs->Units2;
+		pSensorInfo->Units3                 = scs->Units3;
+		pSensorInfo->OEMField 				= scs->OEMField ;
+    }
+}
+
+/*---------------------------------------
+ * GetDevSDRInfo
+ *---------------------------------------*/
+int
+GetDevSDRInfo ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    GetSDRInfoRes_T* 	pGetDevSDRInfoRes = (GetSDRInfoRes_T*) pRes;
+
+    /* Fill in response data */
+    pGetDevSDRInfoRes->CompletionCode = CC_NORMAL;
+    pGetDevSDRInfoRes->NumSensor     = g_BMCInfo.SenConfig.ValidSensorCnt;
+    pGetDevSDRInfoRes->Flags         = 0x01; /* BIT7 = 0 (static sensors), BIT0 = 1 (on LUN 0) */
+    pGetDevSDRInfoRes->TimeStamp = 0;
+
+    return sizeof (GetSDRInfoRes_T);
+}
+
+
+/*---------------------------------------
+ * GetDevSDR
+ *---------------------------------------*/
+int
+GetDevSDR ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    return GetSDR (pReq, ReqLen, pRes);
+}
+
+/*---------------------------------------
+ * GetDevSDR
+ *---------------------------------------*/
+int
+ReserveDevSDRRepository ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    return ReserveSDRRepository (pReq, ReqLen, pRes);
+}
+
+
+/*---------------------------------------
+ * SetSensorType
+ *---------------------------------------*/
+int
+SetSensorType ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	printf("SetSensorType not implement\r\n");
+//    //pRes [0] = CC_INV_CMD;
+//    //return sizeof (*pRes);
+//     SetSensorTypeReq_T * pSetSensorTypeReq=( SetSensorTypeReq_T *)pReq;
+//     SetSensorTypeRes_T * pSetSensorTypeRes=( SetSensorTypeRes_T *)pRes;
+//     SensorSharedMem_T*	pSenSharedMem; 
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+
+
+//    /* Check for the reserved bytes should b zero */
+
+//    if  ( 0 !=  (pSetSensorTypeReq->EventTypeCode & RESERVED_BITS_SETSENSORTYPE ) )
+//    {
+//         pSetSensorTypeRes->CompletionCode = CC_INV_DATA_FIELD;
+//        return sizeof(*pRes);
+//    }
+
+//    OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
+//    pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem; //m_hSensorSharedMem;
+
+//    if (!pSenSharedMem->SensorInfo [pSetSensorTypeReq->SensorNum].IsSensorPresent)
+//    {
+//        /* Release mutex for Sensor shared memory */
+//        OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
+
+//        /* return sdr record not present completion code */
+//        pSetSensorTypeRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
+//        return sizeof (*pRes);
+//    }
+
+//    pSenSharedMem->SensorInfo[pSetSensorTypeReq->SensorNum].SensorTypeCode=pSetSensorTypeReq->SensorType;
+//    pSenSharedMem->SensorInfo[pSetSensorTypeReq->SensorNum].EventTypeCode=pSetSensorTypeReq->EventTypeCode;
+
+//    OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
+
+//    pSetSensorTypeRes->CompletionCode=CC_NORMAL;
+
+//    return sizeof(*pSetSensorTypeRes);
+	return 0;
+}
+
+
+/*---------------------------------------
+ * GetSensorType
+ *---------------------------------------*/
+int
+GetSensorType ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    //pRes [0] = CC_INV_CMD;
+    // return sizeof (*pRes);
+
+     GetSensorTypeReq_T * pGetSensorTypeReq=( GetSensorTypeReq_T *)pReq;
+     GetSensorTypeRes_T * pGetSensorTypeRes=( GetSensorTypeRes_T *)pRes;
+	SensorInfo_T*	pSensorInfo	=	NULL;
+
+	pSensorInfo	=	getSensorInfo(pGetSensorTypeReq->SensorNum);
+    pGetSensorTypeRes->CompletionCode=CC_NORMAL;
+    pGetSensorTypeRes->SensorType=pSensorInfo->SensorTypeCode;
+    pGetSensorTypeRes->EventTypeCode=pSensorInfo->EventTypeCode;
+
+    return sizeof(*pGetSensorTypeRes);
+
+}
+
+
+/*---------------------------------------
+ * ReArmSensor
+ *---------------------------------------*/
+int
+ReArmSensor ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	printf("ReArmSensor not implement\r\n");
+//      MsgPkt_T        Msg;
+//    HQueue_T hSMHndlr_Q;
+//      ReArmSensorReq_T    ReArmSensorReq;
+//      ReArmSensorReq_T*   pReArmSensorReq = &ReArmSensorReq;
+//      ReArmSensorRes_T*   pReArmSensorRes = ( ReArmSensorRes_T*) pRes;
+
+//    _fmemset (&ReArmSensorReq,  0, sizeof (ReArmSensorReq_T));
+//    _fmemcpy (&ReArmSensorReq,  pReq, ReqLen);
+//     SensorSharedMem_T*	pSenSharedMem; 
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+
+//     /* if request length is invalid */
+//    if ((ReqLen < 2) || (ReqLen > sizeof (ReArmSensorReq_T)))
+//    {
+//        /* return request invalid length completion code */
+//        pReArmSensorRes->CompletionCode = CC_REQ_INV_LEN;
+//        return sizeof (*pRes);
+//    }
+
+//    /* Check for the reserved bytes should b zero */
+
+//    if ( 0 !=  (pReArmSensorReq->ReArmAllEvents & RESERVED_BITS_REARMSENSOR_REARMALLEVENTS ) )
+//    {
+//        pReArmSensorRes->CompletionCode = CC_INV_DATA_FIELD;
+//        return sizeof (*pRes);
+//    }
+
+//    OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo.SensorSharedMemMutex, WAIT_INFINITE);
+//    pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem; //m_hSensorSharedMem;
+
+//    /* Check for the reserved bits */ 
+//    if (pSenSharedMem->SensorInfo [pReArmSensorReq->SensorNum].SensorReadType == THRESHOLD_SENSOR_CLASS)
+//    {
+//        if ((pReArmSensorReq->ReArmAssertionEvents2 & RESERVED_BITS_REARMSENSOR_REARMASSEVT2_1) ||
+//            (pReArmSensorReq->ReArmDeassertionEvents2 & RESERVED_BITS_REARMSENSOR_REARMDEASSEVT2_1))
+//        {
+//            pReArmSensorRes->CompletionCode = CC_INV_DATA_FIELD;
+//            OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+//            return sizeof (*pRes);
+//        }
+//    }
+//    else
+//    {
+//        if ((pReArmSensorReq->ReArmAssertionEvents2 & RESERVED_BITS_REARMSENSOR_REARMASSEVT2_2) ||
+//            (pReArmSensorReq->ReArmDeassertionEvents2 & RESERVED_BITS_REARMSENSOR_REARMDEASSEVT2_2))
+//        {
+//            pReArmSensorRes->CompletionCode = CC_INV_DATA_FIELD;
+//            OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+//            return sizeof (*pRes);
+//        }
+//    }
+
+//    if (g_BMCInfo.IpmiConfig.OPMASupport == 1)
+//    {
+//        if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
+//        {
+//            pReArmSensorRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//            OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+//            return sizeof (*pRes);
+//        }
+//    }
+
+//  if (!pSenSharedMem->SensorInfo [pReArmSensorReq->SensorNum].IsSensorPresent)
+//    {
+//        /* return sdr record not present completion code */
+//        pReArmSensorRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
+//        OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+//        return sizeof (*pRes);
+//    }
+
+
+//     Msg.Param = PARAM_REARM_SENSOR;
+//     Msg.Size = sizeof (ReArmSensorReq_T);
+//    _fmemcpy(Msg.Data, &ReArmSensorReq, sizeof (ReArmSensorReq_T));
+
+//    /* Post to sensormonitor task Thread to rearm this sensor */
+//    GetQueueHandle(SM_HNDLR_Q,&hSMHndlr_Q,BMCInst);
+//    if ( -1 != hSMHndlr_Q )
+//    {
+//        PostMsg(&Msg, SM_HNDLR_Q,BMCInst);
+
+//        /* return normal completion code */
+//        pReArmSensorRes->CompletionCode = CC_NORMAL;
+//    }else
+//    {
+//        /* return normal completion code */
+//        pReArmSensorRes->CompletionCode = 0xFF;
+//    }
+//    OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+
+//    return (sizeof(ReArmSensorRes_T));
+	return 1;
+}
+
+
+/*---------------------------------------
+ * GetSensorEventStatus
+ *---------------------------------------*/
+int
+GetSensorEventStatus ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+      GetSensorEventStatusReq_T*  pSensorEventStatusReq = ( GetSensorEventStatusReq_T*) pReq;
+      GetSensorEventStatusRes_T*  pSensorEventStatusRes = ( GetSensorEventStatusRes_T*) pRes;
+      SensorInfo_T*	pSensorInfo	=	getSensorInfo(pSensorEventStatusReq->SensorNum);
+
+    pSensorEventStatusRes->CompletionCode      = CC_NORMAL;
+    pSensorEventStatusRes->Flags               = (pSensorInfo->EventFlags & 0xe0);
+
+    /* Set optional response bytes to zero if event messages are disabled for this sensor */
+    if (0 == ((pSensorInfo->EventFlags) & BIT7))
+    {
+        pSensorEventStatusRes->AssertionEvents1    = 0;
+        pSensorEventStatusRes->AssertionEvents2    = 0;
+        pSensorEventStatusRes->DeassertionEvents1 = 0;
+        pSensorEventStatusRes->DeassertionEvents2  = 0;
+        return sizeof (GetSensorEventStatusRes_T);
+    }
+
+     if (0 == ((pSensorInfo->SensorCaps) & BIT6))
+     {
+          /* Get sensor event status history */
+         pSensorEventStatusRes->AssertionEvents1    = (pSensorInfo->AssertionHistoryByte1 & pSensorInfo->AssertionEventEnablesByte1);
+         pSensorEventStatusRes->AssertionEvents2    = (pSensorInfo->AssertionHistoryByte2 & pSensorInfo->AssertionEventEnablesByte2);
+         pSensorEventStatusRes->DeassertionEvents1 =  (pSensorInfo->DeassertionHistoryByte1 & pSensorInfo->DeassertionEventEnablesByte1);
+         pSensorEventStatusRes->DeassertionEvents2  = (pSensorInfo->DeassertionHistoryByte2 & pSensorInfo->DeassertionEventEnablesByte2);
+      }
+     else
+     {
+		/* Get present sensor event status */
+		pSensorEventStatusRes->AssertionEvents1    = (pSensorInfo->AssertionEventOccuredByte1 & pSensorInfo->AssertionEventEnablesByte1);
+		pSensorEventStatusRes->AssertionEvents2    = (pSensorInfo->AssertionEventOccuredByte2 & pSensorInfo->AssertionEventEnablesByte2);
+		pSensorEventStatusRes->DeassertionEvents1 =	(pSensorInfo->DeassertionEventOccuredByte1 & pSensorInfo->DeassertionEventEnablesByte1);
+		pSensorEventStatusRes->DeassertionEvents2  =(pSensorInfo->DeassertionEventOccuredByte2 & pSensorInfo->DeassertionEventEnablesByte2);
+      }
+    return sizeof (GetSensorEventStatusRes_T);
+}
+
+/*---------------------------------------
+ * SetSensorHysterisis
+ *---------------------------------------*/
+int
+SetSensorHysterisis ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+//	 SetSensorHysterisisReq_T* pSensorHysReq =
+//									 ( SetSensorHysterisisReq_T*) pReq;
+	 SetSensorHysterisisRes_T* pSensorHysRes =
+									 ( SetSensorHysterisisRes_T*) pRes;
+	printf("SetSensorHysterisis not implement\r\n");
+//     SensorSharedMem_T*	pSenSharedMem; 
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//    pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem; //m_hSensorSharedMem;
+
+//    if (g_BMCInfo.IpmiConfig.OPMASupport == 1)
+//    {
+//        if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
+//        {
+//            pSensorHysRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//            return sizeof (*pRes);
+//        }
+//    }
+
+//    /* Acquire Shared memory   */
+//   OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo.SensorSharedMemMutex, WAIT_INFINITE);
+
+//    if (!pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].IsSensorPresent)
+//    {
+//        /* Release mutex for Sensor shared memory */
+//         OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+
+//        pSensorHysRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
+//        return sizeof (*pRes);
+//    }
+
+//    if (pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].SensorReadType != THRESHOLD_SENSOR_CLASS) 
+//    { 
+//        /* Release mutex for Sensor shared memory */ 
+//        OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex); 
+//        pSensorHysRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC; 
+//        return sizeof (*pRes); 
+//    }
+
+//    if(BIT5 != (pSenSharedMem->SensorInfo[pSensorHysReq->SensorNum].SensorCaps & (BIT5 | BIT4)))
+//    {
+//        OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+//       //set operation is not allowed
+//       *pRes = CC_INV_DATA_FIELD;
+//        return sizeof(*pRes);
+//    } 
+
+//    /* Set the hysterisis values */
+//    pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].PosHysteresis = pSensorHysReq->PositiveHysterisis;
+//    pSenSharedMem->SensorInfo [pSensorHysReq->SensorNum].NegHysteresis =  pSensorHysReq->NegativeHysterisis;
+
+//    /* Release mutex for Sensor shared memory */
+//    OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+
+    pSensorHysRes->CompletionCode = CC_NORMAL;
+    return sizeof (SetSensorHysterisisRes_T);
+}
+
+
+/*---------------------------------------
+ * GetSensorHysterisis
+ *---------------------------------------*/
+int
+GetSensorHysterisis ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+     GetSensorHysterisisReq_T* pSensorHysReq =
+                                     ( GetSensorHysterisisReq_T*) pReq;
+     GetSensorHysterisisRes_T* pSensorHysRes =
+                             ( GetSensorHysterisisRes_T*) pRes;
+     SensorInfo_T*	pSensorInfo	=	getSensorInfo(pSensorHysReq->SensorNum);
+
+    if (pSensorInfo->SensorReadType != THRESHOLD_SENSOR_CLASS) 
+    { 
+          pSensorHysRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC; 
+        return sizeof (*pRes); 
+    } 
+
+    if(SENSOR_HYSTERESIS_ACCESS_BITS == (pSensorInfo->SensorCaps & (BIT5 | BIT4)))
+    {
+       //set operation is not allowed
+       *pRes = CC_INV_DATA_FIELD;
+        return sizeof(*pRes);
+    }
+
+    /* Get the hysterisis values */
+    pSensorHysRes->PositiveHysterisis = pSensorInfo->PosHysteresis;
+    pSensorHysRes->NegativeHysterisis = pSensorInfo->NegHysteresis;
+
+    pSensorHysRes->CompletionCode = CC_NORMAL;
+
+    return sizeof (GetSensorHysterisisRes_T);
+}
+
+
+
+/*---------------------------------------
+ * SetSensorThresholds
+ *---------------------------------------*/
+int
+SetSensorThresholds ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	SetSensorThresholdReq_T* pSensorThreshReq =
+								( SetSensorThresholdReq_T*) pReq;
+	SetSensorThresholdRes_T* pSensorThreshRes =
+						( SetSensorThresholdRes_T*) pRes;
+	uint8_t   		SettableMask=0;
+	SensorInfo_T*	pSensorInfo	=	getSensorInfo(pSensorThreshReq->SensorNum);
+	SDRRecHdr_T*	pSDRRec = SR_FindSDR(pSensorThreshReq->SensorNum);
+	FullSensorRec_T*      sfs = NULL;
+    //CompactSensorRec_T*   scs = NULL;
+	
+	if(pSDRRec->Type == FULL_SDR_REC)
+	{
+		sfs = (FullSensorRec_T*)pSDRRec;
+	}
+
+    /* Check for the reserved bytes should b zero */
+
+    if ( 0 !=  (pSensorThreshReq->SetFlags & RESERVED_BITS_SETSENSORTHRESHOLDS ) )
+    {
+         pSensorThreshRes->CompletionCode = CC_INV_DATA_FIELD;
+        return sizeof (*pRes);
+    }
+
+    if (pSensorInfo->SensorReadType != THRESHOLD_SENSOR_CLASS)
+    {
+		pSensorThreshRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
+        return sizeof (*pRes);
+    }
+
+    if(BIT3 != (pSensorInfo->SensorCaps & (BIT2 | BIT3)))
+    {
+        //set operation is not allowed
+       *pRes = CC_INV_DATA_FIELD;
+        return sizeof(*pRes);
+    }
+
+    pSensorThreshRes->CompletionCode = CC_NORMAL;
+    SettableMask=(uint8_t)(pSensorInfo->SettableThreshMask >> 8);
+    /* Set the threshold values */
+    //if (pSenSharedMem->SensorInfo [pSensorThreshReq->SensorNum].SensorInit & BIT5)
+    if ( (pSensorInfo->SensorInit & BIT4 ) && (SettableMask |  pSensorThreshReq->SetFlags ) == SettableMask) //<<Modified to support "set sensor enable>>
+    {
+        if (pSensorThreshReq->SetFlags & LWR_CRIT)
+        {
+            pSensorInfo->LowerCritical = pSensorThreshReq->LowerCritical;
+			if(sfs != NULL) {sfs->LowerCritical = pSensorThreshReq->LowerCritical;}
+        }
+        if (pSensorThreshReq->SetFlags & LWR_NON_CRIT)
+        {
+            pSensorInfo->LowerNonCritical    = pSensorThreshReq->LowerNonCritical;
+			if(sfs != NULL) {sfs->LowerNonCritical = pSensorThreshReq->LowerNonCritical;}
+        }
+        if (pSensorThreshReq->SetFlags & LWR_NON_REC)
+        {
+            pSensorInfo->LowerNonRecoverable = pSensorThreshReq->LowerNonRecoverable;
+			if(sfs != NULL) {sfs->LowerNonRecoverable = pSensorThreshReq->LowerNonRecoverable;}
+        }
+        if (pSensorThreshReq->SetFlags & UPR_CRIT)
+        {
+            pSensorInfo->UpperCritical          = pSensorThreshReq->UpperCritical;
+			if(sfs != NULL) {sfs->UpperCritical = pSensorThreshReq->UpperCritical;}
+        }
+        if (pSensorThreshReq->SetFlags & UPR_NON_CRIT)
+        {
+            pSensorInfo->UpperNonCritical   = pSensorThreshReq->UpperNonCritical;
+			if(sfs != NULL) {sfs->UpperNonCritical = pSensorThreshReq->UpperNonCritical;}
+        }
+        if (pSensorThreshReq->SetFlags & UPR_NON_REC)
+        {
+            pSensorInfo->UpperNonRecoverable = pSensorThreshReq->UpperNonRecoverable;
+			if(sfs != NULL) {sfs->UpperNonRecoverable = pSensorThreshReq->UpperNonRecoverable;}
+        }
+
+        if(g_BMCInfo.IpmiConfig.RearmSetSensorThreshold == 1)
+        {
+            /*  Since Changes in Threshold  .We have to monitor the sensor again .*/
+            /* Already the Sensor  reached the particular state . so we have to reset for generate the event according to  the new Event mask */
+            if ( 0 ==(pSensorInfo->SensorCaps & BIT6))
+            {
+                /* Manual ReARM Sensor */
+                pSensorInfo->AssertionHistoryByte1=0;
+                pSensorInfo->AssertionHistoryByte2=0;
+                pSensorInfo->DeassertionHistoryByte1=0;
+                pSensorInfo->DeassertionHistoryByte2=0;
+                pSensorInfo->EventLevel=SENSOR_STATUS_NORMAL;
+                pSensorInfo->HealthLevel= SENSOR_STATUS_NORMAL;
+            }else
+            {
+                /* Auto ReARM Sensor */
+                pSensorInfo->EventLevel=SENSOR_STATUS_NORMAL;
+                pSensorInfo->HealthLevel = SENSOR_STATUS_NORMAL;
+                pSensorInfo->AssertionEventOccuredByte1     = 0;
+                pSensorInfo->AssertionEventOccuredByte2     = 0;
+                pSensorInfo->DeassertionEventOccuredByte1   = 0;
+                pSensorInfo->DeassertionEventOccuredByte2   = 0;
+            }
+        }
+
+        pSensorThreshRes->CompletionCode = CC_NORMAL;
+		UpdateFlash();
+    }
+	else
+    {
+		pSensorThreshRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
+
+    }
+
+    return sizeof (SetSensorThresholdRes_T);
+}
+
+
+
+/*---------------------------------------
+ * GetSensorThresholds
+ *---------------------------------------*/
+int
+GetSensorThresholds ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+     GetSensorThresholdReq_T* pSensorThreshReq =
+                                ( GetSensorThresholdReq_T*) pReq;
+     GetSensorThresholdRes_T* pSensorThreshRes =
+                                ( GetSensorThresholdRes_T*) pRes;
+
+	SensorInfo_T*	pSensorInfo	=	getSensorInfo(pSensorThreshReq->SensorNum);
+    
+
+    if (pSensorInfo->SensorReadType != THRESHOLD_SENSOR_CLASS)
+    {
+        pSensorThreshRes->CompletionCode = CC_ILLEGAL_CMD_FOR_SENSOR_REC;
+        return sizeof (*pRes);
+    }
+    
+    memset (pSensorThreshRes,  0, sizeof (GetSensorThresholdRes_T));
+    
+    if(SENSOR_THRESOLD_ACCESS_BITS != (pSensorInfo->SensorCaps & (BIT2 | BIT3)))
+    {
+        pSensorThreshRes->GetFlags           = pSensorInfo->SettableThreshMask & 0xFF;
+        
+        /* Get the Threshold values according to readable threshold flag */
+        if( pSensorThreshRes->GetFlags & BIT0 )
+            pSensorThreshRes->LowerNonCritical    = pSensorInfo->LowerNonCritical;
+        if( pSensorThreshRes->GetFlags & BIT1 )
+            pSensorThreshRes->LowerCritical       = pSensorInfo->LowerCritical;
+        if( pSensorThreshRes->GetFlags & BIT2 )
+            pSensorThreshRes->LowerNonRecoverable = pSensorInfo->LowerNonRecoverable;
+        if( pSensorThreshRes->GetFlags & BIT3 )
+            pSensorThreshRes->UpperNonCritical    = pSensorInfo->UpperNonCritical;
+        if( pSensorThreshRes->GetFlags & BIT4 )
+            pSensorThreshRes->UpperCritical       = pSensorInfo->UpperCritical;
+        if( pSensorThreshRes->GetFlags & BIT5 )
+            pSensorThreshRes->UpperNonRecoverable = pSensorInfo->UpperNonRecoverable;
+    }
+    
+    pSensorThreshRes->CompletionCode      = CC_NORMAL;
+
+    return sizeof (GetSensorThresholdRes_T);
+}
+
+
+
+/*---------------------------------------
+ * GetSensorReadingFactors
+ *---------------------------------------*/
+int
+GetSensorReadingFactors ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+     GetSensorReadingFactorReq_T* pSensorFactorsReq =
+                            ( GetSensorReadingFactorReq_T*) pReq;
+     GetSensorReadingFactorRes_T* pSensorFactorsRes =
+                            ( GetSensorReadingFactorRes_T*) pRes;
+    SensorInfo_T*	pSensorInfo	=	getSensorInfo(pSensorFactorsReq->SensorNum);
+  
+   memcpy (&(pSensorFactorsRes->M_LSB), &(pSensorInfo->M_LSB),
+              sizeof (GetSensorReadingFactorRes_T) - (2 * sizeof (uint8_t)));
+    pSensorFactorsRes->CompletionCode = CC_NORMAL;
+
+    return sizeof (GetSensorReadingFactorRes_T);
+}
+
+
+
+/*---------------------------------------
+ * SetSensorEventEnable
+ *---------------------------------------*/
+int
+SetSensorEventEnable ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+//     SensorInfo_T*	pSensorInfo;
+//    uint8_t			LocalReq [6];
+//     SetSensorEventEnableReq_T* pSensorEvtEnReq;
+//     SetSensorEventEnableRes_T* pSensorEvtEnRes =
+//                              ( SetSensorEventEnableRes_T*) pRes;
+	printf("SetSensorEventEnable not implement\r\n");
+//    uint16_t  AssertMask, DeassertMask;
+//    uint16_t  ValidMask = htoipmi_u16(0x0FFF);
+//     SensorSharedMem_T*	pSenSharedMem; 
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//    pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem; //m_hSensorSharedMem;
+//    uint16_t  LUNSensorNum;
+//    uint16_t  *OwnerLUN = 0;
+
+//    if (g_BMCInfo.IpmiConfig.OPMASupport == 1)
+//    {
+//        if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
+//        {
+//            pSensorEvtEnRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//            return sizeof (*pRes);
+//        }
+//    }
+
+//    AssertMask = DeassertMask = 0;
+
+//    memset (LocalReq, 0, sizeof (LocalReq));
+//    memcpy (LocalReq, pReq, ReqLen);
+//    pSensorEvtEnReq = ( SetSensorEventEnableReq_T*)LocalReq;
+
+//    if(g_corefeatures.more_than_256_sensors == ENABLED)
+//    {
+
+//        OS_THREAD_TLS_GET(g_tls.OwnerLUN,OwnerLUN);
+//        LUNSensorNum = ((*OwnerLUN & VALID_LUN) << 8 | pSensorEvtEnReq->SensorNum);
+//    }
+//    else
+//    {
+//        LUNSensorNum = pSensorEvtEnReq->SensorNum;
+//    }
+
+
+
+//    /* Atleast two bytes are expected remaining bytes (3,4,5,6) are optional */
+//    if ((ReqLen < sizeof(uint16_t)) ||  (ReqLen > sizeof (SetSensorEventEnableReq_T)))
+//    {
+//        pSensorEvtEnRes->CompletionCode = CC_REQ_INV_LEN;
+//        return sizeof (*pRes);
+//    }
+
+//    /* Check for the reserved bytes should b zero */
+
+//    if ( 0 !=  (pSensorEvtEnReq->Flags & RESERVED_BITS_SETSENEVTEN_FLAGS ) )
+//    {
+//        pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
+//        return sizeof (*pRes);
+//    }
+
+//    if (ReqLen > sizeof(uint16_t))
+//    {
+//        /* Check for the reserved bits */ 
+//        if (pSenSharedMem->SensorInfo [LUNSensorNum].SensorReadType == THRESHOLD_SENSOR_CLASS)
+//        {
+//            if ((pSensorEvtEnReq->AssertionMask & ~ValidMask) ||
+//                    (pSensorEvtEnReq->DeAssertionMask & ~ValidMask))
+//            {
+//                pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
+//                return sizeof (*pRes);
+//            }
+//        }
+//        else
+//        {
+//            if ((pSensorEvtEnReq->AssertionMask & RESERVED_BITS_SETSENEVTEN_ASSERTIONMASK) ||
+//                    (pSensorEvtEnReq->DeAssertionMask & RESERVED_BITS_SETSENEVTEN_DEASSERTIONMASK))
+//            {
+//                pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
+//                return sizeof (*pRes);
+//            }
+//        }
+//    }
+
+//    /* Get the sensor Info for the sensor */
+//    if(g_corefeatures.more_than_256_sensors == ENABLED)
+//    {
+//        pSensorInfo = GetSensorInfo (pSensorEvtEnReq->SensorNum, *OwnerLUN, BMCInst);
+//    }
+//    else
+//    {
+//        pSensorInfo = GetSensorInfo (pSensorEvtEnReq->SensorNum, 0x0, BMCInst);
+//    }
+
+//    if (NULL == pSensorInfo)
+//    {
+//        pSensorEvtEnRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
+//        return sizeof (*pRes);
+//    }
+
+//       // If not threshold, adjust mask
+//    if (pSensorInfo->EventTypeCode != 0x01)
+//    {
+//        ValidMask = htoipmi_u16(0x7FFF);
+//    }
+
+
+//    /* Acquire Shared memory   */
+//    OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo.SensorSharedMemMutex, WAIT_INFINITE);
+
+//    if (!pSensorInfo->IsSensorPresent)
+//    {
+//        /* Release mutex for Sensor shared memory */
+//       OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+
+//        pSensorEvtEnRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
+//        return sizeof (*pRes);
+//    }
+
+//    /* Disable Events and scanning based on the flags */
+//    if (0 == (pSensorEvtEnReq->Flags & EVENT_MSG_MASK))
+//    {
+//        /* DisableAllEventSensors () */
+//    }
+
+//    if ((0 == (pSensorEvtEnReq->Flags & SCAN_MASK)) && (SCAN_MASK == (pSensorInfo->EventFlags & SCAN_MASK)))
+//    {
+//    	// Check sensor accepts the ‘enable/disable scanning’
+//        if(0 == (pSensorInfo->SensorInit & BIT6))
+//        {
+//            OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+//            pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
+//            return sizeof (*pRes);
+//        }
+//        pSensorInfo->EventFlags |= BIT5;  ///* Bit 5 -  Unable to read           */
+//    }
+//    else if((SCAN_MASK == (pSensorEvtEnReq->Flags & SCAN_MASK)) && (0 == (pSensorInfo->EventFlags & SCAN_MASK)))
+//    {
+//    	// Check sensor accepts the ‘enable/disable scanning’
+//        if(0 == (pSensorInfo->SensorInit & BIT6))
+//        {
+//            OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+//            pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
+//            return sizeof (*pRes);
+//        }
+//        pSensorInfo->EventFlags &= ~BIT5;  ///* Bit 5 -  Unable to read           */
+//    }
+//    pSensorInfo->EventFlags &= ~(EVENT_MSG_MASK | SCAN_MASK);
+//    pSensorInfo->EventFlags |= (pSensorEvtEnReq->Flags & (EVENT_MSG_MASK | SCAN_MASK));
+
+//    AssertMask =
+//        htoipmi_u16(((pSenSharedMem->SensorInfo [LUNSensorNum].AssertionEventEnablesByte2 << 8) |
+//        (pSenSharedMem->SensorInfo [LUNSensorNum].AssertionEventEnablesByte1)) & ValidMask);
+
+//    DeassertMask =
+//        htoipmi_u16(((pSenSharedMem->SensorInfo [LUNSensorNum].DeassertionEventEnablesByte2 << 8) |
+//        (pSenSharedMem->SensorInfo [LUNSensorNum].DeassertionEventEnablesByte1)) & ValidMask);
+
+//    /* Enable disable assertion based on the flag */
+//    if(ENABLE_DISABLE_EVENT_MASK == (pSensorEvtEnReq->Flags & ENABLE_DISABLE_EVENT_MASK))
+//    {
+//        // Flags [5:4] - 11b Reserved.
+//        /* Release mutex for Sensor shared memory */
+//       OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+
+//        pSensorEvtEnRes->CompletionCode = CC_INV_DATA_FIELD;
+//        return sizeof (*pRes);
+//    }
+//    else if (ENABLE_SELECTED_EVENT_MSG == (pSensorEvtEnReq->Flags & ENABLE_DISABLE_EVENT_MASK))
+//    {
+//        AssertMask |= ipmitoh_u16(pSensorEvtEnReq->AssertionMask);
+//        DeassertMask |= ipmitoh_u16(pSensorEvtEnReq->DeAssertionMask);
+//    }
+//    else if (DISABLE_SELECTED_EVENT_MSG == (pSensorEvtEnReq->Flags & ENABLE_DISABLE_EVENT_MASK))
+//    {
+//        AssertMask &= ~ipmitoh_u16(pSensorEvtEnReq->AssertionMask);
+//        DeassertMask &= ~ipmitoh_u16(pSensorEvtEnReq->DeAssertionMask);
+//    }
+
+//    //For Threshold class sensors upper word bits are reserved
+//    if(pSensorInfo->EventTypeCode == THRESHOLD_SENSOR_CLASS)
+//    {
+//        pSensorInfo->AssertionEventEnablesByte2 &= 0xF0;
+//        pSensorInfo->AssertionEventEnablesByte2 |= (AssertMask >> 8);
+//    }
+//    else
+//    {
+//        pSensorInfo->AssertionEventEnablesByte2 = (AssertMask >> 8);
+//    }
+//    pSensorInfo->AssertionEventEnablesByte1 = (AssertMask) & 0xFF;
+
+//    //For Threshold class sensors upper word bits are reserved
+//    if(pSensorInfo->EventTypeCode == THRESHOLD_SENSOR_CLASS)
+//    {
+//        pSensorInfo->DeassertionEventEnablesByte2 &= 0xF0;
+//        pSensorInfo->DeassertionEventEnablesByte2 |= (DeassertMask >> 8);
+//    }
+//    else
+//        {
+//    pSensorInfo->DeassertionEventEnablesByte2 = (DeassertMask >> 8);
+//    }
+
+//    pSensorInfo->DeassertionEventEnablesByte1 = (DeassertMask);
+
+//    // For threshold sensors, reset the threshold state machine for the sensor
+//    // in order to pickup any newly enabled events.
+//    if(pSensorInfo->EventTypeCode == THRESHOLD_SENSOR_CLASS)
+//    {
+//    pSensorInfo->EventLevel=SENSOR_STATUS_NORMAL;
+//        pSensorInfo->HealthLevel = SENSOR_STATUS_NORMAL;
+//    }
+
+//    pSensorEvtEnRes->CompletionCode = CC_NORMAL;
+
+//    /* Release mutex for Sensor shared memory */
+//    OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+
+
+    return sizeof (SetSensorEventEnableRes_T);
+}
+
+
+/*---------------------------------------
+ * GetSensorEventEnable
+ *---------------------------------------*/
+int
+GetSensorEventEnable ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+     GetSensorEventEnableReq_T* pSensorEvtEnReq =
+                  ( GetSensorEventEnableReq_T*) pReq;
+     GetSensorEventEnableRes_T* pSensorEvtEnRes =
+                  ( GetSensorEventEnableRes_T*) pRes;
+    SensorInfo_T*	pSensorInfo	=	getSensorInfo(pSensorEvtEnReq->SensorNum);
+    uint16_t  ValidMask = (0x0FFF);
+   
+
+    if (pSensorInfo->EventTypeCode != 0x01)
+    {
+        ValidMask = (0x7FFF);
+    }
+    /* Get the assertion enables */
+    pSensorEvtEnRes->AssertionMask =
+        (((pSensorInfo->AssertionEventEnablesByte2 << 8) | (pSensorInfo->AssertionEventEnablesByte1)) & ValidMask);
+
+    /* Get the deassertion enables */
+    pSensorEvtEnRes->DeAssertionMask =
+        (((pSensorInfo->DeassertionEventEnablesByte2 << 8) | (pSensorInfo->DeassertionEventEnablesByte1)) & ValidMask);
+
+    /* Set the flags */
+    pSensorEvtEnRes->Flags = (pSensorInfo->EventFlags & 0xc0);
+
+    pSensorEvtEnRes->CompletionCode = CC_NORMAL;
+
+    return sizeof (GetSensorEventEnableRes_T);
+}
+
+/**
+ * @fn CheckForEntityPresence
+ * @brief This function checks for the entity presence bit
+ * 			or the entity presence sensor.
+ * @param[in] SensorNum - Sensor number for reading.
+ * @param[in] EventTypeCode - Event type code of the sdr.
+ * @param[in] SensorType - Sensor type of the sdr.
+ * @retval 	ENTITY_FOUND, if present,
+ * 			ENTITY_NOT_FOUND, if not present,
+ * 			NOT_FOUND_SCAN_DISABLED, if not able to find,
+ * 			NOT_FOUND_SCAN_ENABLED, if Scanning bit enabled but failed.
+ */
+static int
+CheckForEntityPresence (uint8_t SensorNum, uint8_t OwnerLUN, uint8_t EventTypeCode, uint8_t SensorType)
+{
+    int RetVal = NOT_FOUND_SCAN_ENABLED;
+     SensorInfo_T* pSensorInfo;
+    int i;
+     
+     
+
+    pSensorInfo = getSensorInfo(SensorNum);
+
+    if( BIT0 == (BIT0 & pSensorInfo->SensorInit) )
+    {
+        // If Event/Reading type code is 0x08 then look for
+        // reading DEVICE_PRESENT to state the Entity Presence
+        if( GENERIC_EVENT_TYPE_DEV_PRESENCE == EventTypeCode )
+        {
+            if( DEVICE_PRESENT == pSensorInfo->SensorReading )
+            {
+                RetVal = ENTITY_FOUND;
+            }
+            else
+            {
+                RetVal = ENTITY_NOT_FOUND;
+            }
+        }
+        // If Event/Reading type code is 0x09 then look for
+        // reading DEVICE_ENABLED to state the Entity Enabled
+        else if( GENERIC_EVENT_TYPE_DEV_AVAILABLE == EventTypeCode )
+        {
+            if( DEVICE_ENABLED == pSensorInfo->SensorReading )
+            {
+                RetVal = ENTITY_FOUND;
+            }
+            else
+            {
+                RetVal = ENTITY_NOT_FOUND;
+            }
+        }
+        // If Event/Reading Type code is 0x6f then look for the
+        // special sensors like Processor, Memory etc.,
+        else if ( EVENT_TYPE_SENSOR_SPECIFIC == EventTypeCode )
+        {
+            for(i = 0; i < SENSOR_PRESENCE_COUNT; i++)
+            {
+                if( SensorType == sensor_presence[i][0] )
+                {
+                    if( pSensorInfo->SensorReading == sensor_presence[i][1] )
+                        RetVal = ENTITY_FOUND;
+                    else
+                        RetVal = ENTITY_NOT_FOUND;
+                    }
+            }
+        }
+		return RetVal;
+    }
+	return NOT_FOUND_SCAN_DISABLED;
+}
+
+/**
+ * @fn IsSensorPresence
+ * @brief Check the presence bit for the entity or checks with 
+ * 	  entity presence sensor to identify Entity presence
+ * @param[in] EntityID - Entity id of the sensor.
+ * @param[in] EntityIns - Entity instance of the sensor.
+ * @param[in] SensorNum - Sensor number.
+ * @retval	1, if present
+ * 		0, if not present
+ * 		-1, if not able to find.
+ */
+static int
+IsSensorPresence (uint8_t  EntityID, uint8_t EntityIns, uint8_t SensorNum, uint8_t OwnerLUN)
+{
+     SDRRecHdr_T*          sr = NULL;
+     CommonSensorRec_T*    scs = NULL;
+     
+
+    int RetVal, tmpRet = -1;
+
+    sr = SDR_GetFirstSDRRec ();
+
+    while (0 != sr)
+    {
+        // Populate sensor information for Threshold sensors
+        if (FULL_SDR_REC == sr->Type || COMPACT_SDR_REC == sr->Type)
+        {
+            /* Populate sensor information for full or Compact Record */
+            scs = ( CommonSensorRec_T*) sr;
+
+            // Check for EntityId and EntityIns
+            if((EntityID == scs->EntityID) && (EntityIns == scs->EntityIns) &&
+				((SensorNum != scs->SensorNum) || (OwnerLUN != scs->OwnerLUN))  )
+            {
+                RetVal = CheckForEntityPresence (scs->SensorNum, scs->OwnerLUN, scs->EventTypeCode,
+                			scs->SensorType);
+                if( NOT_FOUND_SCAN_DISABLED != RetVal && NOT_FOUND_SCAN_ENABLED != RetVal)
+                {
+                    return RetVal;
+                }
+                else if( NOT_FOUND_SCAN_ENABLED == RetVal)
+                {
+                    // An Entity is present if there is at least one active
+                    // sensor for the Entity (and there is no explicit sensor saying
+                    // the Entity is 'absent').
+                    // A sensor is 'active' if scanning is enabled.
+                    // We can return this value only after searching all the sensors.
+                    tmpRet = 1;
+                }
+            }
+        }
+        /* Get the next record */
+        sr = SDR_GetNextSDRRec (sr);
+    }
+    return tmpRet;
+}
+
+/**
+ * @fn IsEntityAssociationPresence
+ * @brief Check the EntityID and Entity instance to see if the entity is 
+ * 	  a container entity in an entity-association. If so, check to 
+ * 	  see if any of the contained entities are present, if so, assume 
+ * 	  the container entity exists.
+ * @param[in] EntityID - Entity id of the sensor.
+ * @param[in] EntityIns - Entity instance of the sensor.
+ * @retval	1, if present
+ * 		0, if not present
+ * 		-1, if not able to find.
+ */
+static int
+IsEntityAssociationPresence (uint8_t EntityID, uint8_t EntityIns)
+{
+	//TODO
+    return -1;
+}
+
+/**
+ * @fn IsFRUPresence
+ * @brief Check the entity to see if FRU device is present.
+ * @param[in] EntityID - Entity id of the sensor.
+ * @param[in] EntityIns - Entity instance of the sensor.
+ * @retval	1, if present
+ * 		0, if not present
+ * 		-1, if not able to find.
+ */
+static int
+IsFRUPresence (uint8_t EntityID, uint8_t EntityIns)
+{
+	printf("IsFRUPresence not implement\r\n");
+//     SDRRecHdr_T*          sr = NULL;
+//     FRUDevLocatorRec_T* frudl;
+//    FRUReadReq_T   FRUReadReq;
+//    uint8_t FRUReadRes[64];
+
+//    sr = SDR_GetFirstSDRRec (BMCInst);
+//    while (0 != sr)
+//    {
+//        // Check for FRU Device locator SDR Record
+//        if (sr->Type == FRU_DEVICE_LOCATOR_SDR_REC)
+//        {
+//            frudl = ( FRUDevLocatorRec_T*) sr;
+//            frudl->EntityID, frudl->EntityIns);
+//            // If EntityID and EntityIns are equal try to read the fru data.
+//            if(frudl->EntityID == EntityID &&
+//            frudl->EntityIns == EntityIns)
+//            {
+//                FRUReadReq.FRUDeviceID=frudl->FRUIDSlaveAddr;
+//                FRUReadReq.Offset=0x0;
+//                FRUReadReq.CountToRead=sizeof(FRUCommonHeader_T);
+//                ReadFRUData((uint8_t *)&FRUReadReq, sizeof(FRUReadReq_T), FRUReadRes);
+//                if (((FRUReadRes_T *)FRUReadRes)->CompletionCode == FRU_ACCESSIBLE)
+//                {
+//                    return 1;
+//                }
+//                else
+//                {
+//                    return 0;
+//                }
+//            }
+//        }
+//        sr = SDR_GetNextSDRRec (sr);
+//    }
+    return -1;
+}
+
+/**
+ * @fn InitSensorScanningBit
+ * @brief Initializes all the sensor's Scanning bit with respect 
+ *        to the presence of the entity
+ * @retval 0.
+ */
+
+int InitSensorScanningBit()
+{
+     SDRRecHdr_T*          sr = NULL;
+     CommonSensorRec_T*    scs = NULL;
+    int RetVal;
+     
+     
+	SensorInfo_T*		pSensorInfo	=	NULL;
+	uint16_t  LUNSensorNum;
+    sr = SDR_GetFirstSDRRec ();
+    
+    while (0 != sr)
+    {
+        // Populater sensor information for Threshold sensors
+        if (FULL_SDR_REC == sr->Type || COMPACT_SDR_REC == sr->Type)
+        {
+            scs = ( CommonSensorRec_T*) sr;
+            
+			RetVal = 1;
+			if( BIT7 == (BIT7 & scs->SensorCaps) )
+			{
+				/* As per IPMI Spec Section 40.2
+				* Entity presence can be detected if any one of the following point is
+				* Satisfied,
+				* 1. If there is an active sensor that includes a presence bit,
+				*    or the entity has an active Entity Presence sensor,
+				*    use the sensor to determine the presence of the entity.
+				* 2. Check the SDRs to see if the entity is a container entity
+				*    in an entity-association. If so, check to see if any of the
+				*    contained entities are present, if so, assume the container
+				*    entity exists. Note that this may need to be iterative.
+				* 3. The entity is present is there is a FRU device for the
+				*    entity, and the FRU device is present.
+				*/
+
+				RetVal = IsSensorPresence(scs->EntityID, scs->EntityIns, scs->SensorNum, scs->OwnerLUN);
+				if( -1 == RetVal )
+				{
+					RetVal = IsEntityAssociationPresence(scs->EntityID, scs->EntityIns);
+					if( -1 == RetVal )
+					{
+						RetVal = IsFRUPresence(scs->EntityID, scs->EntityIns);
+					}
+				}
+			}
+			LUNSensorNum = (scs->SensorNum);
+			/*
+			* [7] - 0b = All Event Messages disabled from this sensor
+			* [6] - 0b = sensor scanning disabled
+			* [5] - 1b = reading/state unavailable
+			*/
+			if(1 == RetVal)
+			{
+				pSensorInfo	=	getSensorInfo(LUNSensorNum);
+				if((BIT0 | BIT1) == (pSensorInfo->SensorInit & (BIT0 | BIT1)))
+				{
+					/* Enabling Sensor Scanning and Event Messages*/
+					pSensorInfo->EventFlags = EVENT_AND_SCANNING_ENABLE;
+				}
+				else if(BIT1 == (pSensorInfo->SensorInit & BIT1))
+				{
+					/* Enabling Event Messages */
+					pSensorInfo->EventFlags =  EVENT_MSG_MASK;
+				}
+				else if(BIT0 == (pSensorInfo->SensorInit & BIT0))
+				{
+					/*Enabling Scanning*/
+					pSensorInfo->EventFlags = SCAN_MASK;
+				}
+				if(0 == (pSensorInfo->SensorInit & BIT0))
+				{
+					/* Reading Unavailable */
+					pSensorInfo->EventFlags |= READING_UNAVAILABLE;
+				}
+			}
+			else
+			{
+				pSensorInfo->EventFlags = READING_UNAVAILABLE;
+				if(BIT1 == (pSensorInfo->SensorInit & BIT1))
+				{
+					/* Enabling Event Messages */
+					pSensorInfo->EventFlags |=  EVENT_MSG_MASK;
+				}
+			}
+        }
+        /* Get the next record */
+        sr = SDR_GetNextSDRRec (sr);
+    }
+    printf("Leaving : %s with 0\n", __func__);
+    return 0;
+}
+
+/* Compare two sensor values.
+ * Returns -1 if val1 < val2
+ * Returns 0 if val1 == val2
+ * Returns 1 if val1 > val2
+ */
+ int
+CompareValues(uint8_t isSigned, uint8_t val1, uint8_t val2)
+{
+    int retval = 0; // default to equal
+	// Signed comparison
+	int8_t  sval1, sval2;
+
+    /* Do comparison based on isSigned flag */
+    if (FALSE == isSigned)
+    {
+        // Unsigned comparison
+        if (val1 < val2)
+        {
+            retval = -1;
+        }
+        else if (val1 > val2)
+        {
+            retval = 1;
+        }
+    }
+    else
+    {
+        sval1 = (int8_t)val1;
+        sval2 = (int8_t)val2;
+
+        if (sval1 < sval2)
+        {
+            retval = -1;
+        }
+        else if (sval1 > sval2)
+        {
+            retval = 1;
+        }
+    }
+
+    return retval;
+}
+
+/*-----------------------------------------
+ * GetSensorReading
+ *-----------------------------------------*/
+int
+GetSensorReading ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	GetSensorReadingReq_T* pSensorReadReq =
+				  ( GetSensorReadingReq_T*) pReq;
+	GetSensorReadingRes_T* pSensorReadRes =
+				  ( GetSensorReadingRes_T*) pRes;
+	uint16_t              	SensorReading;
+	uint8_t                  	SensorIsSigned = FALSE;
+	
+	SensorInfo_T *			pSensorInfo	=	NULL;
+	pSensorInfo	=	getSensorInfo(pSensorReadReq->SensorNum);
+
+    pSensorReadRes->Flags = pSensorInfo->EventFlags & 0xe0;
+
+    if (0 != (pSensorInfo->EventFlags & BIT5))
+    {
+        pSensorReadRes->SensorReading = 0;
+        pSensorReadRes->CompletionCode = CC_NORMAL;
+        pSensorReadRes->ComparisonStatus = (((uint8_t) (pSensorReadRes->SensorReading & 0x00FF)) & ((uint8_t) (pSensorInfo->SettableThreshMask & 0x00FF)) );
+        pSensorReadRes->OptionalStatus   = (((uint8_t) (pSensorReadRes->SensorReading >> 8)) & ((uint8_t)(pSensorInfo->SettableThreshMask >> 8)) );
+        // For Discrete sensor, [7] - reserved. Returned as 1b. Ignore on read.
+        pSensorReadRes->OptionalStatus  |= 0x80;
+       
+        return sizeof (GetSensorReadingRes_T);
+    }
+
+    pSensorReadRes->CompletionCode = CC_NORMAL;
+
+    SensorReading = pSensorInfo->SensorReading;
+
+    pSensorReadRes->SensorReading = 0;
+
+    SensorIsSigned = (0 != (pSensorInfo->Units1 & 0xC0)) ? TRUE : FALSE;
+
+    if (THRESHOLD_SENSOR_CLASS  == pSensorInfo->EventTypeCode)
+    {
+        pSensorReadRes->SensorReading = (SensorReading & 0x00FF);		//notice
+        pSensorReadRes->ComparisonStatus = 0x00;
+        if((pSensorInfo->DeassertionEventEnablesByte2 & BIT6) == BIT6 )
+        {
+            if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
+            pSensorInfo->UpperNonRecoverable) >= 0)
+            {
+                pSensorReadRes->ComparisonStatus |= BIT5;
+            }
+        }
+        if((pSensorInfo->DeassertionEventEnablesByte2 & BIT5) == BIT5 )
+        {
+            if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
+            pSensorInfo->UpperCritical) >= 0)
+            {
+                pSensorReadRes->ComparisonStatus |= BIT4;
+            }
+        }
+        if((pSensorInfo->DeassertionEventEnablesByte2 & BIT4) == BIT4 )
+        {
+            if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
+            pSensorInfo->UpperNonCritical) >= 0)
+            {
+                pSensorReadRes->ComparisonStatus |= BIT3;
+            }
+        }
+        if((pSensorInfo->AssertionEventEnablesByte2 & BIT6) == BIT6 )
+        {
+            if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
+            pSensorInfo->LowerNonRecoverable) <= 0)
+            {
+                pSensorReadRes->ComparisonStatus |= BIT2;
+            }
+        }
+        if((pSensorInfo->AssertionEventEnablesByte2 & BIT5) == BIT5 )
+        {
+            if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
+            pSensorInfo->LowerCritical) <= 0)
+            {
+                pSensorReadRes->ComparisonStatus |= BIT1;
+            }
+        }
+        if((pSensorInfo->AssertionEventEnablesByte2 & BIT4) == BIT4 )
+        {
+            if (CompareValues(SensorIsSigned, pSensorReadRes->SensorReading,
+            pSensorInfo->LowerNonCritical) <= 0)
+            {
+                pSensorReadRes->ComparisonStatus |= BIT0;
+            }
+        }
+
+        pSensorReadRes->ComparisonStatus &=
+        ((pSensorInfo->SettableThreshMask >>  8) & 0xFF);
+        pSensorReadRes->OptionalStatus = 0;
+        // For Threshold sensor, [7:6] - reserved. Returned as 1b. Ignore on read.
+        pSensorReadRes->ComparisonStatus |= 0xC0;
+    }
+    else
+    {
+        pSensorReadRes->ComparisonStatus = (((uint8_t) (SensorReading & 0x00FF)) & ((uint8_t) (pSensorInfo->SettableThreshMask & 0x00FF)) );
+        pSensorReadRes->OptionalStatus   = (((uint8_t) (SensorReading >> 8)) & ((uint8_t)(pSensorInfo->SettableThreshMask >> 8)) );
+        // For Discrete sensor, [7] - reserved. Returned as 1b. Ignore on read.
+        pSensorReadRes->OptionalStatus  |= 0x80;
+    }
+
+    return sizeof (GetSensorReadingRes_T);
+}
+
+
+
+/*-----------------------------------------
+ * SetSensorReading
+ *-----------------------------------------*/
+int
+SetSensorReading ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	printf("SetSensorReading not implement\r\n");
+//     SetSensorReadingReq_T* pSensorReadReq =
+//                          ( SetSensorReadingReq_T*) pReq;
+//     SetSensorReadingRes_T* pSensorReadRes =
+//                          ( SetSensorReadingRes_T*) pRes;
+//     SensorSharedMem_T*	pSenSharedMem; 
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//    pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem; //m_hSensorSharedMem;
+
+//    /* Check for the reserved bits */ 
+//    if (pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].SensorReadType == THRESHOLD_SENSOR_CLASS)
+//    {
+//        if (((ReqLen>=LEN_FOR_ASSERT_DATA) && (pSensorReadReq->AssertionEventOccuredByte2 & RESERVED_BITS_SETSENRD_ASSEVTOCCBYTE_1)) ||
+//            ((ReqLen>=LEN_FOR_DEASSERT_DATA) && (pSensorReadReq->DeAssertionEventOccuredByte2 & RESERVED_BITS_SETSENRD_DEASSEVTOCCBYTE_1)))
+//        {
+//            pSensorReadRes->CompletionCode = CC_INV_DATA_FIELD;
+//            return sizeof (*pRes);
+//        }
+//    }
+//    else
+//    {
+//        if (((ReqLen>=LEN_FOR_ASSERT_DATA) && (pSensorReadReq->AssertionEventOccuredByte2 & RESERVED_BITS_SETSENRD_ASSEVTOCCBYTE_2)) ||
+//            ((ReqLen>=LEN_FOR_DEASSERT_DATA) && (pSensorReadReq->DeAssertionEventOccuredByte2 & RESERVED_BITS_SETSENRD_DEASSEVTOCCBYTE_2)))
+//        {
+//            pSensorReadRes->CompletionCode = CC_INV_DATA_FIELD;
+//            return sizeof (*pRes);
+//        }
+//    }
+
+//    if (g_BMCInfo.IpmiConfig.OPMASupport == 1)
+//    {
+//        if (pSenSharedMem->GlobalSensorScanningEnable == FALSE)
+//        {
+//            pSensorReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//            return sizeof (*pRes);
+//        }
+//    }
+
+//    /* Acquire Shared memory   */
+//    OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo.SensorSharedMemMutex, WAIT_INFINITE);
+
+//    if (!pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].IsSensorPresent)
+//    {
+//        /* Release mutex for Sensor shared memory */
+//       OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+
+//        pSensorReadRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
+//        return sizeof (*pRes);
+//    }
+
+//    if (ReqLen < MIN_SET_SEN_READING_CMD_LEN)
+//    {
+//        /* Release mutex for Sensor shared memory */
+//       OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+
+//        pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
+//        return sizeof (*pRes);
+//    }
+
+
+//    /* Check if the sensor is settable */
+//    if (0 == GET_SETTABLE_SENSOR_BIT(pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].SensorInit))
+//    {
+//        /* Release mutex for Sensor shared memory */
+//       OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+
+//        pSensorReadRes->CompletionCode = CC_INVALID_ATTEMPT_TO_SET;
+//        return sizeof (*pRes);
+//    }
+
+//    pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].Operation = pSensorReadReq->Operation;
+
+//    /* Set Sensor Event Data based on the Operation byte */
+//    switch (GET_EVENT_DATA_OP(pSensorReadReq->Operation))
+//    {
+//        case WRITE_NO_EVTDATA1:
+//        pSensorReadReq->EvtData1 &= 0xF0;
+//        /* Intentional Fall thru */
+//        case WRITE_EVTDATA1:
+//            if (LEN_FOR_EVT_DATA != ReqLen)
+//            {
+//                /* Release mutex for Sensor shared memory */
+//                OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+
+//                pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
+//                return sizeof (*pRes);
+//            }
+//            /* Update EvtData fields */
+//            pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].EvtData1 = pSensorReadReq->EvtData1;
+//            pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].EvtData2 = pSensorReadReq->EvtData2;
+//            pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].EvtData3 = pSensorReadReq->EvtData3;
+//            break;
+//    }
+
+//    /* Check Length for Assertion Set Opetation */
+//    if (0 != GET_ASSERT_EVT_OP(pSensorReadReq->Operation))
+//    {
+//        if ((ReqLen < LEN_FOR_ASSERT_DATA) || (ReqLen > MAX_SET_SEN_READ_LEN))
+//        {
+//            /* Release mutex for Sensor shared memory */
+//            OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+
+//            pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
+//            return sizeof (*pRes);
+//        }
+//    }
+
+//    /* Set Sensor Assertion Event based on the Operation byte */
+//    switch (GET_ASSERT_EVT_OP(pSensorReadReq->Operation))
+//    {
+//        case CLEAR_ASSERT_BITS:
+//            pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte1 &= pSensorReadReq->AssertionEventOccuredByte1;
+//            pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte2 &= pSensorReadReq->AssertionEventOccuredByte2;
+//            break;
+
+//        case SET_ASSERT_BITS:
+//            pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte1 |= pSensorReadReq->AssertionEventOccuredByte1;
+//            pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte2 |= pSensorReadReq->AssertionEventOccuredByte2;
+//            break;
+
+//        case WRITE_ASSERT_BITS:
+//            pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte1 |= pSensorReadReq->AssertionEventOccuredByte1;
+//            pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].AssertionEventOccuredByte2 |= pSensorReadReq->AssertionEventOccuredByte2;
+//            break;
+//    }
+
+
+//    /* Check Length for Assertion Set Opetation */
+//    if (0 != GET_DEASSERT_EVT_OP(pSensorReadReq->Operation))
+//    {
+//        if ((ReqLen < LEN_FOR_DEASSERT_DATA) || (ReqLen > MAX_SET_SEN_READ_LEN))
+//        {
+//            /* Release mutex for Sensor shared memory */
+//            OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+
+//            pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
+//            return sizeof (*pRes);
+//        }
+//    }
+
+//    /* Set Sensor DeAssertion Event based on the Operation byte */
+//    switch (GET_DEASSERT_EVT_OP(pSensorReadReq->Operation))
+//    {
+//        case CLEAR_DEASSERT_BITS:
+//            pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte1 &= pSensorReadReq->DeAssertionEventOccuredByte1;
+//            pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte2 &= pSensorReadReq->DeAssertionEventOccuredByte2;
+//            break;
+
+//        case SET_DEASSERT_BITS:
+//            pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte1 |= pSensorReadReq->DeAssertionEventOccuredByte1;
+//            pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte2 |= pSensorReadReq->DeAssertionEventOccuredByte2;
+//            break;
+
+//        case WRITE_DEASSERT_BITS:
+//            pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte1 |= pSensorReadReq->DeAssertionEventOccuredByte1;
+//            pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].DeassertionEventOccuredByte2 |= pSensorReadReq->DeAssertionEventOccuredByte2;
+//            break;
+//    }
+
+
+//    /* Check Length for Set Sensor Reading Operation */
+//    if (0 != GET_SETSENSOR_OP(pSensorReadReq->Operation))
+//    {
+//        if ((ReqLen < LEN_FOR_SETSENSOR_DATA) || (ReqLen > MAX_SET_SEN_READ_LEN))
+//        {
+//            /* Release mutex for Sensor shared memory */
+//            OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+
+//            pSensorReadRes->CompletionCode = CC_REQ_INV_LEN;
+//            return sizeof (*pRes);
+//        }
+
+//        /* Set new Sensor Reading */
+//        pSenSharedMem->SensorInfo [pSensorReadReq->SensorNum].SensorReading = pSensorReadReq->SensorReading;
+
+//    }
+
+//    pSensorReadRes->CompletionCode = CC_NORMAL;
+
+//    /* Release mutex for Sensor shared memory */
+//   OS_THREAD_MUTEX_RELEASE(&g_BMCInfo.SensorSharedMemMutex);
+
+//    return sizeof (SetSensorReadingRes_T);
+	return 0;
+}
+
+
+/*-------------------------------------------
+ * GetSensorSDR
+ *-------------------------------------------*/
+SDRRecHdr_T*
+SR_GetSensorSDR (uint8_t SensorNum)
+{
+    SDRRecHdr_T*  SDRRec;
+
+    /* Search for the record containing the sensor */
+    SDRRec = SDR_GetFirstSDRRec ();
+    while (0 != SDRRec)
+    {
+		switch (SDRRec->Type)
+		{
+			case FULL_SDR_REC :
+				if ((( FullSensorRec_T*) SDRRec)->SensorNum == SensorNum)
+				{
+					return SDRRec;
+				}
+				break;
+
+			case COMPACT_SDR_REC:
+			{
+				uint16_t SharedRecs =  ((( CompactSensorRec_T*) SDRRec)->RecordSharing) &
+							SHARED_RECD_COUNT;
+				if ((SensorNum == (( CompactSensorRec_T*) SDRRec)->SensorNum ) ||
+					((SensorNum >= ((( CompactSensorRec_T*) SDRRec)->SensorNum )) &&
+					(SensorNum <  ((( CompactSensorRec_T*) SDRRec)->SensorNum + SharedRecs)))
+					)
+				{
+					return SDRRec;
+				}
+			}
+			break;
+
+		default :
+			break;
+		}
+
+        /* Get the next record */
+        SDRRec = SDR_GetNextSDRRec (SDRRec);
+        if (0 == SDRRec)
+        {
+            return 0;
+        }
+    }
+
+    return 0;
+}
+
+
+
+///**
+// * @brief Update global variables with number sensors.
+//**/
+//static void
+//FindNumSensors ()
+//{
+//     SDRRecHdr_T*          pSDRRec;
+//     FullSensorRec_T*      pFSR;
+//     CompactSensorRec_T*   pCSR;
+
+//    pFSR = 0;
+//    pCSR = 0;
+
+//    /* Get First SDR Record */
+//    pSDRRec = SDR_GetFirstSDRRec ();
+//    while (0 != pSDRRec)
+//    {
+//        switch (pSDRRec->Type)
+//        {
+//        case FULL_SDR_REC :
+
+//            pFSR = ( FullSensorRec_T*) pSDRRec;
+//            if (THRESHOLD_SENSOR_CLASS == pFSR->EventTypeCode)
+//            {
+//                g_BMCInfo.SenConfig.NumThreshSensors++;
+//            }
+//            else
+//            {
+//                g_BMCInfo.SenConfig.NumNonThreshSensors++;
+//            }
+//            break;
+
+//        case COMPACT_SDR_REC :
+
+//            pCSR = ( CompactSensorRec_T*) pSDRRec;
+//            if (THRESHOLD_SENSOR_CLASS == pCSR->EventTypeCode)
+//            {
+//                g_BMCInfo.SenConfig.NumThreshSensors += ( (pCSR->RecordSharing) & SHARED_RECD_COUNT);
+//            }
+//            else
+//            {
+//                g_BMCInfo.SenConfig.NumNonThreshSensors += ( (pCSR->RecordSharing) & SHARED_RECD_COUNT);
+//            }
+//            break;
+
+//        default:
+
+//            break;
+//        }
+
+//        /* Get the next record */
+//        pSDRRec = SDR_GetNextSDRRec (pSDRRec);
+
+//    }
+
+
+//    printf("Thereshold  Sensors	= %d\n",g_BMCInfo.SenConfig.NumThreshSensors);
+//    printf("Non Thershold Sensors	= %d\n",g_BMCInfo.SenConfig.NumNonThreshSensors);
+
+
+//    return;
+//}
+
+
+
+int
+GetRecordIdsforDCMISensor (uint8_t EntityID,uint8_t SensorType, uint8_t EntityInstance,
+                            uint8_t StartingEntityInstance, uint16_t* pBuf, uint8_t* pTotalValidInstances)
+{
+	printf("GetRecordIdsforDCMISensor not implement\r\n");
+//    int i, ValidInstances;
+//     SensorSharedMem_T*	pSenSharedMem; 
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//    pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem; //m_hSensorSharedMem;
+
+//    if (0 != EntityInstance)
+//    {
+//        *pTotalValidInstances = 0;
+//        ValidInstances = 0;
+//        /* Acquire Shared memory to populate sensor information  */
+//        //OS_ACQUIRE_MUTEX(m_hSensorSharedMemMutex, SHARED_MEM_TIMEOUT);
+//        OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
+
+//        for (i = 0; i < MAX_SENSOR_NUMBERS + 1; i++ )
+//        {
+//            if ((TRUE == pSenSharedMem->SensorInfo [i].IsDCMITempsensor) && (pSenSharedMem->SensorInfo[i].SDRRec->Type == FULL_SDR_REC) )
+//            {
+//                if(SensorType != pSenSharedMem->SensorInfo[i].SensorTypeCode)
+//                {
+//                    /*Check the Sensor type*/
+//                    continue;
+//                }
+
+//                if ((((EntityID == DCMI_INLET_TEMP_ENTITY_ID) || (EntityID == IPMI_INLET_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_INLET_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_INLET_TEMP_ENTITY_ID))) || 
+//                   (((EntityID == DCMI_CPU_TEMP_ENTITY_ID) || (EntityID == IPMI_CPU_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_CPU_TEMP_ENTITY_ID)  || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_CPU_TEMP_ENTITY_ID))) || 
+//                   (((EntityID == DCMI_BASEBOARD_TEMP_ENTITY_ID) || (EntityID == IPMI_BASEBOARD_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_BASEBOARD_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_BASEBOARD_TEMP_ENTITY_ID))))
+//                {
+//                    *pTotalValidInstances += 1;
+//                    if (EntityInstance == pSenSharedMem->SensorInfo [i].EntiryInstance)
+//                    {
+//                        pBuf [0] = pSenSharedMem->SensorInfo [i].RecordID;
+//                        ValidInstances = 1;
+//                    }
+//                }
+//            }
+//        }
+//        /* Release mutex for Sensor shared memory */
+//        OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
+//        return ValidInstances;
+//    }
+//    else
+//    {
+//        *pTotalValidInstances = 0;
+//        ValidInstances = 0;
+//        /* Acquire Shared memory to populate sensor information  */
+//        //OS_ACQUIRE_MUTEX(m_hSensorSharedMemMutex, SHARED_MEM_TIMEOUT);
+//        OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
+
+//        for (i = StartingEntityInstance; i < MAX_SENSOR_NUMBERS + 1; i++ )
+//        {
+//            if ((TRUE == pSenSharedMem->SensorInfo [i].IsDCMITempsensor) && (pSenSharedMem->SensorInfo[i].SDRRec->Type == FULL_SDR_REC) )
+//            {
+//                if(SensorType != pSenSharedMem->SensorInfo[i].SensorTypeCode)
+//                {
+//                    /*Check the Sensor type*/
+//                    continue;
+//                }
+
+//                if ((((EntityID == DCMI_INLET_TEMP_ENTITY_ID) || (EntityID == IPMI_INLET_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_INLET_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_INLET_TEMP_ENTITY_ID))) || 
+//                   (((EntityID == DCMI_CPU_TEMP_ENTITY_ID) || (EntityID == IPMI_CPU_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_CPU_TEMP_ENTITY_ID)  || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_CPU_TEMP_ENTITY_ID))) || 
+//                   (((EntityID == DCMI_BASEBOARD_TEMP_ENTITY_ID) || (EntityID == IPMI_BASEBOARD_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_BASEBOARD_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_BASEBOARD_TEMP_ENTITY_ID))))
+//                {
+//                    *pTotalValidInstances += 1;
+//                    if (ValidInstances < 8)
+//                    {
+//                        pBuf [ValidInstances] = pSenSharedMem->SensorInfo [i].RecordID;
+//                        ValidInstances += 1;
+//                    }
+//                }
+//            }
+//        }
+//        /* Release mutex for Sensor shared memory */
+//        //OS_RELEASE_MUTEX(m_hSensorSharedMemMutex);
+//        OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
+//        return (ValidInstances > 8) ? 8: ValidInstances;
+//    }
+	return 0;
+}
+
+int GetDCMITempReading(uint8_t EntityID,uint8_t SensorType, uint8_t EntityInstance,
+                            uint8_t StartingEntityInstance, uint8_t* pBuf, uint8_t* pTotalValidInstances)
+{
+	printf("GetDCMITempReading not implement\r\n");
+//    int i, ValidInstances,j = 0;
+//     SensorSharedMem_T*	pSenSharedMem; 
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//    pSenSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem; //m_hSensorSharedMem;
+//      SDRRecHdr_T*     pSDRRec;
+//     FullSensorRec_T*      FullSDR;
+//    float convreading = 0;
+//    uint8_t   MinReading = 0, MaxReading = 0,Linear = 0;
+
+//    if (0 != EntityInstance)
+//    {
+//        *pTotalValidInstances = 0;
+//        ValidInstances = 0;
+//        OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
+
+//        for (i = 0; i < MAX_SENSOR_NUMBERS + 1; i++ )
+//        {
+//            if ((TRUE == pSenSharedMem->SensorInfo [i].IsDCMITempsensor) && (pSenSharedMem->SensorInfo[i].SDRRec->Type == FULL_SDR_REC) )
+//            {
+
+//                if(SensorType != pSenSharedMem->SensorInfo[i].SensorTypeCode)
+//                {
+//                    /*Check the Sensor type*/
+//                    continue;
+//                }
+
+//                if ((((EntityID == DCMI_INLET_TEMP_ENTITY_ID) || (EntityID == IPMI_INLET_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_INLET_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_INLET_TEMP_ENTITY_ID))) || 
+//                   (((EntityID == DCMI_CPU_TEMP_ENTITY_ID) || (EntityID == IPMI_CPU_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_CPU_TEMP_ENTITY_ID)  || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_CPU_TEMP_ENTITY_ID))) || 
+//                   (((EntityID == DCMI_BASEBOARD_TEMP_ENTITY_ID) || (EntityID == IPMI_BASEBOARD_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_BASEBOARD_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_BASEBOARD_TEMP_ENTITY_ID))))
+//                {
+//                    *pTotalValidInstances += 1;
+//                    if (EntityInstance == pSenSharedMem->SensorInfo [i].EntiryInstance)
+//                    {
+//                            if( !( pSenSharedMem->SensorInfo[i].EventFlags & 0x40)  || (pSenSharedMem->SensorInfo[i].EventFlags & 0x20) )
+//                            {
+//                                printf("event flag is disabled\n");
+//                                pBuf[DCMI_TEMP_READING] = 0;
+//                                pBuf[DCMI_INST_NUMBER] = 0;
+//                            }
+//                            else
+//                            {
+//                                pSDRRec = GetSDRRec(pSenSharedMem->SensorInfo[i].SDRRec->ID,BMCInst);
+//                               
+//                                FullSDR = ( FullSensorRec_T *)pSDRRec;
+//                                MinReading = FullSDR->MinReading;
+//                                MaxReading = FullSDR->MaxReading;
+//                                Linear  = FullSDR->Linearization;
+//                                
+//                                ipmi_conv_reading(pSenSharedMem->SensorInfo[i].SDRRec->Type, pSenSharedMem->SensorInfo[i].SensorReading, &convreading, MinReading,MaxReading, pSenSharedMem->SensorInfo[i].Units1,Linear, pSenSharedMem->SensorInfo[i].M_LSB,
+//                                                                    pSenSharedMem->SensorInfo[i].B_LSB, pSenSharedMem->SensorInfo[i].M_MSB_Tolerance, pSenSharedMem->SensorInfo[i].B_MSB_Accuracy, pSenSharedMem->SensorInfo[i].RExp_BExp);
+
+//                                pBuf [DCMI_TEMP_READING] = (int8_t)convreading;
+//                                pBuf [DCMI_INST_NUMBER] = EntityInstance;
+//                            }
+//                            ValidInstances = 1;
+//                    }
+//                }
+//            }
+//        }
+//        /* Release mutex for Sensor shared memory */
+//        OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
+//        return ValidInstances;
+//    }
+//    else
+//    {
+//        *pTotalValidInstances = 0;
+//        ValidInstances = 0;
+
+//        OS_THREAD_MUTEX_ACQUIRE(&g_BMCInfo[BMCInst].SensorSharedMemMutex, WAIT_INFINITE);
+
+//        for (i = StartingEntityInstance; i < MAX_SENSOR_NUMBERS + 1; i++ )
+//        {
+//            if ((TRUE == pSenSharedMem->SensorInfo [i].IsDCMITempsensor) && (pSenSharedMem->SensorInfo[i].SDRRec->Type == FULL_SDR_REC) )
+//            {
+
+//                if(SensorType != pSenSharedMem->SensorInfo[i].SensorTypeCode)
+//                {
+//                    /*Check the Sensor type*/
+//                    continue;
+//                }
+
+//                if ((((EntityID == DCMI_INLET_TEMP_ENTITY_ID) || (EntityID == IPMI_INLET_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_INLET_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_INLET_TEMP_ENTITY_ID))) || 
+//                   (((EntityID == DCMI_CPU_TEMP_ENTITY_ID) || (EntityID == IPMI_CPU_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_CPU_TEMP_ENTITY_ID)  || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_CPU_TEMP_ENTITY_ID))) || 
+//                   (((EntityID == DCMI_BASEBOARD_TEMP_ENTITY_ID) || (EntityID == IPMI_BASEBOARD_TEMP_ENTITY_ID)) && ((pSenSharedMem->SensorInfo [i].EntityID == DCMI_BASEBOARD_TEMP_ENTITY_ID) || (pSenSharedMem->SensorInfo [i].EntityID == IPMI_BASEBOARD_TEMP_ENTITY_ID))))
+//                {
+//                    *pTotalValidInstances += 1;
+//                    if (ValidInstances < 8)
+//                    {
+//                        if( !( pSenSharedMem->SensorInfo[i].EventFlags & 0x40)  || (pSenSharedMem->SensorInfo[i].EventFlags & 0x20) )
+//                        {
+//                            pBuf[DCMI_TEMP_READING + j] = 0;
+//                            pBuf[DCMI_INST_NUMBER + j] = 0;
+//                            j = j+2;
+//                        }
+//                        else
+//                        {
+//                            pSDRRec = GetSDRRec(pSenSharedMem->SensorInfo[i].SDRRec->ID,BMCInst);
+//                            FullSDR = ( FullSensorRec_T *)pSDRRec;
+//                            MinReading = FullSDR->MinReading;
+//                            MaxReading = FullSDR->MaxReading;
+//                            Linear  = FullSDR->Linearization;
+//                            
+//                            ipmi_conv_reading(pSenSharedMem->SensorInfo[i].SDRRec->Type, pSenSharedMem->SensorInfo[i].SensorReading, &convreading, MinReading,MaxReading, pSenSharedMem->SensorInfo[i].Units1,Linear, pSenSharedMem->SensorInfo[i].M_LSB,
+//                                            pSenSharedMem->SensorInfo[i].B_LSB, pSenSharedMem->SensorInfo[i].M_MSB_Tolerance, pSenSharedMem->SensorInfo[i].B_MSB_Accuracy, pSenSharedMem->SensorInfo[i].RExp_BExp);
+//                            
+//                            pBuf[ j++] = (int8_t)convreading;
+//                            pBuf[ j++] = pSenSharedMem->SensorInfo[i].EntiryInstance;
+//                            TDBG("j value %d\n",j);
+//                        }
+//                            ValidInstances += 1;
+//                    }
+//                }
+//            }
+//        }
+
+//        OS_THREAD_MUTEX_RELEASE(&g_BMCInfo[BMCInst].SensorSharedMemMutex);
+//        return (ValidInstances > 8) ? 8: ValidInstances;
+
+//    }
+	return 0;
+}
+#endif /* SENSOR_DEVICE */

+ 1031 - 0
app/bmc/msghndlr/SensorEvent/SensorDevice/SensorMonitor.c

@@ -0,0 +1,1031 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ *****************************************************************
+ *
+ * SensorMonitor.c
+ * Sensor Monitor
+ *
+ * Author: Rama Rao Bisa <ramab@ami.com>
+ *
+ *****************************************************************/
+
+#include "MsgHndlr.h"
+#include "SensorEvent.h"
+#include "com_IPMI_SDRRecord.h"
+#include "Sensor.h"
+#include "sensor_tbl.h"
+#include "SEL.h"
+#include "Support.h"
+#include <time.h>
+#include "main.h"
+#include "Api.h"
+
+//#if SENSOR_DEVICE == 1
+
+/*** Local Definitions ***/
+#define FULL_SDR_REC                0x01
+#define COMPACT_SDR_REC             0x02
+#define EVENT_MSG_LENGTH            9
+
+#define TEMP_SENSOR_TYPE            0x01
+#define VOLT_SENSOR_TYPE            0x02
+#define FAN_SENSOR_TYPE             0x04
+#define POWER_SENSOR_TYPE           0x08
+#define CURRENT_SENSOR_TYPE         0x03
+#define MONITOR_ASIC_IC_SENSOR_TYPE 0x26
+#define OEM_SENSOR_TYPE             0xC0
+#define OTHER_UNITS_SENSOR_TYPE     0x0B
+
+#define LOWER_CRITICAL_GNG_LOW         0x02
+#define UPPER_CRITICAL_GNG_HIGH        0x09 
+#define LOWER_NON_CRITICAL_GNG_LOW     0x00
+#define UPPER_NON_CRITICAL_GNG_HIGH    0x07
+#define LOWER_NON_RECOVERABLE_GNG_LOW  0x04 
+#define UPPER_NON_RECOVERABLE_GNG_HIGH 0x0B
+
+
+/*** Prototype Declaration ***/
+static void MonitorTSensors ( SensorInfo_T*  pSensorInfo);
+static void MonitorNonTSensors ( SensorInfo_T*  pSensorInfo);
+
+/*-------------------------------------------
+ * SensorMonitorTask
+ *----------------------               --------------------*/
+void *SensorMonitorTask (void *pArg)
+{
+	int    					i;
+	SensorInfo_T*        	pSensorInfo;
+	SensorSharedMem_T*    	pSMSharedMem;
+
+	printf("SensorMonitorTask start...\r\n");
+
+	g_BMCInfo.SenConfig.MonitorBusy = 0;
+	g_BMCInfo.SenConfig.InitAgentRearm = FALSE;
+	/* Get the Sensor Shared Memory */
+	pSMSharedMem = ( SensorSharedMem_T*)&g_BMCInfo.SensorSharedMem;
+	
+	g_BMCInfo.SenConfig.ValidSensorCnt			=	SENSOR_NUMBERS;
+	
+	InitSensorInfo ();
+	InitSensorDev();
+	
+	pSMSharedMem->GlobalSensorScanningEnable 	= 	TRUE;
+
+	pSMSharedMem->SensorTick	=	0;
+	while (1)
+	{
+		g_BMCInfo.SenConfig.InitAgentRearm = FALSE;
+		
+		/* Monitor all sensors */
+		for (i = 0; i < g_BMCInfo.SenConfig.ValidSensorCnt; i++)
+		{
+			/* Check if Global Scanning Enabled or Disabled */
+			if (pSMSharedMem->GlobalSensorScanningEnable)
+			{
+				pSensorInfo = (SensorInfo_T *)&pSMSharedMem->SensorInfo [i];
+
+				//printf("sensor number: %d, RecordID: %d\n", pSensorInfo->SensorNumber, pSensorInfo->RecordID);
+				/* Monitoring cycle */
+				if (THRESHOLD_SENSOR_CLASS  == pSensorInfo->EventTypeCode)
+				{
+					if ((0 == (pSMSharedMem->SensorTick %  pSensorInfo->SensorMonitorInterval)) &&
+						(g_BMCInfo.SenConfig.PowerOnTick >= pSensorInfo->PowerOnDelay) &&
+						(g_BMCInfo.SenConfig.SysResetTick >= pSensorInfo->SysResetDelay)) 
+					{ 
+						/* Clear the Error status for this scan */
+						pSensorInfo->Err = 0; 
+						
+						/* Monitor threshold sensor */
+						MonitorTSensors (pSensorInfo); 		
+					}
+				}
+				else
+				{
+					if ((0 == (pSMSharedMem->SensorTick %  pSensorInfo->SensorMonitorInterval)) &&
+						(g_BMCInfo.SenConfig.PowerOnTick >= pSensorInfo->PowerOnDelay) &&
+						(g_BMCInfo.SenConfig.SysResetTick >= pSensorInfo->SysResetDelay))
+					{ 
+						/* Clear the Error status for this scan */
+						pSensorInfo->Err = 0;
+						/* Monitor Non threshold sensor */
+						MonitorNonTSensors (pSensorInfo);
+						
+					}
+				}
+			}
+		}
+		g_BMCInfo.SenConfig.MonitorBusy = 0;
+		
+		sleep(1);
+	} 
+}
+
+// Return a high deassertion threshold.
+// This routine takes into account signed sensors as well as
+// values wrapping around boundaries.
+static
+int16_t GetHighDeassertValue(uint8_t IsSigned, int16_t Value, uint8_t Hysteresis)
+{
+	int16_t deassertValue = (Value - Hysteresis);
+	
+	if (FALSE == IsSigned)
+	{
+		if (deassertValue < 0)
+			deassertValue = 0;
+	}
+	else
+	{
+		if (deassertValue < -128)
+			deassertValue = -128;
+	}
+	
+	return deassertValue;
+}
+
+// Return a low deassertion threshold.
+// This routine takes into account signed sensors as well as
+// values wrapping around boundaries.
+static
+int16_t GetLowDeassertValue(uint8_t IsSigned, int16_t Value, uint8_t Hysteresis)
+{
+	int16_t deassertValue = (Value + Hysteresis);
+	if (FALSE == IsSigned)
+	{
+		if (deassertValue > 255)
+			deassertValue = 255;
+	}
+	else
+	{
+		if (deassertValue > 127)
+			deassertValue = 127;
+	}
+	
+	return deassertValue;
+}
+
+/**
+ * @brief Monitor Threshold sensors.
+ * @param i - Sensor index.
+**/
+static void
+MonitorTSensors ( SensorInfo_T*     pSensorInfo)
+{
+	uint8_t                   EventData1;
+	uint8_t                   EventData3;
+	uint8_t                   EvData1;
+	uint8_t                   SendDeassertion;
+	uint8_t                   SendAssertion;
+	uint8_t                   EventMsg [EVENT_MSG_LENGTH];
+	uint8_t                   Level;
+	uint8_t                   HealthLevel;
+	uint8_t                   StartLevel;
+	int16_t                   Value;
+	uint8_t                   AssertionEventOccuredByte1;
+	uint8_t                   AssertionEventOccuredByte2;
+	uint8_t                   DeassertionEventOccuredByte1;
+	uint8_t                   DeassertionEventOccuredByte2;
+	uint8_t                   DeassertionEventEnablesByte1;
+	uint8_t                   DeassertionEventEnablesByte2;
+	uint8_t                   AssertionEventEnablesByte1;
+	uint8_t                   AssertionEventEnablesByte2;
+	int16_t                   WarningLow;
+	int16_t                   WarningHigh;
+	uint8_t                   NegHysteresis;
+	uint8_t                   PosHysteresis;
+	int16_t                   CriticalHigh;
+	int16_t                   CriticalLow;
+	int16_t                   NonRecoverableHigh;
+	int16_t                   NonRecoverableLow;
+//	uint8_t                   SensorLevel;
+	uint8_t                   SettableThreshMask;
+	uint8_t		    	 	  SensorReading;
+	uint8_t  		    		PSGood = 0;
+
+	uint8_t                       AssertionHistoryByte1;
+	uint8_t                       AssertionHistoryByte2;
+	uint8_t                       DeassertionHistoryByte1;
+	uint8_t                       DeassertionHistoryByte2;
+	uint8_t                   OEMField;
+//	uint8_t			    	SensorNum;	
+	uint8_t                	SignedSensor = 0; // 1 if sensor has signed values
+	int16_t               	SensorMax = 255;
+	int16_t               	SensorMin = 0;
+	//uint16_t_t              OrgSensorValue;
+	int16_t               	DeassertThreshold;
+	// Added for Sensor Override capability
+//	int                 	Override = 0;
+//	uint8_t 				ReadFlags = 0;
+//	FullSensorRec_T*      	sfs=NULL;
+//	CompactSensorRec_T*   	scs=NULL;
+//	int				index,j;
+	
+	PSGood = g_BMCInfo.PowerGoodFlag;
+ 
+
+	/* If sensor is not need to monitor on stand by power, and if Server */
+	/* is power off then return setting error "sensor not acceble at present state" */
+	if  (( 0 == (pSensorInfo->SensorState & 0x1) ) && ( 0 == PSGood)) 
+	{
+		// Response cannot be provided in this state
+		pSensorInfo->Err = CC_PARAM_NOT_SUP_IN_CUR_STATE ; 
+		pSensorInfo->EventFlags |= BIT5;
+		return;
+	}
+	else
+	{
+		pSensorInfo->Err	=	get_sensor_reading(pSensorInfo->SensorNumber, &SensorReading);
+		
+//		if (FULL_SDR_REC == pSensorInfo->SDRRec->Type)
+//		{
+//			sfs = ( FullSensorRec_T*)pSensorInfo->SDRRec;
+//		}
+//		else if (COMPACT_SDR_REC==pSensorInfo->SDRRec->Type)
+//		{
+//			scs = ( CompactSensorRec_T*)pSensorInfo->SDRRec;
+//		}
+		pSensorInfo->SensorReading = SensorReading;
+		
+//		//keep sensor history
+//		index = getSensorIndex(pSensorInfo->SensorNumber);
+//		if((index >= 0) && (g_BMCInfo.CurTimerSecond%180 == 0) && (g_sensorList[index].supportHistory == 1))	//3 minutes
+//		{
+//			for(j=1;j<HISTORY_DATA_SIZE;j++)
+//			{
+//				g_sensorHistory[index][j-1] =  g_sensorHistory[index][j];
+//			}
+//			g_sensorHistory[index][HISTORY_DATA_SIZE-1] = pSensorInfo->SensorReading;
+//		}
+	}
+
+
+	if (0 == pSensorInfo->Err)
+	{
+		pSensorInfo->EventFlags &= ~BIT5;
+	}
+	else
+	{
+		pSensorInfo->EventFlags |= BIT5;
+	}
+	
+	do
+	{
+		EvData1                      = 0;
+		EventData1                   = 0;
+		EventData3                   = 0;
+		SendDeassertion              = 0;
+		SendAssertion                = 0;
+		//SensorLevel                  = 0;
+		Level                        = pSensorInfo->EventLevel;
+		Value                        = pSensorInfo->SensorReading;
+		AssertionEventOccuredByte1   = pSensorInfo->AssertionEventOccuredByte1;
+		AssertionEventOccuredByte2   = pSensorInfo->AssertionEventOccuredByte2;
+		DeassertionEventOccuredByte1 = pSensorInfo->DeassertionEventOccuredByte1;
+		DeassertionEventOccuredByte2 = pSensorInfo->DeassertionEventOccuredByte2;
+		AssertionEventEnablesByte1   = pSensorInfo->AssertionEventEnablesByte1;
+		AssertionEventEnablesByte2   = pSensorInfo->AssertionEventEnablesByte2;
+		DeassertionEventEnablesByte1 = pSensorInfo->DeassertionEventEnablesByte1;
+		DeassertionEventEnablesByte2 = pSensorInfo->DeassertionEventEnablesByte2;
+		WarningLow                   = pSensorInfo->LowerNonCritical;
+		WarningHigh                  = pSensorInfo->UpperNonCritical;
+		NegHysteresis                = pSensorInfo->NegHysteresis;
+		PosHysteresis                = pSensorInfo->PosHysteresis;
+		CriticalHigh                 = pSensorInfo->UpperCritical;
+		CriticalLow                  = pSensorInfo->LowerCritical;
+		NonRecoverableHigh           = pSensorInfo->UpperNonRecoverable;
+		NonRecoverableLow            = pSensorInfo->LowerNonRecoverable;
+		OEMField					 = pSensorInfo->OEMField;
+//		SensorNum					 = pSensorInfo->SensorNumber;
+
+		if(1==OEMField)
+		{
+			SensorAverage(pSensorInfo->SensorNumber, &pSensorInfo->SensorReading);
+		}
+
+		SettableThreshMask           = (uint8_t)(pSensorInfo->SettableThreshMask >> 8);
+
+		SignedSensor = (0 != (pSensorInfo->Units1 & 0xC0));	//Analog data format
+		if (SignedSensor)
+		{
+			// These are max and min sensor readings for a signed sensor
+			SensorMax =  127;
+			SensorMin = -128;
+
+			//
+			// All Thresholds and the sensor value need to be sign extended to 16 bits
+			// for signed sensors (if the value is negative).
+			//
+			WarningLow                = (int16_t)((int8_t)pSensorInfo->LowerNonCritical);
+			WarningHigh               = (int16_t)((int8_t)pSensorInfo->UpperNonCritical);
+			CriticalHigh                 = (int16_t)((int8_t)pSensorInfo->UpperCritical);
+			CriticalLow                  = (int16_t)((int8_t)pSensorInfo->LowerCritical);
+			NonRecoverableHigh    = (int16_t)((int8_t)pSensorInfo->UpperNonRecoverable);
+			NonRecoverableLow     = (int16_t)((int8_t)pSensorInfo->LowerNonRecoverable);
+			Value                          = (int16_t)((int8_t)pSensorInfo->SensorReading);
+		}
+
+		//
+		// For unused thresholds, set them to a value that the sensor value cannot
+		// have in an 8 bit value so no match can happen.
+		//
+		if (0 == (SettableThreshMask & BIT5))
+		{
+			// Set to a value that the sensor cannot have
+			NonRecoverableHigh = SensorMax + 1;
+		}
+		if (0 == (SettableThreshMask & BIT2))
+		{
+			// Set to a value that the sensor cannot have
+			NonRecoverableLow = SensorMin - 1;
+		}
+		if (0 == (SettableThreshMask & BIT4))
+		{
+			CriticalHigh = NonRecoverableHigh;
+		}
+		if (0 == (SettableThreshMask & BIT1))
+		{
+			CriticalLow  = NonRecoverableLow;
+		}
+		if (0 == (SettableThreshMask & BIT3))
+		{
+			WarningHigh = CriticalHigh;
+		}
+		if (0 == (SettableThreshMask & BIT0))
+		{
+			WarningLow = CriticalLow;
+		}
+
+		StartLevel = Level;
+
+		switch (Level)
+		{
+			case SENSOR_STATUS_NORMAL:
+				if (Value <= WarningLow)
+				{
+					//sensor_dbg_printf("#%02x LNC(A) - Value: %02x Threshold: %02x\r\n", (pSensorInfo->SensorNumber), (uint8_t)Value, (uint8_t)WarningLow);
+					/* deassert WarningLow going High */
+					EvData1 = 0x51;
+					if (DeassertionEventEnablesByte1 & 0x02)
+					{
+						SendDeassertion = 1;
+					}
+					/* remove WarnignLow going Low deassertion */
+					DeassertionEventOccuredByte1 &= ~0x01;
+					/* deassert WarningLow going High */
+					DeassertionEventOccuredByte1 |= 0x02;
+
+					/* assert WarningLow going Low */
+					EventData1 = 0x50;
+					if(AssertionEventEnablesByte1 & 0x01)
+					{
+						SendAssertion = 1;
+					}
+					Level = SENSOR_STATUS_WARNING_LOW;
+					EventData3 = WarningLow;
+					/* set de/assertion event */
+					/* remove WarningLow going High assertion */
+					AssertionEventOccuredByte1 &= ~0x02;
+					/* assert WarningLow going Low */
+					AssertionEventOccuredByte1 |= 0x01;
+					//SensorLevel = LWR_NON_CRITICAL_GOING_LOW_CTRL_FN;
+				}
+				if (Value >= WarningHigh)
+				{
+					//sensor_dbg_printf("#%02x UNC(A) - Value: %02x Threshold: %02x\n", pSensorInfo->SensorNumber, (uint8_t)Value, (uint8_t)WarningHigh);
+					/* deassert WarningHigh going Low */
+					EvData1 = 0x56;
+					if (DeassertionEventEnablesByte1 & 0x40)
+					{
+						SendDeassertion = 1;
+					}
+
+					/* remove WarningHigh going High deassertion */
+					DeassertionEventOccuredByte1 &= ~0x80;
+					/*  deassert WarningHigh going Low */
+					DeassertionEventOccuredByte1 |= 0x40;
+
+					/* assert WarningHigh going High */
+					EventData1 = 0x57;
+					if (AssertionEventEnablesByte1 & 0x80)
+					{
+						SendAssertion = 1;
+					}
+					/* set de/assertion occured */
+					/* remove WarningHigh going Low assertion */
+					AssertionEventOccuredByte1 &= ~0x40;
+					/* assert WarningHigh going High */
+					AssertionEventOccuredByte1 |= 0x80;
+					Level = SENSOR_STATUS_WARNING_HIGH;
+					/* Threshold that caused event */
+					EventData3 = WarningHigh;
+					//SensorLevel = UPPER_NON_CRITICAL_GOING_HIGH_CTRL_FN;
+				}
+				break;
+
+			case SENSOR_STATUS_WARNING_HIGH:
+				DeassertThreshold = GetHighDeassertValue(SignedSensor, WarningHigh, PosHysteresis);
+				if(Value < DeassertThreshold)
+				{
+					//sensor_dbg_printf("#%02x UNC(D) - Value: %02x Threshold: %02x\n", pSensorInfo->SensorNumber, (uint8_t)Value, (uint8_t)DeassertThreshold);
+					/* deassert WarningHigh going High */
+					EvData1 = 0x57;
+					if (DeassertionEventEnablesByte1 & 0x80)
+					{
+						SendDeassertion = 1;
+					}
+					/* remove WarningHigh going Low deassertion */
+					DeassertionEventOccuredByte1 &= ~0x40;
+					/* deassert WarningHigh going High */
+					DeassertionEventOccuredByte1 |= 0x80;
+
+					/* assert WaningHigh going Low */
+					EventData1 = 0x56;
+					if (AssertionEventEnablesByte1 & 0x40)
+					{
+						SendAssertion = 1;
+					}
+					Level = SENSOR_STATUS_NORMAL;
+					EventData3 = WarningHigh;
+					/* remove WarningHigh going High assertion */
+					AssertionEventOccuredByte1 &= ~0x80;
+					/* assert WarningHigh going Low */
+					AssertionEventOccuredByte1 |= 0x40;
+				    //SensorLevel = UPPER_NON_CRITICAL_GOING_LOW_CTRL_FN;
+				}
+				if (Value >= CriticalHigh)
+				{
+					//sensor_dbg_printf("#%02x UC(A) - Value: %02x Threshold: %02x\n", pSensorInfo->SensorNumber, (uint8_t)Value, (uint8_t)CriticalHigh);
+					/* deassert CriticalHigh going Low */
+					EvData1 = 0x58;
+					if (DeassertionEventEnablesByte2 & 0x01)
+					{
+						SendDeassertion = 1;
+					}
+
+					/* remove CriticalHigh going High deassertion */
+					DeassertionEventOccuredByte2 &= ~0x02;
+					/* deassert CriticalHigh going Low */
+					DeassertionEventOccuredByte2 |= 0x01;
+					/*  assert CriticalHigh going High */
+					EventData1 = 0x59;
+					if (AssertionEventEnablesByte2 & 0x02)
+					{
+						SendAssertion = 1;
+					}
+					Level = SENSOR_STATUS_CRITICAL_HIGH;
+					EventData3 = CriticalHigh;
+					/* set de/assertion event occured */
+					/* remove CriticalHigh going Low assertion */
+					AssertionEventOccuredByte2 &= ~0x01;
+					/* assert CriticalHigh going High */
+					AssertionEventOccuredByte2 |= 0x02;
+					//SensorLevel = UPPER_CRITICAL_GOING_HIGH_CTRL_FN;
+				}
+				break;
+
+			case SENSOR_STATUS_WARNING_LOW:
+				DeassertThreshold = GetLowDeassertValue(SignedSensor, WarningLow, NegHysteresis);
+				if (Value > DeassertThreshold)
+				{
+					//sensor_dbg_printf("#%02x LNC(D) - Value: %02x Threshold: %02x\n", pSensorInfo->SensorNumber, (uint8_t)Value, (uint8_t)DeassertThreshold);
+					/* deassert WarningLow going Low */
+					EvData1 = 0x50;
+					if (DeassertionEventEnablesByte1 & 0x01)
+					{
+						SendDeassertion = 1;
+					}
+
+					/* remove WarningLow going High deassertion */
+					DeassertionEventOccuredByte1 &= ~0x02;
+					/* deassert WarningLow going Low */
+					DeassertionEventOccuredByte1 |= 0x01;
+
+					/* assert WarningLow going High */
+					EventData1 = 0x51;
+					if (AssertionEventEnablesByte1 & 0x02)
+					{
+						SendAssertion = 1;
+					}
+					Level = SENSOR_STATUS_NORMAL;
+					EventData3 = WarningLow;
+					/* set de/assertion event */
+					/* remove WarningLow going Low assertion */
+					AssertionEventOccuredByte1 &= ~0x01;
+					/* assert WarningLow going High */
+					AssertionEventOccuredByte1 |= 0x02;
+					//SensorLevel = LWR_NON_CRITICAL_GOING_HIGH_CTRL_FN;
+				}
+				if (Value <= CriticalLow)
+				{
+					//sensor_dbg_printf("#%02x LC(A) - Value: %02x Threshold: %02x\n", pSensorInfo->SensorNumber, (uint8_t)Value, (uint8_t)CriticalLow);
+					/* deassert CriticalLow going High */
+					EvData1 = 0x53;
+					if (DeassertionEventEnablesByte1 & 0x08)
+					{
+						SendDeassertion = 1;
+					}
+
+					/* remove CriticalLow going Low deassertion */
+					DeassertionEventOccuredByte1 &= ~0x04;
+					/* deassert CriticalHigh going High */
+					DeassertionEventOccuredByte1 |= 0x08;
+
+					/* assert CriticalLow going Low */
+					EventData1 = 0x52;
+					if (AssertionEventEnablesByte1 & 0x04)
+					{
+						SendAssertion = 1;
+					}
+					Level = SENSOR_STATUS_CRITICAL_LOW;
+					EventData3 = CriticalLow;
+					/* remove CriticalLow going High assertion */
+					AssertionEventOccuredByte1 &= ~0x08;
+					/* assert CriticalLow going Low */
+					AssertionEventOccuredByte1 |= 0x04;
+					//SensorLevel = LWR_CRITICAL_GOING_LOW_CTRL_FN;
+				}
+				break;
+
+			case SENSOR_STATUS_CRITICAL_HIGH:
+				DeassertThreshold = GetHighDeassertValue(SignedSensor, CriticalHigh, PosHysteresis);
+				if (Value < DeassertThreshold)
+				{
+					//sensor_dbg_printf("#%02x UC(D) - Value: %02x Threshold: %02x\n",pSensorInfo->SensorNumber, (uint8_t)Value, (uint8_t)DeassertThreshold);
+					/* deassert CriticalHigh going High */
+					EvData1 = 0x59;
+					if (DeassertionEventEnablesByte2 & 0x02)
+					{
+						SendDeassertion = 1;
+					}
+
+					/* remove CriticalHigh going Low deassertion */
+					DeassertionEventOccuredByte2 &= ~0x01;
+					/* deassert CriticalHigh going High */
+					DeassertionEventOccuredByte2 |= 0x02;
+
+					/* assert CriticalHigh going Low */
+					EventData1 = 0x58;
+					if (AssertionEventEnablesByte2 & 0x01)
+					{
+						SendAssertion = 1;
+					}
+					Level = SENSOR_STATUS_WARNING_HIGH;
+					EventData3 = CriticalHigh;
+					/* set de/assertion event occured */
+					/* remove CriticalHigh going High assertion */
+					AssertionEventOccuredByte2 &= ~0x02;
+					/* assert CriticalHigh going Low */
+					AssertionEventOccuredByte2 |= 0x01;
+					//SensorLevel = UPPER_CRITICAL_GOING_LOW_CTRL_FN;
+				}
+				if (Value >= NonRecoverableHigh)
+				{
+					//sensor_dbg_printf("#%02x UNR(A) - Value: %02x Threshold: %02x\n", pSensorInfo->SensorNumber, (uint8_t)Value, (uint8_t)NonRecoverableHigh);
+					/*  deassert NonRecoverableHigh going Low */
+					EvData1 = 0x5A;
+					if (DeassertionEventEnablesByte2 & 0x04)
+					{
+						SendDeassertion = 1;
+					}
+					/* remove NonRecoverableHigh going High deassertion */
+					DeassertionEventOccuredByte2 &= ~0x08;
+					/* deassert NonRecoverableHigh going Low */
+					DeassertionEventOccuredByte2 |= 0x04;
+
+					/* assert NonRecoverableHigh going High */
+					EventData1 = 0x5B;
+					if (AssertionEventEnablesByte2 & 0x08)
+					{
+						SendAssertion = 1;
+					}
+					Level = SENSOR_STATUS_NONRECOVERABLE_HIGH;
+					EventData3 = NonRecoverableHigh;
+					/* remove NonRecoverableHigh going Low assertion */
+					AssertionEventOccuredByte2 &= ~0x04;
+					/* assert NonRecoverableHigh going High */
+					AssertionEventOccuredByte2 |= 0x08;
+					//SensorLevel = UPPER_NON_RECOVERABLE_GOING_HIGH_CTRL_FN;
+				}
+				break;
+
+			case SENSOR_STATUS_CRITICAL_LOW:
+				DeassertThreshold = GetLowDeassertValue(SignedSensor, CriticalLow, NegHysteresis);
+				if (Value > DeassertThreshold)
+				{
+					//sensor_dbg_printf("#%02x LC(D) - Value: %02x Threshold: %02x\n",pSensorInfo->SensorNumber, (uint8_t)Value, (uint8_t)DeassertThreshold);
+					/* deassert CriticalLow going Low */
+					EvData1 = 0x52;
+					if (DeassertionEventEnablesByte1 & 0x04)
+					{
+						SendDeassertion = 1;
+					}
+
+					/* remove CriticalLow going High deassertion */
+					DeassertionEventOccuredByte1 &= ~0x08;
+					/* deassert CriticalLow going Low */
+					DeassertionEventOccuredByte1 |= 0x04;
+
+					/* assert CriticalLow going High */
+					EventData1 = 0x53;
+					if (AssertionEventEnablesByte1 & 0x08)
+					{
+						SendAssertion = 1;
+					}
+					Level = SENSOR_STATUS_WARNING_LOW;
+					EventData3 = CriticalLow;
+					/* remove CriticalLow going Low assertion */
+					AssertionEventOccuredByte1 &= ~0x04;
+					/* assert CriticalLow going High */
+					AssertionEventOccuredByte1 |= 0x08;
+					//SensorLevel = LWR_CRITICAL_GOING_HIGH_CTRL_FN;
+				}
+				if (Value <= NonRecoverableLow)
+				{
+					//sensor_dbg_printf("#%02x LNR(A) - Value: %02x Threshold: %02x\n", pSensorInfo->SensorNumber, (uint8_t)Value, (uint8_t)NonRecoverableLow);
+					/* deassert NonRecoverableLow going High */
+					EvData1 = 0x55;
+					if (DeassertionEventEnablesByte1 & 0x20)
+					{
+						SendDeassertion = 1;
+					}
+
+					/* remove NonRecoverableLow going Low deassertion */
+					DeassertionEventOccuredByte1 &= ~0x10;
+					/* deassert NonRecoverableLow going High */
+					DeassertionEventOccuredByte1 |= 0x20;
+
+					/* assert NonRecoverableLow going Low */
+					EventData1 = 0x54;
+					if (AssertionEventEnablesByte1 & 0x10)
+					{
+						SendAssertion = 1;
+					}
+					Level = SENSOR_STATUS_NONRECOVERABLE_LOW;
+					EventData3 = NonRecoverableLow;
+					/* remove NonRecoverableLow going High assertion */
+					AssertionEventOccuredByte1 &= ~0x20;
+					/* assert NonRecoverableLow going Low */
+					AssertionEventOccuredByte1 |= 0x10;
+					//SensorLevel = LWR_NON_RECOVERABLE_GOING_LOW_CTRL_FN;
+				}
+				break;
+
+			case SENSOR_STATUS_NONRECOVERABLE_HIGH:
+				DeassertThreshold = GetHighDeassertValue(SignedSensor, NonRecoverableHigh, PosHysteresis);
+				if (Value < DeassertThreshold)
+				{
+					//sensor_dbg_printf("#%02x UNR(D) - Value: %02x Threshold: %02x\n", pSensorInfo->SensorNumber, (uint8_t)Value, (uint8_t)DeassertThreshold);
+					/* deassert NonRecoverableHigh going High */
+					EvData1 = 0x5B;
+					if (DeassertionEventEnablesByte2 & 0x08)
+					{
+						SendDeassertion = 1;
+					}
+
+					/* remove NonRecoverableHigh going Low deassertion */
+					DeassertionEventOccuredByte2 &= ~0x04;
+					/* deassert NonRecoverableHigh going High */
+					DeassertionEventOccuredByte2 |= 0x08;
+
+					/* assert NonRecoverableHigh going Low */
+					EventData1 = 0x5A;
+					if (AssertionEventEnablesByte2 & 0x04)
+					{
+						SendAssertion = 1;
+					}
+					Level = SENSOR_STATUS_CRITICAL_HIGH;
+					EventData3 = NonRecoverableHigh;
+					/* remove NonRecoverableHigh going High assertion */
+					AssertionEventOccuredByte2 &= ~0x08;
+					/* assert NonRecoverableHigh going Low */
+					AssertionEventOccuredByte2 |= 0x04;
+					//SensorLevel = UPPER_NON_RECOVERABLE_GOING_LOW_CTRL_FN;
+				}
+				break;
+
+			case SENSOR_STATUS_NONRECOVERABLE_LOW:
+				DeassertThreshold = GetLowDeassertValue(SignedSensor, NonRecoverableLow, NegHysteresis);
+				if (Value > DeassertThreshold)
+				{
+					//sensor_dbg_printf("#%02x LNR(D) - Value: %02x Threshold: %02x\n", pSensorInfo->SensorNumber, (uint8_t)Value, (uint8_t)DeassertThreshold);
+					/* deassert NonRecoverableLow going Low */
+					EvData1 = 0x54;
+					if (DeassertionEventEnablesByte1 & 0x10)
+					{
+						SendDeassertion = 1;
+					}
+
+					/* remove NonRecoverableLow going High deassertion */
+					DeassertionEventOccuredByte1 &= ~0x20;
+					/* deassert NonRecoverableLow going Low */
+					DeassertionEventOccuredByte1 |= 0x10;
+
+					/* assert NonRecoverableLow going High */
+					EventData1 = 0x55;
+					if (AssertionEventEnablesByte1 & 0x20)
+					{
+						SendAssertion = 1;
+					}
+					Level = SENSOR_STATUS_CRITICAL_LOW;
+					EventData3 = NonRecoverableLow;
+					/* remove NonRecoverableLow going Low assertion */
+					AssertionEventOccuredByte1 &= ~0x10;
+					/* assert NonRecoverableLow going High */
+					AssertionEventOccuredByte1 |= 0x20;
+					//SensorLevel = LWR_NON_RECOVERABLE_GOING_HIGH_CTRL_FN;
+				}
+				break;
+
+			case SENSOR_STATUS_FATAL:
+				break;
+
+		} /* switch(m_SensorEventLevel[i]) */
+
+		pSensorInfo->EventLevel = Level;
+		pSensorInfo->AssertionEventOccuredByte1 = AssertionEventOccuredByte1;
+		pSensorInfo->AssertionEventOccuredByte2 = AssertionEventOccuredByte2;
+		pSensorInfo->DeassertionEventOccuredByte1 = DeassertionEventOccuredByte1;
+		pSensorInfo->DeassertionEventOccuredByte2 = DeassertionEventOccuredByte2;
+
+		AssertionHistoryByte1   = 0;
+		AssertionHistoryByte2   = 0;
+		DeassertionHistoryByte1 = 0;
+		DeassertionHistoryByte2 = 0;
+		
+		//TODO: post event message to SEL Task.
+		EventMsg [0] = 0x20;
+		EventMsg [1] = (pSensorInfo->SensorOwnerLun & 0x03);	/* Multi-LUN support */
+		/* EvMRev */
+		EventMsg [2] = IPMI_EVM_REVISION;
+		/* sensor type */
+		EventMsg [3] = pSensorInfo->SensorTypeCode;
+		/* sensor number */
+		EventMsg [4] = pSensorInfo->SensorNumber;
+
+		/* event direction|type */
+		EventMsg [5] = 0x01;
+
+		EventMsg [6] = 0;	
+
+		/* Set Sensor Event Data based on the Operation byte */
+		switch (pSensorInfo->Operation>>6)
+		{
+			case WRITE_NO_EVTDATA1:
+				/* Event Data 1 */
+				EventMsg [6] =  pSensorInfo->EvtData1;
+				/* Intentional Fall thru */
+			case WRITE_EVTDATA1:
+				/* Event Data 1 */
+				EventMsg [6] |= EventData1;
+				/* Update EvtData fields */
+				/* Current Reading */
+				EventMsg [7] = pSensorInfo->EvtData2;
+				/* Trigger that caused event */
+				EventMsg [8] = pSensorInfo->EvtData3;
+				break;
+
+			case USE_SM_EVTDATA:
+				/* Event Data 1 */
+				EventMsg [6] = EventData1;
+				/* Current Reading */
+				EventMsg [7] = Value;
+				/* Trigger that caused event */
+				EventMsg [8] = EventData3;
+				break;
+		}
+
+		if (SendAssertion)
+		{
+			if ((EventData1 & 0x0f) < 8)    
+			{
+				AssertionHistoryByte1 = (1 << (EventData1 & 0x0f));
+			}
+			else
+			{
+				AssertionHistoryByte2 = (1 << ((EventData1 & 0x0f) - 8));
+			}
+
+			/* For Manual Rearm Sensor - Check for already generated events in the History bytes 
+			For Auto Rearm Sensor -History bytes are not valid */
+			if ( (0 == (AssertionHistoryByte1 & pSensorInfo->AssertionHistoryByte1)) &&
+				(0 == (AssertionHistoryByte2 & pSensorInfo->AssertionHistoryByte2)) )
+			{
+				/* if sensor is manual arming */
+				if (0 == (pSensorInfo->SensorCaps & BIT6))
+				{
+					/* Update assertion History */
+					pSensorInfo->AssertionHistoryByte1 |= AssertionHistoryByte1;
+					pSensorInfo->AssertionHistoryByte2 |= AssertionHistoryByte2;
+				}
+				
+				/* Is event message generation enabled ? */
+				if (0 != (pSensorInfo->EventFlags & BIT7))
+				{
+					/* Post Event Message */
+					PostEventMessage (EventMsg, sizeof (EventMsg));
+				}
+			}
+			SendAssertion = 0;
+		}
+		
+		if (SendDeassertion)
+		{
+			if ((EvData1 & 0x0f) < 8)    
+			{
+				DeassertionHistoryByte1 = (1 << (EvData1 & 0x0f));
+			}
+			else
+			{
+				DeassertionHistoryByte2 = (1 << ((EvData1 & 0x0f) - 8));
+			}
+
+			/* For Manual Rearm Sensor - Check for already generated events in the History bytes 
+			For Auto Rearm Sensor -History bytes are not valid */
+			if ( (0 == (DeassertionHistoryByte1 & pSensorInfo->DeassertionHistoryByte1)) &&
+			(0 == (DeassertionHistoryByte2 & pSensorInfo->DeassertionHistoryByte2)) )
+			{
+
+				/* Event Data 1 */
+				EventMsg [6] = EvData1;
+				EventMsg [5] = 0x81;
+
+				/* if sensor is manual arming */
+				if (0 == (pSensorInfo->SensorCaps & BIT6))
+				{
+					/* Update Deassertion History */
+					pSensorInfo->DeassertionHistoryByte1 |= DeassertionHistoryByte1;
+					pSensorInfo->DeassertionHistoryByte2 |= DeassertionHistoryByte2;
+				}
+					/* Call PreEventLog hook function(s) and don't do
+					sensor SEL event log if the return is not zero */
+					if (0 != (pSensorInfo->EventFlags & BIT7))
+					{						
+						/* Post Event Message Here */
+						PostEventMessage (EventMsg, sizeof (EventMsg));
+					}
+			}
+			SendDeassertion = 0;
+		}
+	}while (StartLevel != Level);
+
+	/* Auto Rearm sensor: Get current assertions */
+	AssertionHistoryByte1 = pSensorInfo->AssertionEventOccuredByte1;
+	AssertionHistoryByte2 = pSensorInfo->AssertionEventOccuredByte2;
+
+	// The following checks need to be done from lowest severity to highest.
+	HealthLevel = SENSOR_STATUS_NORMAL;
+	if (0 != (AssertionHistoryByte1 & 0x01 & AssertionEventEnablesByte1))
+		HealthLevel = SENSOR_STATUS_WARNING_LOW;
+	if (0 != (AssertionHistoryByte1 & 0x80 & AssertionEventEnablesByte1))
+		HealthLevel = SENSOR_STATUS_WARNING_HIGH;
+	if (0 != (AssertionHistoryByte1 & 0x04 & AssertionEventEnablesByte1))
+		HealthLevel = SENSOR_STATUS_CRITICAL_LOW;
+	if (0 != (AssertionHistoryByte2 & 0x02 & AssertionEventEnablesByte2))
+		HealthLevel = SENSOR_STATUS_CRITICAL_HIGH;
+	if (0 != (AssertionHistoryByte1 & 0x10 & AssertionEventEnablesByte1))
+		HealthLevel = SENSOR_STATUS_NONRECOVERABLE_LOW;
+	if (0 != (AssertionHistoryByte2 & 0x08 & AssertionEventEnablesByte2))
+		HealthLevel = SENSOR_STATUS_NONRECOVERABLE_HIGH;
+
+	pSensorInfo->HealthLevel = HealthLevel;
+
+	// Make sure the "Reading Not Available" bit is clear.
+	pSensorInfo->EventFlags &= ~BIT5;
+}
+
+
+/**
+ * @brief Monitor Non-threshold sensors.
+ * @param i - Sensor index.
+*/
+static void
+MonitorNonTSensors ( SensorInfo_T*  pSensorInfo)
+{
+	//TODO:
+	printf("MonitorNonTSensors: not implement\r\n");
+	
+}
+
+/**
+ * @fn hal_read_sensor
+ * @brief This function reads the sensor reading for given sensor number
+ *
+**/
+int get_sensor_reading (uint8_t sensor_num, uint8_t *preading)
+{
+    sensor_tbl_t    *pdev_tbl;
+
+    pdev_tbl = (sensor_tbl_t*)getSensorDev (sensor_num);
+
+    if (pdev_tbl == NULL)
+    {
+        printf ("Error: couldn't find sensor %x\n", sensor_num);
+        return 1;
+    }
+
+
+    /* Execute at the requested sensor reading handler */
+    if (0 != pdev_tbl->device_read (preading))
+    {
+        printf ("Error executing read function\n");
+        return -1;
+    }
+     
+
+//    sensor_dbg_printf ("sensor number %x  reading = %x\r\n", sensor_num, *preading);
+    return 0;
+}
+
+//<<KAMAL>>Added to support Sensor Averaging ../
+
+#define AVERAGING_SIZE					10
+int SensorAverage(uint8_t SensorNum, uint8_t* pSensorReading)
+{
+    static uint8_t	AverageBuf [AVERAGING_SIZE];
+    static int		AverageCount = 0;
+    static int		InitDone	   = 0;
+    SensorInfo_T*	pSensorInfo    = NULL;
+    int 			AverageIndex   = 0;
+    int 			i   		   = 0;
+    uint32_t		AverageSum	   = 0;
+
+    pSensorInfo = getSensorInfo(SensorNum);
+    /* Check if we received valid sensor information */
+    if (pSensorInfo == NULL) 
+    {
+		printf ("Error: Unable to get SensorInfo \n");
+		return 0;  
+    }		
+
+	/* Averaging index */
+	AverageIndex = AverageCount % AVERAGING_SIZE;
+	
+	/* Set Sensor state to be update in progress unless
+	 * we receive all  AVERAGING_SIZE values */
+	if (0 == InitDone) 
+	{ 
+		/* Settting update in progress */
+		pSensorInfo->EventFlags |= BIT1;
+		
+		/* Checking if we have enough to do averaging */
+		if (AverageIndex == (AVERAGING_SIZE -1))
+		{
+			InitDone = 1;
+		}
+	}
+	else
+	{
+		/* Clearing update in progress */
+		pSensorInfo->EventFlags &= ~BIT1;
+	}
+	
+	/* Update averaging buffer */	
+	AverageBuf [AverageIndex ] = 	*pSensorReading;
+	
+	AverageCount++;
+	
+	if (AverageCount == AVERAGING_SIZE) { AverageCount = 0; }
+	
+	for (i = 0; i <  AVERAGING_SIZE; i++)
+	{
+		AverageSum += AverageBuf [i];
+	}
+
+	if (1 == InitDone)
+	{
+		*pSensorReading = (uint8_t)(AverageSum / AVERAGING_SIZE);
+	}
+		
+	/* Averaging done */
+	return 0;	
+}
+
+SensorInfo_T* getSensorInfo(uint8_t sensorNum)
+{
+	uint16_t i;
+	for(i=0;i<g_BMCInfo.SenConfig.ValidSensorCnt;i++)
+	{
+		if(sensorNum == g_BMCInfo.SensorSharedMem.SensorInfo[i].SensorNumber)
+		{
+			return &g_BMCInfo.SensorSharedMem.SensorInfo[i];
+		}
+	}
+	
+	return NULL;
+}
+
+
+
+
+
+//#endif /*SENSOR_DEVICE == 1*/
+

+ 75 - 0
app/bmc/msghndlr/SensorEvent/SensorEvent.c

@@ -0,0 +1,75 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************/
+/*****************************************************************
+ *
+ * SensorEvent.c
+ * Sensor Event Command Handler
+ *
+ * Author: Bakka Ravinder Reddy <bakkar@ami.com>
+ * 
+ *****************************************************************/
+#define UNIMPLEMENTED_AS_FUNC
+#include "MsgHndlr.h"
+#include "SensorEvent.h"
+#include "com_IPMI_SensorEvent.h"
+#include "Support.h"
+#include "Sensor.h"
+#include "SDRFunc.h"
+#include "SDR.h"
+
+//#include "Storlead_BMC_LIb.h"
+
+/*** Global Variables ***/
+const CmdHndlrMap_T	g_SensorEvent_CmdHndlr [] =	//notice!
+{
+#if EVENT_PROCESSING_DEVICE == 1
+    { CMD_SET_EVENT_RECEIVER,			PRIV_ADMIN,		SET_EVENT_RECEIVER,			sizeof (SetEvtRcvReq_T),	0xAAAA ,0xFFFF},
+    { CMD_GET_EVENT_RECEIVER,			PRIV_USER,		GET_EVENT_RECEIVER,			0x00,	0xAAAA	,0xFFFF},
+    { CMD_PLATFORM_EVENT,				PRIV_OPERATOR, 	PLATFORM_EVENT,				0xFF,	0xAAAA	,0xFFFF},
+#endif	/* EVENT_PROCESSING_DEVICE */
+
+#if PEF_DEVICE == 1
+    { CMD_GET_PEF_CAPABILITIES,			PRIV_USER,		GET_PEF_CAPABILITIES,		0x00,	0xAAAA	,0xFFFF},											
+    { CMD_ARM_PEF_POSTPONE_TIMER,		PRIV_ADMIN,		ARM_PEF_POSTPONE_TIMER,		0x01,	0xAAAA	,0xFFFF},
+    { CMD_SET_PEF_CONFIG_PARAMS,		PRIV_ADMIN,		SET_PEF_CONFIG_PARAMS,		0xFF,	0xAAAA	,0xFFFF},											
+    { CMD_GET_PEF_CONFIG_PARAMS,		PRIV_OPERATOR,	GET_PEF_CONFIG_PARAMS,		sizeof (GetPEFConfigReq_T),	0xAAAA ,0xFFFF},											
+    { CMD_SET_LAST_PROCESSED_EVENT_ID,	PRIV_ADMIN,		SET_LAST_PROCESSED_EVENT_ID,sizeof (SetLastEvtIDReq_T),	0xAAAA	,0xFFFF},									
+    { CMD_GET_LAST_PROCESSED_EVENT_ID,	PRIV_ADMIN,		GET_LAST_PROCESSED_EVENT_ID,0x00,	0xAAAA	,0xFFFF},									
+    { CMD_ALERT_IMMEDIATE,				PRIV_ADMIN,		ALERT_IMMEDIATE,			0xFF,	0xAAAA  ,0xFFFF},														
+    { CMD_PET_ACKNOWLEDGE,				PRIV_NONE,		PET_ACKNOWLEDGE,			sizeof (PETAckReq_T),	0xAAAA	,0xFFFF},														
+#endif /* PEF_DEVICE */
+
+#if SENSOR_DEVICE == 1
+    { CMD_GET_DEV_SDR_INFO,				PRIV_LOCAL,		GET_DEV_SDR_INFO,			0xFF,	0xAAA8	,0xFFFF},
+    { CMD_GET_DEV_SDR,					PRIV_LOCAL,		GET_DEV_SDR,				0xFF,	0xAAA8	,0xFFFF},
+    { CMD_RESERVE_DEV_SDR_REPOSITORY,	PRIV_LOCAL,		RESERVE_DEV_SDR_REPOSITORY, 0x00,	0xAAA8	,0xFFFF},
+    { CMD_GET_SENSOR_READING_FACTORS,	PRIV_USER,	 	GET_SENSOR_READING_FACTORS, sizeof (GetSensorReadingFactorReq_T),	0xAAA8 ,0xFFFF},
+    { CMD_SET_SENSOR_HYSTERISIS,		PRIV_OPERATOR, 	SET_SENSOR_HYSTERISIS,		sizeof (SetSensorHysterisisReq_T),	0xAAAA	,0xFFFF},
+    { CMD_GET_SENSOR_HYSTERISIS,		PRIV_USER,	 	GET_SENSOR_HYSTERISIS,		sizeof (GetSensorHysterisisReq_T),	0xAAAA ,0xFFFF},
+    { CMD_SET_SENSOR_THRESHOLDS,		PRIV_OPERATOR, 	SET_SENSOR_THRESHOLDS,		sizeof (SetSensorThresholdReq_T),	0xAAAA ,0xFFFF},
+    { CMD_GET_SENSOR_THRESHOLDS,		PRIV_USER,	 	GET_SENSOR_THRESHOLDS,		sizeof (GetSensorThresholdReq_T),	0xAAAA ,0xFFFF},
+    { CMD_SET_SENSOR_EVENT_ENABLE,		PRIV_OPERATOR, 	SET_SENSOR_EVENT_ENABLE,	0xFF,	0xAAAA ,0xFFFF},
+    { CMD_GET_SENSOR_EVENT_ENABLE,		PRIV_USER,	 	GET_SENSOR_EVENT_ENABLE,	sizeof (GetSensorEventEnableReq_T),	0xAAAA ,0xFFFF},
+    { CMD_REARM_SENSOR_EVENTS,			PRIV_OPERATOR,	REARM_SENSOR_EVENTS,		0xFF,	0xAAAA ,0xFFFF},
+    { CMD_GET_SENSOR_EVENT_STATUS,		PRIV_USER,		GET_SENSOR_EVENT_STATUS,	sizeof (GetSensorEventStatusReq_T),	0xAAAA ,0xFFFF},
+    { CMD_GET_SENSOR_READING,			PRIV_USER,	 	GET_SENSOR_READING,			sizeof (GetSensorReadingReq_T),	0xAAAA ,0xFFFF},
+    { CMD_SET_SENSOR_TYPE,				PRIV_OPERATOR,	SET_SENSOR_TYPE,			sizeof (SetSensorTypeReq_T),	0xAAA8 ,0xFFFF},
+    { CMD_GET_SENSOR_TYPE,				PRIV_USER,	 	GET_SENSOR_TYPE,			sizeof (GetSensorTypeReq_T),	0xAAA8 ,0xFFFF},
+    { CMD_SET_SENSOR_READING, 			PRIV_USER,		SET_SENSOR_READING,			0xFF, 0xAAAA ,0xFFFF},
+
+#endif /* SENSOR_DEVICE */
+
+    { 0x00, 					0x00, 			0x00,				  0x00,	0x0000  , 0x0000}
+};
+

+ 132 - 0
app/bmc/msghndlr/SensorEvent/SensorEvent.h

@@ -0,0 +1,132 @@
+/*
+* Brief:	The header file of MsgHndlr_SensorEvent packet.
+* Author:	Jimbo_Zhang@outlook.com
+* Date:		2019-9-16
+*/
+
+#ifndef __MSG_HNDLR_SENSOR_EVENT_H__
+#define __MSG_HNDLR_SENSOR_EVENT_H__
+
+#include "MsgHndlr.h"
+//#include "SensorMonitor.h"
+
+
+/**
+ * @var g_SensorEvent_CmdHndlr
+ * @brief Sensor event command handler map.
+**/
+extern const CmdHndlrMap_T  g_SensorEvent_CmdHndlr [];
+
+
+
+/*** External Definitions ***/
+
+/*** Global definitions ***/
+
+/* SEL Sensor */
+#define EVENT_LOG_AREA_RESET					0x2
+#define EVENT_SEL_ALMOST_FULL					0x5
+#define EVENT_SEL_IS_FULL					0x4	
+
+
+
+/* Watchdog Sensor */
+#define EVENT_TIMER_EXPIRED					0x00
+#define EVENT_HARD_RESET					0x01
+#define EVENT_POWER_DOWN					0x02
+#define EVENT_POWER_CYCLE					0x03
+#define EVENT_TIMER_INT						0x08
+
+
+//typedef struct
+//{
+//    uint8_t                       SensorTypeCode;     /* Sensor Type code      */
+//    uint16_t                      SensorReading;      /* Sensor Reading        */
+//    uint8_t                       SensorNum;          /* Sensor Number         */	
+//    uint16_t                      u16AssertionHistory;/* Assertion tracking    */
+//    uint8_t                       u8TmrUse;           /* WDT use               */
+//    uint8_t                       u8TmrActions;       /* WDT actions           */
+//    uint8_t                       u8Restarted;        /* WDT restarted         */
+//    pPDK_SensorInitHook_T       pInitSensor;        /* Init Sensor hook      */
+//    pPDK_MonitorHook_T          pPreMonitor;        /* Pre monitor hook      */
+//    pPDK_MonitorHook_T          pPostMonitor;       /* Post monitor hook     */
+//    pPDK_MonitorExtHook_T       pPostMonitorExt;    /* Post monitor Ext hook */
+//    uint8_t                       EntityID;           /* Entity ID             */
+//    uint8_t                       EntityInst;         /* Entity Instance       */
+//    uint32_t                       FeatureSupport;     /* Feature Supported or not*/
+//	uint8_t                       SensorOwnerLun;     /* OwnerLUN            */
+//} InternalSensorTbl_T;
+
+
+///*** Prototype Declaration ***/
+
+///* Functions for SEL Sensor Implementation */
+//int SELSensorInit (void*  pSensorInfo);
+//int SELMonitor (void* pSenInfo, uint8_t* pReadFlags);
+//int SELEventLog (void* pSenInfo, uint8_t* pReadFlags);
+//int SELEventLogExt (void* pSenInfo, uint8_t* pReadFlags);
+
+///* Functions for Watchdog Sensor Implementation */
+//int WD2SensorInit (void*  pSensorInfo);
+//int WD2Monitor (void* pSenInfo, uint8_t* pReadFlags);
+//int WD2DummyEventLog (void* pSenInfo, uint8_t* pReadFlags);
+//int WD2EventLog (void* pSenInfo, uint8_t* pReadFlags);
+//int WD2EventLogExt (void* pSenInfo, uint8_t* pReadFlags);
+
+///* Functions for SSI Compute Blade Operational State Sensor Implementation */
+//int OpStateSensorInit (void* pSenInfo);
+//int OpStateMonitor (void *pSenInfo, uint8_t* pReadFlags);
+//int OpStateEventLog (void *pSenInfo, uint8_t* pReadFlags);
+//int OpStateEventLogExt (void* pSenInfo, uint8_t* pReadFlags);
+
+///* Functions for SSI Compute Blade Aggregated Thermal Sensor Implementation */
+//int AggregateThermalSensorInit (void* pSenInfo);
+//int AggregateThermalMonitor (void *pSenInfo, uint8_t* pReadFlags);
+//int AggregateThermalEventLog (void *pSenInfo, uint8_t* pReadFlags);
+//int AggregateThermalEventLogExt (void* pSenInfo, uint8_t* pReadFlags);
+
+///* Functions for SSI Compute Blade Aggregated Fault Sensor Implementation */
+//int AggregateFaultSensorInit (void* pSenInfo);
+//int AggregateFaultMonitor (void *pSenInfo, uint8_t* pReadFlags);
+//int AggregateFaultEventLog (void *pSenInfo, uint8_t* pReadFlags);
+//int AggregateFaultEventLogExt (void* pSenInfo, uint8_t* pReadFlags);
+
+///* Functions for SSI Compute Blade Service State Sensor Implementation */
+//int ServiceStateSensorInit (void* pSenInfo);
+//int ServiceStateMonitor (void *pSenInfo, uint8_t* pReadFlags);
+//int ServiceStateEventLog (void *pSenInfo, uint8_t* pReadFlags);
+//int ServiceStateEventLogExt (void* pSenInfo, uint8_t* pReadFlags);
+
+
+/*-----------------------------------------
+ * GetSELFullPercentage
+ *-----------------------------------------*/
+extern uint8_t  GetSELFullPercentage(void);
+	
+/**
+ * @brief GetSensorNumFromSensorType.
+ * @param  SensorType       - Sensor Type of the sensor.
+ * @return SensorInfo if success, 0xFF if error.
+**/
+extern void* GetSensorInfoFromSensorType(uint8_t SensorType);
+
+
+///**
+// * @brief SetSELSensorReading.
+// * @param Res       - Sensor reading to be set.
+// * @return 0 if success, -1 if error.
+//**/
+//extern int  SetSELSensorReading (uint16_t Reading);
+
+///**
+// * @brief SetWD2SensorReading.
+// * @param Res       - Sensor reading to be set.
+// * @return 0 if success, -1 if error.
+//**/
+//extern int  SetWD2SensorReading (uint16_t Reading, uint8_t u8TmrUse, uint8_t u8TmrActions); 
+
+//extern int  RestartWD2Sensor(int BMCInst);
+
+//extern int  WD2SELLog (uint8_t Action);
+
+#endif /* __MSG_HNDLR_SENSOR_EVENT_H__ */

+ 329 - 0
app/bmc/msghndlr/SensorEvent/SensorMonitor.h

@@ -0,0 +1,329 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************/
+/*****************************************************************
+ *
+ * SensorMonitor.h
+ * Sensor Monitor 
+ *
+ * Author: Rama Rao Bisa <ramab@ami.com> 
+ * 
+ *****************************************************************/
+#ifndef SENSOR_MONITOR_H
+#define SENSOR_MONITOR_H
+
+#include "com_IPMI_SDRRecord.h"
+
+
+/*** Soft Processor Control functions   ***/    
+#define READ_CTRL_FN                                0x01
+#define LWR_NON_CRITICAL_GOING_LOW_CTRL_FN          0x02
+#define LWR_CRITICAL_GOING_LOW_CTRL_FN              0x03
+#define LWR_NON_RECOVERABLE_GOING_LOW_CTRL_FN       0x04
+#define UPPER_NON_CRITICAL_GOING_HIGH_CTRL_FN       0x05
+#define UPPER_CRITICAL_GOING_HIGH_CTRL_FN           0x06
+#define UPPER_NON_RECOVERABLE_GOING_HIGH_CTRL_FN    0x07
+
+#define LWR_NON_CRITICAL_GOING_HIGH_CTRL_FN         0x82
+#define LWR_CRITICAL_GOING_HIGH_CTRL_FN             0x83
+#define LWR_NON_RECOVERABLE_GOING_HIGH_CTRL_FN      0x84
+#define UPPER_NON_CRITICAL_GOING_LOW_CTRL_FN        0x85
+#define UPPER_CRITICAL_GOING_LOW_CTRL_FN            0x86
+#define UPPER_NON_RECOVERABLE_GOING_LOW_CTRL_FN     0x87
+
+#define GET_NORMAL_VALUE                            0xFE
+#define INIT_CTRL_FN                                0xFF
+
+/*** Sensor Event   definitions ***/
+#define SENSOR_STATUS_NORMAL                    0x00
+#define SENSOR_STATUS_WARNING_HIGH              0x01
+#define SENSOR_STATUS_WARNING_LOW               0x02
+#define SENSOR_STATUS_CRITICAL_HIGH             0x03
+#define SENSOR_STATUS_CRITICAL_LOW              0x04
+#define SENSOR_STATUS_NONRECOVERABLE_HIGH       0x05
+#define SENSOR_STATUS_NONRECOVERABLE_LOW        0x06
+#define SENSOR_STATUS_FATAL                     0x08
+
+#define MAX_SENSORS_ALLOWED                     20
+#ifdef SKIPPER
+#define MAX_SENSORS                             0x13
+#define MAX_FANS                                0x08
+#define MAX_VOLTS                               0x08
+#define MAX_TEMPS                               0x01
+#else
+#define MAX_SENSORS                             0x11
+#define MAX_FANS                                0x07
+#define MAX_VOLTS                               0x08
+#define MAX_TEMPS                               0x00
+#endif
+
+//#define MAX_SENSOR_NUMBERS	    		(64)	//RAM limit
+
+/*---------------------------------------------------
+ * Parameters passed to the sensor monitor handler Q.
+ *---------------------------------------------------*/
+#define PARAM_REARM_ALL_SENSORS     0x01
+#define PARAM_REARM_SENSOR          0x02
+#define PARAM_HANDLE_IRQ            0x03
+#define PARAM_SENSOR_SCAN           0x04
+
+
+//typedef int (*pPDK_MonitorHook_T) (void* pSensorInfo,uint8_t *pReadFlags );
+//typedef int (*pPDK_SensorInitHook_T) (void *pSensorInfo );
+//typedef int (*pPDK_MonitorExtHook_T) (void *pSensorInfo, uint8_t* pReadFlags );
+//typedef int (*pPDK_PreEventLogHook_T) (void *pSensorInfo, uint8_t* pEventData, uint8_t* pReadFlags );
+
+
+///* Hook Type supported */
+//typedef enum
+//{
+//    HT_INIT_SENSOR,
+//    HT_PRE_MONITOR,
+//    HT_POST_MONITOR
+
+//} HookType_e;
+
+//	
+//#define MAX_PRE_MONITOR_HOOKS        3
+//#define MAX_POST_MONITOR_HOOKS       3
+//#define MAX_POST_MONITOR_EXT_HOOKS   3
+//#define MAX_INIT_SENSOR_HOOKS		 3
+//#define MAX_PRE_EVENT_LOG_HOOKS      3
+
+
+/* Sensor Monitor Event Flags */
+
+#define SET_SM_INIT_DONE(FLAGS)			(FLAGS = FLAGS & 0xFE)
+#define SET_SM_REINIT(FLAGS)			(FLAGS = FLAGS | 0x01)
+#define SET_SM_UNABLE_TO_READ(FLAGS)		(FLAGS = FLAGS | 0x20)
+#define SET_SM_CLEAR_UNABLE_TO_READ(FLAGS)	(FLAGS = FLAGS & 0xDF)
+#define SET_SM_ENABLE_SCAN(FLAGS)		(FLAGS = FLAGS | 0x40)
+#define SET_SM_DISABLE_SCAN(FLAGS)		(FLAGS = FLAGS & 0xBF)
+#define SET_SM_ENABLE_EVT(FLAGS)		(FLAGS = FLAGS | 0x80)
+#define SET_SM_DISABLE_EVT(FLAGS)		(FLAGS = FLAGS & 0x7F)
+
+
+#pragma pack (1)
+
+//typedef struct 
+//{ 
+//    uint8_t  MonitorInterval;
+////    uint8_t  MonitorState ;
+////    uint16_t NormalValue;     		
+//    uint8_t  PowerOnDelay; //Delay after chassis power on in seconds. 0 - don't delay
+//    uint8_t  SysResetDelay ; // Delay after chassis reset    in seconds. 0 - don't delay
+//} SensorProperties_T; 
+
+
+//typedef struct
+//{
+//    uint8_t		SensorNum;   	/* Sensor Numbner */	
+//    uint8_t       	HookType;       /* Type of the hook */ 
+//    pPDK_MonitorHook_T	pHook;          /* Hook */ 
+
+//} PDKSensorHook_T; 
+/**
+ * @struct SensorInfo_T
+ * @brief Sensor Information.
+**/
+typedef struct
+{
+
+//    uint8_t               IsSensorPresent;		//nessary  
+    uint8_t               SensorNumber;
+    uint8_t               SensorReading;
+    uint16_t              SettableThreshMask;
+    uint16_t              Err;
+    uint16_t              PreviousState;
+    uint16_t              RecordID;
+    uint8_t               SensorTypeCode;
+    uint8_t               EventTypeCode;
+    uint8_t               SensorInit;			//SDR sensor initialization
+
+    // These values are copied from the SDR.
+    uint8_t           Units1;
+    uint8_t           Units2;
+    uint8_t           Units3;
+
+    // Caution !!! Order of these members has to maintained
+    // Some of the command implementation needs the order to be maintained 
+
+    // the following set are used in Get Sensor Reading Factors command
+    uint8_t   		M_LSB;
+    uint8_t   		M_MSB_Tolerance;
+    uint8_t   		B_LSB;
+    uint8_t   		B_MSB_Accuracy;
+    uint8_t   		Accuracy_MSB_Exp;
+    uint8_t   		RExp_BExp;
+    uint16_t        sensor_send_packed[12];		//nessary??
+
+    // the following set are used in Get/Set Sensor Threshold commands
+    uint8_t               LowerNonCritical;
+    uint8_t               LowerCritical;
+    uint8_t               LowerNonRecoverable;
+    uint8_t               UpperNonCritical;
+    uint8_t               UpperCritical;
+    uint8_t               UpperNonRecoverable;
+    
+    // the following set are used in Get/Set Sensor Hysteresis commands
+    uint8_t               PosHysteresis;
+    uint8_t               NegHysteresis;
+
+
+    // the following set are used in Get/Set Event Enables commands
+    uint8_t   		EventFlags;
+                            /* Event Flags description           */
+                            /* Bit 0 -  Initialization Done      */
+                            /* Bit 1 -  Update in Progress       */
+                            /* Bit 2 -  reserved                 */
+                            /* Bit 3 -  reserved                 */
+                            /* Bit 4 -  reserved                 */
+                            /* Bit 5 -  Unable to read           */
+                            /* Bit 6 -  Sensor Scanning disabled */
+                            /* Bit 7 -  Event Message Disabled   */
+    uint8_t               AssertionEventEnablesByte1;
+    uint8_t               AssertionEventEnablesByte2;
+    uint8_t               DeassertionEventEnablesByte1;
+    uint8_t               DeassertionEventEnablesByte2;
+
+
+    uint8_t               EventLevel;
+    uint8_t               HealthLevel;    // Added to provide correct Health state
+    uint8_t               AssertionEventOccuredByte1;
+    uint8_t               AssertionEventOccuredByte2;
+    uint8_t               DeassertionEventOccuredByte1;
+    uint8_t               DeassertionEventOccuredByte2;
+
+    uint8_t               SensorMonitorInterval;  // added to effect different sensor monitor intervals.
+    uint8_t               SensorState;				//wether monitor on standby
+    uint8_t               SensorReadType;
+    uint8_t               PowerOnDelay; //Delay after chassis power on in seconds. 0 - don't delay
+    uint8_t               SysResetDelay ; // Delay after chassis reset    in seconds. 0 - don't delay
+
+    /* Settable Sensor Fields */
+    uint8_t   Operation;		
+    uint8_t   EvtData1;
+    uint8_t   EvtData2;
+    uint8_t   EvtData3;
+
+
+    uint8_t		  ComparisonStatus;
+    uint8_t       SensorCaps;              // JM 062306 - Added to support manual re-arm sensors
+    uint8_t       AssertionHistoryByte1;   // JM 062306 - Added to support manual re-arm sensors
+    uint8_t       AssertionHistoryByte2;   // JM 062306 - Added to support manual re-arm sensors
+    uint8_t       DeassertionHistoryByte1; // JM 062306 - Added to support manual re-arm sensors
+    uint8_t       DeassertionHistoryByte2; // JM 062306 - Added to support manual re-arm sensors
+
+    /* Sensor Monitor Internal Flags 
+     * This flags overrides any IPMI SDR settings.
+     * 
+     * 
+     * */  	
+//    uint8_t   		InternalFlags;   
+                            /* Bit 0 -  Enable/Disable scanning - overrides SDR scanning bit      */
+                            /* Bit 1 -  reserved                 */
+                            /* Bit 2 -  reserved                 */
+                            /* Bit 3 -  reserved                 */
+                            /* Bit 4 -  reserved                 */
+                            /* Bit 5 -  reserved                 */
+                            /* Bit 6 -  reserved                 */
+                            /* Bit 7 -  reserved                 */
+    uint8_t 	      OEMField;	
+
+//	pPDK_MonitorHook_T pPreMonitor;
+//	pPDK_MonitorHook_T pPostMonitor;
+//    pPDK_SensorInitHook_T pInitSensor [MAX_INIT_SENSOR_HOOKS];
+//    uint8_t				InitSensorHookCnt;
+//    pPDK_MonitorExtHook_T  	pPostMontiorExt [MAX_POST_MONITOR_EXT_HOOKS];
+//    uint8_t					PostMonitorExtHookCnt;
+//    pPDK_PreEventLogHook_T 	pPreEventLog [MAX_PRE_EVENT_LOG_HOOKS];
+//    uint8_t					PreEventLogHookCnt;
+
+   /* The offset for the sensor is added for OPMA Support */
+   uint8_t SenReadingOffset;
+   uint8_t SensorOwnerLun;
+
+   uint8_t	IsDCMITempsensor;
+   uint8_t	EntityID;
+   uint8_t	EntiryInstance;
+
+   SDRRecHdr_T* SDRRec;
+
+} SensorInfo_T;
+
+
+/**
+ * @struct SensorSharedMem_T
+ * @brief Shared memory for Sensor Information.
+**/
+
+typedef struct
+{
+    SensorInfo_T        SensorInfo [MAX_SENSOR_NUMBERS + 1]; /* Holds all sensor informations */
+	uint32_t			SensorTick;
+    uint8_t       		GlobalSensorScanningEnable;
+
+} SensorSharedMem_T;
+
+
+
+
+#pragma pack ()
+
+///*---------------------------------------
+// * InitInternalSensors
+// *---------------------------------------*/
+//extern int InitInternalSensors (SensorInfo_T *pSensorInfo);
+
+
+///**
+// * @var g_SensorValues 
+// * @brief Global array that holds current sensor values.
+//**/
+//extern uint8_t  g_SensorValues [];
+
+
+///*
+// * @fn InitPowerOnTick
+// * @brief Initialize the power on tick counter, 
+// *        should be invoked when ever power on occurs.
+// */
+//extern void InitPowerOnTick ();
+
+///*
+// * @fn InitSysResetTick
+// * @brief Initialize the System Reset tick counter, 
+// *        should be invoked when ever power reset occurs.
+// */
+//extern void InitSysResetTick ();
+///**
+// * @brief Initialize Sensor monitoring.
+// * @return 0 if success, -1 if error.
+//**/
+//extern int InitSensorMonitor (void);
+
+/**
+ * @brief Sensor monitoring task.
+**/
+extern void *SensorMonitorTask (void*);
+
+///**
+// * @brief Returns the current sensor reading
+//**/
+//extern uint16_t SM_GetSensorReading (uint8_t SenNum, uint16_t *pSensorReading);
+
+
+SensorInfo_T* getSensorInfo(uint8_t sensorNum);
+int SensorAverage(uint8_t SensorNum, uint8_t* pSensorReading);
+int get_sensor_reading (uint8_t sensor_num, uint8_t *preading);
+#endif /* SENSOR_MONITOR_H */

+ 201 - 0
app/bmc/msghndlr/Storage/FRUDevice/FRU.c

@@ -0,0 +1,201 @@
+/*****************************************************************
+ *****************************************************************
+ ***                                                            **
+ ***    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ ***                                                            **
+ ***            All Rights Reserved.                            **
+ ***                                                            **
+ ***        6145-F, Northbelt Parkway, Norcross,                **
+ ***                                                            **
+ ***        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ ***                                                            **
+ *****************************************************************
+ *****************************************************************
+ ******************************************************************
+ *
+ * fru.c
+ * fru functions.
+ *
+ *  Author: Rama Bisa <ramab@ami.com>
+ *
+ ******************************************************************/
+
+#include "com_BmcType.h"
+#include "com_IPMI_FRU.h"
+#include <string.h>
+#include "Support.h"
+#include "main.h"
+#include <stdio.h>
+
+#if FRU_DEVICE == 1
+#define     IPMI_FRU_FORMAT_VERSION     0x01
+#define     CC_FRU_DATA_UNAVAILABLE     0x81
+
+#define DEV_ACCESS_MODE_IN_BYTES 		0
+#define FRU_TYPE_OWNER_FLASH            1	//GD32 internal flash
+#define FRU_TYPE_EEPROM                 2
+
+FRUInfo_T	FRUInfo = {
+	FRU_TYPE_OWNER_FLASH,		/* FRU type NVR/EEPROM/....                     */
+	FRU_TOTAL_SIZE,				/* FRU Device size                              */
+	DEV_ACCESS_MODE_IN_BYTES,	/* FRU device access type BYTE/WORD             */
+	0,							/* Bus number if FRU is EEPROM                  */
+	0,							/* FRU device slave address if FRU is EEPROM    */
+	0							/* FRU device type if FRU is EEPROM             */
+};
+
+static int ReadFRUDevice (FRUInfo_T* pFRUInfo, uint16_t Offset, uint8_t Len, uint8_t* pData)
+{
+	switch (pFRUInfo->Type)
+	{
+		case FRU_TYPE_OWNER_FLASH:
+			memcpy(pData, (((uint8_t*)&g_BMCInfo.FRU) + Offset), Len);
+			return Len;
+
+		case FRU_TYPE_EEPROM:
+			//return  READ_EEPROM (pFRUInfo->DeviceType, pFRUInfo->BusNumber, pFRUInfo->SlaveAddr, pData,
+			//									 pFRUInfo->Offset + Offset, Len); 
+			printf("Read FRU from EEPROM not implement\r\n");
+			return 0;
+
+		default:
+			printf ("PDKFRU.c : FRU Type not supported\n");
+			return 0;
+	}
+}
+
+static int WriteFRUDevice (FRUInfo_T* pFRUInfo, uint16_t Offset, uint8_t Len, uint8_t* pData)
+{
+    switch (pFRUInfo->Type)
+    {
+        case FRU_TYPE_OWNER_FLASH:
+            //return  API_WriteNVR (pFRUInfo->NVRFile, Offset, Len, pData);
+			memcpy((((uint8_t*)&g_BMCInfo.FRU) + Offset), pData, Len);
+			UpdateFlash();
+            return Len;
+
+        case FRU_TYPE_EEPROM:
+            //return  WRITE_EEPROM (pFRUInfo->DeviceType, pFRUInfo->BusNumber, pFRUInfo->SlaveAddr, pData,
+            //                                        pFRUInfo->Offset + Offset, Len);
+            printf("Write FRU to EEPROM not implement\r\n");
+			return 0;
+
+        default:
+            printf ("PDKFRU.c : FRU Type not supported\n");
+            return 0;
+    }
+}
+
+/*-----------------------------------------------------
+ * GetFRUAreaInfo
+ *----------------------------------------------------*/
+int
+GetFRUAreaInfo ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    FRUInventoryAreaInfoRes_T*  pFRUAreaInfoRes = (FRUInventoryAreaInfoRes_T*) pRes;
+
+    pFRUAreaInfoRes->CompletionCode     = 	CC_NORMAL;
+    pFRUAreaInfoRes->Size               = 	FRUInfo.Size;
+    pFRUAreaInfoRes->DeviceAccessMode   = 	FRUInfo.AccessType;
+
+    return sizeof(FRUInventoryAreaInfoRes_T);
+}
+
+
+/*-----------------------------------------------------
+ * Read FRU Data
+ *----------------------------------------------------*/
+int
+ReadFRUData ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    uint16_t          Offset;
+    FRUReadReq_T*   pFRUReadReq = (FRUReadReq_T*) pReq;
+    FRUReadRes_T*   pFRUReadRes = (FRUReadRes_T*) pRes;
+    int retval = 0;
+
+	Offset = pFRUReadReq->Offset;
+    /* check if the offset is valid offset */
+    if (Offset >= FRUInfo.Size)
+    {
+        pFRUReadRes->CompletionCode = CC_INV_DATA_FIELD;
+        return sizeof(uint8_t);
+    }
+
+    /* Is CountToRead too big? */
+    if (pFRUReadReq->CountToRead > (FRUInfo.Size - Offset))
+    {
+		pFRUReadRes->CompletionCode = CC_PARAM_OUT_OF_RANGE;
+		return sizeof(uint8_t);
+    }
+
+    pFRUReadRes->CompletionCode  =  CC_NORMAL;
+
+    /* Read the FRU date from the FRU device */
+    retval = ReadFRUDevice (&FRUInfo, Offset,
+                                    pFRUReadReq->CountToRead,
+                                    (uint8_t*)(pFRUReadRes + 1));
+
+    if (retval != -1)
+    {
+        pFRUReadRes->CountReturned = (uint8_t) retval;
+    }
+    else
+    {
+        pFRUReadRes->CompletionCode = CC_FRU_DATA_UNAVAILABLE;
+        return sizeof(uint8_t);
+    }
+
+//    printf ("FRU Count returned  %x\r\n", pFRUReadRes->CountReturned);
+    
+    /*Updating Response Length.*/
+    return (pFRUReadRes->CountReturned + sizeof(FRUReadRes_T));
+}
+
+
+/*-----------------------------------------------------
+ * Write FRU Data
+ *----------------------------------------------------*/
+int
+WriteFRUData ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    uint16_t        Offset,Length;
+    FRUWriteReq_T   *pFRUWriteReq = (FRUWriteReq_T*) pReq;
+    FRUWriteRes_T   *pFRUWriteRes = (FRUWriteRes_T*) pRes;
+    int 			retval = 0;
+	
+    /* Get the offset to write & number of bytes to write */
+    Offset  =  (pFRUWriteReq->Offset);
+    Length  = ReqLen - sizeof (FRUWriteReq_T);
+
+    /* check if the offset is valid offset */
+    if (Offset >= FRUInfo.Size)
+    {
+        pFRUWriteRes->CompletionCode = CC_INV_DATA_FIELD;
+        return sizeof(uint8_t);
+    }
+
+    /* Is Length too big? */
+    if (Length > (FRUInfo.Size - Offset))
+    {
+		pFRUWriteRes->CompletionCode = CC_PARAM_OUT_OF_RANGE;
+		return sizeof(uint8_t);
+    }
+
+    pFRUWriteRes->CompletionCode = CC_NORMAL;
+
+    /* Wrtie the date to FRU device */
+    retval = WriteFRUDevice (&FRUInfo, Offset, Length,
+                                                (uint8_t*)(pFRUWriteReq + 1));
+    if (retval != -1)
+    {
+    	pFRUWriteRes->CountWritten  = (uint8_t) retval;
+    }
+    else
+    {
+        pFRUWriteRes->CompletionCode = CC_FRU_DATA_UNAVAILABLE;
+        return sizeof(uint8_t);
+    }
+    return sizeof(FRUWriteRes_T);
+}
+
+#endif /* FRU_DEVICE */

+ 6 - 20
app/bmc_server/ipmi_dev/FRU.h → app/bmc/msghndlr/Storage/FRUDevice/FRU.h

@@ -22,7 +22,7 @@
 #ifndef FRU_H
 #define FRU_H
 
-#include "Types.h"
+#include <stdint.h>
 
 /**
  * @defgroup fdc FRU Device Command handlers
@@ -32,28 +32,14 @@
  * @{
 **/
 #define  FRU_DEVICE_NOT_FOUND  0xCB
-#define  FRU_NOT_ACCESSIBLE        0x81
-#define  FRU_ACCESSIBLE                  0x0
-#define MAX_PDK_FRU_SUPPORTED 10
+#define  FRU_NOT_ACCESSIBLE    0x81
+#define  FRU_ACCESSIBLE        0x0
 
 #define FRU_COMMON_HEADER_FORMAT_VERSION 0x01
 
-#define  FRU_IC_ONE  0x01
-#define  FRU_IC_TWO  0x02
 
-#define  FRU_DEVICE_TYPE  10
-
-extern int GetFRUAreaInfo (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int ReadFRUData (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int WriteFRUData (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-/** @} */
-
-/**
- * @brief Validates and Initializes FRU.
- * @return 0 if success, -1 if error.
-**/
-extern int InitFRU (int BMCInst);
-
-extern int ValidateFRUChecksum (INT8U FRUChksumType, INT8U *Ptr);
+extern int GetFRUAreaInfo ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int ReadFRUData ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int WriteFRUData ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
 
 #endif /* FRU_H */

+ 24 - 24
app/bmc_server/ipmi_dev/SDR.h → app/bmc/msghndlr/Storage/SDR.h

@@ -21,9 +21,9 @@
 #ifndef SDR_H
 #define SDR_H
 
-#include "Types.h"
-#include "IPMI_SDR.h"
+#include "com_IPMI_SDR.h"
 #include "SDRRecord.h"
+//#include "main.h"
 
 #pragma pack( 1 )
 
@@ -33,10 +33,10 @@
 **/
 typedef struct
 {
-    INT8U Valid;
-    INT8U Len;
+    uint8_t Valid;
+    uint8_t Len;
 
-} PACKED  E2ROMHdr_T;
+}   E2ROMHdr_T;
 
 #pragma pack( )
 
@@ -44,7 +44,7 @@ typedef struct
  * @var g_SDRRAM
  * @brief SDR Repository.
 **/
-extern _FAR_ SDRRepository_T*   _FAR_   g_SDRRAM;
+extern  SDRRepository_T*      g_SDRRAM;
 
 
 /**
@@ -54,19 +54,19 @@ extern _FAR_ SDRRepository_T*   _FAR_   g_SDRRAM;
  * These commands provide read/write access to BMC's SDR repository.
  * @{
 **/
-extern int GetSDRRepositoryInfo      (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetSDRRepositoryAllocInfo (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int ReserveSDRRepository      (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetSDR                    (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int AddSDR                    (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int PartialAddSDR             (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int DeleteSDR                 (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int ClearSDRRepository        (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetSDRRepositoryTime      (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int SetSDRRepositoryTime      (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int EnterSDRUpdateMode        (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int ExitSDRUpdateMode         (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int RunInitializationAgent    (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
+extern int GetSDRRepositoryInfo      ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetSDRRepositoryAllocInfo ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int ReserveSDRRepository      ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetSDR                    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int AddSDR                    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int PartialAddSDR             ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int DeleteSDR                 ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int ClearSDRRepository        ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetSDRRepositoryTime      ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SetSDRRepositoryTime      ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int EnterSDRUpdateMode        ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int ExitSDRUpdateMode         ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int RunInitializationAgent    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
 /** @} */
 
 /**
@@ -74,14 +74,14 @@ extern int RunInitializationAgent    (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ I
  * @param RecID - Current SDR record ID.
  * @return the next SDR record ID.
 **/
-extern INT16U   SDR_GetNextSDRId     (INT16U RecID,int BMCInst);
+extern uint16_t   SDR_GetNextSDRId     (uint16_t RecID);
 
 /**
  * @brief Reads SDR Repository contents.
  * @param pSDRRec - Current SDR Record header.
  * @return the next SDR Record header.
 **/
-extern _FAR_ SDRRecHdr_T*   ReadSDRRepository (_FAR_ SDRRecHdr_T* pSDRRec,int BMCInst);
+extern  SDRRecHdr_T*   ReadSDRRepository ( SDRRecHdr_T* pSDRRec);
 
 /**
  * @brief Write into SDR Repository.
@@ -90,20 +90,20 @@ extern _FAR_ SDRRecHdr_T*   ReadSDRRepository (_FAR_ SDRRecHdr_T* pSDRRec,int BM
  * @param Size    - Size of write.
  * @return the SDR Record header.
 **/
-extern void WriteSDRRepository (_FAR_ SDRRecHdr_T* pSDRRec, INT8U Offset, INT8U Size,INT8U SdrSize,int BMCInst);
+extern void WriteSDRRepository ( SDRRecHdr_T* pSDRRec, uint8_t Offset, uint8_t Size,uint8_t SdrSize);
 
 /**
  * @brief Get the SDR Record.
  * @param RecID - SDR Record ID.
  * @return the SDR Record.
 **/
-extern _FAR_ SDRRecHdr_T* GetSDRRec  (INT16U RecID,int BMCInst);
+extern  SDRRecHdr_T* GetSDRRec  (uint16_t RecID);
 
 /**
  * @brief Initialize SDR Repository.
  * @return 0 if success, -1 if error
 **/
-extern  int  InitSDR (int BMCInst);
+extern  int  InitSDR (void);
 
 
 #endif /* SDR_H */

+ 1811 - 0
app/bmc/msghndlr/Storage/SDRDevice/SDR.c

@@ -0,0 +1,1811 @@
+/*****************************************************************
+ *****************************************************************
+ ***                                                            **
+ ***    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ ***                                                            **
+ ***            All Rights Reserved.                            **
+ ***                                                            **
+ ***        6145-F, Northbelt Parkway, Norcross,                **
+ ***                                                            **
+ ***        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ ***                                                            **
+ *****************************************************************
+ ******************************************************************
+ *
+ * SDR.c
+ * SDR functions.
+ *
+ *  Author: Govind Kothandapani <govindk@ami.com>
+ *
+ ******************************************************************/
+//#include "main.h"
+#include "com_IPMI_SDRRecord.h"
+#include "SDR.h"
+#include "SDRRecord.h"
+#include <string.h>
+#include "Support.h"
+#include "SDRFunc.h"
+#include "main.h"
+
+
+/**
+ * NVRAM Handles
+**/
+#define NVRH_USERCONFIG 0
+#define NVRH_CHCONFIG     0
+#define NVRH_SDR		0
+
+/* Reserved bit macro definitions */
+#define RESERVED_BITS_PARTIALADDSDR                     0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+
+#if SDR_DEVICE == 1
+
+#define SUPPORT_MULTI_CONTROLLER 1
+/*** Local Definitions ***/
+
+#define SDR_FIRST_FREE_BYTE()   ((( uint8_t*)g_BMCInfo.SDRConfig.SDRRAM) + g_BMCInfo.SDRConfig.SDRRAM->Size)
+
+#define MAX_SDR_LEN             25
+
+#define MAX_RES_LEN             128
+#define SDR_VERSION             0x51
+#define CMD_RUN_INITIALIZATION_AGENT                0x2C
+#define MANAGEMENT_DEV_LOC_REC	0x12
+
+#define PARTIAL_ADD_SDR_SUPPORT             0x04
+#define RESERVE_SDR_SUPPORT                 0x02
+#define GET_SDR_REPOSITORY_ALLOC_SUPPORT    0x01
+#define NON_MODAL_SUPPORT                   0x20
+#define NO_SUPPORT                          0x00
+#define DELETE_SDR_SUPPORT                  0x08
+
+
+
+#define MAX_OEM_REC_LEN  64
+
+#define SDR_ALLOC_UNIT_SIZE                 0x10
+#define SDR_MAX_RECORD_SIZE                 0x80
+#define SDR_ERASE_COMPLETED                 0x01
+#define SDR_INIT_COMPLETED                  0x01
+
+#define ENABLE_SELECTED_EVENT_MSG   0x10
+#define DISABLE_SELECTED_EVENT_MSG  0x20
+
+#define OEM_SDR_NM_REC             0x0D
+
+/**
+ * @brief Size of SDR Record
+**/
+#define SDR_SIZE(SDRRecHdr)     (sizeof (SDRRecHdr_T) + (SDRRecHdr)->Len)
+
+/**
+ * @brief Size the SDR Record occupies in the memory
+**/
+#define SDR_SIZE_IN_MEM(SDRRecHdr)                                  \
+    (((SDR_SIZE(SDRRecHdr) & 0x0f) == 0) ? SDR_SIZE(SDRRecHdr) :    \
+                                    (SDR_SIZE(SDRRecHdr) & 0xf0) + 0x10)
+
+/*** Prototype Declarations ***/
+static          uint8_t            PreCheckSDRUpdateModeCmd ( uint8_t* pRes);
+static          uint16_t          SDR_ReserveSDRRepository (void);
+static     SDRRecHdr_T*    GetLastSDRRec (void);
+//static          void            UpdateRepositoryInfo (void);
+static     SDRRecHdr_T*    SDR_GetSDRRec (uint16_t RecID, uint16_t ReservationID);
+
+//static          void            SDRInitAgent (void);
+
+//static          uint8_t           ValidateSDRSize (uint8_t SDRType, uint8_t Size);  
+//const uint8_t SDRSize [][2] = {  
+////      { SDR Type,                 Maximum Length },  
+//        { FULL_SDR_REC,                         64 },  
+//        { COMPACT_SDR_REC,                      48 },  
+//        { EVENT_ONLY_SDR_REC,                   33 },  
+//        { ENTITY_ASSOCIATION_SDR_REC,           16 },  
+//        { DEV_REL_ENTITY_ASSOCIATION_SDR_REC,   32 },  
+//        { GENERIC_DEVICE_LOCATOR_SDR_REC,       32 },  
+//        { FRU_DEVICE_LOCATOR_SDR_REC,           32 },  
+//        { MGMT_CTRL_DEV_LOCATOR_SDR_REC,        32 },  
+//        { MGMT_CTRL_CONFIRMATION_SDR_REC,       32 },  
+//        { BMC_MSG_CHANNEL_INFO_REC,             16 },  
+//    };  
+
+
+static          uint16_t          SDR_AddSDRRec ( SDRRecHdr_T* pSDRRecHdr);
+
+static          uint16_t          SDR_PartialAddSDR ( uint8_t* SDRData, uint8_t Offset, uint8_t Size,uint8_t IsLast, uint16_t ReservationID);
+
+
+#define CLEAR_SDR_INITIATE_ERASE    0xAA
+#define CLEAR_SDR_GET_STATUS        0x00
+static          int             SDR_ClearSDRRepository (uint16_t ReservationID, uint8_t InitOrStatus);
+
+//static 		uint16_t		SDR_DeleteSDR (uint16_t ReservationID, uint16_t RecID);
+
+/*---------------------------------------
+ * GetSDRRepositoryInfo
+ *---------------------------------------*/
+int
+GetSDRRepositoryInfo ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+     SDRRepositoryInfo_T* pSDRRepInfoRes =
+                        ( SDRRepositoryInfo_T*) pRes;
+
+    memcpy (pSDRRepInfoRes, &g_BMCInfo.SDRConfig.RepositoryInfo, sizeof (SDRRepositoryInfo_T));
+    pSDRRepInfoRes->CompletionCode = CC_NORMAL;
+    
+    return sizeof (SDRRepositoryInfo_T);
+}
+
+
+/*---------------------------------------
+ * GetSDRRepositoryAllocInfo
+ *---------------------------------------*/
+int
+GetSDRRepositoryAllocInfo ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+     SDRRepositoryAllocInfo_T* pSDRRepAllocInfoRes =
+                        ( SDRRepositoryAllocInfo_T*) pRes;
+
+    memcpy (pSDRRepAllocInfoRes, &g_BMCInfo.SDRConfig.RepositoryAllocInfo,
+                        sizeof (SDRRepositoryAllocInfo_T));
+    pSDRRepAllocInfoRes->CompletionCode = CC_NORMAL;
+    
+    return sizeof (SDRRepositoryAllocInfo_T);
+}
+
+/*---------------------------------------
+ * ReserveSDRRepository
+ *---------------------------------------*/
+int
+ReserveSDRRepository ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    
+    ReserveSDRRepositoryRes_T*  pResSDRRepRes =
+                                    ( ReserveSDRRepositoryRes_T*) pRes;
+
+	/* Shouldnt allow to reserve when the SDR is in update mode */
+	if( TRUE == g_BMCInfo.SDRConfig.UpdatingSDR )
+	{
+		  pResSDRRepRes->CompletionCode = CC_SDR_REP_IN_UPDATE_MODE;
+		  return sizeof (pResSDRRepRes->CompletionCode);
+	}
+          
+    pResSDRRepRes->ReservationID  = SDR_ReserveSDRRepository ();
+    g_BMCInfo.SDRConfig.PartAddbytes = 0; 
+    pResSDRRepRes->CompletionCode = CC_NORMAL;
+
+    return sizeof (ReserveSDRRepositoryRes_T);
+}
+
+
+/*---------------------------------------
+ * GetSDR
+ *---------------------------------------*/
+int GetSDR ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	SDRRecHdr_T*     pSDRRec;
+	GetSDRReq_T*     pGetSDRReq = ( GetSDRReq_T*) pReq;
+	GetSDRRes_T*     pGetSDRRes = ( GetSDRRes_T*) pRes;
+	
+	uint8_t SDRLen = 0;
+
+    if (TRUE != PreCheckSDRUpdateModeCmd (pRes))
+    {
+        return sizeof (uint8_t);  /* error code set in func */
+    }
+
+    /* If the Offset is Not zero then its A partial get.. / if SDR is in update mode
+    	then check for the reservation id 		*/
+
+    if ((pGetSDRReq->Offset == 0) && (FALSE == g_BMCInfo.SDRConfig.UpdatingSDR ))
+    {
+        pSDRRec = GetSDRRec (pGetSDRReq->RecID);
+    }
+    else 
+    {
+        pSDRRec = SDR_GetSDRRec ( pGetSDRReq->RecID, pGetSDRReq->ReservationID );
+    }
+
+    if (0 == pSDRRec)
+    {
+        pGetSDRRes->CompletionCode = g_BMCInfo.SDRConfig.SDRError;
+        return sizeof (uint8_t);
+    }
+
+    SDRLen = pSDRRec->Len+sizeof(SDRRecHdr_T);
+
+    if((0xFF == pGetSDRReq->Size) && (SDRLen >= pGetSDRReq->Offset))
+    {
+        pGetSDRReq->Size =  SDRLen - pGetSDRReq->Offset;
+    }
+
+    /* Check for Max Request Bytes */
+    if ((pGetSDRReq->Size > MAX_SDR_LEN) || (pGetSDRReq->Size > SDRLen) || (pGetSDRReq->Offset > SDRLen) 
+        || (pGetSDRReq->Size > (SDRLen-pGetSDRReq->Offset)))
+    {
+        pGetSDRRes->CompletionCode = CC_CANNOT_RETURN_REQ_BYTES;
+        return sizeof (uint8_t);
+    }
+
+    /* Copy the response */
+    pGetSDRRes->CompletionCode = CC_NORMAL;
+    pGetSDRRes->NextRecID      = SDR_GetNextSDRId (pSDRRec->ID);
+    memcpy (pGetSDRRes + 1,
+              (( uint8_t*) pSDRRec) + pGetSDRReq->Offset,
+              pGetSDRReq->Size);
+
+    return sizeof (GetSDRRes_T) + pGetSDRReq->Size;
+}
+
+
+/*---------------------------------------
+ * AddSDR
+ *---------------------------------------*/
+int
+AddSDR ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    uint16_t       RecID;
+     SDRRecHdr_T* pSDRRec    = ( SDRRecHdr_T*) pReq;
+     AddSDRRes_T* pAddSDRRes = ( AddSDRRes_T*) pRes;
+     
+
+    /*Check the Minimum length of the SDR record*/
+    if(ReqLen < sizeof(SDRRecHdr_T))
+    {
+        *pRes = CC_REQ_INV_LEN;
+        return sizeof(uint8_t);
+    }
+
+    /*Check the SDR length*/
+    if((ReqLen - sizeof(SDRRecHdr_T)) != pSDRRec->Len)
+    {
+        *pRes = CC_REQ_INV_LEN;
+        return sizeof(uint8_t);
+    }
+
+    if (TRUE != PreCheckSDRUpdateModeCmd (pRes))
+    {
+        return sizeof (uint8_t);  /* error code set in func */
+    }
+    RecID = SDR_AddSDRRec (pSDRRec);
+    if (INVALID_RECORD_ID == RecID)
+    {
+        pAddSDRRes->CompletionCode = g_BMCInfo.SDRConfig.SDRError;
+        return sizeof (pAddSDRRes->CompletionCode);
+    }
+    pAddSDRRes->CompletionCode  = CC_NORMAL;
+    pAddSDRRes->RecID           = RecID;
+  
+    return sizeof (AddSDRRes_T);
+}
+
+
+/*---------------------------------------
+ * PartialAddSDR
+ *---------------------------------------*/
+int
+PartialAddSDR ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    uint8_t                Size;
+    uint16_t               RecID;
+     PartialAddSDRReq_T*  pPartialAddReq = ( PartialAddSDRReq_T*) pReq;
+     PartialAddSDRRes_T*  pPartialAddRes = ( PartialAddSDRRes_T*) pRes;
+     
+
+    if( ReqLen < sizeof(PartialAddSDRReq_T))
+    {
+        pPartialAddRes->CompletionCode = CC_REQ_INV_LEN;
+        return sizeof (pPartialAddRes->CompletionCode);
+    }	
+
+    /* Check for the reserved bytes should b zero */
+
+    if  ( 0 !=  (pPartialAddReq->Progress & RESERVED_BITS_PARTIALADDSDR ) )
+    {
+        pPartialAddRes->CompletionCode = CC_INV_DATA_FIELD;
+        return sizeof(uint8_t);	
+    }
+
+    if (TRUE != PreCheckSDRUpdateModeCmd (pRes))
+    {
+        return sizeof (uint8_t);  /* error code set in func */
+    }
+
+    Size  = ReqLen - sizeof (PartialAddSDRReq_T);
+    if(0 == pPartialAddReq->Offset )
+    {
+        g_BMCInfo.SDRConfig.TrackPOffset =0;
+        g_BMCInfo.SDRConfig.TrackRecID =pPartialAddReq->RecID;
+    }
+    else if((g_BMCInfo.SDRConfig.TrackPOffset) != pPartialAddReq->Offset || g_BMCInfo.SDRConfig.TrackRecID != pPartialAddReq->RecID)
+    {
+        pPartialAddRes->CompletionCode = CC_INV_DATA_FIELD;
+        return sizeof (pPartialAddRes->CompletionCode);
+    }
+
+    RecID = SDR_PartialAddSDR (( uint8_t*)(pPartialAddReq + 1),
+                           pPartialAddReq->Offset,
+                           Size,
+                           pPartialAddReq->Progress & 0xf,
+                           pPartialAddReq->ReservationID);
+
+    if (RecID == INVALID_RECORD_ID)
+    {
+        pPartialAddRes->CompletionCode = g_BMCInfo.SDRConfig.SDRError;
+        return sizeof (pPartialAddRes->CompletionCode);
+    }
+
+    pPartialAddRes->CompletionCode  = CC_NORMAL;
+    pPartialAddRes->RecID           = RecID;
+
+     g_BMCInfo.SDRConfig.TrackPOffset +=Size;
+     g_BMCInfo.SDRConfig.TrackRecID =RecID;   //We are updating the available or alloted   Record ID 
+   
+    return sizeof (PartialAddSDRRes_T);
+}
+
+
+/*---------------------------------------
+ * DeleteSDR
+ *---------------------------------------*/
+int
+DeleteSDR ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	printf("DeleteSDR not implement\r\n");
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//    DeleteSDRReq_T* pDeleteSDRReq = ( DeleteSDRReq_T*)pReq;
+//    DeleteSDRRes_T* pDeleteSDRRes  = ( DeleteSDRRes_T*)pRes;
+//    uint16_t RecID;
+
+//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SDRConfig.SDRMutex, WAIT_INFINITE);
+//    if (TRUE != PreCheckSDRUpdateModeCmd (pRes,BMCInst))
+//    {
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SDRConfig.SDRMutex);
+//        return sizeof (uint8_t);  /* error code set in func */
+//    }
+//    RecID=SDR_DeleteSDR ( pDeleteSDRReq->ReservationID, pDeleteSDRReq->RecID,BMCInst);
+//    if(RecID == INVALID_RECORD_ID )
+//    {
+//        OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SDRConfig.SDRMutex);
+//        pDeleteSDRRes->CompletionCode = g_BMCInfo[BMCInst].SDRConfig.SDRError;
+//        return sizeof (pDeleteSDRRes->CompletionCode);
+//    }
+//    pDeleteSDRRes->CompletionCode = CC_NORMAL;
+//    pDeleteSDRRes->RecID = RecID;
+
+//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SDRConfig.SDRMutex);
+//	// To send notification to CIM
+//    if(g_PDKCIMEventHandle[PDKCIMEVENT_NOTIFYSERVERUPDATETOCIM] != NULL)
+//    {       
+//	uint8 CMD;
+//	// Set bits for SDR Event & Delete operation
+//	CMD = 0x13;
+//	((int(*)(uint8, uint16))g_PDKCIMEventHandle[PDKCIMEVENT_NOTIFYSERVERUPDATETOCIM])(CMD, RecID);
+//	
+//    }
+
+    return sizeof (DeleteSDRRes_T);
+}
+
+
+/*---------------------------------------
+ * ClearSDRRepository
+ *---------------------------------------*/
+int
+ClearSDRRepository ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    int            status;
+     ClearSDRReq_T* pClrSDRReq = ( ClearSDRReq_T*) pReq;
+     ClearSDRRes_T* pClrSDRRes = ( ClearSDRRes_T*) pRes;
+     
+
+    if (TRUE != PreCheckSDRUpdateModeCmd (pRes))
+    {
+        return sizeof (uint8_t);  /* error code set in func */
+    }
+
+    if(pClrSDRReq->CLR[0] != 'C'  || pClrSDRReq->CLR[1] != 'L'  || pClrSDRReq->CLR[2] != 'R' )
+    {
+        pClrSDRRes->CompletionCode= CC_PASSWORD_TEST_FAILED;
+        return sizeof(uint8_t);
+    }
+
+    status = SDR_ClearSDRRepository (pClrSDRReq->ReservationID,pClrSDRReq->InitOrStatus);
+    if (0 != status)
+    {
+        pClrSDRRes->CompletionCode = g_BMCInfo.SDRConfig.SDRError;
+        return sizeof (pClrSDRRes->CompletionCode);
+    }
+
+    pClrSDRRes->CompletionCode = CC_NORMAL;
+    pClrSDRRes->EraseProgress  = SDR_ERASE_COMPLETED;
+ 
+    return sizeof (ClearSDRRes_T);
+}
+
+
+/*---------------------------------------
+ * GetSDRRepositoryTime
+ *---------------------------------------*/
+int
+GetSDRRepositoryTime ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	//TODO
+    uint32_t                      SDRTime = 0;
+    GetSDRRepositoryTimeRes_T*  pGetSDRTimeRes =
+                                ( GetSDRRepositoryTimeRes_T*) pRes;
+    
+
+     /* Get the time */
+//    SDRTime = GetSelTimeStamp ();
+    pGetSDRTimeRes->CompletionCode  = CC_NORMAL;
+    pGetSDRTimeRes->Time            = SDRTime;
+
+    return sizeof (GetSDRRepositoryTimeRes_T);
+}
+
+
+/*--------------------------------------
+ *  * SetSDRRepositoryTime
+ *   * -------------------------------------*/
+int
+SetSDRRepositoryTime ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	//TODO
+    SetSDRRepositoryTimeReq_T* pSetSDRTimeReq = ( SetSDRRepositoryTimeReq_T*) pReq;
+    
+
+    pSetSDRTimeReq->Time = (pSetSDRTimeReq->Time);
+
+    //SET_SYSTEM_TIME_STAMP (&pSetSDRTimeReq->Time);
+
+    /* Resetting the SELTimeUTCOffset to default value */
+//    pBMCInfo->GenConfig.SELTimeUTCOffset = UNSPECIFIED_UTC_OFFSET;
+
+    /*Write to NVRAM*/
+//    FlushIPMI((uint8_t*)&pBMCInfo->GenConfig,(uint8_t*)&pBMCInfo->GenConfig,pBMCInfo->IPMIConfLoc.GenConfigAddr,
+//                      sizeof(GENConfig_T));
+
+    pRes [0] = CC_NORMAL;
+    return sizeof (*pRes);
+}
+
+
+/*---------------------------------------
+ * EnterSDRUpdateMode
+ *---------------------------------------*/
+int
+EnterSDRUpdateMode ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+     EnterSDRUpdateModeRes_T* pEnterSDRUpdateModeRes =
+                                ( EnterSDRUpdateModeRes_T*) pRes;
+    
+  
+
+    g_BMCInfo.SDRConfig.UpdatingSDR       = TRUE;
+    g_BMCInfo.SDRConfig.UpdatingChannel   = 0;//*curchannel  & 0xF;
+    pEnterSDRUpdateModeRes->CompletionCode = CC_NORMAL;
+
+    return sizeof (EnterSDRUpdateModeRes_T);
+}
+
+
+/*------------------------------------------
+ * ExitSDRUpdateMode
+ *------------------------------------------*/
+int
+ExitSDRUpdateMode ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+     ExitSDRUpdateModeRes_T*  pExitSDRUpdateModeRes =
+                            ( ExitSDRUpdateModeRes_T*) pRes;
+     
+
+    if (TRUE != PreCheckSDRUpdateModeCmd (pRes))
+    {
+        return sizeof (uint8_t);  /* error code set in func */
+    }
+
+    g_BMCInfo.SDRConfig.UpdatingSDR = FALSE;
+
+    pExitSDRUpdateModeRes->CompletionCode = CC_NORMAL;
+   
+    return sizeof (ExitSDRUpdateModeRes_T);
+}
+
+
+/*-------------------------------------------------
+ * RunInitializationAgent
+ *--------------------------------------------------*/
+int
+RunInitializationAgent ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	printf("RunInitializationAgent not implement\r\n");
+//     RunInitAgentRes_T*   pRunInitAgentRes =
+//                        ( RunInitAgentRes_T*) pRes;
+//     BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    /* Reserved bit Checking */
+//    if((pReq[0] & 0xFE)  != 0x00)
+//    {
+//        pRes [0] = CC_INV_DATA_FIELD;
+//        return sizeof (*pRes);
+//    }
+
+//    OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SDRConfig.SDRMutex, WAIT_INFINITE);
+//    if (0 != pReq[0])
+//    {
+//        InitSDR (BMCInst);
+//        SDRInitAgent (BMCInst);
+//        // The sensor monitor loop has been made 0 for
+//        // initializing the sensor scanning bit.
+//        pBMCInfo->SenConfig.SensorMonitorLoopCount = 0;
+//    }
+//    pRunInitAgentRes->CompletionCode = CC_NORMAL;
+//    pRunInitAgentRes->Status         = SDR_INIT_COMPLETED;
+//    OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SDRConfig.SDRMutex);
+
+    return sizeof (RunInitAgentRes_T);
+}
+
+/*-----------------------------------------
+ * GetSDRRec
+ *-----------------------------------------*/
+ SDRRecHdr_T*
+GetSDRRec (uint16_t RecID)
+{
+     SDRRecHdr_T*  pSDRRec;
+
+    /* If ID == 0x0000  return first record */
+    if (0 == RecID)
+    {
+        pSDRRec = SDR_GetFirstSDRRec ();
+        if (0== pSDRRec)	/* is SDR empty? */
+        {
+            g_BMCInfo.SDRConfig.SDRError = CC_SDR_REC_NOT_PRESENT;
+            return 0;
+        }
+        return pSDRRec;
+    }
+
+    /* If ID == 0xFFFF return the last record */
+    if (0xFFFF == RecID)
+    {
+        return GetLastSDRRec ();
+    }
+
+    pSDRRec = SDR_GetFirstSDRRec ();
+    while (TRUE)
+    {
+        if (0== pSDRRec)
+        {
+            g_BMCInfo.SDRConfig.SDRError = CC_SDR_REC_NOT_PRESENT;
+            return 0;
+        }
+        if (pSDRRec->ID == RecID)
+        {
+            return pSDRRec;
+        }
+        pSDRRec = SDR_GetNextSDRRec (pSDRRec);
+    }
+}
+
+
+/*-----------------------------------------------------
+ * InitSDR
+ *-----------------------------------------------------*/
+int InitSDR ()
+{
+//	uint8_t* 			pSDRRec;
+//	SDRRecHdr_T*      	pSDRRecord;
+//    int             	i;				/* Multi-LUN support index will have more than 256 sensors*/
+
+//    uint8_t     OEM_Recdata[MAX_OEM_REC_LEN];
+//    BMCInfo_t* 	pBMCInfo = &g_BMCInfo;
+
+//    pBMCInfo->SDRConfig.SDRRAM = ( SDRRepository_T*) GetSDRSELNVRAddr(NVRH_SDR, BMCInst);
+//    pSDRRec    = GetSDRSELNVRAddr (NVRH_SDR + sizeof(SDRRepository_T), BMCInst);
+//    pBMCInfo->SDRConfig.SDRRAM->NumRecords    = 0;
+//    pBMCInfo->SDRConfig.LatestRecordID     =0;
+//    pBMCInfo->SDRConfig.SDRRAM->Size          = 16;          /* SDR Repository Header */
+//#if (0x01 == MARK_FOR_DELETION_SUPPORT)
+//    pBMCInfo->SDRConfig.NumMarkedRecords= 0;
+//#endif
+//    if (pBMCInfo->SDRConfig.RepositoryInfo.OpSupport & OVERFLOW_FLAG)
+//    {
+//        pBMCInfo->SDRConfig.RepositoryInfo.OpSupport &= ~OVERFLOW_FLAG;
+//    }
+
+//    printf ("Init SDR\n");
+
+//    while (TRUE)
+//    {
+//#if (0x01 == MARK_FOR_DELETION_SUPPORT)
+//        if ((0x5A == (( E2ROMHdr_T*)pSDRRec)->Valid)
+//        || (0x01 == (( E2ROMHdr_T*)pSDRRec)->Valid) )
+//        {
+//            //count the records marked for deletion.
+//            if (0x01 == (( E2ROMHdr_T*)pSDRRec)->Valid)
+//            {
+//                pBMCInfo->SDRConfig.NumMarkedRecords++;
+//            }
+//            else
+//            {
+//                pBMCInfo->SDRConfig.SDRRAM->NumRecords ++;
+//            }
+//#else
+//        if (0x5A == (( E2ROMHdr_T*)pSDRRec)->Valid)
+//        {
+//            pBMCInfo->SDRConfig.SDRRAM->NumRecords ++;
+//#endif
+
+//            pBMCInfo->SDRConfig.LatestRecordID = ((SDRRecHdr_T *)((( E2ROMHdr_T*)pSDRRec)+1))->ID;
+//            pBMCInfo->SDRConfig.SDRRAM->Size +=  (( E2ROMHdr_T*)pSDRRec)->Len;
+//            pSDRRec += (( E2ROMHdr_T*)pSDRRec)->Len;
+//        }
+//        /* if No more Records */
+//        else
+//        {
+//            break;
+//        }
+//    }
+
+//   /* Check if SDR (valid record count) Empty */
+//    if (0 == pBMCInfo->SDRConfig.SDRRAM->NumRecords)
+//    {
+//#if IPM_DEVICE == 1
+//        pBMCInfo->Msghndlr.SelfTestByte |= GST_SDR_EMPTY;
+//#endif
+
+//        printf ("SDR EMPTY \n");
+
+//    }
+
+//    /* Update the SDR Erase Time Stamp */
+//   pBMCInfo->SDRConfig.RepositoryInfo.EraseTimeStamp = pBMCInfo->GenConfig.SDREraseTime ;
+
+
+//    /* Update the repository information */
+//    UpdateRepositoryInfo (BMCInst);
+
+//    pSDRRecord = SDR_GetFirstSDRRec (BMCInst);
+//    for (i=0; i < pBMCInfo->SDRConfig.SDRRAM->NumRecords && pSDRRecord != NULL; i++)
+//    {
+//      if ((OEM_SDRFRU_REC == pSDRRecord->Type)||(OEM_SDRNM_REC == pSDRRecord->Type))
+//     {
+//         uint8_t Rec_len;
+//         Rec_len=pSDRRecord->Len ;
+//         memcpy(OEM_Recdata , pSDRRecord ,sizeof(SDRRecHdr_T)+Rec_len);
+//         if(g_PDKHandle[PDK_PROCESSOEMRECORD] != NULL)
+//        {
+//            ((void(*)(uint8_t *,int))g_PDKHandle[PDK_PROCESSOEMRECORD]) ((uint8_t*)&OEM_Recdata,BMCInst);
+//        }
+//     }
+//      if(g_corefeatures.node_manager == ENABLED)
+//      {
+//        if(OEM_SDRNM_REC == pSDRRecord->Type)
+//        {
+//         OEM_NMRec_T* sonm;
+//         sonm =(OEM_NMRec_T*) ( (UINT8*)pSDRRecord );
+
+//         if(sonm->RecordSubType == OEM_SDR_NM_REC)
+//           pBMCInfo->NMConfig.NMDevSlaveAddress = sonm->NMDevSlaveAddress;
+//        }
+//      }
+//      if(g_PDKHandle[PDK_PROCESSSENSORDATARECORD] != NULL)
+//      {
+//          ((void(*)(uint8_t *,int))g_PDKHandle[PDK_PROCESSSENSORDATARECORD]) ((uint8_t*)pSDRRecord,BMCInst);
+//      }
+
+//     pSDRRecord = SDR_GetNextSDRRec (pSDRRecord,BMCInst);
+//   }
+//    
+//    if(g_PDKHandle[PDK_AFTERSDRINIT] != NULL)
+//    {
+//        ((void(*)(uint8_t))g_PDKHandle[PDK_AFTERSDRINIT]) (BMCInst);
+//    }
+    
+    return 0;
+}
+
+
+/*----------------------------------------------------------*
+ * SDR_GetNextSDRId
+ *----------------------------------------------------------*/
+uint16_t
+SDR_GetNextSDRId (uint16_t RecID)
+{
+     SDRRecHdr_T*  pSDRRec;
+
+    pSDRRec = GetSDRRec(RecID);
+    if (0 == pSDRRec)
+    {
+        return INVALID_RECORD_ID;
+    }
+
+    pSDRRec = SDR_GetNextSDRRec (pSDRRec);
+    if (0 == pSDRRec)
+    {
+        /* return last record ID (0xFFFF) */
+        return 0xFFFF;
+    }
+    else
+    {
+        return pSDRRec->ID;
+    }
+}
+
+
+/*--------------------------------------------------
+ * SDR_GetFirstSDRRec
+ *--------------------------------------------------*/
+ SDRRecHdr_T*
+SDR_GetFirstSDRRec ()
+{
+    return ReadSDRRepository (NULL);
+}
+
+
+/*--------------------------------------------------
+ * SDR_GetNextSDRRec
+ *-------------------------------------------------*/
+ SDRRecHdr_T*
+SDR_GetNextSDRRec ( SDRRecHdr_T* pSDRRec)
+{
+    return ReadSDRRepository (pSDRRec);
+}
+
+
+/*--------------------------------------------------
+ * ReadSDRRepository
+ *-------------------------------------------------*/
+ SDRRecHdr_T*
+ReadSDRRepository ( SDRRecHdr_T* pSDRRec)
+{
+    E2ROMHdr_T* InternalHdr;
+//    uint8_t SDRSize=0;
+
+    if (pSDRRec == 0)
+    {
+        InternalHdr = ( E2ROMHdr_T*)(g_BMCInfo.pSDR + sizeof(SDRRepository_T));
+    }
+    else
+    {
+        
+        InternalHdr = ( E2ROMHdr_T*)(( uint8_t*)pSDRRec + SDR_SIZE (pSDRRec));
+        
+        /* is address >= First free byte ? */
+        if (( uint8_t*) InternalHdr >= ( uint8_t*)SDR_FIRST_FREE_BYTE() )
+        {
+            /* No more records to read */
+            //log("No more records to read\r\n");
+            return 0;
+        }
+        //log("Reading the next record of %x \r\n", pSDRRec->ID);
+    }
+
+    /* is SDR Empty ?*/
+    if (g_BMCInfo.SDRConfig.SDRRAM->NumRecords == 0)
+    {
+        return 0;
+    }
+
+#if (0x01 == MARK_FOR_DELETION_SUPPORT)
+    /* Fetch a Valid SDR */
+    while (TRUE)
+    {
+        if( InternalHdr->Valid == 0x5a )
+        {
+            printf("Returning Valid record ID %x \n", (( SDRRecHdr_T*)(InternalHdr+1))->ID );
+            return (( SDRRecHdr_T*)(InternalHdr+1));
+        }
+
+        InternalHdr = ( E2ROMHdr_T*) (((uint8_t*)InternalHdr) + InternalHdr->Len);
+
+        /* is address >= First free byte ? */
+        if (( uint8_t*) InternalHdr >= ( uint8_t*)SDR_FIRST_FREE_BYTE(BMCInst) )
+        {
+            log("No more valid records found \n");
+            return 0;
+        }
+    }
+#else
+	return (( SDRRecHdr_T*)(InternalHdr+1));
+#endif
+}
+
+
+/*--------------------------------------------------
+ * WriteSDRRepository
+ *-------------------------------------------------*/
+void
+WriteSDRRepository ( SDRRecHdr_T* pSDRRec, uint8_t Offset, uint8_t Size,uint8_t SdrSize)
+{
+	//TODO:
+	printf("WriteSDRRepository not implement\r\n");
+//     E2ROMHdr_T* InternalHdr = ( E2ROMHdr_T *)SDR_FIRST_FREE_BYTE(BMCInst);
+//     uint8_t*      WriteAddr;
+
+//    /* Update Validity and Length */
+//    if ( Offset < sizeof(SDRRecHdr_T ) && ((Offset + Size) >= sizeof(SDRRecHdr_T)) )
+//    {
+//        InternalHdr->Valid  = 0x5A;
+//        InternalHdr->Len    = SdrSize;
+//    }
+
+//    WriteAddr = ( uint8_t*)(InternalHdr+1);
+//    memset((WriteAddr + Offset),0,SdrSize);
+//    _fmemcpy ((WriteAddr + Offset), pSDRRec, Size);
+
+    return ;
+}
+
+
+/**
+ * @brief Check the SDR update mode.
+ * @param pRes - Response.
+ * @return TRUE/FALSE
+**/
+static uint8_t
+PreCheckSDRUpdateModeCmd ( uint8_t* pRes)
+{
+	//TODO: when update SDR return FALSE.
+    return TRUE;
+}
+
+
+/**
+ * @brief Reserve the SDR Repository.
+ * @return Reservation ID.
+**/
+static uint16_t
+SDR_ReserveSDRRepository ()
+{
+    if (0xffff == g_BMCInfo.SDRConfig.ReservationID)
+    {
+        g_BMCInfo.SDRConfig.ReservationID = 1;
+    }else
+    {
+        g_BMCInfo.SDRConfig.ReservationID++;
+    }
+    g_BMCInfo.SDRConfig.TrackPOffset =0;	
+    return g_BMCInfo.SDRConfig.ReservationID;
+
+}
+
+
+/**
+ * @brief Get an SDR record.
+ * @param RecID         - SDR record ID.
+ * @param ReservationID - SDR Reservation ID.
+ * @return SDR record.
+**/
+static  SDRRecHdr_T*
+SDR_GetSDRRec (uint16_t RecID, uint16_t ReservationID)
+{
+
+    /* Bail out with error, if both the conditions are False (Reservation not valid)
+    1. Reservation ID matches, not equal to 0x00 & SDR is not in Update mode  /
+    2. SDR is in Update mode & Reservation ID equals to 0x00
+    */
+    if ( !(((g_BMCInfo.SDRConfig.ReservationID == ReservationID) && (0x00 != ReservationID) && 
+		(FALSE == g_BMCInfo.SDRConfig.UpdatingSDR)) || ((TRUE == g_BMCInfo.SDRConfig.UpdatingSDR) && 
+		(0x00 == ReservationID))))
+    {
+        if( TRUE == g_BMCInfo.SDRConfig.UpdatingSDR )
+        {
+            g_BMCInfo.SDRConfig.SDRError = CC_SDR_REP_IN_UPDATE_MODE;
+        }else /* Reservation ID doesn't match, return invalid reservation ID */
+        {
+            g_BMCInfo.SDRConfig.SDRError = CC_INV_RESERVATION_ID;
+        }
+        return 0;
+    }
+
+    return GetSDRRec (RecID);
+}
+
+//static uint8_t
+//ValidateSDRSize (uint8_t SDRType, uint8_t Size)
+//{
+//	//TODO:
+//	printf("ValidateSDRSize not implement\r\n");
+//    int i;
+
+//    IPMI_DBG_PRINT_2("ValidateSDR Type : 0x%X, Size : 0x%X\n", SDRType, Size);
+
+//    if ((SDRType == OEM_SDRFRU_REC)||(SDRType == OEM_SDRNM_REC))
+//        return TRUE;
+
+//    for (i = 0; i < sizeof (SDRSize)/ 2; i++)
+//    {
+//        if ((SDRSize[i][0] == SDRType) && (SDRSize[i][1] >= Size))
+//        {
+//            return TRUE;
+//        }
+//    }
+//    return FALSE;
+//	return TRUE;
+//}
+
+/**
+ * @brief Add an SDR record.
+ * @param pSDRRec - SDR record.
+ * @return Record ID.
+**/
+static uint16_t
+SDR_AddSDRRec ( SDRRecHdr_T* pSDRRec)
+{
+	//TODO
+	printf("SDR_AddSDRRec not implement\r\n");
+//    uint16_t SDRSize;
+//    uint8_t AllocSize;
+//    int nRet; 
+
+//    if (FALSE == ValidateSDRSize(pSDRRec->Type, pSDRRec->Len + sizeof (SDRRecHdr_T)))
+//    {
+//        g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_REQ_INV_LEN;
+//        return INVALID_RECORD_ID;
+//    }
+//    
+//    AllocSize =  SDR_SIZE (pSDRRec) + sizeof(E2ROMHdr_T);
+//    if(0 != (AllocSize % SDR_ALLOC_UNIT_SIZE))
+//    {
+//             SDRSize = AllocSize + (SDR_ALLOC_UNIT_SIZE -(AllocSize % SDR_ALLOC_UNIT_SIZE));
+//    }
+//    else
+//    {
+//        SDRSize = AllocSize;
+//    }
+
+//    if (SDRSize > htoipmi_u16 (g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.FreeSpace))
+//    {
+//        g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport |= OVERFLOW_FLAG;
+//        g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_OUT_OF_SPACE;
+//        return INVALID_RECORD_ID;
+//    }
+
+//    /* Update the record ID */
+//    pSDRRec->ID = g_BMCInfo[BMCInst].SDRConfig.LatestRecordID + 1;
+
+//    /* Add this record to the end of the repository */
+//    WriteSDRRepository (pSDRRec, 0, SDR_SIZE (pSDRRec),SDRSize,BMCInst);
+
+//    /* Flush the sdr */
+//    FlushSDR (SDR_FIRST_FREE_BYTE(BMCInst), SDRSize, nRet,BMCInst);
+//#if IPM_DEVICE == 1
+//    if (-1 == nRet)
+//    {
+//        g_BMCInfo[BMCInst].Msghndlr.SelfTestByte |= GST_CANNOT_ACCESS_SDR;
+//    }
+//    else
+//    {
+//        g_BMCInfo[BMCInst].Msghndlr.SelfTestByte &= ~GST_CANNOT_ACCESS_SDR;
+//    }
+//#endif
+
+//    /* Update the fields in SDR Repository */
+//    g_BMCInfo[BMCInst].SDRConfig.SDRRAM->NumRecords++;
+//    g_BMCInfo[BMCInst].SDRConfig.LatestRecordID++;
+
+//#if IPM_DEVICE == 1
+//    if (g_BMCInfo[BMCInst].Msghndlr.SelfTestByte & GST_SDR_EMPTY)
+//    {
+//        g_BMCInfo[BMCInst].Msghndlr.SelfTestByte &= ~GST_SDR_EMPTY;
+//    }
+//#endif
+
+//    
+//    g_BMCInfo[BMCInst].SDRConfig.SDRRAM->Size += SDRSize;
+//    g_BMCInfo[BMCInst].SDRConfig.SDRRAM->AddTimeStamp        = GetSelTimeStamp(BMCInst);
+//    g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.AddTimeStamp = GetSelTimeStamp(BMCInst);
+
+//    /* Update the repository info */
+//    UpdateRepositoryInfo (BMCInst);
+
+//    /* Invalidate Reservation ID if any */
+//    SDR_ReserveSDRRepository (BMCInst);
+
+//    return pSDRRec->ID;
+	return 0;
+}
+
+
+
+/**
+ * @brief Add partial SDR record.
+ * @param SDRData   - SDR Data.
+ * @param Offset    - SDR offset.
+ * @param Size      - Size of the data.
+ * @param IsLast    - Is this a last record?
+ * @param ReservationID - SDR reservation id.
+ * @return the record id.
+**/
+static uint16_t
+SDR_PartialAddSDR ( uint8_t* SDRData, uint8_t Offset, uint8_t Size,
+                                     uint8_t IsLast, uint16_t ReservationID)
+
+{
+	//TODO
+	printf("SDR_PartialAddSDR not implement\r\n");
+//    uint16_t          RecID;
+//       SDRRecHdr_T*    pSDRRecInNVR;
+//    uint8_t SdrSize=0;
+//    int nRet;
+//    
+//     /* Bail out with error, if both the conditions are False (Reservation not valid)
+//    1. Reservation ID matches, not equal to 0x00 & SDR is not in Update mode  /
+//    2. SDR is in Update mode & Reservation ID equals to 0x00
+//    */
+//    if ( !(((g_BMCInfo[BMCInst].SDRConfig.ReservationID == ReservationID) && (0x00 != ReservationID) && (FALSE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR)) ||
+//    ((TRUE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR) && (0x00 == ReservationID))))
+//    {
+//        if( TRUE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR )
+//        {
+//            g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_SDR_REP_IN_UPDATE_MODE;
+//        }else //Reservation ID doesn't match, return invalid reservation ID.
+//        {
+//            g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_INV_RESERVATION_ID;
+//        }
+//        g_BMCInfo[BMCInst].SDRConfig.PartAddbytes=0;
+//        return INVALID_RECORD_ID;
+//    }
+
+//    pSDRRecInNVR = ( SDRRecHdr_T*) (SDR_FIRST_FREE_BYTE(BMCInst) +
+//                    sizeof (E2ROMHdr_T));
+//    RecID = g_BMCInfo[BMCInst].SDRConfig.LatestRecordID + 1;
+
+//    /* If the header is received completely, validate the size */
+//    if ((Offset + Size) >= sizeof(SDRRecHdr_T))
+//    {    
+//        if ( Offset < sizeof(SDRRecHdr_T ))
+//        {
+//             SDRRecHdr_T SDRHdr;
+//			
+//            memcpy((uint8_t*)&SDRHdr, (uint8_t*)pSDRRecInNVR, Offset );
+//            memcpy(((uint8_t*)&SDRHdr) + Offset, SDRData, sizeof(SDRRecHdr_T) - Offset);
+//			
+//            (( SDRRecHdr_T*) pSDRRecInNVR)->ID = SDRHdr.ID = RecID;
+//            memcpy(  SDRData, ((uint8_t*)&SDRHdr) + Offset, sizeof(SDRRecHdr_T) - Offset );
+//			
+//            if (FALSE == ValidateSDRSize(SDRHdr.Type, SDRHdr.Len + sizeof (SDRRecHdr_T)))
+//            {
+//                g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_REQ_INV_LEN;
+//                return INVALID_RECORD_ID;
+//            }
+//            SdrSize = SDRHdr.Len + sizeof (SDRRecHdr_T) + sizeof (E2ROMHdr_T);
+//            if(0 != (SdrSize % SDR_ALLOC_UNIT_SIZE))
+//            {
+//                SdrSize += (SDR_ALLOC_UNIT_SIZE - (SdrSize % SDR_ALLOC_UNIT_SIZE)); 
+//            }
+//            if (SdrSize > ipmitoh_u16 (g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.FreeSpace))
+//            {
+//                g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport |= OVERFLOW_FLAG;
+//                g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_OUT_OF_SPACE;
+//                return INVALID_RECORD_ID;
+//            }
+//            g_BMCInfo[BMCInst].SDRConfig.PartAddbytes = SdrSize;
+
+//            if ((Offset + Size) > (SDRHdr.Len + sizeof (SDRRecHdr_T)))
+//            {
+//                g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_INV_DATA_FIELD;
+//                return INVALID_RECORD_ID;
+//            }
+//        }
+//        else if ((Offset + Size) > (pSDRRecInNVR->Len + sizeof (SDRRecHdr_T)))
+//        {
+//            g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_INV_DATA_FIELD;
+//            return INVALID_RECORD_ID;
+//        }
+//    }    
+
+//    if  ((IsLast == 1) && ((Offset + Size) != (pSDRRecInNVR->Len + sizeof (SDRRecHdr_T))))
+//    {
+//        g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_INCOMPLETE_WRITTEN_BYTES;
+//        return INVALID_RECORD_ID;
+//    }
+
+//    WriteSDRRepository (( SDRRecHdr_T*)SDRData, Offset, Size,SdrSize,BMCInst);
+//  
+//    /* If this is the last data update the data fields and flush. */
+//    if (IsLast == 1)
+//    {
+//        /* Flush the sdr */
+//        FlushSDR (SDR_FIRST_FREE_BYTE(BMCInst), g_BMCInfo[BMCInst].SDRConfig.PartAddbytes, nRet,BMCInst);
+//#if IPM_DEVICE == 1
+//        if (-1 == nRet)
+//        {
+//            g_BMCInfo[BMCInst].Msghndlr.SelfTestByte |= GST_CANNOT_ACCESS_SDR;
+//        }
+//        else
+//        {
+//            g_BMCInfo[BMCInst].Msghndlr.SelfTestByte &= ~GST_CANNOT_ACCESS_SDR;
+//        }
+//#endif
+
+//        /* Update the fields in SDR Repository */
+//        g_BMCInfo[BMCInst].SDRConfig.SDRRAM->NumRecords ++;
+//        g_BMCInfo[BMCInst].SDRConfig.LatestRecordID++;
+//        g_BMCInfo[BMCInst].SDRConfig.TrackPOffset=0;
+
+//#if IPM_DEVICE == 1
+//        if (g_BMCInfo[BMCInst].Msghndlr.SelfTestByte & GST_SDR_EMPTY)
+//        {
+//            g_BMCInfo[BMCInst].Msghndlr.SelfTestByte &= ~GST_SDR_EMPTY;
+//        }
+//#endif
+
+//        g_BMCInfo[BMCInst].SDRConfig.SDRRAM->Size += g_BMCInfo[BMCInst].SDRConfig.PartAddbytes;
+//        g_BMCInfo[BMCInst].SDRConfig.SDRRAM->AddTimeStamp        = GetSelTimeStamp(BMCInst);
+//        g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.AddTimeStamp = GetSelTimeStamp(BMCInst);
+//      
+//        /* Update the repository info */
+//        UpdateRepositoryInfo (BMCInst);
+//        g_BMCInfo[BMCInst].SDRConfig.PartAddbytes =0;
+
+//        /* Invalidate Reservation ID if any */
+//        SDR_ReserveSDRRepository (BMCInst);
+
+//	// To send notification to CIM
+//	if(g_PDKCIMEventHandle[PDKCIMEVENT_NOTIFYSERVERUPDATETOCIM] != NULL)
+//        {
+//                uint8 CMD;
+//		// Set bits for SDR Event & Add operation
+//             CMD = 0x11;
+//             ((int(*)(uint8, uint16))g_PDKCIMEventHandle[PDKCIMEVENT_NOTIFYSERVERUPDATETOCIM])(CMD, RecID);
+//        }
+
+//    }
+
+//    return RecID;
+	
+	return 0;
+}
+
+
+
+///**
+// * @brief Delete the SDR.
+// * @param ReservationID - SDR reservation id.
+// * @param RecordID        - SDR Record ID, which needs to be deleted
+// * @return 0 if success, -1 if error.
+//**/
+//static uint16_t
+//SDR_DeleteSDR (uint16_t ReservationID, uint16_t RecID)
+//{
+//	//TODO:
+//	printf("SDR_DeleteSDR not implement\r\n");
+//    //#define MARK_FOR_DELETION
+//     SDRRecHdr_T*  pSDRRec = NULL;
+//    int nRet;
+//    BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+//#if (0x01 == MARK_FOR_DELETION_SUPPORT)
+//     E2ROMHdr_T* pRec = NULL;
+//#else
+//     uint8_t* pDestLocation = NULL;
+//     uint8_t* pSrcData = NULL;
+//     uint8_t*	 pFreeBytes= NULL;
+//     uint8_t deleteSDR_Size;
+//     uint16_t  size;
+//#endif
+
+//    /* Bail out with error, if both the conditions are False (Reservation not valid)
+//    1. Reservation ID matches, not equal to 0x00 & SDR is not in Update mode  /
+//    2. SDR is in Update mode & Reservation ID equals to 0x00
+//    */
+//    if ( !(((g_BMCInfo[BMCInst].SDRConfig.ReservationID == ReservationID) && (0x00 != ReservationID) && (FALSE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR)) ||
+//        ((TRUE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR) && (0x00 == ReservationID))))
+//    {
+//        if( TRUE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR )
+//        {
+//            g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_SDR_REP_IN_UPDATE_MODE;
+//        }else /* Reservation ID doesn't match, return invalid reservation ID */
+//        {
+//            g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_INV_RESERVATION_ID;
+//        }
+//        return INVALID_RECORD_ID;
+//    }
+
+//    while(TRUE)
+//    {
+//        pSDRRec = ReadSDRRepository(pSDRRec,BMCInst);
+//        if (pSDRRec == 0)
+//            {
+//            g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_SDR_REC_NOT_PRESENT;
+//            return INVALID_RECORD_ID;
+//        }
+//        if (pSDRRec->ID == RecID)
+//        {
+//#if (0x01 == MARK_FOR_DELETION_SUPPORT)
+//            pRec = ((E2ROMHdr_T *) pSDRRec) -1;
+//            pRec->Valid = 0x01;   /* Mark this record for deletion */
+//            FlushSDR((uint8_t *)pRec, sizeof(pRec->Valid), nRet,BMCInst);
+//#if IPM_DEVICE == 1
+//            if (-1 == nRet)
+//            {
+//                g_BMCInfo[BMCInst].Msghndlr.SelfTestByte |= GST_CANNOT_ACCESS_SDR;
+//            }
+//            else
+//            {
+//                g_BMCInfo[BMCInst].Msghndlr.SelfTestByte &= ~GST_CANNOT_ACCESS_SDR;
+//            }
+//#endif
+//            g_BMCInfo[BMCInst].SDRConfig.SDRRAM->NumRecords--;
+//            g_BMCInfo[BMCInst].SDRConfig.NumMarkedRecords++;
+//#else
+//            /* Delete SDR - delete the current SDR, and rearrange the subsequent SDR's */
+//            pDestLocation = (uint8_t*)(((E2ROMHdr_T *) pSDRRec) -1);
+//            deleteSDR_Size = (((E2ROMHdr_T *) pSDRRec) -1)->Len;
+
+//            pSrcData = pDestLocation + deleteSDR_Size;
+
+//            pFreeBytes = (uint8_t*)SDR_FIRST_FREE_BYTE(BMCInst);
+//            size = ( uint8_t*) pFreeBytes - ( uint8_t*)pDestLocation;
+
+//            _fmemcpy (pDestLocation, pSrcData, size-deleteSDR_Size);
+//            _fmemset ((pFreeBytes - deleteSDR_Size), '\0', deleteSDR_Size );
+//            g_BMCInfo[BMCInst].SDRConfig.SDRRAM->Size -= deleteSDR_Size;
+//            FlushSDR(pDestLocation, size, nRet,BMCInst);
+//#if IPM_DEVICE == 1
+//            if (-1 == nRet)
+//            {
+//                g_BMCInfo[BMCInst].Msghndlr.SelfTestByte |= GST_CANNOT_ACCESS_SDR;
+//            }
+//            else
+//            {
+//                g_BMCInfo[BMCInst].Msghndlr.SelfTestByte &= ~GST_CANNOT_ACCESS_SDR;
+//            }
+//#endif
+//            g_BMCInfo[BMCInst].SDRConfig.SDRRAM->NumRecords--;
+//#endif
+//            /* Update the SDR Erase Timestamp */
+//            g_BMCInfo[BMCInst].SDRConfig.SDRRAM->EraseTimeStamp        = GetSelTimeStamp (BMCInst);
+//            g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.EraseTimeStamp = GetSelTimeStamp(BMCInst);
+
+//            /* Store the SDR Ease Time Stamp in NVR */
+//            pBMCInfo->GenConfig.SDREraseTime = g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.EraseTimeStamp;
+//            FlushIPMI((uint8_t*)&pBMCInfo->GenConfig,(uint8_t*)&pBMCInfo->GenConfig,pBMCInfo->IPMIConfLoc.GenConfigAddr,
+//                              sizeof(GENConfig_T),BMCInst);
+
+//            /* Update the repository info */
+//            UpdateRepositoryInfo (BMCInst);
+
+//            /* Invalidate Reservation ID if any */
+//            SDR_ReserveSDRRepository (BMCInst);
+
+//            return RecID;
+//        }
+//    }
+//return 0;
+
+//}
+
+/**
+ * @brief Clear the SDR repository.
+ * @param ReservationID - SDR reservation id.
+ * @param InitOrStatus - Initiate erase or get status flag
+ * @return 0 if success, -1 if error.
+**/
+static int
+SDR_ClearSDRRepository (uint16_t ReservationID, uint8_t InitOrStatus)
+{
+	//TODO:
+	printf("SDR_ClearSDRRepository not implement\r\n");
+//    int nRet;
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    /* Bail out with error, if both the conditions are False (Reservation not valid)
+//    1. Reservation ID matches, not equal to 0x00 & SDR is not in Update mode  /
+//    2. SDR is in Update mode & Reservation ID equals to 0x00
+//    */
+//    if ( !(((g_BMCInfo[BMCInst].SDRConfig.ReservationID == ReservationID) && (0x00 != ReservationID) && (FALSE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR)) ||
+//        ((TRUE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR) && (0x00 == ReservationID))))
+//    {
+//        if( TRUE == g_BMCInfo[BMCInst].SDRConfig.UpdatingSDR )
+//        {
+//            g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_SDR_REP_IN_UPDATE_MODE;
+//        }else //Reservation ID doesn't match, return invalid reservation ID.
+//        {
+//            g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_INV_RESERVATION_ID;
+//        }
+//        return -1;
+//    }
+
+//    // AAh = initiate erase, 00h = get erasure status.
+//    if (InitOrStatus != CLEAR_SDR_INITIATE_ERASE &&
+//            InitOrStatus != CLEAR_SDR_GET_STATUS)
+//    {
+//        g_BMCInfo[BMCInst].SDRConfig.SDRError = CC_INV_DATA_FIELD;
+//        return -1;
+//    }
+//    else if (InitOrStatus == CLEAR_SDR_GET_STATUS)
+//    {
+//        return 0;
+//    }
+//    _fmemset ((( uint8_t*)g_BMCInfo[BMCInst].SDRConfig.SDRRAM + 16), 0xFF,(pBMCInfo->IpmiConfig.SDRAllocationSize * 1024) - 16 );
+
+//    /* Flush the NVRAM */
+//    FlushSDR (g_BMCInfo[BMCInst].SDRConfig.SDRRAM, (pBMCInfo->IpmiConfig.SDRAllocationSize * 1024), nRet,BMCInst);
+//#if IPM_DEVICE == 1
+//    if (-1 == nRet)
+//    {
+//        g_BMCInfo[BMCInst].Msghndlr.SelfTestByte |= GST_CANNOT_ACCESS_SDR;
+//    }
+//    else
+//    {
+//        g_BMCInfo[BMCInst].Msghndlr.SelfTestByte &= ~GST_CANNOT_ACCESS_SDR;
+//    }
+//#endif
+
+//    /* Clear the fields of the SDR */
+//    g_BMCInfo[BMCInst].SDRConfig.SDRRAM->NumRecords = 0;
+//    g_BMCInfo[BMCInst].SDRConfig.LatestRecordID =0;
+//#if (0x01 == MARK_FOR_DELETION_SUPPORT)
+//    g_BMCInfo[BMCInst].SDRConfig.NumMarkedRecords=0;
+//#endif
+//    if (g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport & OVERFLOW_FLAG)
+//    {
+//        g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport &= ~OVERFLOW_FLAG;
+//    }
+
+//#if IPM_DEVICE == 1
+//    g_BMCInfo[BMCInst].Msghndlr.SelfTestByte |= GST_SDR_EMPTY;
+//#endif
+
+//    g_BMCInfo[BMCInst].SDRConfig.SDRRAM->Size                  = 16;
+//    g_BMCInfo[BMCInst].SDRConfig.SDRRAM->EraseTimeStamp        = GetSelTimeStamp (BMCInst);
+//    g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.EraseTimeStamp = GetSelTimeStamp(BMCInst);
+
+//    /* Store the SDR Ease Time Stamp in NVR */
+//    pBMCInfo->GenConfig.SDREraseTime = g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.EraseTimeStamp;
+//    FlushIPMI((uint8_t*)&pBMCInfo->GenConfig,(uint8_t*)&pBMCInfo->GenConfig,pBMCInfo->IPMIConfLoc.GenConfigAddr,
+//                      sizeof(GENConfig_T),BMCInst);
+
+//    /* Update the Repository Info */
+//    UpdateRepositoryInfo (BMCInst);
+
+//    /* Invalidate Reservation ID if any */
+//    SDR_ReserveSDRRepository (BMCInst);
+
+    return 0;
+}
+
+
+
+/**
+ * @brief Get the last SDR record.
+ * @return the last SDR record.
+**/
+static  SDRRecHdr_T*
+GetLastSDRRec ()
+{
+     SDRRecHdr_T*  pSDRRec;
+
+    pSDRRec = SDR_GetFirstSDRRec ();
+    while (TRUE)
+    {
+         SDRRecHdr_T*  pCurSDRRec;
+
+        /* Save this record and get the next record */
+        pCurSDRRec = pSDRRec;
+        pSDRRec    = SDR_GetNextSDRRec (pSDRRec);
+
+        /* If we have reached past the last return the last record */
+        if (0 == pSDRRec)
+        {
+            return pCurSDRRec;
+        }
+    }
+}
+
+
+///**
+// * @brief Update SDR repository information.
+//**/
+//static void
+//UpdateRepositoryInfo ()
+//{
+//	//TODO:
+//	printf("UpdateRepositoryInfo not implement\r\n");
+	// BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//    /* Update the version */
+//    g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.Version = SDR_VERSION;
+
+//    /* Update the record count */
+//    g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.RecCt = htoipmi_u16 (g_BMCInfo[BMCInst].SDRConfig.SDRRAM->NumRecords);
+
+//    /* Update the free space available */
+//    g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.FreeSpace = htoipmi_u16 (((pBMCInfo->IpmiConfig.SDRAllocationSize * 1024) - g_BMCInfo[BMCInst].SDRConfig.SDRRAM->Size));
+
+//    /* Update the the operation support */
+//    g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport=NO_SUPPORT;
+
+//     if(g_PDKCmdsHandle[PDKCMDS_PDKISCOMMANDENABLED]!= NULL)
+//     {
+//        if(((int(*)(uint8_t,uint8_t*,uint8_t,int))g_PDKCmdsHandle[PDKCMDS_PDKISCOMMANDENABLED])(NETFN_STORAGE,NULL,CMD_RESERVE_SDR_REPOSITORY,BMCInst) == 0)
+//        {
+//           g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport|=RESERVE_SDR_SUPPORT;
+//        }
+//        if(((int(*)(uint8_t,uint8_t*,uint8_t,int))g_PDKCmdsHandle[PDKCMDS_PDKISCOMMANDENABLED])(NETFN_STORAGE,NULL,CMD_GET_SDR_REPOSITORY_ALLOCATION_INFO,BMCInst) == 0)
+//        {
+//           g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport|=NON_MODAL_SUPPORT+GET_SDR_REPOSITORY_ALLOC_SUPPORT;
+//        }
+//        if(((int(*)(uint8_t,uint8_t*,uint8_t,int))g_PDKCmdsHandle[PDKCMDS_PDKISCOMMANDENABLED])(NETFN_STORAGE,NULL,CMD_PARTIAL_ADD_SDR,BMCInst) == 0)
+//        {      
+//           g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport|=PARTIAL_ADD_SDR_SUPPORT;
+//        }
+//        if(((int(*)(uint8_t,uint8_t*,uint8_t,int))g_PDKCmdsHandle[PDKCMDS_PDKISCOMMANDENABLED])(NETFN_STORAGE,NULL,CMD_DELETE_SDR,BMCInst) == 0)
+//        {
+//           g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.OpSupport|=DELETE_SDR_SUPPORT;
+//        }
+//     }
+
+//    /* Update the repository allocation information */
+//    g_BMCInfo[BMCInst].SDRConfig.RepositoryAllocInfo.NumAllocUnits     = htoipmi_u16 (((pBMCInfo->IpmiConfig.SDRAllocationSize * 1024) - 16) / SDR_ALLOC_UNIT_SIZE); /* Because 16 bytes are reserved for header info */
+//    g_BMCInfo[BMCInst].SDRConfig.RepositoryAllocInfo.AllocUnitSize     = htoipmi_u16 (SDR_ALLOC_UNIT_SIZE);
+//    g_BMCInfo[BMCInst].SDRConfig.RepositoryAllocInfo.NumFreeAllocUnits = htoipmi_u16 (ipmitoh_u16 (g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.FreeSpace) /
+//                                                SDR_ALLOC_UNIT_SIZE);
+//    g_BMCInfo[BMCInst].SDRConfig.RepositoryAllocInfo.LargestFreeBlock  = htoipmi_u16 (ipmitoh_u16 (g_BMCInfo[BMCInst].SDRConfig.RepositoryInfo.FreeSpace) /
+//                                                SDR_ALLOC_UNIT_SIZE);
+//    g_BMCInfo[BMCInst].SDRConfig.RepositoryAllocInfo.MaxRecSize        = SDR_MAX_RECORD_SIZE / SDR_ALLOC_UNIT_SIZE;
+//}
+
+
+///**
+// * @brief SDR initialization agent.
+//**/
+//static void
+//SDRInitAgent ()
+//{
+//	//TODO:
+//	printf("SDRInitAgent not implement\r\n");
+//    uint8_t             i,Count =0;
+//    uint8_t             CmdRes [MAX_RES_LEN];
+//     SDRRecHdr_T*      pSDRRec;
+//    HQueue_T IfcQ;
+//     BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+
+//    if(g_PDKHandle[PDK_BEFOREINITAGENT] != NULL)
+//    {
+//         if(-1 == ((int(*)(int))g_PDKHandle[PDK_BEFOREINITAGENT]) (BMCInst))
+//        {
+//            return;
+//        }
+//    }
+
+
+//#if SET_EVENT_RECEIVER == 1
+//    /* Turn off Event Generation */
+//    {
+//        SetEvtRcvReq_T SetEvtRcvReq = { 0xFF, 0 };
+//        SetEventReceiver (( uint8_t*)&SetEvtRcvReq,
+//                          sizeof (SetEvtRcvReq_T), CmdRes,BMCInst);
+//    }
+//#endif
+//    /* Get the MMC Controller addresses*/
+//    pSDRRec = SDR_GetFirstSDRRec (BMCInst);
+
+//        if(0 != GetQueueHandle(LAN_IFC_Q,&IfcQ,BMCInst))
+//        {
+//            IPMI_WARNING("Error in getting LanIfcQ Handle \n");
+//        }
+
+//        for (i=0; i < pBMCInfo->SDRConfig.SDRRAM->NumRecords && pSDRRec != NULL; i++)
+//        {
+//            if(MANAGEMENT_DEV_LOC_REC == pSDRRec->Type)
+//            {
+//                 MgmtCtrlrDevLocator_T* pMgmtDevLocRec = ( MgmtCtrlrDevLocator_T*)pSDRRec;
+//                if(pBMCInfo->IpmiConfig.BMCSlaveAddr !=  pMgmtDevLocRec->DevSlaveAddr )
+//                {
+//                    pBMCInfo->MgmtTbl[Count].OWNERID=pMgmtDevLocRec->DevSlaveAddr; 
+//                    pBMCInfo->MgmtTbl[Count++].PowerNotification=pMgmtDevLocRec->PowerStateNotification;
+//                }
+//            }
+//            pSDRRec = SDR_GetNextSDRRec (pSDRRec,BMCInst);
+//        }
+//        pBMCInfo->MgmtTbl[Count].OWNERID= 0xff;
+
+//#if SUPPORT_MULTI_CONTROLLER   == 1
+//        /* Sending the Set Event Reciver Disable Command to all MMC in IPMB BUS */
+//        if(pBMCInfo->IpmiConfig.PrimaryIPMBSupport == 0x01)
+//        {
+//            for(i=0; i<Count; i++)
+//            {
+//                MsgPkt_T		Req;
+//                memset(&Req,0,sizeof(MsgPkt_T));
+//                IPMIMsgHdr_T*	pIPMIMsgHdr = (IPMIMsgHdr_T*)Req.Data;
+//                  SetEvtRcvReq_T* SetEvtRcvReq = ( SetEvtRcvReq_T*) &Req.Data[sizeof(IPMIMsgHdr_T)];
+//                pIPMIMsgHdr->ResAddr	=pBMCInfo->MgmtTbl[i].OWNERID;
+//                pIPMIMsgHdr->NetFnLUN	 = (NETFN_SENSOR<< 2) | BMC_LUN_00;
+//                pIPMIMsgHdr->ChkSum 	= ~(pIPMIMsgHdr->ResAddr + pIPMIMsgHdr->NetFnLUN) + 1;
+//                pIPMIMsgHdr->ReqAddr	= pBMCInfo->IpmiConfig.BMCSlaveAddr;
+//                pBMCInfo->SDRConfig.IPMB_Seqnum++;
+//                if (pBMCInfo->SDRConfig.IPMB_Seqnum >= 0x3F) { pBMCInfo->SDRConfig.IPMB_Seqnum = 0xFF; }
+//                pIPMIMsgHdr->RqSeqLUN =   pBMCInfo->SDRConfig.IPMB_Seqnum<< 2;  /* Request Seq Num */
+//                pIPMIMsgHdr->RqSeqLUN  |= BMC_LUN_00;       /* LUN =00 */
+//                pIPMIMsgHdr->Cmd		= CMD_SET_EVENT_RECEIVER;
+//                SetEvtRcvReq->RcvSlaveAddr 	  =0xFF ;
+//                SetEvtRcvReq->RcvLUN =BMC_LUN_00;
+//                Req.Param=BRIDGING_REQUEST;
+//                Req.Channel=PRIMARY_IPMB_CHANNEL;
+//                Req.Data [sizeof (IPMIMsgHdr_T) + sizeof(SetEvtRcvReq_T)] =
+//                CalculateCheckSum2 (Req.Data, sizeof (IPMIMsgHdr_T) + sizeof(SetEvtRcvReq_T));
+//                Req.Size = sizeof(IPMIMsgHdr_T) + sizeof(SetEvtRcvReq_T) +1 ; //Plus 1 for Check sum
+//                /* Post Msg to IPMB  task  to send the set event  receiver	*/
+//                if ( -1 != IfcQ )
+//                {
+//                    if(0 != PostMsg(&Req, IPMB_PRIMARY_IFC_Q,BMCInst))
+//                    {
+//                        IPMI_WARNING ("SDR.c : Error posting message to IPMBIfc_Q\n");
+//                    }
+//                    pBMCInfo->MgmtTbl[i].Status =TRUE;
+//                }
+//            }
+//        }
+
+//#endif
+
+
+//#if SUPPORT_MULTI_CONTROLLER   == 1
+//        /* Sending the Run Initalization Command to all MMC in IPMB BUS */
+//        if(pBMCInfo->IpmiConfig.PrimaryIPMBSupport == 0x01)
+//        {
+//            for(i=0; i<Count; i++)
+//            {
+//                MsgPkt_T		Req;
+//                memset(&Req,0,sizeof(MsgPkt_T));
+//                IPMIMsgHdr_T*	pIPMIMsgHdr = (IPMIMsgHdr_T*)Req.Data;
+//                pIPMIMsgHdr->ResAddr	=pBMCInfo->MgmtTbl[i].OWNERID;
+//                pIPMIMsgHdr->NetFnLUN	 = (NETFN_STORAGE<< 2) | BMC_LUN_00;
+//                /* Get Device ID */		 
+//                //		 pIPMIMsgHdr->NetFnLUN	 = (NETFN_APP<< 2) | BMC_LUN_00;
+//                pIPMIMsgHdr->ChkSum 	= ~(pIPMIMsgHdr->ResAddr + pIPMIMsgHdr->NetFnLUN) + 1;
+//                pIPMIMsgHdr->ReqAddr	= pBMCInfo->IpmiConfig.BMCSlaveAddr;
+//                Req.Channel=PRIMARY_IPMB_CHANNEL; 
+
+//                g_BMCInfo[BMCInst].SDRConfig.IPMB_Seqnum++;
+//                if (g_BMCInfo[BMCInst].SDRConfig.IPMB_Seqnum >= 0x3F) { g_BMCInfo[BMCInst].SDRConfig.IPMB_Seqnum = 0xFF; }
+//                pIPMIMsgHdr->RqSeqLUN =   g_BMCInfo[BMCInst].SDRConfig.IPMB_Seqnum<< 2;	/* Request Seq Num */
+//                pIPMIMsgHdr->RqSeqLUN  |= BMC_LUN_00; 	  /* LUN =00 */
+//                Req.Param=BRIDGING_REQUEST;
+//                pIPMIMsgHdr->Cmd		= CMD_RUN_INITIALIZATION_AGENT;
+//                Req.Data[sizeof(IPMIMsgHdr_T)]=0x1; 
+//                Req.Data [sizeof (IPMIMsgHdr_T) + 1] =
+//                CalculateCheckSum2 (Req.Data, sizeof (IPMIMsgHdr_T) +1);
+//                Req.Size = sizeof(IPMIMsgHdr_T) + 2;  //Plus 2 for  req data's
+
+//                if ( -1 !=IfcQ  )
+//                {
+//                    if(0 != PostMsg(&Req, IPMB_PRIMARY_IFC_Q,BMCInst))
+//                    {
+//                        IPMI_WARNING ("SDR.c : Error posting message to IPMBIfc_Q\n");
+//                    }
+//                    pBMCInfo->MgmtTbl[i].Status =TRUE;
+//                }
+//            }
+//        }
+//#endif	
+
+
+//    pSDRRec = SDR_GetFirstSDRRec (BMCInst);
+//    for (i=0; i < pBMCInfo->SDRConfig.SDRRAM->NumRecords && pSDRRec != NULL; i++)
+//    {
+//        if (FULL_SDR_REC == pSDRRec->Type)
+//        {
+//            /* For all records of type 01h */
+//             FullSensorRec_T* pFullRec = ( FullSensorRec_T*)pSDRRec;
+//            uint16_t  ValidMask = htoipmi_u16(0x0FFF); 
+//            // If not a threshold sensor, then 15 event bits are used.
+//            if (pFullRec->EventTypeCode != 0x01)
+//            {
+//                ValidMask = htoipmi_u16(0x7FFF);
+//            }
+//            /* Disable Event & Scanning messages, if Disable is supported */
+//            if (0x03 != (pFullRec->SensorCaps & 0x03))
+//            {
+//                SetSensorEventEnableReq_T SetSEReq;
+
+//                // disable all events for sensor 
+//                SetSEReq.SensorNum       = pFullRec->SensorNum;
+//                SetSEReq.Flags		 = DISABLE_SELECTED_EVENT_MSG; // Event Disabled
+//                SetSEReq.AssertionMask   = ValidMask;
+//                SetSEReq.DeAssertionMask = ValidMask;
+
+//                SetSensorEventEnable (( uint8_t*)&SetSEReq,
+//                sizeof (SetSensorEventEnableReq_T), CmdRes,BMCInst);
+//            }
+
+//        /* Set Sensor Type */
+//#if SET_SENSOR_TYPE != UNIMPLEMENTED
+//            if (pFullRec->SensorInit & BIT2)
+//            {
+//                /* Set Sensor Type */
+//                SetSensorTypeReq_T SetSensorTypeReq;
+//                SetSensorTypeReq.SensorNum 	 = pFullRec->SensorNum;
+//                SetSensorTypeReq.SensorType	 = pFullRec->SensorType;
+//                SetSensorTypeReq.EventTypeCode  = pFullRec->EventTypeCode;
+//                SetSensorType (( uint8_t*)&SetSensorTypeReq, sizeof(SetSensorTypeReq), CmdRes,BMCInst);
+//            }
+//#endif
+
+//            /* Set Sensor Thresholds */
+//            {
+//                SetSensorThresholdReq_T SetThresholdReq;
+
+//                SetThresholdReq.SensorNum            = pFullRec->SensorNum;
+//                SetThresholdReq.SetFlags             = ((pFullRec->DiscreteReadingMask >> 8) & 0x3F);
+//                if  (pFullRec->SensorInit & BIT4)
+//                {
+//                    SetThresholdReq.LowerNonCritical     = pFullRec->LowerNonCritical;
+//                    SetThresholdReq.LowerCritical        = pFullRec->LowerCritical;
+//                    SetThresholdReq.LowerNonRecoverable  = pFullRec->LowerNonRecoverable;
+//                    SetThresholdReq.UpperNonCritical     = pFullRec->UpperNonCritical;
+//                    SetThresholdReq.UpperCritical        = pFullRec->UpperCritical;
+//                    SetThresholdReq.UpperNonRecoverable  = pFullRec->UpperNonRecoverable;
+
+//                    SetSensorThresholds (( uint8_t*)&SetThresholdReq,
+//                                                        sizeof (SetSensorThresholdReq_T), CmdRes,BMCInst);
+//                }
+//            }
+
+//            /* Set Sensor Hysteresis */
+//            {
+//                SetSensorHysterisisReq_T SetHysteresisReq;
+
+//                SetHysteresisReq.SensorNum           = pFullRec->SensorNum;
+//                SetHysteresisReq.Reserved            = 0;
+//                if  (pFullRec->SensorInit & BIT3) //Added for DR#31091
+//                {
+//                    SetHysteresisReq.PositiveHysterisis  = pFullRec->PositiveHysterisis;
+//                    SetHysteresisReq.NegativeHysterisis  = pFullRec->NegativeHysterisis;
+
+//                    SetSensorHysterisis (( uint8_t*)&SetHysteresisReq,
+//                    sizeof (SetSensorHysterisisReq_T), CmdRes,BMCInst);
+//                }
+//            }
+
+//            /* Enable Event & Scanning messages, if Disabled */
+//            if (0x03 != (pFullRec->SensorCaps & 0x03))
+//            {
+//                SetSensorEventEnableReq_T SetSEReq;
+
+//                SetSEReq.SensorNum       = pFullRec->SensorNum;
+//                SetSEReq.Flags           = (pFullRec->SensorInit & BIT6) | ((pFullRec->SensorInit & BIT5) << 2) | ENABLE_SELECTED_EVENT_MSG; // Event Enabled
+//                SetSEReq.AssertionMask   = (pFullRec->AssertionEventMask & ValidMask);
+//                SetSEReq.DeAssertionMask = (pFullRec->DeAssertionEventMask & ValidMask);
+
+//                SetSensorEventEnable (( uint8_t*)&SetSEReq,
+//                                                        sizeof (SetSensorEventEnableReq_T), CmdRes,BMCInst);
+//            }
+//        }
+
+//        if (pSDRRec->Type == COMPACT_SDR_REC)
+//        {
+//             CompactSensorRec_T* pCompactRec = ( CompactSensorRec_T*)pSDRRec;
+//            uint16_t  ValidMask = htoipmi_u16(0x0FFF); 
+//            // If not a threshold sensor, then 15 event bits are used.
+//            if (pCompactRec->EventTypeCode != 0x01)
+//            {
+//                ValidMask = htoipmi_u16(0x7FFF);
+//            }
+
+//            /* Disable Event & Scanning messages, if Disable is supported */
+//            if (0x03 != (pCompactRec->SensorCaps & 0x03))
+//            {
+//                SetSensorEventEnableReq_T SetSEReq;
+
+//                SetSEReq.SensorNum       = pCompactRec->SensorNum;
+//                SetSEReq.Flags		 = DISABLE_SELECTED_EVENT_MSG; // Event Disabled
+//                SetSEReq.AssertionMask   = ValidMask;
+//                SetSEReq.DeAssertionMask = ValidMask;
+
+//                SetSensorEventEnable (( uint8_t*)&SetSEReq,
+//                sizeof (SetSensorEventEnableReq_T), CmdRes,BMCInst);
+//            }
+
+//        /* Set Sensor Type */
+//#if SET_SENSOR_TYPE != UNIMPLEMENTED
+//            if (pCompactRec->SensorInit & BIT2)
+//            {
+//                /* Set Sensor Type */
+//                SetSensorTypeReq_T SetSensorTypeReq;
+//                SetSensorTypeReq.SensorNum 	 = pCompactRec->SensorNum;
+//                SetSensorTypeReq.SensorType	 = pCompactRec->SensorType;
+//                SetSensorTypeReq.EventTypeCode  = pCompactRec->EventTypeCode;
+//                SetSensorType (( uint8_t*)&SetSensorTypeReq, sizeof(SetSensorTypeReq), CmdRes,BMCInst);
+//            }
+//#endif
+
+//            /* Set Sensor Hysteresis */
+//            {
+//                SetSensorHysterisisReq_T SetHysteresisReq;
+
+//                SetHysteresisReq.SensorNum           = pCompactRec->SensorNum;
+//                SetHysteresisReq.Reserved            = 0;
+//                SetHysteresisReq.PositiveHysterisis  = pCompactRec->PositiveHysteris;
+//                SetHysteresisReq.NegativeHysterisis  = pCompactRec->NegativeHysterisis;
+
+//                SetSensorHysterisis (( uint8_t*)&SetHysteresisReq,
+//                                                    sizeof (SetSensorHysterisisReq_T), CmdRes,BMCInst);
+//            }
+
+//            /* Enable Event & Scanning messages, if Disabled */
+//            if (0x03 != (pCompactRec->SensorCaps & 0x03))
+//            {
+//                SetSensorEventEnableReq_T SetSEReq;
+
+//                SetSEReq.SensorNum       = pCompactRec->SensorNum;
+//                SetSEReq.Flags           = (pCompactRec->SensorInit & BIT6) | ((pCompactRec->SensorInit & BIT5) << 2) |ENABLE_SELECTED_EVENT_MSG ; // Event Enabled
+//                SetSEReq.AssertionMask   = (pCompactRec->AssertionEventMask & ValidMask);
+//                SetSEReq.DeAssertionMask = (pCompactRec->DeAssertionEventMask & ValidMask);
+
+//                SetSensorEventEnable (( uint8_t*)&SetSEReq,
+//                                                        sizeof (SetSensorEventEnableReq_T), CmdRes,BMCInst);
+//            }
+//        }
+//    pSDRRec = SDR_GetNextSDRRec (pSDRRec,BMCInst);
+//    }
+
+
+
+//#if SET_EVENT_RECEIVER == 0
+//    /* Enable Event Generation */
+//    {
+//        SetEvtRcvReq_T SetEvtRcvReq = { 0x20, 0 };
+//        SetEventReceiver (( uint8_t*)&SetEvtRcvReq, 
+//                                        sizeof (SetEvtRcvReq_T), CmdRes,BMCInst);
+//    }
+//#endif
+
+
+//#if SUPPORT_MULTI_CONTROLLER   == 1
+
+//    /* Sending the Set Event Reciver enable Command to all MMC in IPMB BUS */
+//    for(i=0;i<Count;i++)
+//    {
+//        MsgPkt_T        Req;
+//        IPMIMsgHdr_T*   pIPMIMsgHdr = (IPMIMsgHdr_T*)Req.Data;
+//          SetEvtRcvReq_T* SetEvtRcvReq = ( SetEvtRcvReq_T*) &Req.Data[sizeof(IPMIMsgHdr_T)];
+//        pIPMIMsgHdr->ResAddr    =pBMCInfo->MgmtTbl[i].OWNERID;
+//        pIPMIMsgHdr->NetFnLUN   = (NETFN_SENSOR<< 2) | BMC_LUN_00;
+//        pIPMIMsgHdr->ChkSum     = ~(pIPMIMsgHdr->ResAddr + pIPMIMsgHdr->NetFnLUN) + 1;
+//        pIPMIMsgHdr->ReqAddr    = pBMCInfo->IpmiConfig.BMCSlaveAddr;
+//        Req.Channel=PRIMARY_IPMB_CHANNEL;
+
+//        g_BMCInfo[BMCInst].SDRConfig.IPMB_Seqnum++;
+//        if (g_BMCInfo[BMCInst].SDRConfig.IPMB_Seqnum >= 0x3F) { g_BMCInfo[BMCInst].SDRConfig.IPMB_Seqnum = 0xFF; }
+//        pIPMIMsgHdr->RqSeqLUN =   g_BMCInfo[BMCInst].SDRConfig.IPMB_Seqnum<< 2;  /* Request Seq Num */
+//        pIPMIMsgHdr->RqSeqLUN  |= BMC_LUN_00;       /* LUN =00 */
+//        pIPMIMsgHdr->Cmd        = CMD_SET_EVENT_RECEIVER;
+//        SetEvtRcvReq->RcvSlaveAddr       = pBMCInfo->IpmiConfig.BMCSlaveAddr;
+//        SetEvtRcvReq->RcvLUN =BMC_LUN_00;
+//        Req.Param=BRIDGING_REQUEST;
+//        Req.Data [sizeof (IPMIMsgHdr_T) + sizeof(SetEvtRcvReq_T)] =
+//        CalculateCheckSum2 (Req.Data, sizeof (IPMIMsgHdr_T) + sizeof(SetEvtRcvReq_T));
+//        Req.Size = sizeof(IPMIMsgHdr_T) + sizeof(SetEvtRcvReq_T)+1; // plus 1 for checksum
+
+//        /* Post Msg to IPMB  task  to send the set event  receiver  */
+//        if ( -1 != IfcQ )
+//        {
+//            if(0 != PostMsg(&Req, IPMB_PRIMARY_IFC_Q,BMCInst))
+//            {
+//                IPMI_WARNING ("SDR.c : Error posting message to IPMBIfc_Q\n");
+//            }
+//            pBMCInfo->MgmtTbl[i].Status =TRUE;
+//        }
+//        //PDK_SMCDelay(pBMCInfo->MgmtTbl[i].OWNERID);
+//        //PDK_SMCDelay(0x40);
+//        //sleep(3);
+//    }
+
+
+//#endif
+
+//    if(g_PDKHandle[PDK_AFTERINITAGENT] != NULL)
+//    {
+//         ((int(*)(uint8_t,int))g_PDKHandle[PDK_AFTERINITAGENT]) (CmdRes[0],BMCInst);
+//    }
+
+//    return;
+//}
+
+#endif /* SDR_DEVICE */

+ 3 - 4
app/bmc_server/ipmi_dev/SDRFunc.h → app/bmc/msghndlr/Storage/SDRFunc.h

@@ -22,16 +22,15 @@
 #ifndef SDRFUNC_H
 #define SDRFUNC_H
 
-#include "Types.h"
 #include "SDRRecord.h"
-#include "IPMI_SDR.h"
+#include "com_IPMI_SDR.h"
 
 
 /**
  * @brief Get the first SDR record. 
  * @return First SDR record if success, 0 if error.
 **/             
-extern  _FAR_ SDRRecHdr_T* SDR_GetFirstSDRRec (int BMCInst);
+extern   SDRRecHdr_T* SDR_GetFirstSDRRec (void);
 
 
 /**
@@ -39,6 +38,6 @@ extern  _FAR_ SDRRecHdr_T* SDR_GetFirstSDRRec (int BMCInst);
  * @param pSDRRec - Current SDR Record.
  * @return Next SDR record if success, 0 if error.
 **/             
-extern  _FAR_ SDRRecHdr_T* SDR_GetNextSDRRec (_FAR_ SDRRecHdr_T* pSDRRec,int BMCInst);
+extern   SDRRecHdr_T* SDR_GetNextSDRRec ( SDRRecHdr_T* pSDRRec);
 
 #endif /* SDRFUNC_H */

+ 33 - 37
app/bmc_server/ipmi_dev/SDRRecord.h → app/bmc/msghndlr/Storage/SDRRecord.h

@@ -22,9 +22,9 @@
 #ifndef SDR_RECORD_H
 #define SDR_RECORD_H
 
-#include "Types.h"
-//#include "IPMI_SDRRecord.h"
-#include "IPMI_IPM.h"
+#include "com_IPMI_SDRRecord.h"
+#include "com_BmcType.h"
+
 
 #pragma pack( 1 )
 
@@ -44,11 +44,11 @@
 **/
 typedef struct
 {
-    INT8U                   Valid;
-    INT8U                   Len;
+    uint8_t                   Valid;
+    uint8_t                   Len;
     FullSensorRec_T         FullSensorRec;
 
-} PACKED  HdrFullSensorRec_T;
+}   HdrFullSensorRec_T;
 
 
 /**
@@ -57,11 +57,11 @@ typedef struct
 **/
 typedef struct
 {
-    INT8U                   Valid;
-    INT8U                   Len;
+    uint8_t                   Valid;
+    uint8_t                   Len;
     MgmtCtrlrConfirmRec_T   MgmtCtrlrConfirmRec;
 
-} PACKED  HdrMgmtCtrlrConfirmRec_T;
+}   HdrMgmtCtrlrConfirmRec_T;
 
 
 /**
@@ -70,11 +70,11 @@ typedef struct
 **/
 typedef struct
 {
-    INT8U                   Valid;
-    INT8U                   Len;
+    uint8_t                   Valid;
+    uint8_t                   Len;
     MgmtCtrlrDevLocator_T   MgmtCtrlrDevLocator;
 
-} PACKED  HdrMgmtCtrlrDevLocator_T;
+}   HdrMgmtCtrlrDevLocator_T;
 
 
 /**
@@ -83,11 +83,11 @@ typedef struct
 **/
 typedef struct
 {
-    INT8U                   Valid;
-    INT8U                   Len;
+    uint8_t                   Valid;
+    uint8_t                   Len;
     BMCMsgChannelInfoRec_T  BMCMsgChannelInfoRec;
 
-} PACKED  HdrBMCMsgChannelInfoRec_T;
+}   HdrBMCMsgChannelInfoRec_T;
 
 
 /**
@@ -96,11 +96,11 @@ typedef struct
 **/
 typedef struct
 {
-    INT8U                   Valid;
-    INT8U                   Len;
+    uint8_t                   Valid;
+    uint8_t                   Len;
     GnrcDevLocatorRec_T     GnrcDevLocatorRec;
 
-} PACKED  HdrGnrcDevLocatorRec_T;
+}   HdrGnrcDevLocatorRec_T;
 
 
 /**
@@ -109,32 +109,28 @@ typedef struct
 **/
 typedef struct
 {
-    INT8U                   Valid;
-    INT8U                   Len;
+    uint8_t                   Valid;
+    uint8_t                   Len;
     CompactSensorRec_T      CompactSensorRec;
 
-} PACKED  HdrCompactSensorRec_T;
-
-
-/**
- * @struct SDRRepository_T
- * @brief SDR Repository organisation
-**/
-typedef struct
-{
-    INT8U   Signature [4];      /* $SDR */
+}   HdrCompactSensorRec_T;
 
-    INT16U  NumRecords;         /* Number of records */
-    INT16U  Size;               /* Size of the SDR Records Data */
 
-    INT32U  AddTimeStamp;       /* Most recent addition timestamp */
-    INT32U  EraseTimeStamp;     /* Most recent erase timestamp */
+// /**
+//  * @struct SDRRepository_T
+//  * @brief SDR Repository organisation
+// **/
+// typedef struct
+// {
+//     uint8_t   Signature [4];      /* $SDR */
 
-    /* NOTE: If anything addede here - update SDR_NUM_FREE_BYTES */
+//     uint16_t  NumRecords;         /* Number of records */
+//     uint16_t  Size;               /* Size of the SDR Records Data */
 
-    //INT8U   FreeBytes [SDR_NUM_FREE_BYTES]; /* Free Record bytes */
+//     uint32_t  AddTimeStamp;       /* Most recent addition timestamp */
+//     uint32_t  EraseTimeStamp;     /* Most recent erase timestamp */
 
-} PACKED  SDRRepository_T;
+// }   SDRRepository_T;
 
 #pragma pack( )
 

+ 20 - 20
app/bmc_server/ipmi_dev/SEL.h → app/bmc/msghndlr/Storage/SEL.h

@@ -22,7 +22,7 @@
 #ifndef SEL_H
 #define SEL_H
 
-#include "Types.h"
+#include "com_BmcType.h"
 
 /*--------------System Event Record-------------*/
 #define SYSTEM_EVT_RECORD                    0x02
@@ -45,21 +45,21 @@
  * This set of commands provides read/write access to BMC's SEL.
  * @{
 **/
-extern int GetSELInfo           (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetSELAllocationInfo (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int ReserveSEL           (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int ClearSEL             (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetSELEntry          (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int AddSELEntry          (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int PartialAddSELEntry   (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int DeleteSELEntry       (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetSELTime           (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int SetSELTime           (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int GetAuxiliaryLogStatus(_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int SetAuxiliaryLogStatus(_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst);
-extern int LockedAddSELEntry    (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes, INT8U SysIfcFlag, INT8U SelectTbl,_NEAR_ int BMCInst);
-extern int GetSELTimeUTC_Offset  (_NEAR_ INT8U * pReq, INT8U ReqLen, _NEAR_ INT8U * pRes,_NEAR_ int BMCInst);
-extern int SetSELTimeUTC_Offset   (_NEAR_ INT8U * pReq, INT8U ReqLen, _NEAR_ INT8U * pRes,_NEAR_ int BMCInst);
+extern int GetSELInfo           ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetSELAllocationInfo ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int ReserveSEL           ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int ClearSEL             ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetSELEntry          ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int AddSELEntry          ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int PartialAddSELEntry   ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int DeleteSELEntry       ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetSELTime           ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SetSELTime           ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetAuxiliaryLogStatus( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int SetAuxiliaryLogStatus( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int LockedAddSELEntry    ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes);
+extern int GetSELTimeUTC_Offset  ( uint8_t * pReq, uint8_t ReqLen,  uint8_t * pRes);
+extern int SetSELTimeUTC_Offset   ( uint8_t * pReq, uint8_t ReqLen,  uint8_t * pRes);
 
 /** @} */
 
@@ -67,13 +67,13 @@ extern int SetSELTimeUTC_Offset   (_NEAR_ INT8U * pReq, INT8U ReqLen, _NEAR_ INT
  * @brief Get SEL timestamp.
  * @return The timestamp.
 **/
-extern INT32U GetSelTimeStamp (int BMCInst);
+extern uint32_t GetSelTimeStamp (void);
 
 /**
  * @brief Initialize SEL Device.
  * @return 0 if success, -1 if error
 **/
-extern int InitSEL (int BMCInst);
+extern int InitSEL (void);
 
 /*---------------------------------------------------------------------------
  * @fn SetSELPolicy
@@ -84,7 +84,7 @@ extern int InitSEL (int BMCInst);
  * @param   Policy  - Specify Linear SEL policy or Circular SEL policy.
  * @param   BMCInst - Index of BMC instance.
  *---------------------------------------------------------------------------*/
-extern void SetSELPolicy(INT8U Policy, int BMCInst);
+//extern void SetSELPolicy(uint8_t Policy);
 
 /*----------------------------------------------------------------- 
  * @fn CheckLastSELRecordID 
@@ -96,6 +96,6 @@ extern void SetSELPolicy(INT8U Policy, int BMCInst);
  *  
  * @param BMCInst 
  *-----------------------------------------------------------------*/ 
-extern void CheckLastSELRecordID (int BMCInst);
+extern void CheckLastSELRecordID (void);
 
 #endif  /* SEL_H */

+ 2 - 2
app/bmc_server/ipmi_dev/SELAPI.h → app/bmc/msghndlr/Storage/SELAPI.h

@@ -21,8 +21,8 @@
  ******************************************************************/
 #ifndef SELAPI_H
 #define SELAPI_H
-#include "Types.h"
-#include "IPMI_SEL.h"
+#include "types.h"
+#include "com_IPMI_SEL.h"
 #define ADD_SEL_FAILED   0xFFFF
 
 

+ 981 - 0
app/bmc/msghndlr/Storage/SELDevice/SEL.c

@@ -0,0 +1,981 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends .           **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ *****************************************************************
+ *
+ * Sel.c
+ * Sel Command Handler
+ *
+ * Author: Bakka Ravinder Reddy <bakkar@ami.com>
+ *
+ *****************************************************************/
+#define ENABLE_DEBUG_MACROS 0
+
+#include "SEL.h"
+#include "com_IPMI_Sensor.h"
+#include "SELRecord.h"
+#include <string.h>
+//#include "Storlead_BMC_LIb.h"
+#include "Support.h"
+#include "main.h"
+#include <stdio.h>
+#include "Api.h"
+
+
+/* Reserved bit macro definitions */
+#define RESERVED_BITS_PARTIALADDSELENTRY                0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+
+#if SEL_DEVICE == 1
+
+
+/*** Local Definitions ***/
+#define SEL_RECORD_SIZE             16
+#define CLR_SEL_PASSWORD_STR_LEN    3
+#define CLEAR_SEL_GET_STATUS        0x00
+#define CLEAR_SEL_ACTION            0xaa
+
+#define SEL_ERASE_IN_PROGRESS       0x00
+#define SEL_ERASE_COMPLETED         0x01
+#define SEL_ALLOC_UNIT_SIZE         0x10
+#define SEL_MAX_RECORD_SIZE         0x10
+#define INVALID_RECORD_ID           0x00
+
+#define OVERFLOW_FLAG               0x80
+#define DELETE_SEL_SUPPORT          0x08
+#define PARTIAL_ADD_SEL_SUPPORT     0x04
+#define RESERVE_SEL_SUPPORT         0x02
+#define GET_SEL_ALLOC_SUPPORT       0x01
+#define NO_SUPPORT                  0x00
+
+
+#define STATUS_DELETE_SEL           ((uint8_t)0xA5)
+
+#define SEL_ALMOST_FULL_PERCENTAGE  75
+#define SEL_PARTIAL_ADD_REQUEST_MISC_BYTES		6
+#define SEL_PARTIAL_ADD_CMD_MAX_LEN				22
+#define SEL_INITIALIZED 0x01
+#define SEL_UNINITIALIZED 0x00
+
+
+#define PRE_CLK_SET     0x00
+#define POST_CLK_SET    0x80
+
+/*** Prototype Declaration ***/
+static  SELRec_T*    GetNextSELEntry ( SELRec_T* rec);
+static  SELRec_T* GetSELRec(uint16_t RecID);
+static uint8_t SELTimeClockSync(uint8_t Action);
+
+
+/*** Global variables ***/
+
+/*** Module variables ***/
+//SELRepository_T*     m_sel;
+#define SENSOR_TYPE_EVT_LOGGING                 0x10
+
+
+/* System Event Message */
+static uint8_t m_SysEventMsg [] = {
+
+        0x00, 0x00,                 //Record ID
+        0x02,                       //Record Type is System
+        0x00, 0x00, 0x00, 0x00,     //TimeStamp
+        0x20, 0x00,                 //Generator ID is BMC
+        IPMI_EVM_REVISION,
+        SENSOR_TYPE_SYSTEM_EVENT,
+        0x6F,
+        0xFF,
+        0xFF,
+        0xFF,
+        0xFF
+};
+
+/*---------------------------------------
+ * GetSELInfo
+ *---------------------------------------*/
+int
+GetSELInfo ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	SELInfo_T*   pSelInfo = ( SELInfo_T*) pRes;
+	SELRepository_T* 	m_sel;
+
+ 
+	m_sel = ( SELRepository_T*) g_BMCInfo.pSEL;
+	pSelInfo->RecCt          = m_sel->NumRecords;
+	pSelInfo->FreeSpace      = (g_BMCInfo.SELConfig.MaxSELRecord - m_sel->NumRecords) * sizeof(SELRec_T);
+	pSelInfo->AddTimeStamp   = (m_sel->AddTimeStamp);
+	pSelInfo->EraseTimeStamp =( m_sel->EraseTimeStamp);
+  
+
+    pSelInfo->CompletionCode = CC_NORMAL;
+    pSelInfo->Version        = SEL_VERSION;
+    pSelInfo->OpSupport=NO_SUPPORT;
+
+    if(g_BMCInfo.SELConfig.SELOverFlow == TRUE)
+    {
+        pSelInfo->OpSupport |= OVERFLOW_FLAG;
+    }
+
+	pSelInfo->OpSupport|= RESERVE_SEL_SUPPORT;
+
+	pSelInfo->OpSupport|= GET_SEL_ALLOC_SUPPORT;
+	
+	pSelInfo->OpSupport|=PARTIAL_ADD_SEL_SUPPORT;
+
+	pSelInfo->OpSupport|= DELETE_SEL_SUPPORT;
+        
+  
+    return sizeof (SELInfo_T);
+}
+
+
+/*---------------------------------------
+ * GetSELAllocationInfo
+ *---------------------------------------*/
+int
+GetSELAllocationInfo( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	SELAllocInfo_T* pAllocInfo = ( SELAllocInfo_T*) pRes;
+	SELRepository_T* 	m_sel;
+
+    pAllocInfo->CompletionCode    = CC_NORMAL;
+    pAllocInfo->NumAllocUnits     =  1;
+    pAllocInfo->AllocUnitSize     =  (sizeof (SELRec_T));
+
+	m_sel = ( SELRepository_T*) g_BMCInfo.pSEL;
+	pAllocInfo->NumFreeAllocUnits =  ((g_BMCInfo.SELConfig.MaxSELRecord - m_sel->NumRecords));
+	pAllocInfo->LargestFreeBlock  =  (sizeof (SELRec_T));
+
+
+    pAllocInfo->MaxRecSize        = (sizeof (SELRec_T));
+    
+    return sizeof (SELAllocInfo_T);
+}
+
+
+/*---------------------------------------
+ * ReserveSEL
+ *---------------------------------------*/
+int
+ReserveSEL ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    ReserveSELRes_T* pRsvSelRes = ( ReserveSELRes_T*) pRes;
+   
+	g_BMCInfo.SELConfig.SelReservationID++;
+    if (0 == g_BMCInfo.SELConfig.SelReservationID) { g_BMCInfo.SELConfig.SelReservationID = 1; }
+    pRsvSelRes->CompletionCode = CC_NORMAL;
+    pRsvSelRes->ReservationID  = g_BMCInfo.SELConfig.SelReservationID;
+    g_BMCInfo.SELConfig.PartialAdd=0 ;//Addded for DR#30287 
+    return sizeof (ReserveSELRes_T);
+}
+
+
+/*---------------------------------------
+ * GetSELEntry
+ *---------------------------------------*/
+int
+GetSELEntry ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)      
+{
+	SELRec_T*    pSelRec;
+	SELRec_T*    pNextSelRec;
+	GetSELReq_T* pGetSelReq = ( GetSELReq_T*) pReq;
+	GetSELRes_T* pGetSelRes = ( GetSELRes_T*) pRes;
+	uint16_t         	LastRecID = 0,FirstRecID = 0;
+	SELRepository_T* 	m_sel = NULL;
+	uint16_t NumRecords = 0;
+
+   
+	m_sel = ( SELRepository_T*) g_BMCInfo.pSEL;
+	NumRecords = m_sel->NumRecords;
+  
+    pGetSelRes->CompletionCode = CC_NORMAL;
+//    if (pGetSelReq->ReservationID && g_BMCInfo.SELConfig.RsrvIDCancelled)
+//    {
+//        pGetSelRes->CompletionCode = CC_INV_RESERVATION_ID;
+//        return sizeof (uint8_t);
+//    }
+
+    /* Check if the reservation IDs match */
+    if ((g_BMCInfo.SELConfig.SelReservationID != pGetSelReq->ReservationID) &&
+        ((0 != pGetSelReq->Offset) || (pGetSelReq->ReservationID != 0)) )
+    {
+        pGetSelRes->CompletionCode = CC_INV_RESERVATION_ID;
+        return sizeof (uint8_t);
+    }
+
+    if (0 == m_sel->NumRecords)
+    { 
+        pGetSelRes->CompletionCode = CC_SEL_REC_NOT_PRESENT;
+        return sizeof (uint8_t);
+    }
+   
+
+    FirstRecID = m_sel->FirstRecID;
+    LastRecID = m_sel->LastRecID;
+
+    /* If ID == 0x0000  return first record */
+    if (0 == pGetSelReq->RecID)
+    {
+        pSelRec = GetSELRec(FirstRecID);
+        if (0 == pSelRec) 
+        {
+            pGetSelRes->CompletionCode = CC_SEL_REC_NOT_PRESENT;
+            return sizeof(uint8_t);
+        }
+        else 
+        { 
+            pNextSelRec = GetNextSELEntry (pSelRec); 
+        }
+		
+        if (0 == pNextSelRec) 
+        { 
+            pGetSelRes->NextRecID = 0xFFFF;
+        }
+        else
+        {
+            pGetSelRes->NextRecID = pNextSelRec->EvtRecord.hdr.ID;
+        }
+		
+		pGetSelReq->RecID = FirstRecID;
+    }
+    else if (0xFFFF == pGetSelReq->RecID)
+    {
+        pSelRec = GetSELRec(LastRecID);
+        if(0== pSelRec)
+        {
+            pGetSelRes->CompletionCode = CC_SEL_REC_NOT_PRESENT;
+            return sizeof(uint8_t);
+        }
+        pGetSelRes->NextRecID = 0xFFFF;
+    }
+
+	pSelRec = GetSELRec(pGetSelReq->RecID);
+	if (pSelRec == 0)
+	{
+		pGetSelRes->CompletionCode = CC_SEL_REC_NOT_PRESENT;
+		return sizeof (uint8_t);
+	}
+
+	if(LastRecID == pGetSelReq->RecID)
+	{
+		pGetSelRes->NextRecID = 0xFFFF;
+	}
+	else
+	{
+		pNextSelRec = GetNextSELEntry (pSelRec);
+		if (0 == pNextSelRec) 
+		{
+			/*If the given SEL ID is the maximum SEL record ,then the next SEL ID will be the First SEL ID 
+				in case of Circular SEL Implementation */
+			if(g_BMCInfo.SELConfig.MaxSELRecord == NumRecords)
+			{
+				pGetSelRes->NextRecID = 0;
+			}
+			else
+			{
+				pGetSelRes->NextRecID = 0xFFFF;
+			}
+		}
+		else 
+		{
+			pGetSelRes->NextRecID = pNextSelRec->EvtRecord.hdr.ID;
+		}
+	}
+
+    if ((0xff == pGetSelReq->Size) && (sizeof (SELEventRecord_T) >= pGetSelReq->Offset)) 
+    { 
+        pGetSelReq->Size = sizeof (SELEventRecord_T) - pGetSelReq->Offset;        
+    }
+    // Check for the request bytes and offset not to exceed the actual size of the record
+    else if ((pGetSelReq->Size > (sizeof(SELEventRecord_T))) ||
+             (pGetSelReq->Offset > (sizeof(SELEventRecord_T))) ||
+             (pGetSelReq->Size > ((sizeof(SELEventRecord_T))- pGetSelReq->Offset)))
+    {
+        pGetSelRes->CompletionCode = CC_PARAM_OUT_OF_RANGE;
+        return sizeof (uint8_t);
+    }
+    
+	memcpy(pGetSelRes + 1, (( uint8_t*)&pSelRec->EvtRecord) +
+             pGetSelReq->Offset, pGetSelReq->Size);
+
+    return sizeof(GetSELRes_T) + pGetSelReq->Size;
+}
+
+/*---------------------------------------
+ * LockedAddSELEntry with SEL locked 
+ *---------------------------------------*/
+int
+LockedAddSELEntry ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	AddSELRes_T*     pAddSelRes = ( AddSELRes_T*) pRes;
+	SELRecHdr_T*     pSelRec    = ( SELRecHdr_T*) pReq;
+	uint16_t         	index = 0;
+	uint16_t 			NumRecords=0;
+
+//	m_sel = ( SELRepository_T*)g_BMCInfo.pSEL;
+	NumRecords = (( SELRepository_T*)g_BMCInfo.pSEL)->NumRecords;
+
+    /* If we dont have enough space return invalid ID */
+    if (NumRecords >= g_BMCInfo.SELConfig.MaxSELRecord)
+    {
+		if (((( SELRepository_T*)g_BMCInfo.pSEL)->SELIndex == g_BMCInfo.SELConfig.MaxSELRecord))
+		{
+			(( SELRepository_T*)g_BMCInfo.pSEL)->SELIndex = 0;
+		}
+		/*Reset the SEL OverFlow Flag in Circular SEL mode*/
+		g_BMCInfo.SELConfig.SELOverFlow = FALSE;
+    }
+
+	if((( SELRepository_T*)g_BMCInfo.pSEL)->LastRecID == 0xFFFE)
+	{
+		(( SELRepository_T*)g_BMCInfo.pSEL)->LastRecID = 0;
+	}
+
+	if( (( SELRepository_T*)g_BMCInfo.pSEL)->FirstRecID == 0xFFFE)
+	{
+		(( SELRepository_T*)g_BMCInfo.pSEL)->FirstRecID = 0;
+	}
+
+	if(NumRecords == g_BMCInfo.SELConfig.MaxSELRecord)
+	{
+		(( SELRepository_T*)g_BMCInfo.pSEL)->FirstRecID +=1;
+	}
+
+	/* time stamp for record type less than 0xE0*/
+	if (pSelRec->Type < 0xE0)
+	{
+		// The timestamp gets set if the hook is not present or if the hook returns -1 
+		pSelRec->TimeStamp = GetSelTimeStamp ();
+	}
+
+	pSelRec->ID = ((( SELRepository_T*)g_BMCInfo.pSEL)->LastRecID) + 1;
+	index = (( SELRepository_T*)g_BMCInfo.pSEL)->SELIndex ;
+
+	memcpy (&(( SELRepository_T*)g_BMCInfo.pSEL)->SELRecord [index].EvtRecord , pSelRec, 
+				  sizeof (SELEventRecord_T));
+
+	(( SELRepository_T*)g_BMCInfo.pSEL)->SELRecord [index].Valid  = VALID_RECORD;
+	(( SELRepository_T*)g_BMCInfo.pSEL)->SELRecord [index].Len  = sizeof (SELEventRecord_T) + 2;
+
+
+	if (( NumRecords < g_BMCInfo.SELConfig.MaxSELRecord))
+	{
+		NumRecords = ++(( SELRepository_T*)g_BMCInfo.pSEL)->NumRecords;
+	}
+
+	/*Update the First SEL entry after clear SEL command*/
+	if( (( SELRepository_T*)g_BMCInfo.pSEL)->FirstRecID == 0)
+	{
+		(( SELRepository_T*)g_BMCInfo.pSEL)->FirstRecID = pSelRec->ID;
+	}
+
+	(( SELRepository_T*)g_BMCInfo.pSEL)->LastRecID += 1;
+	(( SELRepository_T*)g_BMCInfo.pSEL)->SELIndex += 1;
+
+	g_BMCInfo.SELConfig.LastEvtTS = (( SELRepository_T*)g_BMCInfo.pSEL)->AddTimeStamp = GetSelTimeStamp ();
+
+	pAddSelRes->CompletionCode = CC_NORMAL;
+	pAddSelRes->RecID          = pSelRec->ID;
+
+	return sizeof (AddSELRes_T);
+}
+
+/*---------------------------------------
+ * AddSELEntry
+ *---------------------------------------*/
+int
+AddSELEntry ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    int reslen = 0;
+
+    reslen = LockedAddSELEntry(pReq, ReqLen, pRes);
+   
+	UpdateFlash();
+	return reslen;
+}
+
+/*---------------------------------------
+ * PartialAddSELEntry
+ *---------------------------------------*/
+int
+PartialAddSELEntry ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	PartialAddSELReq_T*  pParAddSelReq = ( PartialAddSELReq_T*) pReq;
+	PartialAddSELRes_T*  pParAddSelRes = ( PartialAddSELRes_T*) pRes;
+	uint16_t    RecordID=0, ReservationID=0;
+	uint8_t     RecordOffset=0,Len=0;
+	SELRepository_T* m_sel = ( SELRepository_T*)g_BMCInfo.pSEL; 
+
+
+    ReservationID = (uint16_t)(pParAddSelReq->LSBReservationID | 
+                                            ((uint16_t)pParAddSelReq->MSBReservationID << 8));
+
+    RecordID = (uint16_t)(((uint16_t)pParAddSelReq->MSBRecordID << 8) |
+                                    pParAddSelReq->LSBRecordID);
+
+
+    RecordOffset = (uint32_t)pParAddSelReq->Offset;
+    Len = ReqLen;
+
+//   /*  Checks for the Valid Reservation ID */
+//    while(g_BMCInfo.SELConfig.RsrvIDCancelled)
+//    {
+//        if((ReservationID == 0) && (pParAddSelReq->Progress == 1) && (ReqLen == SEL_PARTIAL_ADD_CMD_MAX_LEN))
+//            break;
+//        else
+//        {
+//            if(ReqLen < SEL_PARTIAL_ADD_REQUEST_MISC_BYTES)
+//            {
+//                pParAddSelRes->CompletionCode = CC_REQ_INV_LEN;
+//                return(sizeof(PartialAddSELRes_T));	
+//            }
+//            else
+//            {
+//                pParAddSelRes->CompletionCode = CC_INV_RESERVATION_ID;
+//                pParAddSelRes->RecID          = 0;
+//                return(sizeof(PartialAddSELRes_T));
+//            }
+//        }
+//    }
+
+    /* Check for the reserved bytes should b zero */
+    if  ( 0 !=  (pParAddSelReq->Progress & RESERVED_BITS_PARTIALADDSELENTRY ) )
+    {
+        pParAddSelRes->CompletionCode = CC_INV_DATA_FIELD;
+        return sizeof(uint8_t);
+    }
+
+    if((pParAddSelReq->Progress>1)|| (pParAddSelReq->Offset>SEL_RECORD_SIZE))
+    {
+        pParAddSelRes->CompletionCode = CC_PARAM_OUT_OF_RANGE;
+        return(sizeof(PartialAddSELRes_T));
+    }
+    else if(g_BMCInfo.SELConfig.PartialAdd==0)
+    {
+        if(((RecordOffset+(Len-SEL_PARTIAL_ADD_REQUEST_MISC_BYTES)==SEL_RECORD_SIZE)&&(pParAddSelReq->Progress!=1))||
+        (( RecordOffset+(Len-SEL_PARTIAL_ADD_REQUEST_MISC_BYTES)<SEL_RECORD_SIZE)&&(pParAddSelReq->Progress==1))||
+        (RecordOffset+(Len-SEL_PARTIAL_ADD_REQUEST_MISC_BYTES)>SEL_RECORD_SIZE))
+
+        {
+            pParAddSelRes->CompletionCode = CC_REQ_INV_LEN;
+            return(sizeof(PartialAddSELRes_T));
+        }
+    }
+    else if((ReservationID==0)&&(Len==SEL_PARTIAL_ADD_CMD_MAX_LEN)&&(pParAddSelReq->Progress!=1))
+    {
+        pParAddSelRes->CompletionCode =CC_INV_DATA_FIELD;
+        return(sizeof(PartialAddSELRes_T));
+    }
+
+    /*Checking for reservation ID <<Added few more condition checking */
+    if(((ReservationID == g_BMCInfo.SELConfig.SelReservationID)&&(g_BMCInfo.SELConfig.PartialAdd==0)) ||  
+    ((ReservationID == g_BMCInfo.SELConfig.SelReservationID) && (ReqLen <= SEL_PARTIAL_ADD_CMD_MAX_LEN))
+    ||((ReservationID == 0) && (pParAddSelReq->Progress == 1) && (ReqLen == SEL_PARTIAL_ADD_CMD_MAX_LEN)))  
+    {
+        if(g_BMCInfo.SELConfig.PartialAdd==0)
+        {
+            // Requirement says partial adds must start at 0, with no
+            // gaps or overlaps. First request must be to RecordID = 0.
+            if ((RecordID != 0) || (RecordOffset != 0))
+            {
+                pParAddSelRes->CompletionCode = CC_INV_DATA_FIELD;
+                return(sizeof(PartialAddSELRes_T));// Modified from sizeof (uint8_t);
+            }
+
+            memset((void *)&g_BMCInfo.SELConfig.SelPartialAddRecord, 0xFF, sizeof(SELEventRecord_T));
+
+            // Fill in the record ID into the partial add record. The
+            // record ID is always the offset in memory of where the
+            // SEL record starts (which includes a delete time first).
+            RecordID = g_BMCInfo.SELConfig.SelPartialAddRecord.hdr.ID = m_sel->LastRecID +1;
+
+            g_BMCInfo.SELConfig.PartialAddRecordID=RecordID;
+            g_BMCInfo.SELConfig.PartialAddRecOffset = 0;
+            g_BMCInfo.SELConfig.PartialAdd=1;
+        }
+        else
+        {
+            if (RecordID != g_BMCInfo.SELConfig.PartialAddRecordID)
+            {
+                pParAddSelRes->CompletionCode = CC_INV_DATA_FIELD;
+                return sizeof (PartialAddSELRes_T); 
+            }
+        }
+
+        if (pParAddSelReq->Offset != g_BMCInfo.SELConfig.PartialAddRecOffset)
+        {
+            pParAddSelRes->CompletionCode = CC_INV_DATA_FIELD;
+            return(sizeof(PartialAddSELRes_T));
+        }
+
+        // Checking for Exceeding data values //
+        if((g_BMCInfo.SELConfig.PartialAddRecOffset + Len - SEL_PARTIAL_ADD_REQUEST_MISC_BYTES) > SEL_MAX_RECORD_SIZE)
+            {
+            pParAddSelRes->CompletionCode = CC_REQ_INV_LEN;
+            return(sizeof(PartialAddSELRes_T));
+        }
+
+        if((( g_BMCInfo.SELConfig.PartialAddRecOffset + Len - SEL_PARTIAL_ADD_REQUEST_MISC_BYTES) < SEL_MAX_RECORD_SIZE) && 
+        (pParAddSelReq->Progress == 1))	
+        {
+            pParAddSelRes->CompletionCode = CC_REQ_INV_LEN;
+            return(sizeof(PartialAddSELRes_T));
+        }
+
+        if(((g_BMCInfo.SELConfig.PartialAddRecOffset + Len - SEL_PARTIAL_ADD_REQUEST_MISC_BYTES) == SEL_MAX_RECORD_SIZE) &&
+            (pParAddSelReq->Progress != 1))
+        {
+            pParAddSelRes->CompletionCode = CC_REQ_INV_LEN;
+            return(sizeof(PartialAddSELRes_T));
+        }
+
+
+        memcpy((void *)((uint8_t *)&g_BMCInfo.SELConfig.SelPartialAddRecord + RecordOffset),
+			(void *)pParAddSelReq->RecordData, 
+			((uint8_t)(Len - SEL_PARTIAL_ADD_REQUEST_MISC_BYTES)));
+        g_BMCInfo.SELConfig.PartialAddRecordID=RecordID;
+        pParAddSelRes->RecID = RecordID;
+        g_BMCInfo.SELConfig.PartialAddRecOffset +=	(Len - SEL_PARTIAL_ADD_REQUEST_MISC_BYTES);
+        g_BMCInfo.SELConfig.PartialAdd=1;
+        pParAddSelRes->CompletionCode = CC_NORMAL;
+        //if the progress bit is 1 indicates that this is the last data of the record so put the entire record in sel repository
+
+        if(pParAddSelReq->Progress==1)
+        {
+            // Checking for complete filling of gap
+            if((pParAddSelReq->Offset + Len) == SEL_PARTIAL_ADD_CMD_MAX_LEN)
+            {
+                g_BMCInfo.SELConfig.PartialAdd=0;
+                LockedAddSELEntry ( (uint8_t*)&g_BMCInfo.SELConfig.SelPartialAddRecord, sizeof(SELEventRecord_T),  pRes);
+            }
+            else
+            {
+                pParAddSelRes->CompletionCode = CC_REQ_INV_LEN;
+                return(sizeof(PartialAddSELRes_T));
+            }
+        }
+    }
+    else
+    {
+        if(ReservationID != g_BMCInfo.SELConfig.SelReservationID)
+        {
+            pParAddSelRes->CompletionCode = CC_INV_RESERVATION_ID;
+            return(sizeof(PartialAddSELRes_T));
+        }
+        else
+        {
+            pParAddSelRes->CompletionCode = CC_INV_DATA_FIELD;
+            return(sizeof(PartialAddSELRes_T));
+        }
+    }
+
+	UpdateFlash();
+    return sizeof (PartialAddSELRes_T);
+}
+
+
+/*---------------------------------------
+ * DeleteSELEntry
+ *---------------------------------------*/
+int
+DeleteSELEntry ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	DeleteSELReq_T*  pDelSelReq = ( DeleteSELReq_T*) pReq;
+	DeleteSELRes_T*  pDelSelRes = ( DeleteSELRes_T*) pRes;
+	uint16_t LastRecID = 0,FirstRecID = 0;
+	SELRepository_T* 	m_sel = NULL;
+	SELRec_T *pRec = NULL, *pNextRec = NULL;
+	
+
+	m_sel = ( SELRepository_T*) g_BMCInfo.pSEL;
+
+    /* Check if the reservation IDs match */
+    if (((g_BMCInfo.SELConfig.SelReservationID != pDelSelReq->ReservationID) &&
+       (pDelSelReq->ReservationID != 0)) || (pDelSelReq->ReservationID == 0))
+    {
+        pDelSelRes->CompletionCode = CC_INV_RESERVATION_ID;
+        return sizeof (uint8_t);
+    }
+
+
+    LastRecID = m_sel->LastRecID;
+    FirstRecID = m_sel->FirstRecID;
+
+    if ( pDelSelReq->RecID == 0x0000 )
+    {
+        pDelSelReq->RecID = FirstRecID ;
+    }
+    else if ( pDelSelReq->RecID == 0xFFFF )
+    {
+        pDelSelReq->RecID = LastRecID;
+    }
+
+    pRec= GetSELRec(pDelSelReq->RecID);
+    if ( pRec == 0 ||(pRec->Valid != VALID_RECORD) )
+    {
+        pDelSelRes->CompletionCode = CC_SDR_REC_NOT_PRESENT;
+        return sizeof (uint8_t);
+    }
+
+	//Update first record id after delete first sel entity.
+	if(pDelSelReq->RecID == m_sel->FirstRecID)
+	{
+		pNextRec = GetNextSELEntry(pRec);
+		if(pNextRec != NULL)
+		{
+			m_sel->FirstRecID = pNextRec->EvtRecord.hdr.ID;
+		}
+		else	//No sel
+		{
+			m_sel->FirstRecID = 0;
+		}
+	}
+	pRec->Valid = STATUS_DELETE_SEL;
+	m_sel->NumRecords--;
+	/*Update the Last Deleted SEL time*/
+	m_sel->EraseTimeStamp = GetSelTimeStamp ();
+
+//    /*Update the First and last Record ID if the requested RecID is either First or Last*/
+//	FindRecOrder();
+	
+    pDelSelRes->CompletionCode  = CC_NORMAL;
+    pDelSelRes->RecID           = pDelSelReq->RecID;
+
+	UpdateFlash();
+    return sizeof (DeleteSELRes_T);
+}
+
+
+/*---------------------------------------
+ * ClearSEL
+ *---------------------------------------*/
+int
+ClearSEL ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)     
+{
+	ClearSELReq_T* pClrSelReq = ( ClearSELReq_T*) pReq;
+	ClearSELRes_T* pClrSelRes = ( ClearSELRes_T*) pRes;
+	SELRepository_T* 	m_sel = NULL;
+
+	m_sel = ( SELRepository_T*) g_BMCInfo.pSEL;
+    
+    if (memcmp(pClrSelReq->CLR, "CLR", CLR_SEL_PASSWORD_STR_LEN))
+    {
+        pClrSelRes->CompletionCode = CC_INV_DATA_FIELD;
+        return sizeof (uint8_t);
+    }
+    
+    if (pClrSelReq->InitOrStatus == CLEAR_SEL_GET_STATUS)
+    {
+        pClrSelRes->CompletionCode = CC_NORMAL;
+        pClrSelRes->EraseProgress  = SEL_ERASE_COMPLETED;
+        return sizeof (ClearSELRes_T);
+    }
+
+
+    if (pClrSelReq->InitOrStatus != CLEAR_SEL_ACTION)
+    {
+        pClrSelRes->CompletionCode = CC_INV_DATA_FIELD;
+        return sizeof (uint8_t);
+    }
+
+	/* Clear the fields of the SEL */
+	m_sel->LastRecID        = 0;
+	m_sel->FirstRecID       = 0;
+	m_sel->SELIndex         = 0;
+	m_sel->NumRecords   = 0;
+	memset (&m_sel->SELRecord [0], 0xFF, g_BMCInfo.SELConfig.MaxSELRecord * sizeof (SELRec_T));
+	
+	/*Update the Last Deleted SEL time*/
+	g_BMCInfo.SELConfig.LastEvtTS  = m_sel->EraseTimeStamp = GetSelTimeStamp (); 
+
+    pClrSelRes->CompletionCode = CC_NORMAL;
+    pClrSelRes->EraseProgress  = SEL_ERASE_COMPLETED;
+    g_BMCInfo.SELConfig.SELOverFlow = FALSE;
+    g_BMCInfo.SELConfig.selalmostfull = 0;
+
+	UpdateFlash();
+    return sizeof (ClearSELRes_T);
+}
+
+/*---------------------------------------
+ * GetSELTime
+ *---------------------------------------*/
+int
+GetSELTime ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    GetSELTimeRes_T* pGetSelTimeRes = ( GetSELTimeRes_T*) pRes;
+
+    pGetSelTimeRes->CompletionCode = CC_NORMAL;
+    pGetSelTimeRes->Time           = (GET_SYSTEM_TIME_STAMP ());
+    
+    return sizeof (GetSELTimeRes_T);
+}
+
+
+/**
+ * @fn setUTC_Offset
+ * @brief Set the UTC offset in the linux kernel.
+ * @param[in] UTCOffset - Offset value in minutes.
+ * @retval 0, on success.
+ *         1, on failure.
+ */
+static int setUTC_Offset (int16_t UTCOffset)
+{
+    int mins = 0, hrs = 0;
+    
+    if ((SEL_UTC_MIN_RANGE > UTCOffset) || (SEL_UTC_MAX_RANGE < UTCOffset) || (0 != (UTCOffset % 15)))
+    {
+        return 1;
+    }
+    
+    hrs = UTCOffset / 60;
+    mins = UTCOffset % 60;
+    
+    printf ("hrs : %d, mins : %d\n", hrs, mins);
+
+	g_BMCInfo.IpmiConfig.SELTimeUTCOffset = UTCOffset;
+    return 0;
+}
+
+/*---------------------------------------
+ * SetSELTime
+ *---------------------------------------*/
+int
+SetSELTime ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    uint32_t localTime = 0;
+    SetSELTimeReq_T* pSetSelTimeReq = ( SetSELTimeReq_T*) pReq;
+   
+    localTime = (pSetSelTimeReq->Time);
+
+    SELTimeClockSync(PRE_CLK_SET);
+
+    SET_SYSTEM_TIME_STAMP (&localTime);
+
+    SELTimeClockSync(POST_CLK_SET);
+
+    pRes [0] = CC_NORMAL;
+    
+	return sizeof (*pRes);
+}
+
+
+/*---------------------------------------
+ * GetSELTimeUTC_Offset
+ *---------------------------------------*/
+int
+GetSELTimeUTC_Offset ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    GetSELTimeUTCOffsetRes_T* pGetSelTimeUTCOffsetRes = ( GetSELTimeUTCOffsetRes_T*) pRes;
+    pGetSelTimeUTCOffsetRes->CompletionCode = CC_NORMAL;
+    pGetSelTimeUTCOffsetRes->UTCOffset = (g_BMCInfo.IpmiConfig.SELTimeUTCOffset);
+
+    return sizeof (GetSELTimeUTCOffsetRes_T);
+}
+
+
+
+/*---------------------------------------
+ * SetSELTimeUTC_Offset
+ *---------------------------------------*/
+int
+SetSELTimeUTC_Offset ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+	SetSELTimeUTCOffsetReq_T* pSetSELTimeUTCOffsetReq = ( SetSELTimeUTCOffsetReq_T*) pReq;
+	SetSELTimeUTCOffsetRes_T* pSetSELTimeUTCOffsetRes = ( SetSELTimeUTCOffsetRes_T*) pRes;
+	int16_t UTCOffset;
+
+    UTCOffset = (int16_t) (pSetSELTimeUTCOffsetReq->UTCOffset);
+
+    if (((UTCOffset <= SEL_UTC_MAX_RANGE) && (UTCOffset >= SEL_UTC_MIN_RANGE)) || (UTCOffset == UNSPECIFIED_UTC_OFFSET))
+    {
+        if (0 != setUTC_Offset ((UTCOffset == UNSPECIFIED_UTC_OFFSET) ? 0 : UTCOffset))
+        {
+            pSetSELTimeUTCOffsetRes->CompletionCode = CC_INV_DATA_FIELD;
+            return sizeof (*pRes);
+        }
+        
+        pSetSELTimeUTCOffsetRes->CompletionCode = CC_NORMAL;
+    }
+    else
+    {
+        pSetSELTimeUTCOffsetRes->CompletionCode = CC_PARAM_OUT_OF_RANGE;
+    }
+	
+	UpdateFlash();
+    
+    return sizeof (*pRes);
+}
+
+
+/*---------------------------------------
+ * GetAuxiliaryLogStatus
+ *---------------------------------------*/
+int
+GetAuxiliaryLogStatus( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    return 0;
+}
+
+
+/*---------------------------------------
+ * SetAuxiliaryLogStatus
+ *---------------------------------------*/
+int
+SetAuxiliaryLogStatus( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
+{
+    return 0;
+}
+
+
+/*---------------------------------------
+ * GetNextSELEntry
+ *---------------------------------------*/
+static  SELRec_T*
+GetNextSELEntry ( SELRec_T* rec)
+{ 
+	SELRec_T* pRec = rec;
+	SELRec_T* pLastRec = (((SELRepository_T*)g_BMCInfo.pSEL)->SELRecord + g_BMCInfo.SELConfig.MaxSELRecord - 1);
+	pRec++;
+	while (1)
+	{
+		if(pRec > pLastRec)
+		{
+			pRec = ((SELRepository_T*)g_BMCInfo.pSEL)->SELRecord;
+		}
+		
+		if(pRec == rec)
+		{
+			break;
+		}
+		
+		if (pRec->Valid == VALID_RECORD)
+		{
+			return pRec;
+		}
+		else if (pRec->Valid == STATUS_DELETE_SEL)
+		{
+			pRec++;
+		}
+		else
+		{
+			break;
+		}
+		
+	}
+
+     return 0;
+}
+
+/*
+ @ fn GetSELRec
+ @ brief This function is used to get the SEL Record based Record ID
+ @ params RecID[in] Record ID BMCInst[in]
+ @ returns SELRecord pointer on success and 0 on failures
+ */
+static  SELRec_T* GetSELRec(uint16_t RecID)
+{
+	int i=0;
+	SELRepository_T*  m_sel;
+
+	m_sel = ( SELRepository_T*) g_BMCInfo.pSEL;
+
+	for(i=0;i<g_BMCInfo.SELConfig.MaxSELRecord;i++)
+	{
+		if((m_sel->SELRecord[i].EvtRecord.hdr.ID == RecID) && (m_sel->SELRecord[i].Valid== VALID_RECORD))
+		{
+			return &m_sel->SELRecord[i];
+		}
+	}
+	
+	return 0;
+}
+
+/*---------------------------------------
+ * GetSelTimeStamp
+ *---------------------------------------*/
+uint32_t GetSelTimeStamp()
+{
+    return (GET_SYSTEM_TIME_STAMP());
+}
+
+#endif  /* SEL_DEVICE */
+
+/*---------------------------------------------------------------------------
+ * @fn SELTimeClockSync
+ *
+ * @brief This function is invoked when set SEL time, generate a pair of
+ *        events(pre and post clock setting) correlating the timestamps
+ *        for events occurring before and after the new clock value.
+ *
+ * @param   Action  - Specify pre-event or post-event.
+ * @param   BMCInst - Index of BMC instance.
+ *
+ * @return  0	- if success.
+ *			-1	- if error.
+ *---------------------------------------------------------------------------*/
+static uint8_t SELTimeClockSync(uint8_t Action)
+{
+    SELEventRecord_T *EventRec = (SELEventRecord_T*)m_SysEventMsg;
+    uint8_t pRes[sizeof(AddSELRes_T)];
+
+    EventRec->SensorNum  = 0xFF;
+    EventRec->EvtDirType = 0x6F;    // Sensor Specific
+    EventRec->EvtData1   = 0x05;    // Offset 05h - Timestamp Clock Sync
+    EventRec->EvtData2   = Action;
+    EventRec->EvtData3   = 0xFF;
+
+    LockedAddSELEntry((uint8_t*)EventRec, sizeof(SELEventRecord_T), pRes);
+	
+	UpdateFlash();
+    return 0;
+}
+
+
+///*---------------------------------------------------------------------------
+// * @fn SetSELPolicy
+// *
+// * @brief This function is invoked when switch SEL policy, make appropriate
+// *        adjustment for environment variables that related to SEL buffer.
+// *
+// * @param   Policy  - Specify Linear SEL policy or Circular SEL policy.
+// * @param   BMCInst - Index of BMC instance.
+// *---------------------------------------------------------------------------*/
+//void
+//SetSELPolicy(uint8_t Policy)
+//{
+////    SELRepository_T* m_sel = NULL;
+
+//	m_sel = (SELRepository_T*)g_BMCInfo.pSEL;
+
+//    switch (Policy)
+//    {
+//        case LINEAR_SEL:
+//            /* Reset LastRecID because GetNextSELEntry func will stop finding the next record if RecID >= LastRecRD,
+//               but RecID may greater than LastRecID in Circular SEL mode. */
+///*            LOCK_BMC_SHARED_MEM(BMCInst);
+//            BMC_GET_SHARED_MEM (BMCInst)->m_LastRecID = m_sel->SELRecord[pBMCInfo->SELConfig.MaxSELRecord].EvtRecord.hdr.ID;
+//            BMC_GET_SHARED_MEM (BMCInst)->m_SELIndex = m_sel->NumRecords;
+//            BMC_GET_SHARED_MEM (BMCInst)->m_FirstRecID = m_sel->SELRecord[0].EvtRecord.hdr.ID;
+//            UNLOCK_BMC_SHARED_MEM(BMCInst);*/
+//            break;
+
+//        case CIRCULAR_SEL:
+//            /*Update the Last and First Record ID when switch back to Circular-linear-Circular cycle */
+////            if(m_sel->NumRecords == g_BMCInfo.SELConfig.MaxSELRecord)
+////            {
+////                FindRecOrder();
+////            }
+//            break;
+//    }
+//}
+
+

+ 172 - 0
app/bmc/msghndlr/Storage/SELRecord.h

@@ -0,0 +1,172 @@
+/*****************************************************************
+ *****************************************************************
+ ***                                                            **
+ ***    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ ***                                                            **
+ ***            All Rights Reserved.                            **
+ ***                                                            **
+ ***        6145-F, Northbelt Parkway, Norcross,                **
+ ***                                                            **
+ ***        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ ***                                                            **
+ *****************************************************************
+ *****************************************************************
+ ******************************************************************
+ *
+ * SELRecord.h
+ * SEL record structures.
+ *
+ *  Author: Rama Rao Bisa<ramab@ami.com>
+ *
+ ******************************************************************/
+#ifndef SEL_RECORD_H
+#define SEL_RECORD_H
+
+#include "com_IPMI_SEL.h"
+
+/*** External Definitions ***/
+#define VALID_RECORD        0x5A
+
+#define MAX_RECORD_ID 		(65535)
+
+//#define SEL_RECLAIM_HEAD_NODE(BMCInst)     g_BMCInfo[BMCInst].SELReclaimRepos.HeadeNode
+//#define SEL_RECLAIM_TAIL_NODE(BMCInst)     g_BMCInfo[BMCInst].SELReclaimRepos.TailNode
+
+//#define SEL_RECLAIM_RECORD_HEAD_NODE(BMCInst)     g_BMCInfo[BMCInst].SELReclaimRepos.HeadeRecNode
+//#define SEL_RECLAIM_RECORD_TAIL_NODE(BMCInst)     g_BMCInfo[BMCInst].SELReclaimRepos.TailRecNode
+
+//#define SEL_RECORD_ADDR(BMCInst,Var)          g_BMCInfo[BMCInst].SELReclaimRepos.pSELRecAddr[Var]
+//#define SEL_PREV_RECORD_ADDR(BMCInst,Var)     g_BMCInfo[BMCInst].SELReclaimRepos.pSELRecAddr[Var].RecAddr->PrevRec
+//#define SEL_NEXT_RECORD_ADDR(BMCInst,Var)     g_BMCInfo[BMCInst].SELReclaimRepos.pSELRecAddr[Var].RecAddr->NextRec
+
+//#define SEL_MALLOC(Var)    (struct Var *)malloc(sizeof(Var))
+
+#define SIGN_SIZE 4
+
+//#define SEL_RECLAIM_SECTION_INFO "SELRECLAIMINFO"
+
+//#define SEL_SIGNATURE     "signature"
+//#define SEL_NUMRECORDS    "NumRecords"
+//#define SEL_ADDTIMESTAMP    "AddTimeStamp"
+//#define SEL_ERASETIMESTAMP    "EraseTimeStamp"
+//#define SEL_LASTFILEINDEX    "LastFileIndex"
+//#define SEL_MAXRECPOS    "MaxRecPos"
+
+//#define SEL_FREE(Var)    \
+//do{                      \
+//    free(Var);           \
+//    Var=NULL;            \
+//}while(0);
+
+
+#pragma pack( 1 )
+
+/**
+ * @struct SELRec_T
+ * @brief SEL Record
+**/
+typedef struct
+{
+    uint8_t               Valid;
+    uint8_t               Len;
+    SELEventRecord_T    EvtRecord;
+}   SELRec_T;
+
+
+/**
+ * @struct SELRepository_T
+ * @brief SEL Repository structure.
+**/
+typedef struct
+{
+    uint8_t       Signature [SIGN_SIZE];      /* $SDR */
+    uint16_t      NumRecords;
+    uint16_t      Padding;
+    uint32_t      AddTimeStamp;
+    uint32_t      EraseTimeStamp;
+	uint16_t	FirstRecID;
+	uint16_t	LastRecID;
+	uint16_t	SELIndex;
+    SELRec_T    *SELRecord;
+
+}   SELRepository_T;
+
+
+/* * @struct SELRecIDNode
+ * @brief SELRecIDNode structure.
+**/
+typedef struct SELRecIDNode
+{ 
+    int16_t RecordID;
+    struct SELRecIDNode *NextRecID;
+ }SELRecIDNode;
+
+/**
+ * @struct SELEventNode
+ * @brief SELEventNode structure.
+**/
+typedef struct SELEventNode
+{
+    int32_t FileIndex;
+    SELRec_T SELRecord;
+    struct SELEventNode *NextRec;
+    struct SELEventNode *PrevRec;
+ }SELEventNode;
+
+typedef struct
+{  
+    int32_t RecPos;
+    struct SELEventNode *RecAddr;
+}SELRecAddr;
+
+/**
+ * @struct SELReclaimInfo_T
+ * @brief SELReclaimInfo_T structure.
+**/
+typedef struct
+{
+    int8_t Signature[SIGN_SIZE];
+    int16_t NumRecords;
+    int32_t AddTimeStamp;
+    int32_t EraseTimeStamp;
+    int32_t LastFileIndex;
+    int32_t MaxRecPos;
+} SELReclaimInfo_T;
+
+/**
+ * @struct SELReclaimRepository_T
+ * @brief SELReclaimRepository_T structure.
+**/
+typedef struct
+{
+/* The Node Pointer needs to be maintained
+ * at the top in order to avoid structure
+ * alignment issues */
+    SELEventNode *HeadeNode;
+    SELEventNode *TailNode;
+    SELRecIDNode *HeadeRecNode;
+    SELRecIDNode *TailRecNode;
+    SELRecAddr *pSELRecAddr;
+    SELReclaimInfo_T *pSELReclaimInfo;
+} SELReclaimRepository_T;
+
+///* SEL Reclaim Function Prototypes */
+//extern int DeleteSELRecordIDHeadNode(SELRecIDNode **HeadNode,SELRecIDNode **TailNode);
+//extern int DeleteSELReclaimNode(SELEventNode **HeadNode,SELEventNode **TailNode,int16_t RecordID,unsigned int *FileIndex);
+//extern int AddSELRecalimNode(SELEventNode **HeadNode,SELEventNode **TailNode,SELRec_T *SELRecord,unsigned int FileIndex);
+//extern int16_t GetNextReclaimRecordID(void);
+//extern int FlushAddReclaimSEL(SELRec_T *SELRecord);
+//extern int ReFlushDeleteReclaimSEL(int16_t RecordID);
+//extern int AddSELRecordIDNode(SELRecIDNode **HeadNode,SELRecIDNode **TailNode,int16_t RecordID);
+//extern int32_t GetReclaimFileSize(char *FileName);
+//extern void DeleteReclaimAllSELNode(SELEventNode **HeadNode,SELEventNode **TailNode);
+//extern int UpdateRecordIDList(int8_t *RecordID);
+//extern int CopySELReclaimEntries(SELEventNode **HeadNode,int8_t *RecordData,int32_t NumEntriesRetrd,int32_t NumOfEntries);
+//extern int LoadSELReclaimInfo( SELReclaimInfo_T *SELInfo);
+//extern int SaveSELReclaimInfo( SELReclaimInfo_T *SELInfo);
+//extern int CheckPreviousReclaimFile(int32_t FileIndex,int32_t FileSize,SELRec_T *pSELReclaimRec,int8_t *SELCount,char *PrevFileName);
+//extern int FilterSELReclaimFiles(const struct dirent *entry);
+
+#pragma pack( )
+
+#endif  /* SEL_RECORD_H */

+ 77 - 0
app/bmc/msghndlr/Storage/Storage.c

@@ -0,0 +1,77 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************/
+/*****************************************************************
+ *
+ * Storage.c
+ * Storage Command Handler
+ *
+ * Author:   Rama Bisa <ramab@ami.com>
+ *           Bakka Ravinder Reddy <bakkar@ami.com>
+ *****************************************************************/
+
+#include "MsgHndlr.h"
+#include "com_IPMI_Storage.h"
+#include "Support.h"
+#include "main.h"
+
+const CmdHndlrMap_T g_Storage_CmdHndlr [] =
+{
+    /*--------------------- FRU Device Commands ---------------------------------*/
+#if FRU_DEVICE == 1
+                                                                                            
+    { CMD_FRU_INVENTORY_AREA_INFO,  PRIV_USER,      GET_FRU_INVENTORY_AREA_INFO,    sizeof (FRUInventoryAreaInfoReq_T), 0xAAAA ,0xFFFF},
+    { CMD_READ_FRU_DATA,            PRIV_USER,      READ_FRU_DATA,                  sizeof (FRUReadReq_T),  0xAAAA  ,0xFFFF},
+    { CMD_WRITE_FRU_DATA,           PRIV_OPERATOR,  WRITE_FRU_DATA,                 0xFF,   0xAAAA  ,0xFFFF},
+
+#endif  /* FRU_DEVICE */
+
+    /*--------------------- SDR Device Commands ---------------------------------*/
+#if SDR_DEVICE == 1
+    { CMD_GET_SDR_REPOSITORY_INFO,              PRIV_USER,      GET_SDR_REPOSITORY_INFO,                0x00,   0xAAAA ,0xFFFF},
+    { CMD_GET_SDR_REPOSITORY_ALLOCATION_INFO,   PRIV_USER,      GET_SDR_REPOSITORY_ALLOCATION_INFO,     0x00,   0xAAAA ,0xFFFF},
+    { CMD_RESERVE_SDR_REPOSITORY,               PRIV_USER,      RESERVE_SDR_REPOSITORY,                 0x00,   0xAAAA ,0xFFFF},
+    { CMD_GET_SDR,                              PRIV_USER,      GET_SDR,                                sizeof(GetSDRReq_T),    0xAAAA ,0xFFFF},
+    { CMD_ADD_SDR,                              PRIV_OPERATOR,  ADD_SDR,                                0xFF,   0xAAAA ,0xFFFF},
+    { CMD_PARTIAL_ADD_SDR,                      PRIV_OPERATOR,  PARTIAL_ADD_SDR,                        0xFF,   0xAAAA ,0xFFFF},
+    { CMD_DELETE_SDR,                           PRIV_OPERATOR,  DELETE_SDR,                             sizeof(DeleteSDRReq_T),   0xAAAA ,0xFFFF},
+    { CMD_CLEAR_SDR_REPOSITORY,                 PRIV_OPERATOR,  CLEAR_SDR_REPOSITORY,                   sizeof(ClearSDRReq_T),  0xAAAA ,0xFFFF},
+    { CMD_GET_SDR_REPOSITORY_TIME,              PRIV_USER,      GET_SDR_REPOSITORY_TIME,                0x00,   0xAAAA ,0xFFFF},
+    // { CMD_SET_SDR_REPOSITORY_TIME,              PRIV_OPERATOR,  SET_SDR_REPOSITORY_TIME,                sizeof(SetSDRRepositoryTimeReq_T),  0xAAAA ,0xFFFF},
+    // { CMD_ENTER_SDR_REPOSITORY_UPDATE_MODE,     PRIV_OPERATOR,  ENTER_SDR_REPOSITORY_UPDATE_MODE,       0x00,   0xAAAA ,0xFFFF},
+    // { CMD_EXIT_SDR_REPOSITORY_UPDATE_MODE,      PRIV_OPERATOR,  EXIT_SDR_REPOSITORY_UPDATE_MODE,        0x00,   0xAAAA ,0xFFFF},
+    { CMD_RUN_INITIALIZATION_AGENT,             PRIV_OPERATOR,  RUN_INITIALIZATION_AGENT,               sizeof(RunInitAgentReq_T),  0xAAAA ,0xFFFF},
+
+#endif /* SDR_DEVICE */
+
+    /*--------------------- SEL Device Commands ----------------------------------*/
+#if SEL_DEVICE == 1
+    { CMD_GET_SEL_INFO,                         PRIV_USER,      GET_SEL_INFO,                           0x00,   0xAAAA ,0xFFFF},
+    { CMD_GET_SEL_ALLOCATION_INFO,              PRIV_USER,      GET_SEL_ALLOCATION_INFO,                0x00,   0xAAAA ,0xFFFF},
+    { CMD_RESERVE_SEL,                          PRIV_USER,      RESERVE_SEL,                            0x00,   0xAAAA ,0xFFFF},
+    { CMD_GET_SEL_ENTRY,                        PRIV_USER,      GET_SEL_ENTRY,                          sizeof(GetSELReq_T),    0xAAAA ,0xFFFF},
+    { CMD_ADD_SEL_ENTRY,                        PRIV_OPERATOR,  ADD_SEL_ENTRY,                          sizeof(SELEventRecord_T),   0xAAAA ,0xFFFF},
+    { CMD_PARTIAL_ADD_SEL_ENTRY,                PRIV_OPERATOR,  PARTIAL_ADD_SEL_ENTRY,                  0xFF,   0xAAAA ,0xFFFF},
+    { CMD_DELETE_SEL_ENTRY,                     PRIV_OPERATOR,  DELETE_SEL_ENTRY,                       sizeof(DeleteSELReq_T),   0xAAAA ,0xFFFF},
+    { CMD_CLEAR_SEL,                            PRIV_OPERATOR,  CLEAR_SEL,                              sizeof(ClearSELReq_T),  0xAAAA ,0xFFFF},
+    { CMD_GET_SEL_TIME,                         PRIV_USER,      GET_SEL_TIME,                           0x00,   0xAAAA ,0xFFFF},
+    { CMD_SET_SEL_TIME,                         PRIV_OPERATOR,  SET_SEL_TIME,                           sizeof(SetSELTimeReq_T),    0xAAAA ,0xFFFF},
+    // { CMD_GET_AUXILIARY_LOG_STATUS,             PRIV_USER,      GET_AUXILIARY_LOG_STATUS,               0xFF,   0xAAAA ,0xFFFF},
+    // { CMD_SET_AUXILIARY_LOG_STATUS,             PRIV_ADMIN,     SET_AUXILIARY_LOG_STATUS,               0xFF,   0xAAAA ,0xFFFF},
+    { CMD_GET_SEL_TIME_UTC_OFFSET,              PRIV_USER,      GET_SEL_TIME_UTC_OFFSET,                0x00,   0xAAAA ,0xFFFF},
+    { CMD_SET_SEL_TIME_UTC_OFFSET,              PRIV_OPERATOR,  SET_SEL_TIME_UTC_OFFSET,                sizeof(SetSELTimeUTCOffsetReq_T),   0xAAAA ,0xFFFF},
+
+#endif /* SEL_DEVICE */
+    { 0x00,                     0x00,           0x00,                 0x00, 0x0000  ,  0x0000}
+};
+

+ 18 - 0
app/bmc/msghndlr/Storage/Storage.h

@@ -0,0 +1,18 @@
+/*
+* Brief:	The header file of MsgHndlr_Storage packet.
+* Author:	Jimbo_Zhang@outlook.com
+* Date:		2019-9-16
+*/
+
+#ifndef __MSG_HNDLR_STORAGE_H__
+#define __MSG_HNDLR_STORAGE_H__
+
+#include "MsgHndlr.h"
+
+/**
+ * @var g_Storage_CmdHndlr
+ * @brief Storage Command Handler Table
+**/
+extern const CmdHndlrMap_T  g_Storage_CmdHndlr [];
+
+#endif /* __MSG_HNDLR_STORAGE_H__ */

+ 702 - 0
app/bmc/msghndlr/Support.h

@@ -0,0 +1,702 @@
+/*****************************************************************
+ *****************************************************************
+ ***                                                            **
+ ***    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ ***                                                            **
+ ***            All Rights Reserved.                            **
+ ***                                                            **
+ ***        6145-F, Northbelt Parkway, Norcross,                **
+ ***                                                            **
+ ***        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ ***                                                            **
+ *****************************************************************
+ *****************************************************************
+ ******************************************************************
+ *
+ * support.h
+ * supported commands Macros
+ *
+ *  Author: Basavaraj Astekar <basavaraja@ami.com>
+ *
+ ******************************************************************/
+#ifndef SUPPORT_H
+#define SUPPORT_H
+
+#include "AppDevice.h"
+#include "IPMDevice.h"
+#include "Bridge.h"
+#include "ChassisDevice.h"
+#include "OemSMMCmds.h"
+#include "Sensor.h"
+#include "PICMG.h"
+#include "Chassis.h"
+#include "SensorEvent.h"
+#include "FRU.h"
+#include "SDR.h"
+#include "SEL.h"
+#include "SELRecord.h"
+#include "Storage.h"
+#include "SDRRecord.h"
+
+
+/*---------------------------------------------------------------------------*
+ * DEVICES SUPPORTED
+ *---------------------------------------------------------------------------*/
+#define IPM_DEVICE					1
+#define APP_DEVICE					1
+
+#define CHASSIS_DEVICE				1
+
+#define EVENT_PROCESSING_DEVICE		0
+#define PEF_DEVICE					0
+#define SENSOR_DEVICE				1
+
+#define SDR_DEVICE					1
+#define	SEL_DEVICE					1
+#define FRU_DEVICE					1
+
+#define BRIDGE_DEVICE				0
+
+#define AMI_DEVICE				    0
+
+#define OEM_DEVICE				    0
+
+#define PICMG_DEVICE				0
+/*---------------------------------------------------------------------------*
+ * FEATURE SUPPORTED
+ *---------------------------------------------------------------------------*/
+#define FW_UPGRADE					0
+#define FRB_SUPPORT					0
+#define TERMINAL_MODE_SUPPORT       1
+#define INTERNAL_PSGOOD_MONITORING  0
+#define NO_WDT_PRETIMEOUT_INTERRUPT 0
+
+
+/*---------------------------------------------------------------------------*
+ * IPMI 2.0 SPECIFIC DEFINITIONS
+ *---------------------------------------------------------------------------*/
+#define IPMI20_SUPPORT				0
+#define MAX_SOL_IN_PAYLD_SIZE       252
+#define MAX_SOL_OUT_PAYLD_SIZE      252
+#define MAX_IN_PAYLD_SIZE			1024
+#define MAX_OUT_PAYLD_SIZE			1024
+#define MAX_PYLDS_SUPPORT			2
+#define MAX_PAYLD_INST				15  /* 1 to 15 only */
+#define SYS_SERIAL_PORT_NUM			0
+
+/*---------------------------------------------------------------------------*
+ * OEM CONFIGURATION DATA SUPPORTED & CONFIGURATION DATA SIZE
+ *---------------------------------------------------------------------------*/
+#define	OEM_CONFIG_DATA_SUPPORTED	1
+#define	MAX_OEM_CONFIG_DATA_SIZE	100
+
+
+/*-------------------------------------------------------------------------*
+ * Define the Unimplemented function based on the choice
+ *-------------------------------------------------------------------------*/
+// #if defined UNIMPLEMENTED_AS_FUNC
+
+// #define UNIMPLEMENTED   UnImplementedFunc
+// extern int UnImplementedFunc (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes, int BMCInst);
+
+// #elif defined AMI_UNIMPLEMENTED_AS_FUNC
+
+// #define UNIMPLEMENTED   UnImplementedFuncAMI
+// extern int UnImplementedFuncAMI (_NEAR_ INT8U* pReq, INT32U ReqLen, _NEAR_ INT8U* pRes, int BMCInst);
+
+// #else
+
+#define UNIMPLEMENTED 	-1
+
+// #endif
+
+
+#define GET_DCMI_CAPABILITY_INFO                GetDCMICapabilityInfo               /* UNIMPLEMENTED */
+#define GET_POWER_READING                       GetPowerReading                     /* UNIMPLEMENTED */
+#define GET_POWER_LIMIT                         GetPowerLimit                       /* UNIMPLEMENTED */
+#define SET_POWER_LIMIT                         SetPowerLimit                       /* UNIMPLEMENTED */
+#define ACTIVATE_POWER_LIMIT                    ActivatePowerLimit                  /* UNIMPLEMENTED */
+#define GET_ASSET_TAG                           GetAssetTag                         /* UNIMPLEMENTED */
+#define GET_DCMI_SENSOR_INFO                    GetDCMISensorInfo                   /* UNIMPLEMENTED */
+#define SET_ASSET_TAG                           SetAssetTag                         /* UNIMPLEMENTED */
+#define GET_MANAGEMENT_CONTROLLER_ID_STRING     GetManagementControllerIdString     /* UNIMPLEMENTED */
+#define SET_MANAGEMENT_CONTROLLER_ID_STRING     SetManagementControllerIdString     /* UNIMPLEMENTED */
+
+#define SET_THERMAL_LIMIT                       SetThermalLimit                          /* UNIMPLEMENTED */
+#define GET_THERMAL_LIMIT                       GetThermalLimit                          /* UNIMPLEMENTED */
+#define GET_TEMPERATURE_READING                   GetTemperatureReading                          /* UNIMPLEMENTED */
+#define GET_DCMI_CONFIG_PARAMS                   GetDCMIConfigParameters                          /* UNIMPLEMENTED */
+#define SET_DCMI_CONFIG_PARAMS                   SetDCMIConfigParameters                          /* UNIMPLEMENTED */
+
+/*---------------------------------------------------------------------------*
+ * ENABLE (OR) DISABLE INDIVIDUAL COMMANDS
+ *---------------------------------------------------------------------------*/
+
+/*----------------- IPMI Device "Global" Commands ---------------------------*/
+#define GET_DEV_ID				GetDevID				/*UNIMPLEMENTED*/
+#define BROADCAST_GET_DEV_ID  /*BroadCastGetDevID*/		  UNIMPLEMENTED
+#define COLD_RESET				ColdReset				/*UNIMPLEMENTED*/
+#define WARM_RESET			  	WarmReset				/*UNIMPLEMENTED*/
+#define GET_SELF_TEST_RESULTS	GetSelfTestResults		/*UNIMPLEMENTED*/
+#define MFG_TEST_ON				MfgTestOn				/*UNIMPLEMENTED*/
+#define SET_ACPI_PWR_STATE		SetACPIPwrState			/*UNIMPLEMENTED*/
+#define GET_ACPI_PWR_STATE		GetACPIPwrState			/*UNIMPLEMENTED*/
+#define GET_DEV_GUID			GetDevGUID				/*UNIMPLEMENTED*/
+#define GET_NETFN_SUP			GetNetFnSup				/*UNIMPLEMENTED*/
+#define GET_CMD_SUP				GetCmdSup				/*UNIMPLEMENTED*/
+#define GET_SUBFN_SUP			GetSubFnSup				/*UNIMPLEMENTED*/
+#define GET_CONFIG_CMDS			GetConfigCmds			/*UNIMPLEMENTED*/
+#define GET_CONFIG_SUB_FNS		GetConfigSubFns			/*UNIMPLEMENTED*/
+#define SET_CMD_ENABLES			SetCmdEnables			/*UNIMPLEMENTED*/
+#define GET_CMD_ENABLES			GetCmdEnables			/*UNIMPLEMENTED*/
+#define SET_SUBFN_ENABLES		SetSubFnEnables			/*UNIMPLEMENTED*/
+#define GET_SUBFN_ENABLES		GetSubFnEnables			/*UNIMPLEMENTED*/
+#define GET_OEM_NETFN_IANA_SUPPORT	GetOEMNetFnIANASupport		/*UNIMPLEMENTED*/
+
+/*------------------ BMC Watchdog Timer Commands ----------------------------*/
+#define RESET_WDT				ResetWDT				/*UNIMPLEMENTED*/
+#define SET_WDT					SetWDT					/*UNIMPLEMENTED*/
+#define GET_WDT					GetWDT					/*UNIMPLEMENTED*/
+
+/*------------------ BMC Device and Messaging Commands ----------------------*/
+#define SET_BMC_GBL_ENABLES		SetBMCGlobalEnables		/*UNIMPLEMENTED*/
+#define GET_BMC_GBL_ENABLES		GetBMCGlobalEnables		/*UNIMPLEMENTED*/
+#define CLR_MSG_FLAGS			ClrMsgFlags				/*UNIMPLEMENTED*/
+#define GET_MSG_FLAGS			GetMsgFlags				/*UNIMPLEMENTED*/
+#define ENBL_MSG_CH_RCV			EnblMsgChannelRcv		/*UNIMPLEMENTED*/
+#define GET_MSG					GetMessage				/*UNIMPLEMENTED*/
+#define SEND_MSG				SendMessage				/*UNIMPLEMENTED*/
+#define READ_EVT_MSG_BUFFER		ReadEvtMsgBuffer		/*UNIMPLEMENTED*/
+#define GET_BTIFC_CAP		    /*GetBTIfcCap*/			UNIMPLEMENTED
+#define GET_SYSTEM_GUID			GetSystemGUID			/*UNIMPLEMENTED*/
+#define GET_CH_AUTH_CAP			GetChAuthCap			/*UNIMPLEMENTED*/
+#define GET_SESSION_CHALLENGE	GetSessionChallenge		/*UNIMPLEMENTED*/
+#define ACTIVATE_SESSION		ActivateSession			/*UNIMPLEMENTED*/
+#define SET_SESSION_PRIV_LEVEL	SetSessionPrivLevel		/*UNIMPLEMENTED*/
+#define CLOSE_SESSION			CloseSession			/*UNIMPLEMENTED*/
+#define GET_SESSION_INFO		GetSessionInfo			/*UNIMPLEMENTED*/
+#define GET_AUTH_CODE			GetAuthCode				/*UNIMPLEMENTED*/
+#define SET_CH_ACCESS			SetChAccess				/*UNIMPLEMENTED*/
+#define GET_CH_ACCESS			GetChAccess				/*UNIMPLEMENTED*/
+#define GET_CH_INFO				GetChInfo				/*UNIMPLEMENTED*/
+#define SET_USER_ACCESS 		SetUserAccess			/*UNIMPLEMENTED*/
+#define GET_USER_ACCESS 		GetUserAccess			/*UNIMPLEMENTED*/
+#define SET_USER_NAME			SetUserName				/*UNIMPLEMENTED*/
+#define GET_USER_NAME			GetUserName				/*UNIMPLEMENTED*/
+#define SET_USER_PASSWORD		SetUserPassword			/*UNIMPLEMENTED*/
+#define GET_SYSTEM_INFO_PARAM	GetSystemInfoParam /*UNIMPLEMENTED*/
+#define SET_SYSTEM_INFO_PARAM	SetSystemInfoParam /*UNIMPLEMENTED*/
+
+#define ACTIVATE_PAYLOAD		ActivatePayload      	/*UNIMPLEMENTED*/
+#define DEACTIVATE_PAYLOAD		DeactivatePayload		/*UNIMPLEMENTED*/
+#define GET_PAYLD_ACT_STATUS	GetPayldActStatus		/*UNIMPLEMENTED*/
+#define GET_PAYLD_INST_INFO		GetPayldInstInfo		/*UNIMPLEMENTED*/
+#define SET_USR_PAYLOAD_ACCESS	SetUsrPayloadAccess		/*UNIMPLEMENTED*/
+#define GET_USR_PAYLOAD_ACCESS	GetUsrPayloadAccess		/*UNIMPLEMENTED*/
+#define GET_CH_PAYLOAD_SUPPORT	GetChPayloadSupport		/*UNIMPLEMENTED*/
+#define GET_CH_PAYLOAD_VER		GetChPayloadVersion		/*UNIMPLEMENTED*/
+#define GET_CH_OEM_PAYLOAD_INFO	GetChOemPayloadInfo		/*UNIMPLEMENTED*/
+
+#define MASTER_WRITE_READ		MasterWriteRead			/*UNIMPLEMENTED*/
+
+#define GET_CH_CIPHER_SUITES	GetChCipherSuites		/*UNIMPLEMENTED*/
+#define SUS_RES_PAYLOAD_ENCRYPT SusResPayldEncrypt		/*UNIMPLEMENTED*/
+#define SET_CH_SECURITY_KEYS	SetChSecurityKeys		/*UNIMPLEMENTED*/
+#define GET_SYS_IFC_CAPS		GetSysIfcCaps   		/*UNIMPLEMENTED*/
+
+/*--------------------- Chassis Device Commands ----------------------------*/
+#define GET_CHASSIS_CAPABILITIES	GetChassisCaps			/*UNIMPLEMENTED*/
+#define GET_CHASSIS_STATUS			GetChassisStatus		/*UNIMPLEMENTED*/
+#define CHASSIS_CONTROL				ChassisControl			/*UNIMPLEMENTED*/
+#define CHASSIS_RESET_CMD			/*ChassisReset*/		  UNIMPLEMENTED
+#define CHASSIS_IDENTIFY_CMD   		GetChassisIdentify		/*UNIMPLEMENTED*/
+#define SET_CHASSIS_CAPABILITIES	SetChassisCaps			/*UNIMPLEMENTED*/
+#define SET_POWER_RESTORE_POLICY	SetPowerRestorePolicy	/*UNIMPLEMENTED*/
+#define GET_SYSTEM_RESTART_CAUSE	GetSysRestartCause		/*UNIMPLEMENTED*/
+#define SET_SYSTEM_BOOT_OPTIONS		SetSysBOOTOptions		/*UNIMPLEMENTED*/
+#define GET_SYSTEM_BOOT_OPTIONS		GetSysBOOTOptions		/*UNIMPLEMENTED*/
+#define GET_POH_COUNTER				GetPOHCounter			/*UNIMPLEMENTED*/
+#define SET_FP_BTN_ENABLES			SetFPButtonEnables		/*UNIMPLEMENTED*/
+#define SET_POWER_CYCLE_INTERVAL	SetPowerCycleInterval	/*UNIMPLEMENTED*/
+
+/*----------------------- Event Commands -----------------------------------*/
+#define SET_EVENT_RECEIVER			SetEventReceiver		/*UNIMPLEMENTED*/
+#define GET_EVENT_RECEIVER			GetEventReceiver		/*UNIMPLEMENTED*/
+#define PLATFORM_EVENT				PlatformEventMessage	/*UNIMPLEMENTED*/
+
+/*--------------------- PEF and Alerting Commands --------------------------*/
+#define GET_PEF_CAPABILITIES		GetPEFCapabilities		/*UNIMPLEMENTED*/
+#define ARM_PEF_POSTPONE_TIMER		ArmPEFPostponeTimer		/*UNIMPLEMENTED*/
+#define SET_PEF_CONFIG_PARAMS		SetPEFConfigParams		/*UNIMPLEMENTED*/
+#define GET_PEF_CONFIG_PARAMS		GetPEFConfigParams		/*UNIMPLEMENTED*/
+#define SET_LAST_PROCESSED_EVENT_ID	SetLastProcessedEventId	/*UNIMPLEMENTED*/
+#define GET_LAST_PROCESSED_EVENT_ID	GetLastProcessedEventId	/*UNIMPLEMENTED*/
+#define ALERT_IMMEDIATE				AlertImmediate			/*UNIMPLEMENTED*/
+#define PET_ACKNOWLEDGE				PETAcknowledge			/*UNIMPLEMENTED*/
+
+/*----------------------- Sensor Device Commands -------------------------*/
+#define GET_DEV_SDR_INFO		   GetDevSDRInfo		  /*UNIMPLEMENTED*/
+#define GET_DEV_SDR				   GetDevSDR		  	  /*UNIMPLEMENTED*/
+#define RESERVE_DEV_SDR_REPOSITORY ReserveDevSDRRepository /*UNIMPLEMENTED*/
+#define GET_SENSOR_READING_FACTORS  GetSensorReadingFactors	/*UNIMPLEMENTED*/
+#define SET_SENSOR_HYSTERISIS		SetSensorHysterisis		/*UNIMPLEMENTED*/
+#define GET_SENSOR_HYSTERISIS		GetSensorHysterisis		/*UNIMPLEMENTED*/
+#define SET_SENSOR_THRESHOLDS		SetSensorThresholds		/*UNIMPLEMENTED*/
+#define GET_SENSOR_THRESHOLDS		GetSensorThresholds		/*UNIMPLEMENTED*/
+#define SET_SENSOR_EVENT_ENABLE		SetSensorEventEnable	/*UNIMPLEMENTED*/
+#define GET_SENSOR_EVENT_ENABLE		GetSensorEventEnable	/*UNIMPLEMENTED*/
+#define REARM_SENSOR_EVENTS		    ReArmSensor			    /*UNIMPLEMENTED*/
+#define GET_SENSOR_EVENT_STATUS	    GetSensorEventStatus	/*  UNIMPLEMENTED*/
+#define GET_SENSOR_READING		    GetSensorReading		/*UNIMPLEMENTED*/
+#define SET_SENSOR_READING		    SetSensorReading		/*UNIMPLEMENTED*/
+#define SET_SENSOR_TYPE			    SetSensorType			/*UNIMPLEMENTED*/
+#define GET_SENSOR_TYPE			    GetSensorType			/*UNIMPLEMENTED*/
+
+/*------------------------ FRU Device Commands ----------------------------*/
+#define GET_FRU_INVENTORY_AREA_INFO GetFRUAreaInfo			/*UNIMPLEMENTED*/
+#define READ_FRU_DATA				ReadFRUData				/*UNIMPLEMENTED*/
+#define WRITE_FRU_DATA				WriteFRUData			/*UNIMPLEMENTED*/
+
+/*----------------------- SDR Device Commands -----------------------------*/
+#define GET_SDR_REPOSITORY_INFO		GetSDRRepositoryInfo	/*UNIMPLEMENTED*/
+#define GET_SDR_REPOSITORY_ALLOCATION_INFO GetSDRRepositoryAllocInfo	/*UNIMPLEMENTED*/
+#define RESERVE_SDR_REPOSITORY		ReserveSDRRepository	/*UNIMPLEMENTED*/
+#define GET_SDR				GetSDR			/*UNIMPLEMENTED*/
+#define ADD_SDR						AddSDR					/*UNIMPLEMENTED*/
+#define PARTIAL_ADD_SDR				PartialAddSDR			/*UNIMPLEMENTED*/
+#define DELETE_SDR			DeleteSDR                   	/* UNIMPLEMENTED*/
+#define CLEAR_SDR_REPOSITORY		ClearSDRRepository		/*UNIMPLEMENTED*/
+#define GET_SDR_REPOSITORY_TIME		 GetSDRRepositoryTime	 /*UNIMPLEMENTED*/
+#define SET_SDR_REPOSITORY_TIME		 /*SetSDRRepositoryTime*/  UNIMPLEMENTED
+#define ENTER_SDR_REPOSITORY_UPDATE_MODE /*EnterSDRUpdateMode*/	UNIMPLEMENTED
+#define EXIT_SDR_REPOSITORY_UPDATE_MODE	 /*ExitSDRUpdateMode*/    UNIMPLEMENTED
+#define RUN_INITIALIZATION_AGENT	 RunInitializationAgent /*UNIMPLEMENTED*/
+
+/*------------------------- SEL Device Commands ---------------------------*/
+#define GET_SEL_INFO				GetSELInfo				/*UNIMPLEMENTED*/
+#define GET_SEL_ALLOCATION_INFO		GetSELAllocationInfo	/*UNIMPLEMENTED*/
+#define RESERVE_SEL					ReserveSEL				/*UNIMPLEMENTED*/
+#define GET_SEL_ENTRY				GetSELEntry				/*UNIMPLEMENTED*/
+#define ADD_SEL_ENTRY				AddSELEntry				/*UNIMPLEMENTED*/
+#define PARTIAL_ADD_SEL_ENTRY	    PartialAddSELEntry      /*UNIMPLEMENTED*/
+#define DELETE_SEL_ENTRY			DeleteSELEntry		    /*UNIMPLEMENTED*/
+#define CLEAR_SEL				    ClearSEL				/*UNIMPLEMENTED*/
+#define GET_SEL_TIME				GetSELTime				/*UNIMPLEMENTED*/
+#define SET_SEL_TIME				SetSELTime				/*UNIMPLEMENTED*/
+#define GET_AUXILIARY_LOG_STATUS    /*GetAuxiliaryLogStatus*/UNIMPLEMENTED
+#define SET_AUXILIARY_LOG_STATUS    /*SetAuxiliaryLogStatus*/UNIMPLEMENTED
+#define GET_SEL_TIME_UTC_OFFSET		GetSELTimeUTC_Offset	/*UNIMPLEMENTED*/
+#define SET_SEL_TIME_UTC_OFFSET		SetSELTimeUTC_Offset	/*UNIMPLEMENTED*/
+
+/*------------------------- LAN Device Commands ---------------------------*/
+#define SET_LAN_CONFIGURATION_PARAMETERS SetLanConfigParam	/*UNIMPLEMENTED*/
+#define GET_LAN_CONFIGURATION_PARAMETERS GetLanConfigParam	/*UNIMPLEMENTED*/
+#define SUSPEND_BMC_ARPS			     SuspendBMCArps      /*UNIMPLEMENTED*/
+#define GET_IP_UDP_RMCP_STATISTICS	   /*GetIPUDPRMCPStats*/  UNIMPLEMENTED
+
+/*----------------------- Serial/Modem Device Commands --------------------*/
+#define SET_SERIAL_MODEM_CONFIGURATION SetSerialModemConfig  	  		/*UNIMPLEMENTED*/
+#define GET_SERIAL_MODEM_CONFIGURATION GetSerialModemConfig				/*UNIMPLEMENTED*/
+#define SET_SERIAL_MODEM_MUX		   SetSerialModemMUX			  	/*UNIMPLEMENTED*/
+#define GET_TAP_RESPONSE			   GetTAPResponseCodes				/*UNIMPLEMENTED*/
+#define SET_PPP_UDP_PROXY_TRANSMIT_DATA/*SetPPPUDPProxyTransmitData*/	  UNIMPLEMENTED
+#define GET_PPP_UDP_PROXY_TRANSMIT_DATA/*GetPPPUDPProxyTransmitData*/	  UNIMPLEMENTED
+#define SEND_PPP_UDP_PROXY_PACKET	   /*SendPPPUDPProxyPacket*/		  UNIMPLEMENTED
+#define GET_PPP_UDP_PROXY_RECEIVE_DATA /*GetPPPUDPProxyReceiveData*/	  UNIMPLEMENTED
+#define SERIAL_MODEM_CONNECTION_ACTIVITY /*SerialModemConnectActive*/ 	  UNIMPLEMENTED
+#define CALLBACK					   CallBack						  	/*UNIMPLEMENTED*/
+#define SET_USER_CALLBACK_OPTIONS	   SetUserCallBackOptions		    /*UNIMPLEMENTED*/
+#define GET_USER_CALLBACK_OPTIONS	   GetUserCallBackOptions		  	/*UNIMPLEMENTED*/
+#define SOL_ACTIVATING_COMMAND		   SOLActivating		  			/*UNIMPLEMENTED*/
+#define GET_SOL_CONFIGURATION		   GetSOLConfig		  				/*UNIMPLEMENTED*/
+#define SET_SOL_CONFIGURATION		   SetSOLConfig		  				/*UNIMPLEMENTED*/
+
+/*--------------------- Bridge Management Commands (ICMB) ------------------*/
+#define GET_BRIDGE_STATE              GetBridgeState            /*UNIMPLEMENTED*/
+#define SET_BRIDGE_STATE              SetBridgeState            /*UNIMPLEMENTED*/
+#define GET_ICMB_ADDR                 GetICMBAddr				/*UNIMPLEMENTED*/
+#define SET_ICMB_ADDR                 SetICMBAddr				/*UNIMPLEMENTED*/
+#define SET_BRIDGE_PROXY_ADDR	      SetBridgeProxyAddr        /*UNIMPLEMENTED*/
+#define GET_BRIDGE_STATISTICS         GetBridgeStatistics       /*UNIMPLEMENTED*/
+#define GET_ICMB_CAPABILITIES         GetICMBCaps               /*UNIMPLEMENTED*/
+#define CLEAR_BRIDGE_STATISTICS       ClearBridgeStatistics     /*UNIMPLEMENTED*/
+#define GET_BRIDGE_PROXY_ADDR	      GetBridgeProxyAddr        /*UNIMPLEMENTED*/
+#define GET_ICMB_CONNECTOR_INFO       GetICMBConnectorInfo      /*UNIMPLEMENTED*/
+#define GET_ICMB_CONNECTION_ID        /*GetICMBConnectionID*/   UNIMPLEMENTED
+#define SEND_ICMB_CONNECTION_ID       /*SendICMBConnectionID*/  UNIMPLEMENTED
+
+/*--------------------- Discovery Commands (ICMB) --------------------------*/
+#define PREPARE_FOR_DISCOVERY		  PrepareForDiscovery		  /*UNIMPLEMENTED*/
+#define GET_ADDRESSES				  GetAddresses				  /*UNIMPLEMENTED*/
+#define SET_DISCOVERED				  SetDiscovered				  /*UNIMPLEMENTED*/
+#define GET_CHASSIS_DEVICE_ID		  GetChassisDeviceID		  /*UNIMPLEMENTED*/
+#define SET_CHASSIS_DEVICE_ID		  SetChassisDeviceID		  /*UNIMPLEMENTED*/
+
+/*--------------------- Bridging Commands (ICMB) ---------------------------*/
+#define BRIDGE_REQUEST				  BridgeReq					/*UNIMPLEMENTED*/
+#define BRIDGE_MESSAGE				  BridgeMsg					/*UNIMPLEMENTED*/
+
+/*-------------------- Event Commands (ICMB) -------------------------------*/
+#define GET_EVENT_COUNT               GetEventCount             /*UNIMPLEMENTED*/
+#define SET_EVENT_DESTINATION         SetEventDest				/*UNIMPLEMENTED*/
+#define SET_EVENT_RECEPTION_STATE     SetEventReceptionState    /*UNIMPLEMENTED*/
+#define SEND_ICMB_EVENT_MESSAGE       SendICMBEventMsg		    /*UNIMPLEMENTED*/
+#define GET_EVENT_DESTINATION         GetEventDest              /*UNIMPLEMENTED*/
+#define GET_EVENT_RECEPTION_STATE     GetEventReceptionState    /*UNIMPLEMENTED*/
+
+/*---------------- OEM Commands for Bridge NetFn ---------------------------*/
+//#define OEM										/* OemCmdHandler */						UNIMPLEMENTED
+
+// /*----------------- Other Bridge Commands ----------------------------------*/
+// #define ERROR_REPORT				  /*ErrorReport*/				UNIMPLEMENTED
+
+// /*-------------------- AMI Specific Commands -------------------------------*/
+// #define SET_SMTP_CONFIG_PARAMS     SetSMTPConfigParams /*UNIMPLEMENTED*/
+// #define GET_SMTP_CONFIG_PARAMS     GetSMTPConfigParams /*UNIMPLEMENTED*/
+
+// #define AMI_GET_NM_CHANNEL_NUM               AMIGetNMChNum /*UNIMPLEMENTED*/
+// #define AMI_GET_ETH_INDEX               AMIGetEthIndex /*UNIMPLEMENTED*/
+
+
+// /* AMI RESET PASSWORD AND USER EMAIL COMMANDS */
+// #define AMI_SET_EMAIL_USER			AMISetEmailForUser /*UNIMPLEMENTED*/
+// #define AMI_GET_EMAIL_USER			AMIGetEmailForUser /*UNIMPLEMENTED*/
+// #define AMI_RESET_PASS				AMIResetPassword /*UNIMPLEMENTED*/
+// #define AMI_SET_EMAILFORMAT_USER			AMISetEmailFormatUser /*UNIMPLEMENTED*/
+// #define AMI_GET_EMAILFORMAT_USER			AMIGetEmailFormatUser /*UNIMPLEMENTED*/
+
+// //Linux Root User Access Commands
+// #define AMI_GET_ROOT_USER_ACCESS		AMIGetRootUserAccess   	/*UNIMPLEMENTED*/
+// #define AMI_SET_ROOT_PASSWORD			AMISetRootPassword    	/*UNIMPLEMENTED*/
+
+
+// /* AMI Restore Default commands */
+// #define AMI_RESTORE_DEF			AMIRestoreDefaults /*UNIMPLEMENTED*/
+// #define AMI_SET_PRESERVE_CONF			AMISetPreserveConfStatus /*UNIMPLEMENTED*/
+// #define AMI_GET_PRESERVE_CONF			AMIGetPreserveConfStatus /*UNIMPLEMENTED*/
+// #define AMI_SET_ALL_PRESERVE_CONF               AMISetAllPreserveConfStatus /*UNIMPLEMENTED*/
+// #define AMI_GET_ALL_PRESERVE_CONF               AMIGetAllPreserveConfStatus /*UNIMPLEMENTED*/
+
+// /* AMI log configuration commands */
+// #define AMI_GET_LOG_CONF			AMIGetLogConf /*UNIMPLEMENTED*/
+// #define AMI_SET_LOG_CONF			AMISetLogConf /*UNIMPLEMENTED*/
+// /* AMI Get Bios code */
+// #define AMI_GET_BIOS_CODE           AMIGetBiosCode /*UNIMPLEMENTED*/
+// /*Setting and Getting Time Zone commands*/
+// #define AMI_SET_TIMEZONE              AMISetTimeZone /*UNIMPLEMENTED*/
+// #define AMI_GET_TIMEZONE              AMIGetTimeZone /*UNIMPLEMENTED*/
+
+// #define AMI_GET_NTP_CFG             AMIGetNTPCfg
+// #define AMI_SET_NTP_CFG             AMISetNTPCfg
+
+// #ifndef CONFIG_SPX_FEATURE_IPMI_NO_YAFU_SUPPORT
+// #define AMI_YAFU_SWITCH_FLASH_DEVICE              AMIYAFUSwitchFlashDevice
+// #define AMI_YAFU_RESTORE_FLASH_DEVICE               AMIYAFURestoreFlashDevice
+// #define AMI_YAFU_GET_FLASH_INFO        		AMIYAFUGetFlashInfo              /*UNIMPLEMENTED*/
+// #define AMI_YAFU_GET_FIRMWARE_INFO 		AMIYAFUGetFirmwareInfo       /*UNIMPLEMENTED*/
+// #define AMI_YAFU_GET_FMH_INFO            		AMIYAFUGetFMHInfo               /*UNIMPLEMENTED*/
+// #define AMI_YAFU_GET_STATUS                		AMIYAFUGetStatus                  /*UNIMPLEMENTED*/
+// #define AMI_YAFU_ACTIVATE_FLASH         		AMIYAFUActivateFlashMode   /*UNIMPLEMENTED*/
+// #define AMI_YAFU_ALLOCATE_MEMORY      		AMIYAFUAllocateMemory       /*UNIMPLEMENTED*/
+// #define AMI_YAFU_FREE_MEMORY              		AMIYAFUFreeMemory             /*UNIMPLEMENTED*/
+// #define AMI_YAFU_READ_FLASH                 		AMIYAFUReadFlash                 /*UNIMPLEMENTED*/
+// #define AMI_YAFU_WRITE_FLASH		      		AMIYAFUWriteFlash	             /*UNIMPLEMENTED*/
+// #define AMI_YAFU_ERASE_FLASH               		AMIYAFUEraseFlash              /*UNIMPLEMENTED*/
+// #define AMI_YAFU_PROTECT_FLASH           		AMIYAFUProtectFlash		/*UNIMPLEMENTED*/
+// #define AMI_YAFU_ERASE_COPY_FLASH     		AMIYAFUEraseCopyFlash      /*UNIMPLEMENTED*/
+// #define AMI_YAFU_GET_ECF_STATUS			AMIYAFUGetECFStatus
+// #define AMI_YAFU_GET_VERIFY_STATUS		AMIYAFUGetVerifyStatus
+// #define AMI_YAFU_VERIFY_FLASH              		AMIYAFUVerifyFlash              /*UNIMPLEMENTED*/
+// #define AMI_YAFU_READ_MEMORY              		AMIYAFUReadMemory           /*UNIMPLEMENTED*/
+// #define AMI_YAFU_WRITE_MEMORY            		AMIYAFUWriteMemory          /*UNIMPLEMENTED*/
+// #define AMI_YAFU_COPY_MEMORY              		AMIYAFUCopyMemory           /*UNIMPLEMENTED*/
+// #define AMI_YAFU_COMPARE_MEMORY       		AMIYAFUCompareMemory    /*UNIMPLEMENTED*/
+// #define AMI_YAFU_CLEAR_MEMORY            		AMIYAFUClearMemory          /*UNIMPLEMENTED*/
+// #define AMI_YAFU_GET_BOOT_CONFIG      		AMIYAFUGetBootConfig        /*UNIMPLEMENTED*/
+// #define AMI_YAFU_SET_BOOT_CONFIG      		AMIYAFUSetBootConfig        /*UNIMPLEMENTED*/
+// #define AMI_YAFU_GET_BOOT_VARS          		AMIYAFUGetBootVars          /*UNIMPLEMENTED*/
+// #define AMI_YAFU_DEACTIVATE_FLASH_MODE   AMIYAFUDeactivateFlash   /*UNIMPLEMENTED*/
+// #define AMI_YAFU_RESET_DEVICE   			AMIYAFUResetDevice         /*UNIMPLEMENTED*/
+// #define AMI_YAFU_DUAL_IMG_SUP                     AMIYAFUDualImgSup
+// #define AMI_YAFU_FIRMWARE_SELECT_FLASH  AMIYAFUFWSelectFlash
+// #define AMI_YAFU_SIGNIMAGEKEY_REPLACE  AMIYAFUReplaceSignedImageKey /* UNIMPLEMENTED */
+// #endif
+
+// /*--------------------------AMI TFTP Update Commands--------------------------*/
+// #define AMI_START_TFTP_FW_UPDATE                AMIStartTFTPFwUpdate
+// #define AMI_GET_TFTP_FW_PROGRESS_STATUS         AMIGetTftpProgressStatus
+// #define AMI_SET_FW_CONFIGURATION                AMISetFWCfg
+// #define AMI_GET_FW_CONFIGURATION                AMIGetFWCfg
+// #define AMI_SET_FW_PROTOCOL                     AMISetFWProtocol
+// #define AMI_GET_FW_PROTOCOL                     AMIGetFWProtocol
+
+// #define AMI_GET_IPMI_SESSION_TIMEOUT            AMIGetIPMISessionTimeOut
+
+// /*------------------------Get UDS related Commands-------------------------------------------------*/
+// #define AMI_GET_UDS_CHANNEL_INFO     AMIGetUDSInfo                /* UNIMPLEMENTED */
+// #define AMI_GET_UDS_SESSION_INFO     AMIGetUDSSessionInfo         /* UNIMPLEMENTED */
+
+// /*-------------------------AMI Dual Image Support command------------------------*/
+// #define AMI_DUAL_IMG_SUPPORT AMIDualImageSupport
+
+// /*------------------------ AMI Control Debug Messages Commands--------------------*/
+// #define AMI_CTL_DBG_MSG     AMIControlDebugMsg
+// #define AMI_GET_DBG_MSG_STATUS      AMIGetDebugMsgStatus
+
+// #define AMI_SET_PWD_ENCRYPTION_KEY              AMISetPwdEncryptionKey
+// /*--------------------------AMI Service Commands ------------------------------------*/
+// #define AMI_GET_SERVICE_CONF                AMIGetServiceConf             /*UNIMPLEMENTED*/
+// #define AMI_SET_SERVICE_CONF                AMISetServiceConf             /*UNIMPLEMENTED*/
+// #define AMI_LINK_DOWN_RESILENT           AMILinkDownResilent         /*UNIMPLEMENTED*/
+
+// /*--------------------------AMI DNS Commands ------------------------------------*/
+// #define AMI_GET_DNS_CONF                AMIGetDNSConf             /*UNIMPLEMENTED*/
+// #define AMI_SET_DNS_CONF                AMISetDNSConf             /*UNIMPLEMENTED*/
+
+// /*--------------------------AMI Network Interface State Commands ------------------------------------*/
+// #define AMI_SET_IFACE_STATE         AMISetIfaceState             /*UNIMPLEMENTED*/
+// #define AMI_GET_IFACE_STATE         AMIGetIfaceState            /*UNIMPLEMENTED*/
+
+// /*------------------------ AMI FIREWALL - Iptables Commands -----------------------------------------*/
+// #define AMI_SET_FIREWALL			AMISetFirewall				/*UNIMPLEMENTED*/
+// #define AMI_GET_FIREWALL			AMIGetFirewall				/*UNIMPLEMENTED*/
+
+// /*------------------------ AMI FRU Details Commands -----------------------------------------*/
+// #define AMI_GET_FRU_DETAILS			AMIGetFruDetails			/*UNIMPLEMENTED*/
+
+// /*------------------------ AMI PAM Reordering Command---------------------------------------*/
+// #define AMI_SET_PAM_ORDER			AMISetPamOrder			/*UNIMPLEMENTED*/
+// #define AMI_GET_PAM_ORDER			AMIGetPamOrder			/*UNIMPLEMENTED*/
+
+// /*                                           AMI SNMP Commands----------------------------------------------*/
+// #define AMI_GET_SNMP_CONF         AMIGetSNMPConf                          /* UNIMPLEMENTED */
+// #define AMI_SET_SNMP_CONF         AMISetSNMPConf                          /* UNIMPLEMENTED */
+
+// /*----------------------------- AMI SEL Commands -----------------------------*/
+// #define AMI_GET_SEL_POLICY          AMIGetSELPolicy         /* UNIMPLEMENTED */
+// #define AMI_SET_SEL_POLICY          AMISetSELPolicy         /* UNIMPLEMENTED */
+// #define AMI_GET_SEL_ENTRIES           AMIGetSELEntires       /* UNIMPLEMENTED */
+
+// /*------------------------------AMI SensorInfo Commands -----------------------*/
+// #define AMI_GET_SENSOR_INFO         AMIGetSenforInfo        /*UNIMPLEMENTED*/
+// /*--------------------------APML Specific Commands ------------------------------------*/
+// //SB-RMI
+// #define APML_GET_INTERFACE_VERSION	ApmlGetInterfaceVersion   /*UNIMPLEMENTED*/ //APML
+// #define APML_READ_RMI_REG			ApmlReadRMIReg	/*UNIMPLEMENTED*/
+// #define APML_WRITE_RMI_REG			ApmlWriteRMIReg	/*UNIMPLEMENTED*/
+// #define APML_READ_CPUID				ApmlReadCPUId	/*UNIMPLEMENTED*/
+// #define APML_READ_HTC_REG			ApmlReadHTCReg	/*UNIMPLEMENTED*/
+// #define APML_WRITE_HTC_REG			ApmlWriteHTCReg	/*UNIMPLEMENTED*/
+// #define APML_READ_PSTATE			ApmlReadPState	/*UNIMPLEMENTED*/
+// #define APML_READ_MAX_PSTATE		ApmlReadMaxPState	/*UNIMPLEMENTED*/
+// #define APML_READ_PSTATE_LIMIT		ApmlReadPStateLimit	/*UNIMPLEMENTED*/
+// #define APML_WRITE_PSTATE_LIMIT		ApmlWritePStateLimit	/*UNIMPLEMENTED*/
+// #define APML_READ_MCR				ApmlReadMCR	/*UNIMPLEMENTED*/
+// #define APML_WRITE_MCR				ApmlWriteMCR	/*UNIMPLEMENTED*/
+// // SB-TSI
+// #define APML_READ_TSI_REG			ApmlReadTSIReg	/*UNIMPLEMENTED*/
+// #define APML_WRITE_TSI_REG			ApmlWriteTSIReg	/*UNIMPLEMENTED*/
+// #define APML_READ_TDP_LIMIT_REG                 ApmlReadTDPLimitReg       /*UNIMPLEMENTED*/ 
+// #define APML_WRITE_TDP_LIMIT_REG                ApmlWriteTDPLimitReg      /*UNIMPLEMENTED*/ 
+// #define APML_READ_PROCESSOR_POWER_REG           ApmlReadProcessorPowerReg /*UNIMPLEMENTED*/ 
+// #define APML_READ_POWER_AVERAGING_REG           ApmlReadPowerAveragingReg /*UNIMPLEMENTED*/ 
+// #define APML_READ_DRAM_THROTTLE_REG             ApmlReadDramThrottleReg   /*UNIMPLEMENTED*/ 
+// #define APML_WRITE_DRAM_THROTTLE_REG            ApmlWriteDramThrottleReg  /*UNIMPLEMENTED*/
+
+// /*------------------------APML Commands ends here--------------------------------------*/
+
+// /*------------------------OPMA Specific Commands ---------------------------------------*/
+
+// #define SET_SENSOR_READING_OFFSET               SetSensorReadingOffset      /*UNIMPLEMENTED*/
+// #define GET_SENSOR_READING_OFFSET               GetSensorReadingOffset      /*UNIMPLEMENTED*/
+
+// #define SET_SYSTEM_TYPE_IDENTIFIER              SetSystemTypeIdentifier     /*UNIMPLEMENTED*/
+// #define GET_SYSTEM_TYPE_IDENTIFIER              GetSystemTypeIdentifier     /*UNIMPLEMENTED*/
+// #define GET_MCARD_CAPABLITITES                      GetmCardCapabilities            /*UNIMPLEMENTED*/
+// #define CLEAR_CMOS                                              ClearCMOS                               /*UNIMPLEMENTED*/
+// #define SET_LOCAL_ACCESS_LOCKOUT_STATE      SetLocalAccessLockOutState      /*UNIMPLEMENTED*/
+// #define GET_LOCAL_ACCESS_LOCKOUT_STATE      GetLocalAccessLockOutState      /*UNIMPLEMENTED*/
+// #define GET_SUPPORTED_HOST_IDS                      GetSupportedHostIDs                 /*UNIMPLEMENTED*/
+
+// /*------------------------OPMA Commands ends here--------------------------------------*/
+
+// /*--------------------------PNM Specific Commands ------------------------------------*/
+// #define PNM_OEM_GET_READING	        PnmOemGetReading   /*UNIMPLEMENTED*/
+// #define PNM_OEM_ME_POWER_STATE_CHANGE  PnmOemMePowerStateChange	/*UNIMPLEMENTED*/
+
+// /*------------------------PNM Commands ends here--------------------------------------*/
+
+
+// /*------------------------User Shell related commands --------------------------------------*/
+
+// #define AMI_SET_USER_SHELLTYPE  AMISetUserShelltype	/*UNIMPLEMENTED*/
+// #define AMI_GET_USER_SHELLTYPE  AMIGetUserShelltype	/*UNIMPLEMENTED*/
+
+// /*------------------------User Shell related commands --------------------------------------*/
+
+// /*------------------------UserFlag  related commands --------------------------------------*/
+
+// #define AMI_SET_EXTENDED_PRIV  AMISetExtendedPrivilege     /*UNIMPLEMENTED*/
+// #define AMI_GET_EXTENDED_PRIV  AMIGetExtendedPrivilege    /*UNIMPLEMENTED*/
+
+// /*------------------------UserFlag related commands ends here-------------------------------------*/
+
+// /*------------------------Set Trigger Event Configuration-------------------------------------------------*/
+// #define AMI_SET_TRIGGER_EVT    AMISetTriggerEvent              /*UNIMPLEMENTED*/
+// /*------------------------Set Trigger Event Configuration-------------------------------------------------*/
+
+// /*------------------------Get Trigger Event Configuration-------------------------------------------------*/
+// #define AMI_GET_TRIGGER_EVT    AMIGetTriggerEvent              /*UNIMPLEMENTED*/
+// /*------------------------Get Trigger Event Configuration-------------------------------------------------*/
+
+// /*------------------------Get SOL Configuration-------------------------------------------------*/
+// #define AMI_GET_SOL_CONF    AMIGetSolConf              /*UNIMPLEMENTED*/
+// /*------------------------Get SOL Configuration-------------------------------------------------*/
+
+// /*------------------------Set Login Audit Configuration-------------------------------------------------*/
+// #define AMI_SET_LOGIN_AUDIT_CFG    AMISetLoginAuditConfig              /*UNIMPLEMENTED*/
+// /*------------------------Set Login Audit Configuration-------------------------------------------------*/
+
+// /*------------------------Get Login Audit Configuration-------------------------------------------------*/
+// #define AMI_GET_LOGIN_AUDIT_CFG    AMIGetLoginAuditConfig              /*UNIMPLEMENTED*/
+// /*------------------------Get Login Audit Configuration-------------------------------------------------*/
+
+// /*------------------------Get All IPv6 address-------------------------------------------------*/
+// #define AMI_GET_IPV6_ADDRESS          AMIGetAllIPv6Address               /*UNIMPLEMENTED*/
+// /*------------------------Get All IPv6 address-------------------------------------------------*/
+// /*------------------------------Set Virtual Device-----------------------------------------*/
+// #define AMI_VIRTUAL_DEVICE_GET_STATUS AMIVirtualDeviceGetStatus			/*UNIMPLEMENTED*/
+// #define AMI_VIRTUAL_DEVICE_SET_STATUS AMIVirtualDeviceSetStatus			/*UNIMPLEMENTED*/
+// /*------------------------------------------------------------------------------------------*/
+// /*------------------------U-boot Memory Test Command----------------------------------------*/
+// #define AMI_SET_UBOOT_MEMTEST       AMISetUBootMemtest               /*UNIMPLEMENTED*/
+// #define AMI_GET_UBOOT_MEMTEST_STATUS        AMIGetUBootMemtestStatus  /*UNIMPLEMENTED*/
+// /*------------------------U-boot Memory Test Command----------------------------------------*/
+
+// /*-----------------------------------------License Support Commands---------------------------*/
+// #define AMI_GET_LICENSE_VALIDITY AMIGetLicenseValidity
+// #define AMI_ADD_LICENSE_KEY AMIAddLicenseKey
+// /*-----------------------------------------License Support Commands----------------------------*/
+
+// #define AMI_GET_CHANNEL_TYPE  AMIGetChannelType
+// /*_______________________________________________________________________________________________*/
+// /*------------------------------------- AMI CMM  Commands ---------------------------------------*/
+//          /*---------------------------- CMM Commands -------------------------------*/
+// #define AMI_GET_SLOT_MAP_INFO           AMIGetSlotMapInfo               /*UNIMPLEMENTED*/
+// #define AMI_GET_SLOT_INFO               AMIGetSlotInfo                  /*UNIMPLEMENTED*/
+// #define AMI_GET_PWR_INFO                AMIGetPwrInfo                   /*UNIMPLEMENTED*/
+// #define AMI_GET_PWR_DOM_INFO            AMIGetPwrDomInfo                /*UNIMPLEMENTED*/
+// #define AMI_GET_PWR_SUPPLY_INFO         AMIGetPwrSupplyInfo             /*UNIMPLEMENTED*/
+// #define AMI_GET_COOLING_INFO            AMIGetCoolingInfo               /*UNIMPLEMENTED*/
+// #define AMI_GET_COOLING_DOM_INFO        AMIGetCoolingDomInfo            /*UNIMPLEMENTED*/
+// #define AMI_GET_FAN_INFO                AMIGetFanInfo                   /*UNIMPLEMENTED*/
+// #define AMI_GET_BLADE_STATUS            AMIGetBladeStatus               /*UNIMPLEMENTED*/
+// #define AMI_ETH_RESTART_ALL             AMIEthRestartAll                /*UNIMPLEMENTED*/
+
+// /*--------------------------------------OBSM Specific Commands -----------------------------------*/
+//          /*---------------------------- OBSM Commands -------------------------------*/
+// #define OBSM_GET_OPEN_BLADE_PROPS       OBSMGetOpenBladeProps           /*UNIMPLEMENTED*/
+// #define OBSM_GET_ADDR_INFO              OBSMGetAddrInfo                 /*UNIMPLEMENTED*/
+// #define OBSM_PLATFORM_EVT_MSG           OBSMPlatformEvtMsg              /*UNIMPLEMENTED*/
+// #define OBSM_MGD_MOD_BMI_CTRL           /*OBSMManagedModuleBMICtrl*/    UNIMPLEMENTED
+// #define OBSM_MGD_MOD_PAYLD_CTRL         /*OBSMManagedModulePayldCtrl*/  UNIMPLEMENTED
+// #define OBSM_SET_SYS_EVNT_LOG_POLICY    /*OBSMSetSysEvntLogPolicy*/     UNIMPLEMENTED
+// #define OBSM_SET_MOD_ACTVN_POLICY       /*OBSMSetModuleActvnPolicy*/    UNIMPLEMENTED
+// #define OBSM_GET_MOD_ACTVN_POLICY       /*OBSMGetModuleActvnPolicy*/    UNIMPLEMENTED
+// #define OBSM_SET_MOD_ACTVN              /*OBSMSetModuleActivation*/     UNIMPLEMENTED
+// #define OBSM_SET_POWER_LEVEL            /*OBSMSetPowerLevel*/           UNIMPLEMENTED
+// #define OBSM_GET_POWER_LEVEL            /*OBSMGetPowerLevel*/           UNIMPLEMENTED
+// #define OBSM_RENOG_POWER                /*OBSMRenegotiatePower*/        UNIMPLEMENTED
+// #define OBSM_GET_SERVICE_INFO           /*OBSMGetServiceInfo*/          UNIMPLEMENTED
+// #define OBSM_GET_APPLET_PACKAGE_URI     /*OBSMGetAppletPackageURI*/     UNIMPLEMENTED
+// #define OBSM_GET_SERVICE_ENABLE_STATE   /*OBSMGetServiceEnableState*/   UNIMPLEMENTED
+// #define OBSM_SET_SERVICE_ENABLE_STATE   /*OBSMSetServiceEnableState*/   UNIMPLEMENTED
+// #define OBSM_SET_SERVICE_TICKET         /*OBSMSetServiceTiecket*/       UNIMPLEMENTED
+// #define OBSM_STOP_SERVICE_SESSION       /*OBSMStopServiceSession*/      UNIMPLEMENTED
+
+//              /*------------------------ Debug OBSM Commands -------------------------*/
+// #define DBG_GET_CHASSIS_PWR_INFO        DbgGetChassisPwrInfo            /*UNIMPLEMENTED*/
+// #define DBG_GET_CHASSIS_COOLING_INFO    DbgGetChassisCoolingInfo        /*UNIMPLEMENTED*/
+// #define DBG_GET_BLADE_INFO              DbgGetBladeInfo                 /*UNIMPLEMENTED*/
+// #define DBG_BLADE_INS_REM_EVT           DbgBladeInsRemEvent             /*UNIMPLEMENTED*/
+// #define DBG_PS_STATE_CHANGE_EVT         DbgPSStateChangeEvent           /*UNIMPLEMENTED */
+// #define DBG_FAN_STATE_CHANGE_EVT        DbgFanStateChangeEvent          /*UNIMPLEMENTED */
+// #define DBG_THERMAL_STATE_CHANGE_EVT    DbgThermalStateChangeEvent      /*UNIMPLEMENTED */
+
+// /*________________________________AMI CMM Commands ends here ____________________________________*/
+// /*-----------------------------------------------------------------------------------------------*/
+
+// /*-------------------------- SSI Compute Blade Specific Commands ---------------------------------------*/
+// #define SSICB_GET_COMPUTE_BLADE_PROPERTIES  SSICB_GetComputeBladeProperties /* UNIMPLEMENTED */
+// #define SSICB_GET_ADDR_INFO                 SSICB_GetAddrInfo               /* UNIMPLEMENTED */
+// #define SSICB_PLATFORM_EVENT_MESSAGE        SSICB_PlatformEventMessage      /* UNIMPLEMENTED */
+// #define SSICB_MODULE_BMI_CONTROL            SSICB_ModuleBMIControl          /* UNIMPLEMENTED */
+// #define SSICB_MODULE_PAYLOAD_CONTROL        SSICB_ModulePayloadControl      /* UNIMPLEMENTED */
+// #define SSICB_SET_SYSTEM_EVENT_LOG_POLICY   SSICB_SetSystemEventLogPolicy   /* UNIMPLEMENTED */
+// #define SSICB_SET_MODULE_ACTIVATION_POLICY  SSICB_SetModuleActivationPolicy /* UNIMPLEMENTED */
+// #define SSICB_GET_MODULE_ACTIVATION_POLICY  SSICB_GetModuleActivationPolicy /* UNIMPLEMENTED */
+// #define SSICB_SET_MODULE_ACTIVATION         SSICB_SetModuleActivation       /* UNIMPLEMENTED */
+// #define SSICB_SET_POWER_LEVEL               SSICB_SetPowerLevel             /* UNIMPLEMENTED */
+// #define SSICB_GET_POWER_LEVEL               SSICB_GetPowerLevel             /* UNIMPLEMENTED */
+// #define SSICB_RENEGOTIATE_POWER             SSICB_RenegotiatePower          /* UNIMPLEMENTED */
+// #define SSICB_GET_SERVICE_INFO              SSICB_GetServiceInfo            /* UNIMPLEMENTED */
+// #define SSICB_GET_APPLET_PACKAGE_URI        SSICB_GetAppletPackageURI       /* UNIMPLEMENTED */
+// #define SSICB_GET_SERVICE_ENABLE_STATE      SSICB_GetServiceEnableState     /* UNIMPLEMENTED */
+// #define SSICB_SET_SERVICE_ENABLE_STATE      SSICB_SetServiceEnableState     /* UNIMPLEMENTED */
+// #define SSICB_SET_SERVICE_TICKET            SSICB_SetServiceTicket          /* UNIMPLEMENTED */
+// #define SSICB_STOP_SERVICE_SESSION          SSICB_StopServiceSession        /* UNIMPLEMENTED */
+// /*-------------------------- SSI Compute Blade Commands ends here --------------------------------------*/
+
+// /*-------------------- PICMG HPM Specific Commands -------------------------------*/
+// #define GET_TARGET_UPLD_CAPABLITIES   GetTargetUpgradeCapablities  /*UNIMPLEMENTED*/
+// #define GET_COMPONENT_PROPERTIES      GetComponentProperties       /*UNIMPLEMENTED*/
+// #define INITIATE_UPGRADE_ACTION		  InitiateUpgradeAction		   /*UNIMPLEMENTED*/	
+// #define QUERY_SELF_TEST_RESULTS       QuerySelfTestResults         /*UNIMPLEMENTED*/
+// #define ABORT_FIRMWARE_UPGRADE        AbortFirmwareUpgrade         /*UNIMPLEMENTED*/
+// #define UPLOAD_FIRMWARE_BLOCK         UploadFirmwareBlock          /*UNIMPLEMENTED*/
+// #define FINISH_FIRMWARE_UPLOAD        FinishFirmwareUpload         /*UNIMPLEMENTED*/
+// #define GET_UPGRADE_STATUS            GetUpgradeStatus             /*UNIMPLEMENTED*/
+// #define ACTIVATE_FIRMWARE             ActivateFirmware             /*UNIMPLEMENTED*/
+// #define QUERY_ROLLBACK_STATUS         QueryRollbackStatus          /*UNIMPLEMENTED*/
+// #define INITIATE_MANUAL_ROLLBACK      InitiateManualRollback       /*UNIMPLEMENTED*/
+
+// /*--------------------------AMI Service Commands ------------------------------------*/
+// #define AMI_GET_RIS_CONF            AMIGetRISConf           /*UNIMPLEMENTED*/
+// #define AMI_SET_RIS_CONF            AMISetRISConf           /*UNIMPLEMENTED*/
+// #define AMI_RIS_START_STOP          AMIRISStartStop         /*UNIMPLEMENTED*/
+
+// /*--------------------------AMI Host Monitor Lock Commands ------------------------------------*/
+// #define AMI_GET_HOST_LOCK_FEATURE_STATUS            AMIGetHostLockFeatureStatus           /*UNIMPLEMENTED*/
+// #define AMI_SET_HOST_LOCK_FEATURE_STATUS            AMISetHostLockFeatureStatus           /*UNIMPLEMENTED*/
+// #define AMI_GET_HOST_AUTO_LOCK_STATUS            AMIGetHostAutoLockStatus           /*UNIMPLEMENTED*/
+// #define AMI_SET_HOST_AUTO_LOCK_STATUS            AMISetHostAutoLockStatus           /*UNIMPLEMENTED*/
+// /*---------------------------------------------------------------------------*
+//  * ENABLE (OR) DISABLE INDIVIDUAL DEVICES BASED ON INTERFACE SELECTED
+//  *---------------------------------------------------------------------------*/
+// #if	SUPPORT_ICMB_IFC == 0
+// #undef	BRIDGE_DEVICE
+// #define BRIDGE_DEVICE				0
+// #endif
+
+
+#if EVENT_PROCESSING_DEVICE == 1
+#define EVENT_GENERATOR         1
+#define EVENT_RECEIVER          1
+#else
+#define EVENT_GENERATOR         0
+#define EVENT_RECEIVER          0
+#endif
+
+
+#if	DELETE_SDR 	!= UNIMPLEMENTED
+#define MARK_FOR_DELETION_SUPPORT  0x00	/* 0x01 to mark records for deletion */
+#endif
+
+
+
+/***************************  Oem -Specific Commands **********************************/
+#if OEM_DEVICE	==   1
+#include "OemCmdSupport.h"
+#endif // OEM_DEVICE	!=   1
+
+ #endif /* SUPPORT_H */

+ 366 - 0
app/bmc/msghndlr/Transport/Badpasswd.c

@@ -0,0 +1,366 @@
+// /******************************************************************
+//  ******************************************************************
+//  ***                                                                                                           **
+//  ***    (C)Copyright 2006-2009, American Megatrends Inc.                            **
+//  ***                                                                                                           **
+//  ***    All Rights Reserved.                                                                          **
+//  ***                                                                                                           **
+//  ***    5555 , Oakbrook Pkwy, Norcross,                                                       **
+//  ***                                                                                                           **
+//  ***    Georgia - 30093, USA. Phone-(770)-246-8600.                                  **
+//  ***                                                                                                           **
+//  ******************************************************************
+//  ******************************************************************
+//  ******************************************************************
+//  *
+//  * Badpasswd.c
+//  * Badpasswd related codes
+//  *
+//  *  Author: Winston <winstonv@amiindia.co.in>
+//  ******************************************************************/
+
+
+// #include "types.h"
+// #include "Debug.h"
+// #include "PMConfig.h"
+// #include "Session.h"
+// #include "MsgHndlr.h"
+// #include "Ethaddr.h"
+// #include "Badpasswd.h"
+// #include "NVRData.h"
+// #include "NVRAccess.h"
+// #include "SensorMonitor.h"
+// #include "SharedMem.h"
+// #include "IPMIConf.h"
+
+// /*
+// *@fn CheckPasswordViolation
+// *@param SerialorLAN - Denotes the channnel number is Serial or LAN
+// *@param Ch - Channel Number 
+// *@return Returns 0
+// */
+// int CheckPasswordViolation(INT8U SerialorLAN,INT8U Ch )
+// {
+//     int j,EthIndex=0;
+//     INT8U Index=0,ThresholdVal=0;
+//     ChannelInfo_T*pChannelInfo=NULL;
+//     BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+//     ChannelUserInfo_T*  pChUserInfo = NULL;
+//     INT16U AttemptResetInterval = 0,LockOutInterval =0;
+
+//     if(SerialorLAN == LAN_CHANNEL_BADP)
+//     {
+//         EthIndex = GetEthIndex(Ch,BMCInst);
+//         ThresholdVal = pBMCInfo->LANCfs[EthIndex].BadPasswd.ThreshNum;
+//         AttemptResetInterval = pBMCInfo->LANCfs[EthIndex].BadPasswd.ResetInterval;
+//         LockOutInterval = pBMCInfo->LANCfs[EthIndex].BadPasswd.LockoutInterval;
+//     }
+//     else if(SerialorLAN == SERIAL_CHANNEL_BADP)
+//     {
+//         ThresholdVal = pBMCInfo->SMConfig.BadPasswd.ThreshNum;
+//         AttemptResetInterval = pBMCInfo->SMConfig.BadPasswd.ResetInterval;
+//         LockOutInterval = pBMCInfo->SMConfig.BadPasswd.LockoutInterval;
+//     }
+//     else
+//     {
+//         /* Bad Password validation has to be done for only 
+//              Serial and LAN Interface */
+//         return 0;
+//     }
+
+//     if(ThresholdVal != 0)
+//     {
+//         pChannelInfo = getChannelInfo(Ch,BMCInst);
+//         if(NULL == pChannelInfo)
+//         {
+//             TDBG("Unable to get Channel Info to Check Password Violation for channel : %d \n",Ch);
+//             return 0;
+//         }
+
+//         if(pChannelInfo != NULL)
+//         {
+//             for(j=1;j<=g_BMCInfo[BMCInst].IpmiConfig.MaxUsers;j++)
+//             {
+//                 pChUserInfo = getChUserIdInfo(j,&Index,pChannelInfo->ChannelUserInfo,BMCInst);
+//                 if(pChUserInfo != NULL)
+//                 {
+//                     if((pChUserInfo->LockedTime != 0) && (pChUserInfo->Lock == USER_LOCKED)
+//                         && (LockOutInterval != 0))
+//                     {
+//                         if((TimeUpdate() -  pChUserInfo->LockedTime) > (10 * LockOutInterval))
+//                         {
+//                             pChUserInfo->Lock = USER_UNLOCKED;
+//                             pChUserInfo->LockedTime = 0;
+//                             pChUserInfo->FailureAttempts = 0;
+//                         }
+//                     }
+
+//                     if((pChUserInfo->LockedTime != 0) && (pChUserInfo->Lock == USER_UNLOCKED)
+//                         && (AttemptResetInterval!= 0))
+//                     {
+//                         if((TimeUpdate() - pChUserInfo->LockedTime) > (10 * AttemptResetInterval))
+//                         {
+//                             pChUserInfo->LockedTime = 0;
+//                             pChUserInfo->FailureAttempts = 0;
+//                         }
+//                     }
+//                 }
+//             }
+//         }
+//     }
+
+//     return 0;
+// }
+
+// /*
+// *@fn MonitorPassword
+// *@brief This function monitors the invalid password attempts
+// */
+// void MonitorPassword(int BMCInst)
+// {
+//     int i=0;
+//     _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst]; 
+
+//     OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
+//     for(i=0;i<MAX_NUM_CHANNELS;i++)
+//     {
+//         if(IsLANChannel(i,BMCInst))
+//         {
+//             CheckPasswordViolation(LAN_CHANNEL_BADP,i,BMCInst);
+//         }
+//         else if(pBMCInfo->IpmiConfig.SerialIfcSupport == 0x1 && pBMCInfo->SERIALch == i)
+//         {
+//             CheckPasswordViolation(SERIAL_CHANNEL_BADP,i,BMCInst);
+//         }
+//     }
+//     OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+// }
+
+
+// /*
+// *@fn FindUserLockStatus
+// *@param Userid - UserId to get the status
+// *@param Channel - Status of the user for the specified channel
+// *@return Returns 0 success
+// *        Returns -1 on failure
+// */
+// int FindUserLockStatus(INT8U Userid,INT8U Channel )
+// {
+//     INT8U Index=0;
+//     ChannelInfo_T*pChannelInfo = getChannelInfo(Channel,BMCInst);
+//     if(NULL == pChannelInfo)
+//     {
+//         TDBG("Unable to get Channel Info to Find User Lock Status for channel : %d \n",Channel);
+//         return 0;
+//     }
+
+//     if(pChannelInfo != NULL)
+//     {
+//         ChannelUserInfo_T *pChUserInfo = getChUserIdInfo (Userid , &Index, pChannelInfo->ChannelUserInfo,BMCInst);
+//         if(pChUserInfo != NULL)
+//         {
+//             if(pChUserInfo->Lock == USER_UNLOCKED)
+//             {
+//                 return 0;
+//             }
+//             else
+//             {
+//                 return -1;
+//             }
+//         }
+//         else
+//         {
+//             return 0;
+//         }
+//     }
+//     else
+//     {
+//         return 0;
+//     }
+
+//     /* Control doesn't reach here*/
+//     return 0;
+// }
+
+
+// /*
+// * @fn LockUser
+// * @param Userid - Password to be locked for Userid
+// * @param Channel - Channel Number
+// * @return Returns 0 on success
+// */
+// int LockUser(INT8U Userid,INT8U Channel )
+// {
+//     INT8U Index=0,EthIndex=0;
+//     ChannelInfo_T*pChannelInfo = getChannelInfo(Channel,BMCInst);
+//     if(NULL == pChannelInfo)
+//     {
+//         TDBG("Unable to get Channel Info to Lock User for channel : %d \n",Channel);
+//         return 0;
+//     }
+
+//     _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst]; 
+//     INT8U ThresholdNum= 0xFF; 
+
+//     if(IsLANChannel(Channel,BMCInst))
+//     {
+//         EthIndex = GetEthIndex(Channel,BMCInst);
+//         ThresholdNum = pBMCInfo->LANCfs[EthIndex].BadPasswd.ThreshNum;
+//     }
+//     else if(pBMCInfo->IpmiConfig.SYSIfcSupport == 1 && pBMCInfo->SERIALch == Channel)
+//     {
+//         ThresholdNum = pBMCInfo->SMConfig.BadPasswd.ThreshNum; //TBD
+//     }
+//     else
+//     {
+//         /*If Channel no: does not belong to LAN or Serial
+//             Locking of User is discarded*/
+//         return 0;
+//     }
+
+//     ChannelUserInfo_T *pChUserInfo = getChUserIdInfo (Userid , &Index, pChannelInfo->ChannelUserInfo,BMCInst);
+
+//     if(ThresholdNum != 0 && pChUserInfo != NULL)
+//    {
+//          pChUserInfo->FailureAttempts++;
+//          pChUserInfo->LockedTime = TimeUpdate();
+//          if(pChUserInfo->FailureAttempts >= ThresholdNum)
+//          {
+//             pChUserInfo->Lock = USER_LOCKED;
+//             GenerateLockEvent(Channel,Userid,BMCInst);
+//          }
+//     }
+    
+//     return 0;
+// }
+
+// /*
+// *@fn UnlockUser
+// *@param Userid -Password to be unlocked for Userid
+// *@param Channel - Channel Number
+// *@return Returns 0 on success
+// */
+// int UnlockUser(INT8U Userid,INT8U Channel )
+// {
+//     INT8U Index=0,EthIndex=0;
+//     ChannelInfo_T*pChannelInfo = getChannelInfo(Channel,BMCInst);
+//     if(NULL == pChannelInfo)
+//     {
+//         TDBG("Unable to get Channel Info to UnLock User for channel : %d \n",Channel);
+//         return 0;
+//     }
+
+//     _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst]; 
+//     INT8U ThresholdNum= 0xFF; 
+
+//     if(pChannelInfo != NULL)
+//     {
+//         if(IsLANChannel(Channel,BMCInst))
+//         {
+//             EthIndex = GetEthIndex(Channel,BMCInst);
+//             ThresholdNum = pBMCInfo->LANCfs[EthIndex].BadPasswd.ThreshNum;
+//         }
+//         else if(pBMCInfo->IpmiConfig.SYSIfcSupport == 1 && pBMCInfo->SERIALch == Channel)
+//         {
+//             ThresholdNum = pBMCInfo->SMConfig.BadPasswd.ThreshNum; //TBD
+//         }
+//         else
+//         {
+//             /*If Channel no: does not belong to LAN or Serial
+//                 Locking of User is discarded*/
+//             return 0;
+//         }
+
+//         ChannelUserInfo_T *pChUserInfo = getChUserIdInfo (Userid , &Index, pChannelInfo->ChannelUserInfo,BMCInst);
+
+//         if(ThresholdNum != 0 && pChUserInfo != NULL)
+//         {
+//             pChUserInfo->FailureAttempts=0;
+//             pChUserInfo->LockedTime = 0;
+//             pChUserInfo->Lock = USER_UNLOCKED;
+//         }
+//     }
+
+//     return 0;
+// }
+
+// /*
+// *@fn ClearUserLockAttempts
+// */
+// int ClearUserLockAttempts(INT8U SerialorLAN )
+// {
+//     int i=0,j=0;
+//     INT8U Index=0;//,EthIndex=0;
+//     ChannelInfo_T*pChannelInfo=NULL;
+//     ChannelUserInfo_T*  pChUserInfo = NULL;
+//      _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst]; 
+
+//     TDBG("Inside ClearUserlock \n");
+//     for(i=0;i<MAX_NUM_CHANNELS;i++)
+//     {
+//         if((IsLANChannel(i,BMCInst) && SerialorLAN == LAN_CHANNEL_BADP) || 
+//             ((pBMCInfo->IpmiConfig.SerialIfcSupport == 0x01) && (pBMCInfo->SERIALch == i) && (SerialorLAN == SERIAL_CHANNEL_BADP)))
+//         {
+//             pChannelInfo = getChannelInfo(i,BMCInst);
+//             if(pChannelInfo != NULL)
+//             {
+//                 for(j=1;j<=g_BMCInfo[BMCInst].IpmiConfig.MaxChUsers;j++)
+//                 {
+//                     pChUserInfo = getChUserIdInfo(j,&Index,pChannelInfo->ChannelUserInfo,BMCInst);
+//                     if(pChUserInfo != NULL)
+//                     {
+//                     	TDBG("Unlocking the user \n");
+//                         pChUserInfo->LockedTime = 0;
+//                         pChUserInfo->FailureAttempts = 0;
+//                     }
+//                 }
+//             }
+//         }
+//     }
+
+//     return 0;
+// }
+
+
+// /*
+// *@fn GenerateLockEvent
+// *@param Event -Denotes whether event has to be generated
+// *@return Returns 0
+// */
+// int GenerateLockEvent(INT8U Channel,INT8U UserID )
+// {
+//     INT8U EventMsg[9],EthIndex=0,GenEvent=0;
+//     _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst]; 
+
+//     if(IsLANChannel(Channel,BMCInst))
+//     {
+//         EthIndex = GetEthIndex(Channel,BMCInst);
+//         GenEvent = pBMCInfo->LANCfs[EthIndex].BadPasswd.GenEvent & 0x01;
+//     }
+//     else if(pBMCInfo->IpmiConfig.SYSIfcSupport == 1 && pBMCInfo->SERIALch == Channel)
+//     {
+//         GenEvent = pBMCInfo->SMConfig.BadPasswd.GenEvent & 0x01;
+//     }
+
+//     if(GenEvent)
+//     {
+//         EventMsg[0] = pBMCInfo->IpmiConfig.BMCSlaveAddr; /* Generator ID */
+//         EventMsg[1] = 0;                          /* Generator ID */
+//         EventMsg[2] = 4;                          /* EvM Rev */
+//         EventMsg[3] = 0x2A;                     /* Sensor Type */
+//         EventMsg[4] = 0;                          /* Sensor Number*/  //TBD
+//         EventMsg[5] = 0x6F;                     /* Event Dir | Event Type */
+//         EventMsg[6] = 0x03;                /* Event Data 1 */
+//         EventMsg[7] = UserID;                 /* Event Data 2 */
+//         EventMsg[8] = 0xFF;                     /* Event Data 3 */
+
+//         /* Post Event Message */
+//         if ( PostEventMessage(EventMsg,FALSE,sizeof(EventMsg),BMCInst) != 0)
+//         {
+//             TDBG("Generation of Event Message for User Lock failed \n");
+//         }
+//     }
+    
+//     return 0;
+// }
+

+ 63 - 0
app/bmc/msghndlr/Transport/DeviceConfig.c

@@ -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.         **
+//  **                                                            **
+//  ****************************************************************
+//  *****************************************************************
+//  *
+//  * 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},
+
+//     /*--------------------- 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}
+// };
+

+ 3166 - 0
app/bmc/msghndlr/Transport/LANConfig.c

@@ -0,0 +1,3166 @@
+// /*****************************************************************
+//  *****************************************************************
+//  ***                                                            **
+//  ***    (C)Copyright 2005-2006, American Megatrends Inc.        **
+//  ***                                                            **
+//  ***            All Rights Reserved.                            **
+//  ***                                                            **
+//  ***        6145-F, Northbelt Parkway, Norcross,                **
+//  ***                                                            **
+//  ***        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+//  ***                                                            **
+//  *****************************************************************
+//  ******************************************************************
+//  *
+//  * lanconfig.c
+//  * Lan Configuration functions.
+//  *
+//  *  Author: Bakka Ravinder Reddy <bakkar@ami.com>
+//  *
+//  ******************************************************************/
+// #define ENABLE_DEBUG_MACROS 0
+// #include "IPMIConf.h"
+// #include "LANConfig.h"
+// #include "MsgHndlr.h"
+// #include "Debug.h"
+// #include "Support.h"
+// #include "IPMI_LANConfig.h"
+// #include "PMConfig.h"
+// #include "SharedMem.h"
+// #include "IPMIDefs.h"
+// #include "NVRAccess.h"
+// #include "Util.h"
+// #include "Session.h"
+// #include "WDT.h"
+// #include "LANIfc.h"
+// #include "AppDevice.h"
+// #include "RMCP+.h"
+// #include "IPMI_Main.h"
+// #include "IPMI_LANConfig.h"
+// #include "nwcfg.h"
+// #include "PendTask.h"
+// #include "Ciphertable.h"
+// #include "Ethaddr.h"
+// #include "sendarp.h"
+// #include "PDKAccess.h"
+// #include "Message.h"
+// #include <linux/if.h>
+// #include "Badpasswd.h"
+// #include "libncsiconf.h"
+// #include <linux/ip.h>
+// #include <dlfcn.h>
+// #include <sys/prctl.h>
+// #include "featuredef.h"
+// #include <flashlib.h>
+// #include <libphyconf.h>
+// #include "safesystem.h"
+
+// /* Reserved bit macro definitions */
+// #define RESERVED_BITS_SUSPENDBMCARPS                    0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+// #define RESERVED_BITS_GETIPUDPRMCPSTATS_CH              0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+// #define RESERVED_BITS_GETIPUDPRMCPSTATS_CLRSTATE        0xFE //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1)
+
+// /*** Local definitions ***/
+// #define CHANNEL_ID_MASK                         0x0f
+// #define SET_IN_PROGRESS_MASK                    0x03
+// #define PARAMETER_REVISION_MASK                 0x0f
+// #define DEST_ADDR_DATA2_ADDR_FORMAT_MASK        0xf0
+// #define PARAMETER_REVISION_FORMAT               0x11
+// #define GET_PARAMETER_REVISION_MASK             0x80
+// #define LAN_CALLBACK_AUTH_SUPPORT               0x17    /* MD2 & MD5 supported  */
+// #define LAN_USER_AUTH_SUPPORT                   0x17    /* MD2 & MD5 supported  */
+// #define LAN_OPERATOR_AUTH_SUPPORT               0x17    /* MD2 & MD5 supported  */
+// #define LAN_ADMIN_AUTH_SUPPORT                  0x17    /* MD2 & MD5 supported  */
+// #define BRD_CAST_BIT_MASK                       0xFF
+// #define LOOP_BACK_BIT_MASK                      0x7F
+// #define SUBNET_MASK_BIT_CHECK                   0x80
+
+// #define LAN_CONFIGURATION_SET_IN_PROGRESS       0x01
+// #define LAN_CONFIGURATION_SET_COMPLETE          0x00
+
+// #define GRATIUTOUS_ENABLE_MASK                  1
+// #define ENABLE_ARP_RESPONSES                    2
+// #define SUSPEND_ARP_RSVD_BIT_MASK               0xFC
+// #define ENABLE_ARPS                             0x03
+// #define SUSPEND_GRAT_ARP                        0x01
+// #define SUSPEND_ARP                             0x02
+
+// #define ARP_IGNORE_ON	8
+// #define ARP_IGNORE_OFF	0
+
+
+// /* Reserved Bits */
+// #define RESERVED_VALUE_70						0x70
+// #define RESERVED_VALUE_F0						0xF0
+
+// /**
+// *@fn NwInterfacePresenceCheck
+// *@brief This function is invoked to check network interface presence
+// *@param Interface - Char Pointer to buffer for which interface to check
+// */
+// static int NwInterfacePresenceCheck (char * Interface);
+
+// /*** Module Variables ***/
+// //_FAR_        INT8U  m_ArpSuspendReq;
+
+// char **explode(char separator, char *string);
+// int IPAddrCheck(INT8U *Addr,int params);
+// extern int GetLanAMIParamValue (INT8U* ParamSelect, INT8U* ImpType);
+
+// extern IfcName_T Ifcnametable[MAX_LAN_CHANNELS];
+// #define MAX_LAN_PARAMS_DATA  20
+// typedef struct
+// {
+//     INT8U	Params;
+//     INT8U	ReservedBits [MAX_LAN_PARAMS_DATA];
+//     INT8U	DataLen;
+
+// } LANCfgRsvdBits_T;
+
+// static LANCfgRsvdBits_T m_RsvdBitsCheck [] = {
+
+//     /* Param                 Reserved Bits                    Data Size   */
+//     { 0,	     			{ 0xFC }, 				 0x1 },	/* Set In progress  */
+//     { 1,				{ 0xC8 },					 0x1 }, 	 /* Authenication type */
+//     { 2,				{ 0xC8,0xC8,0xC8,0xC8,0xC8 }, 0x5}, 	 /* Authenication Support Enable  */
+//     { 4,				{ 0xF0 },					 0x1 }, 	 /* l */
+//     { 7,				{ 0x0,0x1F,0x01 },			 0x3 }, 	 /* l */
+//     { 0xA,				{ 0xFC },					 0x1 }, 	 /* l */
+//     { 0x11,			{ 0xF0 },					 0x1 }, 	 /* l */
+//     { 0x12,			{ 0xF0,0x78,0x0,0xF8 },		 0x4 },
+//     { 0x13,			{ 0xF0,0x0F, 0xFE },		 0x3 },
+//     { 0x14,			{ 0x0,0x70},				 0x2 },
+//     { 0x15,			{ 0xF8 },					 0x1 },
+//     { 0x16,			{ 0xE0 },					 0x1 },
+//     { 0x17,			{ 0xFF },					 0x1 },
+//     { 0x18,			{ 0xFF },					 0x1 },
+//     { 0x19,			{ 0xF0,0x0F },				 0x2 },
+//     { 0x1A,			{ 0xFE },				 	 0x1 }
+// };
+
+// typedef struct
+// {
+//     INT8U OEMParam;
+//     INT8U Length;
+// }OEMParameterLength_T;
+
+// static OEMParameterLength_T m_OEMParamLen [] = {
+//         {LAN_PARAMS_AMI_OEM_IPV6_ENABLE,                    1 },
+//         {LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_SOURCE,    1 },
+//         {LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR,                17 },
+//         {LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH,      2},
+//         {LAN_PARAMS_AMI_OEM_IPV6_GATEWAY_IP,         16}
+// };
+
+// /**
+//  * @brief LAN configuration request parameter lengths
+// **/
+// static const INT8U LanconfigParameterLength [] = {
+//                     1,  /* Set in progress */
+//                     1,  /* Authentication type support */
+//                     5,  /* Authentication type enables */
+//                     4,  /* IP address */
+//                     1,  /* IP address source */
+//                     6,  /* MAC address */
+//                     4,  /* Subnet mask */
+//                     3,  /* IPv4 header parameters */
+//                     2,  /* Primary RMCP port number */
+//                     2,  /* Secondary RMCP port number */
+//                     1,  /* BMC generated ARP control */
+//                     1,  /* Gratuitous ARP */
+//                     4,  /* Default Gateway address */
+//                     6,  /* Default Gateway MAC address */
+//                     4,  /* Backup Gateway address */
+//                     6,  /* Backup Gateway MAC address */
+//                     18, /* Community string */
+//                     1,  /* Number of destinations */
+//                     4,  /* Destination type */
+//                     13, /* Destination address */
+//                     2,  /* VLAN ID */
+//                     1,  /* VLAN Priority */
+//                     1,  /* Cipher suite entry support */
+//                     17, /* Cipher suite entries */
+//                     9,  /* Cipher suite Privilege levels */
+//                     4,  /* VLAN tags destination address  */
+//                     6,  /* Bad Password Threshold */
+//                     (9+16) /* IPv6 Destination address */
+// };
+
+// /* A copy of ip_tos2prio with numeric format in "linux/net/ipv4/route.c" */ 
+// static const INT8U IP_TOS2PRIO[16] = {
+//     0,        /* TC_PRIO_BESTEFFORT,           */                     
+//     1,        /* ECN_OR_COST(FILLER),          */           
+//     0,        /* TC_PRIO_BESTEFFORT,           */           
+//     0,        /* ECN_OR_COST(BESTEFFORT),      */           
+//     2,        /* TC_PRIO_BULK,                 */           
+//     2,        /* ECN_OR_COST(BULK),            */          
+//     2,        /* TC_PRIO_BULK,                 */          
+//     2,        /* ECN_OR_COST(BULK),            */          
+//     6,        /* TC_PRIO_INTERACTIVE,          */           
+//     6,        /* ECN_OR_COST(INTERACTIVE),     */           
+//     6,        /* TC_PRIO_INTERACTIVE,          */           
+//     6,        /* ECN_OR_COST(INTERACTIVE),     */           
+//     4,        /* TC_PRIO_INTERACTIVE_BULK,     */           
+//     4,        /* ECN_OR_COST(INTERACTIVE_BULK),*/           
+//     4,        /* TC_PRIO_INTERACTIVE_BULK,     */           
+//     4         /* ECN_OR_COST(INTERACTIVE_BULK) */             
+// };
+// static BOOL enableSetMACAddr = FALSE;	//jimbo notice
+
+// /*-------------------------------------------------------
+//  * SetLanConfigParam
+//  *-------------------------------------------------------*/
+// int
+// SetLanConfigParam (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
+// {
+//     _NEAR_  SetLanConfigReq_T*  pSetLanReq = (_NEAR_ SetLanConfigReq_T*) pReq;
+//     _NEAR_  SetLanConfigRes_T*  pSetLanRes = (_NEAR_ SetLanConfigRes_T*) pRes;
+//     _FAR_   BMCSharedMem_T*     pSharedMem = BMC_GET_SHARED_MEM (BMCInst);
+//     _FAR_   ChannelInfo_T*      ptrChannelInfo;
+//     _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//     NWCFG_STRUCT        NWConfig;
+//     NWCFG6_STRUCT      NWConfig6;
+//     INT32U GWIp,IPAddr;
+//     INT32U Subnetmask;
+//     int i,j=0;
+//     INT8U IsOemDefined = FALSE;
+//     INT8U EthIndex,netindex= 0xFF, currBmcGenArpCtrl;
+//     BMCArg *pLANArg=NULL; 
+
+//     char    VLANInterfaceName [32];
+//     INT16U vlanID=0;
+//     INT16U InvalidVlanID[3]={0,1,4095};
+//     char cmdSetPriority[32];
+//     int retValue=0,NIC_Count = 0;
+//     INT16U PriorityLevel[MAX_LAN_CHANNELS]= {0};
+//     INT8U  m_Lan_SetInProgress; /**< Contains setting LAN configuration status */
+    
+//     ETHCFG_STRUCT PHYCfg;
+//     static INT8U macEthIndex = 0xFF;
+//     INT8U TOS = 0, SkbPriority = 0; /* For VLAN priority parameter */
+//     int pendStatus = PEND_STATUS_COMPLETED;
+//     char IfcName[16];     /* Eth interface name */
+
+//     if ( ReqLen >= 2 )
+//     {
+//         ReqLen -= 2;
+//     }
+//     else
+//     {
+//         *pRes = CC_REQ_INV_LEN;
+//         return sizeof (INT8U);
+//     }
+
+//     if(g_corefeatures.dual_image_support == ENABLED)
+//     {
+//         if(IsCardInFlashMode())
+//         {
+//             IPMI_WARNING("Card in Active flash mode, Not safe to set any of LAN configurations...\n");
+//             *pRes = CC_DEV_IN_FIRMWARE_UPDATE_MODE;
+//             return sizeof (*pRes);
+//         }
+//     }
+
+//     EthIndex= GetEthIndex(pSetLanReq->ChannelNum & 0x0F, BMCInst);
+//     if(0xff == EthIndex)
+//     {
+//         *pRes = CC_INV_DATA_FIELD;
+//         return sizeof (INT8U);
+//     }
+
+//     memset(IfcName,0,sizeof(IfcName));
+//     /*Get the EthIndex*/
+//     if(GetIfcName(EthIndex,IfcName, BMCInst) == -1)
+//     {
+//         TCRIT("Error in Getting Ifc name\n");
+//         *pRes = CC_INV_DATA_FIELD;
+//         return sizeof (INT8U);
+//     }
+
+//     for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
+//     {
+//         if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
+//         {
+//             netindex= Ifcnametable[i].Index;
+//             break;
+//         }
+//     }
+
+//     if(netindex == 0xFF)
+//     {
+//         *pRes = CC_INV_DATA_FIELD;
+//         return sizeof (INT8U);
+//     }
+    
+//     if((pSetLanReq->ParameterSelect >= MIN_LAN_OEM_CONF_PARAM) && 
+//             (pSetLanReq->ParameterSelect <= MAX_LAN_OEM_CONF_PARAM) )
+//     {
+//     	/* Converts OEM parameter value to equivalent AMI parameter value */
+//     	if (0 != GetLanAMIParamValue (&pSetLanReq->ParameterSelect, &IsOemDefined) )
+//     	{
+//             pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//             return sizeof(INT8U);
+//     	}
+
+//     	/* Hook for OEM to handle this parameter */
+//         if ( (IsOemDefined)  && (g_PDKHandle[PDK_SETLANOEMPARAM] != NULL) )
+//         {
+// 			return ((int(*)(INT8U *, INT8U, INT8U *,int))(g_PDKHandle[PDK_SETLANOEMPARAM]))(pReq, ReqLen, pRes, BMCInst);
+//     	}
+   	
+//     }    
+
+//     if(0x1b >pSetLanReq->ParameterSelect  )   //Max known Lan paramter
+//     {
+//         if (ReqLen != LanconfigParameterLength [pSetLanReq->ParameterSelect ])
+//         {
+//             *pRes = CC_REQ_INV_LEN;
+//             return sizeof (INT8U);
+//         }
+//     }
+
+//     /*Check the Request length for OEM parameter*/
+//     for(i=0;i<sizeof(m_OEMParamLen)/sizeof(OEMParameterLength_T);i++)
+//     {
+//         if(m_OEMParamLen[i].OEMParam == pSetLanReq->ParameterSelect)
+//         {
+//             if(ReqLen != m_OEMParamLen[i].Length)
+//             {
+//                 *pRes = CC_REQ_INV_LEN;
+//                 return sizeof(INT8U);
+//             }
+//         }
+//     }
+
+//     if(pSetLanReq->ChannelNum & RESERVED_VALUE_F0)
+//     {
+//         /* Alarm !!! Somebody is trying to set Reseved Bits */
+//         *pRes = CC_INV_DATA_FIELD;
+//         return sizeof (*pRes);
+//     }    
+ 
+//     /* Check for Reserved Bits */
+//     for (i = 0; i < sizeof (m_RsvdBitsCheck)/ sizeof (m_RsvdBitsCheck[0]); i++)
+//     {
+//         /* Check if this Parameter Selector needs Reserved bit checking !! */
+//         if (m_RsvdBitsCheck[i].Params == pSetLanReq->ParameterSelect)
+//         {
+//             //IPMI_DBG_PRINT_2 ("Param - %x, DataLen - %x\n", pSetLanReq->ParameterSelect, m_RsvdBitsCheck[i].DataLen);
+//             for (j = 0; j < m_RsvdBitsCheck[i].DataLen; j++)
+//             {
+//                 //	IPMI_DBG_PRINT_2 ("Cmp  %x,  %x\n", pReq[2+j], m_RsvdBitsCheck[i].ReservedBits[j]);
+//                 if ( 0 != (pReq[2+j] & m_RsvdBitsCheck[i].ReservedBits[j]))
+//                 {
+//                     /* Alarm !!! Somebody is trying to set Reseved Bits */
+//                     *pRes = CC_INV_DATA_FIELD;
+//                     return sizeof (*pRes);
+//                 }
+//             }
+//         }
+//      }
+
+//     ptrChannelInfo = getChannelInfo (pSetLanReq->ChannelNum & 0x0F, BMCInst);
+//     if(NULL == ptrChannelInfo)
+//     {
+//         *pRes = CC_INV_DATA_FIELD;
+//         return	sizeof(*pRes);
+//     }
+	
+//     IPMI_DBG_PRINT_1 ("Parameter = %X\n", pSetLanReq->ParameterSelect);
+//     if (g_PDKHandle[PDK_BEFORESETLANPARM] != NULL )
+//     {
+//         retValue = ((int(*)(INT8U *, INT8U, INT8U *,int))(g_PDKHandle[PDK_BEFORESETLANPARM]))(pReq, ReqLen, pRes, BMCInst);
+//         if(retValue != 0)
+//         {
+//               return retValue;
+//         }
+//     }
+
+//     if((pSetLanReq->ParameterSelect == LAN_PARAM_SELECT_DEST_ADDR) || 
+//             (pSetLanReq->ParameterSelect == LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR))
+//     {
+//         /*Destination Address is allowed to configure only if DestType is LAN_PET_TRAP(SNMP alerts types)*/
+//         if(pBMCInfo->LANCfs[EthIndex].DestType [pSetLanReq->ConfigData.DestAddr.SetSelect - 1].DestType == LAN_OEM1_ALERT)
+//         {
+//             *pRes = CC_INV_DATA_FIELD;
+//             return sizeof (INT8U);
+//         }
+//     }
+//     switch (pSetLanReq->ParameterSelect)
+//     {
+//         case LAN_PARAM_SET_IN_PROGRESS:
+//             LOCK_BMC_SHARED_MEM(BMCInst);
+//             m_Lan_SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_Lan_SetInProgress;
+//             UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             /* Commit Write is optional and supported
+//              * only if rollback is supported */
+//             if ( (GetBits(pSetLanReq->ConfigData.SetInProgress, SET_IN_PROGRESS_MASK) !=
+//                     LAN_CONFIGURATION_SET_COMPLETE) &&
+//                  (GetBits(pSetLanReq->ConfigData.SetInProgress, SET_IN_PROGRESS_MASK) !=
+//                     LAN_CONFIGURATION_SET_IN_PROGRESS) )
+//             {
+//                 pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//                 return sizeof(*pSetLanRes);
+//             }
+//             else if ((GetBits(m_Lan_SetInProgress, SET_IN_PROGRESS_MASK) ==
+//                         LAN_CONFIGURATION_SET_IN_PROGRESS) &&
+//                      (GetBits(pSetLanReq->ConfigData.SetInProgress, SET_IN_PROGRESS_MASK) ==
+//                         LAN_CONFIGURATION_SET_IN_PROGRESS))
+//             {
+//                 pSetLanRes->CompletionCode = CC_SET_IN_PROGRESS;
+//                 return sizeof(*pSetLanRes);
+//             }
+
+//             LOCK_BMC_SHARED_MEM(BMCInst);
+//             BMC_GET_SHARED_MEM(BMCInst)->m_Lan_SetInProgress = pSetLanReq->ConfigData.SetInProgress;
+//             UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             break;
+
+//         case LAN_PARAM_AUTH_TYPE_SUPPORT:
+//             pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
+//             return sizeof(*pRes);
+
+//         case LAN_PARAM_AUTH_TYPE_ENABLES:
+//             for(i=0;i<5;i++)
+//             {
+//                  /* Check for Unsupported AuthType */
+//                 if (pBMCInfo->LANCfs[EthIndex].AuthTypeSupport != (pBMCInfo->LANCfs[EthIndex].AuthTypeSupport  |pReq[2+i]))
+//                 {
+//                       IPMI_DBG_PRINT_2("\n Alarm !!! Somebody is trying to Unsupported Bit :%d \t%d\n",pReq[2+i],i);
+//                       *pRes = CC_INV_DATA_FIELD;
+//                       return sizeof (*pRes);
+//                  }
+//             }
+
+//             LOCK_BMC_SHARED_MEM(BMCInst);
+//             _fmemcpy (&pBMCInfo->LANCfs[EthIndex].AuthTypeEnables,
+//                       &(pSetLanReq->ConfigData.AuthTypeEnables), sizeof(AuthTypeEnables_T));
+//             _fmemcpy (ptrChannelInfo->AuthType,
+//                       &(pSetLanReq->ConfigData.AuthTypeEnables), sizeof(AuthTypeEnables_T));
+//             UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             break;
+
+//         case LAN_PARAM_IP_ADDRESS:
+//             pendStatus = GetPendStatus(PEND_OP_SET_IP);
+//             if(pendStatus == PEND_STATUS_PENDING)
+//             {
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+//             //we need to do a read in hte pend task and not here
+//             // because if pend task is still working on setting the source for example t- by then we would have got the
+//             // next command which is ip address and then we would read back DHCP since nwcfg hasnt done its work yet etc. and all hell will breakloose.
+//             //nwReadNWCfg  (&NWConfig);
+
+//             if(pBMCInfo->LANCfs[EthIndex].IPAddrSrc == DHCP_IP_SOURCE)
+//             {
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+
+// 	    nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
+// 	    if(memcmp ( NWConfig.IPAddr, pSetLanReq->ConfigData.IPAddr, IP_ADDR_LEN ) == 0)
+// 	    {
+// 		TCRIT("Same IP address, do nothing\n");
+// 		_fmemcpy (pBMCInfo->LANCfs[EthIndex].IPAddr, pSetLanReq->ConfigData.IPAddr, IP_ADDR_LEN);
+// 		break;
+// 	    }
+
+//             if(IPAddrCheck(pSetLanReq->ConfigData.IPAddr,LAN_PARAM_IP_ADDRESS))
+//             {
+//                 *pRes = CC_INV_DATA_FIELD;
+//                 return sizeof (INT8U);
+//             }
+
+//             pendStatus = GetPendStatus(PEND_OP_SET_IP);
+//             if(pendStatus == PEND_STATUS_PENDING)
+//             {
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+            
+//             _fmemcpy (NWConfig.IPAddr, pSetLanReq->ConfigData.IPAddr, IP_ADDR_LEN);
+//             SetPendStatus(PEND_OP_SET_IP,PEND_STATUS_PENDING);
+//             PostPendTask(PEND_OP_SET_IP,(INT8U*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F),BMCInst);
+//             _fmemcpy (pBMCInfo->LANCfs[EthIndex].IPAddr, pSetLanReq->ConfigData.IPAddr, IP_ADDR_LEN);
+//             //nwWriteNWCfg (&NWConfig);
+//             break;
+
+//         case LAN_PARAM_IP_ADDRESS_SOURCE:
+
+//             if ((pSetLanReq->ConfigData.IPAddrSrc > BMC_OTHER_SOURCE)
+//                 ||(pSetLanReq->ConfigData.IPAddrSrc == UNSPECIFIED_IP_SOURCE))
+//             {
+//                 *pRes = CC_INV_DATA_FIELD;
+//                 return sizeof (INT8U);
+//             }
+//             if ( pBMCInfo->LANCfs[EthIndex].IPAddrSrc == pSetLanReq->ConfigData.IPAddrSrc )
+//             {
+//                 TCRIT("LAN or VLAN if current SRC is DHCP/Static and incoming SRC is DHCP/Static, do nothing\n");
+//                 break;
+//             }
+// 		if(!((pSetLanReq->ConfigData.IPAddrSrc == STATIC_IP_SOURCE ) || (pSetLanReq->ConfigData.IPAddrSrc == DHCP_IP_SOURCE )))
+// 			pBMCInfo->LANCfs[EthIndex].IPAddrSrc = pSetLanReq->ConfigData.IPAddrSrc ;
+//             if ( (pSetLanReq->ConfigData.IPAddrSrc == STATIC_IP_SOURCE ) || (pSetLanReq->ConfigData.IPAddrSrc == DHCP_IP_SOURCE ) )
+//             {
+//                 pendStatus = GetPendStatus(PEND_OP_SET_SOURCE);
+//                 if(pendStatus == PEND_STATUS_PENDING)
+//                 {
+//                     *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                     return sizeof (INT8U);
+//                 }
+// 		pBMCInfo->LANCfs[EthIndex].IPAddrSrc = pSetLanReq->ConfigData.IPAddrSrc ;
+//                 NWConfig.CfgMethod = pSetLanReq->ConfigData.IPAddrSrc;
+//                 SetPendStatus(PEND_OP_SET_SOURCE,PEND_STATUS_PENDING);
+//                 PostPendTask(PEND_OP_SET_SOURCE,(INT8U*) &NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
+//             }
+//             else if(pSetLanReq->ConfigData.IPAddrSrc == BIOS_IP_SOURCE)
+//             {
+//                 /*Perform OEM action*/
+//                 if(g_PDKHandle[PDK_BIOSIPSOURCE] != NULL)
+//                 {
+//                 	 retValue = ((int(*)(INT8U))g_PDKHandle[PDK_BIOSIPSOURCE]) (pSetLanReq->ChannelNum & CHANNEL_ID_MASK);
+// 	                 if(retValue == 1)
+// 	                 {
+// 		                 *pRes = CC_INV_DATA_FIELD;
+// 		                 return sizeof (*pRes);
+// 	                 }
+//                 }
+//                 else
+//                 {
+//                     pendStatus = GetPendStatus(PEND_OP_SET_SOURCE);
+//                     if(pendStatus == PEND_STATUS_PENDING)
+//                     {
+//                         *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                         return sizeof (INT8U);
+//                     }
+//                     NWConfig.CfgMethod = STATIC_IP_SOURCE;
+//                     SetPendStatus(PEND_OP_SET_SOURCE,PEND_STATUS_PENDING);
+//                     PostPendTask(PEND_OP_SET_SOURCE, (INT8U*) &NWConfig,sizeof(NWConfig), (pSetLanReq->ChannelNum & CHANNEL_ID_MASK), BMCInst );
+//                 }
+//             }
+//             else if(pSetLanReq->ConfigData.IPAddrSrc == BMC_OTHER_SOURCE)
+//             {
+//                 /*Perform OEM action*/
+//                 if(g_PDKHandle[PDK_BMCOTHERSOURCEIP] != NULL)
+//                 {
+//                 	retValue = ((int(*)(INT8U))g_PDKHandle[PDK_BMCOTHERSOURCEIP]) (pSetLanReq->ChannelNum & CHANNEL_ID_MASK);
+//                      if(retValue == 1)
+//                      {
+// 		                 *pRes = CC_INV_DATA_FIELD;
+// 		                 return sizeof (*pRes);
+// 	                 }
+//                 }
+//                 else
+//                 {	
+//                      *pRes = CC_INV_DATA_FIELD;
+// 	                 return sizeof (*pRes);
+//                 }
+//             }  
+//             break;
+
+//         case LAN_PARAM_MAC_ADDRESS:
+// #if 0
+//             nwReadNWCfg  (&NWConfig);
+//             printf ( "The MAC is %x %x %x %x %x %x \n", NWConfig.MAC [0],NWConfig.MAC [1],NWConfig.MAC [2],NWConfig.MAC [3],NWConfig.MAC [4],NWConfig.MAC [5] );
+
+//             _fmemcpy (NWConfig.MAC, pSetLanReq->ConfigData.MACAddr, MAC_ADDR_LEN);
+//     	printf ( "The MAC is %x %x %x %x %x %x \n", NWConfig.MAC [0],NWConfig.MAC [1],NWConfig.MAC [2],NWConfig.MAC [3],NWConfig.MAC [4],NWConfig.MAC [5] );
+//             nwWriteNWCfg (&NWConfig);
+// #else
+//             /* According to IPMI 2.0 Specification Revision 3, the MAC address can be read only parameter*/
+//            //*pRes = CC_ATTEMPT_TO_SET_RO_PARAM;
+//            //return sizeof (*pRes);
+
+// 			if (!enableSetMACAddr)
+// 				pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
+// 			else
+// 			{
+// 				EnableSetMACAddress_T macAddrEnabled;
+// 				INT8U InvalidMac[MAC_ADDR_LEN] = {0};
+// 				if((pSetLanReq->ConfigData.MACAddr[0]& BIT0)|| (memcmp(&InvalidMac,&pSetLanReq->ConfigData.MACAddr,MAC_ADDR_LEN) == 0))
+// 				{
+// 					pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
+// 					return sizeof(INT8U);
+// 				}
+			
+// 				memset(&macAddrEnabled, 0, sizeof(EnableSetMACAddress_T));
+// 				macAddrEnabled.EthIndex = macEthIndex;
+// 				memcpy(&macAddrEnabled.MACAddress, &pSetLanReq->ConfigData.MACAddr, MAC_ADDR_LEN);
+			
+//                 pendStatus = GetPendStatus(PEND_OP_SET_MAC_ADDRESS);
+//                 if(pendStatus == PEND_STATUS_PENDING)
+//                 {
+//                     *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                     return sizeof (INT8U);
+//                 }
+// 				SetPendStatus(PEND_OP_SET_MAC_ADDRESS, PEND_STATUS_PENDING);
+// 				PostPendTask(PEND_OP_SET_MAC_ADDRESS, (INT8U*)&macAddrEnabled, sizeof(EnableSetMACAddress_T), (pSetLanReq->ChannelNum & 0x0F), BMCInst);
+			
+// 				enableSetMACAddr = FALSE;
+// 				macEthIndex = 0xFF;
+				
+// 				pSetLanRes->CompletionCode = CC_NORMAL;
+// 			}
+			
+// 			return sizeof(*pSetLanRes);
+
+// #endif
+
+//         case LAN_PARAM_SUBNET_MASK:
+//             pendStatus = GetPendStatus(PEND_OP_SET_SUBNET);
+//             if(pendStatus == PEND_STATUS_PENDING)
+//             {
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+//             /*Returning valid completion code in case of attempt to set netmask in DHCP mode */
+//             if(pBMCInfo->LANCfs[EthIndex].IPAddrSrc == DHCP_IP_SOURCE)
+//             {
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+		
+// 	    nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
+// 	    if(memcmp ( NWConfig.Mask, pSetLanReq->ConfigData.SubNetMask, IP_ADDR_LEN ) == 0)
+// 	    {
+// 		TCRIT("Same Mask, do nothing\n");
+// 		_fmemcpy (pBMCInfo->LANCfs[EthIndex].SubNetMask, pSetLanReq->ConfigData.SubNetMask, IP_ADDR_LEN);
+// 		break;
+// 	    }
+
+//             if(IPAddrCheck(pSetLanReq->ConfigData.SubNetMask,LAN_PARAM_SUBNET_MASK))
+//             {
+//                 *pRes = CC_INV_DATA_FIELD;
+//                 return sizeof (INT8U);
+//             }
+
+//                 _fmemcpy (NWConfig.Mask, pSetLanReq->ConfigData.SubNetMask, IP_ADDR_LEN);
+//                 SetPendStatus(PEND_OP_SET_SUBNET,PEND_STATUS_PENDING);
+//                 PostPendTask(PEND_OP_SET_SUBNET,(INT8U*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F) , BMCInst);
+//                 _fmemcpy (pBMCInfo->LANCfs[EthIndex].SubNetMask, pSetLanReq->ConfigData.SubNetMask, IP_ADDR_LEN);
+
+//             break;
+
+//         case LAN_PARAM_IPv4_HEADER:
+//             pendStatus = GetPendStatus(PEND_OP_SET_IPV4_HEADERS);
+//             if(pendStatus == PEND_STATUS_PENDING)
+//             {
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+//             if(!pSetLanReq->ConfigData.Ipv4HdrParam.TimeToLive > 0)
+//             {
+//                 IPMI_DBG_PRINT("The requested IPv4 header(TTL) to set is invalid.\n");
+//                 *pRes = CC_PARAM_OUT_OF_RANGE;
+//                 return sizeof(*pRes);
+//             }
+//             if(pSetLanReq->ConfigData.Ipv4HdrParam.IpHeaderFlags == 0x60) // Flags can be either of the values: DF(0x40) or MF(0x20)
+//             {
+//                 IPMI_DBG_PRINT("The requested IPv4 header(Flags) to set is invalid.\n");
+//                 *pRes = CC_PARAM_OUT_OF_RANGE;
+//                 return sizeof(*pRes);
+//             }
+//             LOCK_BMC_SHARED_MEM(BMCInst);
+//             _fmemcpy (&pBMCInfo->LANCfs[EthIndex].Ipv4HdrParam,
+//             &pSetLanReq->ConfigData.Ipv4HdrParam, sizeof(IPv4HdrParams_T));
+//             UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             SetPendStatus(PEND_OP_SET_IPV4_HEADERS,PEND_STATUS_PENDING);
+//             PostPendTask(PEND_OP_SET_IPV4_HEADERS, (INT8U*)&(pSetLanReq->ConfigData.Ipv4HdrParam),
+//             sizeof(pSetLanReq->ConfigData.Ipv4HdrParam),(pSetLanReq->ChannelNum & 0x0F),BMCInst);
+//             break;
+
+//         case LAN_PARAM_PRI_RMCP_PORT:
+//             pendStatus = GetPendStatus(PEND_RMCP_PORT_CHANGE);
+//             if(pendStatus == PEND_STATUS_PENDING)
+//             {
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+//             LOCK_BMC_SHARED_MEM(BMCInst);
+//             pBMCInfo->LANCfs[EthIndex].PrimaryRMCPPort = ipmitoh_u16 (pSetLanReq->ConfigData.PrimaryRMCPPort);
+//             UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             SetPendStatus(PEND_RMCP_PORT_CHANGE,PEND_STATUS_PENDING);
+//             PostPendTask(PEND_RMCP_PORT_CHANGE,(INT8U*)&(pSetLanReq->ConfigData.PrimaryRMCPPort),
+//                                     sizeof(pSetLanReq->ConfigData.PrimaryRMCPPort),(pSetLanReq->ChannelNum & 0x0F),BMCInst);
+//             break;
+
+//         case LAN_PARAM_SEC_RMCP_PORT:
+//             /* Returning Invalid error message */
+//             *pRes = CC_PARAM_NOT_SUPPORTED;
+//             return sizeof (INT8U);
+//             /*pPMConfig->LANConfig[EthIndex].SecondaryPort = ipmitoh_u16 (pSetLanReq->ConfigData.SecondaryPort);*/
+//             break;
+
+//         case LAN_PARAM_BMC_GENERATED_ARP_CONTROL:
+
+//         	currBmcGenArpCtrl = pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl;
+        	
+// 			if(currBmcGenArpCtrl != pSetLanReq->ConfigData.BMCGeneratedARPControl)
+// 				pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl = pSetLanReq->ConfigData.BMCGeneratedARPControl;
+
+// 			if((ENABLE_ARP_RESPONSES & currBmcGenArpCtrl) !=
+// 			   (ENABLE_ARP_RESPONSES & pSetLanReq->ConfigData.BMCGeneratedARPControl))
+// 			{
+// 				UpdateArpStatus(EthIndex, BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning, BMCInst);
+// 			}
+
+// 			if(!(GRATIUTOUS_ENABLE_MASK & currBmcGenArpCtrl) &&
+// 			   (GRATIUTOUS_ENABLE_MASK & pSetLanReq->ConfigData.BMCGeneratedARPControl))
+// 			{
+//                 /* Create a thread to Send Gratuitous ARP Packet */
+//                 pLANArg = malloc(sizeof(BMCArg));
+//                 pLANArg->BMCInst = BMCInst; 
+//                 pLANArg->Len = strlen((char *)&EthIndex);
+//                 pLANArg->Argument = malloc(pLANArg->Len);
+//                 memcpy(pLANArg->Argument,(char *)&EthIndex,pLANArg->Len);
+               
+//                 OS_CREATE_THREAD ((void *)GratuitousARPTask,(void *)pLANArg, NULL);
+//             }
+
+//             break;
+
+//         case LAN_PARAM_GRATITIOUS_ARP_INTERVAL:
+
+//             pBMCInfo->LANCfs[EthIndex].GratitousARPInterval =
+//                                     pSetLanReq->ConfigData.GratitousARPInterval;
+//             break;
+
+//         case LAN_PARAM_DEFAULT_GATEWAY_IP:
+//             pendStatus = GetPendStatus(PEND_OP_SET_GATEWAY);
+//             if(pendStatus == PEND_STATUS_PENDING)
+//             {
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+	    
+//             /*Returning valid completion code in case of attempt to set default gateway ip in DHCP mode */
+//             if(pBMCInfo->LANCfs[EthIndex].IPAddrSrc == DHCP_IP_SOURCE)
+//             {
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+
+//             nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
+// 	    if(memcmp ( NWConfig.Gateway, pSetLanReq->ConfigData.DefaultGatewayIPAddr, IP_ADDR_LEN ) == 0)
+// 	    {
+// 		TCRIT("Same Gateway, do nothing\n");
+// 		_fmemcpy(pBMCInfo->LANCfs[EthIndex].DefaultGatewayIPAddr, pSetLanReq->ConfigData.DefaultGatewayIPAddr,IP_ADDR_LEN);
+// 		break;
+//             }
+//             if(IPAddrCheck(pSetLanReq->ConfigData.DefaultGatewayIPAddr,LAN_PARAM_DEFAULT_GATEWAY_IP))
+//             {
+//                 *pRes = CC_INV_DATA_FIELD;
+//                 return sizeof (INT8U);
+//             }
+
+//             _fmemcpy ((INT8U*)&GWIp,pSetLanReq->ConfigData.DefaultGatewayIPAddr, IP_ADDR_LEN);
+//             _fmemcpy ((INT8U*)&Subnetmask,&NWConfig.Mask[0],IP_ADDR_LEN);
+//             _fmemcpy ((INT8U*)&IPAddr,&NWConfig.IPAddr[0], IP_ADDR_LEN);
+//             /* Allowing  When the Default Gateway is Zero without validation to clear the Default Gateway */
+//             if(GWIp != 0)
+//             {
+//                 _fmemcpy ((INT8U*)&Subnetmask,pBMCInfo->LANCfs[EthIndex].SubNetMask,IP_ADDR_LEN);
+//                 _fmemcpy ((INT8U*)&IPAddr,pBMCInfo->LANCfs[EthIndex].IPAddr, IP_ADDR_LEN);
+//                 if((IPAddr & Subnetmask ) != (GWIp & Subnetmask))
+//                 {
+//                     IPMI_DBG_PRINT("\n Default GatewayIP to set is not valid \n");
+//                     *pRes = CC_INV_DATA_FIELD;
+//                     return sizeof (INT8U);
+//                 }
+//              }
+//             _fmemcpy (NWConfig.Gateway,pSetLanReq->ConfigData.DefaultGatewayIPAddr, IP_ADDR_LEN);
+//             LOCK_BMC_SHARED_MEM(BMCInst);
+//             _fmemcpy(pBMCInfo->LANCfs[EthIndex].DefaultGatewayIPAddr,
+//             pSetLanReq->ConfigData.DefaultGatewayIPAddr,IP_ADDR_LEN);
+//             UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             SetPendStatus(PEND_OP_SET_GATEWAY,PEND_STATUS_PENDING);
+//             PostPendTask(PEND_OP_SET_GATEWAY,(INT8U*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
+//              break;
+
+//         case LAN_PARAM_DEFAULT_GATEWAY_MAC:
+//             pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
+//             return sizeof(*pRes);
+//             break;
+
+//         case LAN_PARAM_BACKUP_GATEWAY_IP:
+
+//             nwReadNWCfg_v4_v6( &NWConfig,&NWConfig6, netindex,g_corefeatures.global_ipv6);
+//             _fmemcpy ((INT8U*)&GWIp,pSetLanReq->ConfigData.BackupGatewayIPAddr, IP_ADDR_LEN);
+//             _fmemcpy ((INT8U*)&Subnetmask,&NWConfig.Mask[0],IP_ADDR_LEN);
+//             _fmemcpy ((INT8U*)&IPAddr,&NWConfig.IPAddr[0], IP_ADDR_LEN);
+//             if(GWIp != 0)
+//             {
+//                 if((IPAddr & Subnetmask ) != (GWIp & Subnetmask))
+//                 {
+//                      IPMI_DBG_PRINT("\n Backup GatewayIP to set is not valid \n");
+//                     *pRes = CC_INV_DATA_FIELD;
+//                     return sizeof (INT8U);
+//                 }
+//             }
+//             LOCK_BMC_SHARED_MEM(BMCInst);
+//             _fmemcpy (pBMCInfo->LANCfs[EthIndex].BackupGatewayIPAddr,
+//             pSetLanReq->ConfigData.BackupGatewayIPAddr, IP_ADDR_LEN);
+//             nwSetBkupGWyAddr(pSetLanReq->ConfigData.BackupGatewayIPAddr,netindex);
+//             UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             break;
+
+//         case LAN_PARAM_BACKUP_GATEWAY_MAC:
+
+//             LOCK_BMC_SHARED_MEM(BMCInst);
+//             _fmemcpy (pBMCInfo->LANCfs[EthIndex].BackupGatewayMACAddr,
+//                       pSetLanReq->ConfigData.BackupGatewayMACAddr, MAC_ADDR_LEN);
+//             UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             break;
+
+//         case LAN_PARAM_COMMUNITY_STRING:
+//             if (g_PDKHandle[PDK_SETSNMPCOMMUNITYNAME] != NULL )
+//             {
+//                     if(((int(*)(INT8U *, INT8U,int))(g_PDKHandle[PDK_SETSNMPCOMMUNITYNAME]))(pSetLanReq->ConfigData.CommunityStr,MAX_COMM_STRING_SIZE, BMCInst)==0)
+//                         break;
+//             }
+//             OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->PefConfig.PEFSharedMemMutex, WAIT_INFINITE);
+//             _fmemcpy (pBMCInfo->LANCfs[EthIndex].CommunityStr,
+//                      pSetLanReq->ConfigData.CommunityStr, MAX_COMM_STRING_SIZE);
+//             OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
+//             break;
+
+//         case LAN_PARAM_DEST_NUM:
+
+//             pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
+//             return sizeof(INT8U);
+
+//         case LAN_PARAM_SELECT_DEST_TYPE:
+
+//             // if (pSetLanReq->ConfigData.DestType.SetSelect > NUM_LAN_DESTINATION)
+//             if (pSetLanReq->ConfigData.DestType.SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
+//             {
+//                 *pRes = CC_PARAM_OUT_OF_RANGE;
+//                 return sizeof (*pRes);
+//             }
+
+//             if (0 == pSetLanReq->ConfigData.DestType.SetSelect)
+//             {
+//                 LOCK_BMC_SHARED_MEM(BMCInst);
+//                 _fmemcpy (&pSharedMem->VolLANDestType[EthIndex],
+//                           &pSetLanReq->ConfigData.DestType, sizeof(LANDestType_T));
+//                 UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             }
+//             else
+//             {
+//                 LOCK_BMC_SHARED_MEM(BMCInst);
+//                 _fmemcpy (&pBMCInfo->LANCfs[EthIndex].DestType [pSetLanReq->ConfigData.DestType.SetSelect - 1],
+//                           &pSetLanReq->ConfigData.DestType, sizeof(LANDestType_T));
+//                 UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             }
+//             break;
+
+//         case LAN_PARAM_SELECT_DEST_ADDR:
+//             pendStatus = GetPendStatus(PEND_OP_SET_GATEWAY);
+//             if(pendStatus == PEND_STATUS_PENDING)
+//             {
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+//             // if (pSetLanReq->ConfigData.DestAddr.SetSelect > NUM_LAN_DESTINATION)
+//             if (pSetLanReq->ConfigData.DestType.SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
+//             {
+//                 *pRes = CC_PARAM_OUT_OF_RANGE ;
+//                 return sizeof (*pRes);
+//             }
+
+//             if (0 == pSetLanReq->ConfigData.DestAddr.SetSelect)
+//             {
+//                 LOCK_BMC_SHARED_MEM(BMCInst);
+//                 _fmemcpy (&pSharedMem->VolLANDest[EthIndex],
+//                           &pSetLanReq->ConfigData.DestAddr, sizeof(LANDestAddr_T));
+//                memset(pSharedMem->VolLANv6Dest,0,sizeof(LANDestv6Addr_T));
+//                 UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             }
+//             else
+//             {
+//                 LOCK_BMC_SHARED_MEM(BMCInst);
+//                 _fmemcpy (&pBMCInfo->LANCfs[EthIndex].DestAddr [pSetLanReq->ConfigData.DestAddr.SetSelect - 1],
+//                           &pSetLanReq->ConfigData.DestAddr, sizeof(LANDestAddr_T));
+//                 memset( &pBMCInfo->LANCfs[EthIndex].Destv6Addr [pSetLanReq->ConfigData.Destv6Addr.SetSelect -1], 0 ,
+//                     sizeof(LANDestv6Addr_T));
+//                 UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             }
+//             /* Setting BackupGw to DefaultGw as per request to send trap */
+//             if(pSetLanReq->ConfigData.DestAddr.GateWayUse == 1)
+//             {
+//                 IPMI_DBG_PRINT("Setting Backupgw to Defaultgwip as per Request \n");
+//                 nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
+//                 LOCK_BMC_SHARED_MEM(BMCInst);
+//                 _fmemcpy(NWConfig.Gateway,pBMCInfo->LANCfs[EthIndex].BackupGatewayIPAddr,IP_ADDR_LEN);
+//                 UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                 SetPendStatus(PEND_OP_SET_GATEWAY,PEND_STATUS_PENDING);
+//                 PostPendTask(PEND_OP_SET_GATEWAY,(INT8U*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F),BMCInst);
+
+//              }
+//             break;
+
+//         case LAN_PARAM_VLAN_ID:
+
+//             if( pBMCInfo->IpmiConfig.VLANIfcSupport == 1)
+//             {
+//                 nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
+
+//                 if((pSetLanReq->ConfigData.VLANID & VLAN_MASK_BIT) == VLAN_MASK_BIT)    /* checks for VLAN enable bit*/
+//                 {
+//                     pendStatus = GetPendStatus(PEND_OP_SET_VLAN_ID);
+//                     if(pendStatus == PEND_STATUS_PENDING)
+//                     {
+//                         *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                         return sizeof (INT8U);
+//                     }
+//                     vlanID = (pSetLanReq->ConfigData.VLANID & 0xfff);    /* get the vlan d from the data */
+
+//                     for(i=0;i<sizeof(InvalidVlanID)/sizeof(INT16U);i++)
+//                     {
+//                         if(InvalidVlanID[i] != vlanID)
+//                         {
+//                             continue;
+//                         }
+//                         else        /*invalid vlan id */
+//                         {
+//                             *pRes = CC_INV_DATA_FIELD ;
+//                             return sizeof (*pRes);
+//                         }
+//                     }
+
+//                     if ( NWConfig.VLANID != 0)     /* checks if vlan id already present */
+//                     {
+//                         if(NWConfig.VLANID == vlanID)
+//                         {
+//                             TCRIT("Currently configured vlan id and incoming set vlan id are same thus, do nothing\n");
+//                             break;
+//                         }
+//                         memset(IfcName,0,sizeof(IfcName));
+//                         if(GetIfcName(EthIndex, IfcName,BMCInst) != 0)
+//                         {
+//                             TCRIT("Error in getting Interface Name for the Lan Index :%d\n",EthIndex);
+//                             *pRes = CC_INV_DATA_FIELD ;
+//                             return sizeof (*pRes);
+//                         }
+//                         sprintf(VLANInterfaceName, "%s.%d", IfcName, (int)(NWConfig.VLANID));
+//                         if (0 == NwInterfacePresenceCheck (VLANInterfaceName))
+//                         {
+//                             pendStatus = GetPendStatus(PEND_OP_SET_VLAN_ID);
+//                             if(pendStatus == PEND_STATUS_PENDING)
+//                             {
+//                                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                                 return sizeof (INT8U);
+//                             }
+//                             SetPendStatus(PEND_OP_DECONFIG_VLAN_IFC,PEND_STATUS_PENDING);
+//                             PostPendTask(PEND_OP_DECONFIG_VLAN_IFC,(INT8U*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
+//                             pBMCInfo->LANCfs[EthIndex].VLANPriority =0;
+//                         }
+//                     }
+
+//                     NWConfig.VLANID=vlanID;
+//                     SetPendStatus(PEND_OP_SET_VLAN_ID,PEND_STATUS_PENDING);
+//                     PostPendTask(PEND_OP_SET_VLAN_ID,(INT8U*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
+//                     pBMCInfo->LANCfs[EthIndex].VLANID = pSetLanReq->ConfigData.VLANID;
+//                 }
+//                 else        /* Vlan Bit is Disabled */
+//                 {
+//                     if(NWConfig.VLANID==0)        /* Vlan id is disabled */
+//                     {
+//                         if((pSetLanReq->ConfigData.VLANID & 0xfff)!=0)
+//                         {
+//                             pBMCInfo->LANCfs[EthIndex].VLANID = pSetLanReq->ConfigData.VLANID;
+//                         }
+
+//                         if((pSetLanReq->ConfigData.VLANID & 0xfff)==0)
+//                         {
+//                             if((pBMCInfo->LANCfs[EthIndex].VLANID & 0xfff)!=0)
+//                             {
+//                                 pBMCInfo->LANCfs[EthIndex].VLANID = pSetLanReq->ConfigData.VLANID;
+//                             }
+//                         }
+//                     }
+
+//                     else                /* Vlan ID is enable. so deconfigure it */
+//                     {
+//                         memset(IfcName,0,sizeof(IfcName));
+//                         if(GetIfcName(EthIndex, IfcName,BMCInst) != 0)
+//                         {
+//                             TCRIT("Error in getting Interface Name for the Lan Index :%d\n",EthIndex);
+//                             *pRes = CC_INV_DATA_FIELD ;
+//                             return sizeof (*pRes);
+//                         }
+//                         sprintf(VLANInterfaceName, "%s.%d", IfcName, (int)(NWConfig.VLANID));
+//                         if (0 == NwInterfacePresenceCheck (VLANInterfaceName))
+//                         {
+//                             pendStatus = GetPendStatus(PEND_OP_SET_VLAN_ID);
+//                             if(pendStatus == PEND_STATUS_PENDING)
+//                             {
+//                                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                                 return sizeof (INT8U);
+//                             }
+//                             SetPendStatus(PEND_OP_DECONFIG_VLAN_IFC,PEND_STATUS_PENDING);
+//                             PostPendTask(PEND_OP_DECONFIG_VLAN_IFC,(INT8U*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
+//                             pBMCInfo->LANCfs[EthIndex].VLANPriority =0;
+//                         }
+//                         pendStatus = GetPendStatus(PEND_OP_SET_SOURCE);
+//                         if(pendStatus == PEND_STATUS_PENDING)
+//                         {
+//                             *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                             return sizeof (INT8U);
+//                         }
+//                         //NWConfig.VLANID=0;
+//                         NWConfig.CfgMethod = pBMCInfo->LANCfs[EthIndex].IPAddrSrc;
+//                         SetPendStatus(PEND_OP_SET_SOURCE,PEND_STATUS_PENDING);
+//                         PostPendTask(PEND_OP_SET_SOURCE,(INT8U*) &NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
+//                         pBMCInfo->LANCfs[EthIndex].VLANID = pSetLanReq->ConfigData.VLANID;
+//                     }
+
+//                 }
+//             }
+//             else
+//             {
+//                 pSetLanRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof(INT8U);
+//             }
+//         break;
+
+//         case LAN_PARAM_VLAN_PRIORITY:
+
+//             if( pBMCInfo->IpmiConfig.VLANIfcSupport == 1)
+//             {
+//                 if((pBMCInfo->LANCfs[EthIndex].VLANID & VLAN_MASK_BIT) != VLAN_MASK_BIT)    /* checks for VLAN enable bit*/
+//                 {
+//                     if(g_corefeatures.vlan_priorityset == ENABLED)
+//                     {
+//                         if(pSetLanReq->ConfigData.VLANPriority > 7 )
+//                         {
+//                             TCRIT(" VLAN Priority value should be 0-7 \n");
+//                             *pRes = CC_INV_DATA_FIELD ;
+//                             return sizeof (*pRes);
+//                         }
+//                         if(ReadVLANFile(VLAN_PRIORITY_SETTING_STR, PriorityLevel) == -1)
+//                         {
+//                             return -1;
+//                         }
+//                         if(WriteVLANFile(VLAN_PRIORITY_SETTING_STR, PriorityLevel, netindex,pSetLanReq->ConfigData.VLANPriority) == -1)
+//                         {
+//                             return -1;
+//                         }
+//                         pBMCInfo->LANCfs[EthIndex].VLANPriority = pSetLanReq->ConfigData.VLANPriority;
+//                     }
+//                     else
+//                     {
+//                         TCRIT(" VLAN is not Configured \n");
+//                         *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                         return sizeof (*pRes);
+//                     }
+//                 }
+//                 else
+//                 {
+//                     if(pSetLanReq->ConfigData.VLANPriority > 7 )
+//                     {
+//                         TCRIT(" VLAN Priority value should be 0-7 \n");
+//                         *pRes = CC_INV_DATA_FIELD ;
+//                         return sizeof (*pRes);
+//                     }
+
+//                     if(ReadVLANFile(VLAN_PRIORITY_SETTING_STR, PriorityLevel) == -1)
+//                     {
+//                         return -1;
+//                     }
+
+//                     if(WriteVLANFile(VLAN_PRIORITY_SETTING_STR, PriorityLevel, netindex,pSetLanReq->ConfigData.VLANPriority) == -1)
+//                     {
+//                         return -1;
+//                     }
+
+//                     pBMCInfo->LANCfs[EthIndex].VLANPriority = pSetLanReq->ConfigData.VLANPriority;
+//                     vlanID = (pBMCInfo->LANCfs[EthIndex].VLANID & 0xfff);
+//                     memset(IfcName,0,sizeof(IfcName));
+//                     if(GetIfcName(EthIndex, IfcName,BMCInst) != 0)
+//                     {
+//                          TCRIT("Error in getting Interface Name for the Lan Index :%d\n",EthIndex);
+//                          *pRes = CC_INV_DATA_FIELD;
+//                          return sizeof(*pRes);
+//                     }
+//                     /*vconfig set_egress_map <valninterface> <skb_buffer> <vlan-priority>*/
+//                     sprintf(cmdSetPriority,"vconfig set_egress_map  %s.%d  0  %d",IfcName,vlanID,pSetLanReq->ConfigData.VLANPriority);
+//                     if(((retValue = safe_system(cmdSetPriority)) < 0))
+//                     {
+//                         TCRIT("ERROR %d: Set VLAN Priority failed\n",retValue);
+//                     }
+                
+//                 /* 
+//                  * Set priority of IPMI commands. 
+//                  * The skb->priority value of IPMI command will be modified by TOS option.
+//                  * So, use the mapping table to get the current value.
+//                  */
+//                     memset(&cmdSetPriority,0,sizeof(cmdSetPriority));
+//                     TOS = pBMCInfo->LANCfs[EthIndex].Ipv4HdrParam.TypeOfService;
+//                     SkbPriority = IP_TOS2PRIO[IPTOS_TOS(TOS)>>1];
+//                     sprintf(cmdSetPriority,"vconfig set_egress_map %s.%d %d %d",IfcName,vlanID,SkbPriority,pSetLanReq->ConfigData.VLANPriority);
+//                     if(((retValue = safe_system(cmdSetPriority)) < 0))
+//                     {
+//                         TCRIT("ERROR %d: Set VLAN IPMI Priority failed\n",retValue);
+//                     } 
+//                 }
+//             }
+//             else
+//             {
+//                  pSetLanRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                  return sizeof(INT8U);
+//             }
+//         break;
+
+
+//         case LAN_PARAM_CIPHER_SUITE_ENTRY_SUP:
+//             pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
+//             return sizeof(INT8U);
+
+//         case LAN_PARAM_CIPHER_SUITE_ENTRIES:
+//             pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
+//             return sizeof(INT8U);
+//             break;
+
+//         case LAN_PARAM_CIPHER_SUITE_PRIV_LEVELS:
+//             LOCK_BMC_SHARED_MEM(BMCInst);
+//             _fmemcpy (pBMCInfo->LANCfs[EthIndex].CipherSuitePrivLevels,
+//                       pSetLanReq->ConfigData.CipherSuitePrivLevels, MAX_NUM_CIPHER_SUITE_PRIV_LEVELS);
+//             UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             break;
+
+//         case LAN_PARAM_VLAN_TAGS:
+//             if (0 == pSetLanReq->ConfigData.DestAddr.SetSelect)
+//           {
+//                 LOCK_BMC_SHARED_MEM(BMCInst);
+//                 _fmemcpy(&pSharedMem->VLANDestTag,
+//                          ((_NEAR_ INT8U*)&pSetLanReq->ConfigData) + 1, sizeof(VLANDestTags_T));
+//                 UNLOCK_BMC_SHARED_MEM(BMCInst);
+//           }
+//           else
+//           {
+//                 if (pSetLanReq->ConfigData.DestAddr.SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest)
+//                 {
+//                     pSetLanRes->CompletionCode = CC_PARAM_OUT_OF_RANGE;
+//                     return sizeof (INT8U);
+//                 }
+//                 LOCK_BMC_SHARED_MEM(BMCInst);
+//                 _fmemcpy(&pBMCInfo->LANCfs[EthIndex].VLANDestTags [pSetLanReq->ConfigData.DestAddr.SetSelect - 1],
+//                          ((_NEAR_ INT8U*)&pSetLanReq->ConfigData) + 1, sizeof(VLANDestTags_T));
+//                 UNLOCK_BMC_SHARED_MEM(BMCInst);
+//           }
+//             break;
+
+//         case LAN_PARAMS_BAD_PASSWORD_THRESHOLD:
+//             ClearUserLockAttempts(LAN_CHANNEL_BADP,BMCInst);
+//             LOCK_BMC_SHARED_MEM(BMCInst);
+//             _fmemcpy(&pBMCInfo->LANCfs[EthIndex].BadPasswd,
+//                             &pSetLanReq->ConfigData.BadPasswd,sizeof(BadPassword_T));
+//             UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             break;
+        
+//         case LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR:
+
+//             if (pSetLanReq->ConfigData.DestType.SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
+//             {
+//                 TCRIT("Invalid data for SetSelect");
+//                 *pRes = CC_INV_DATA_FIELD ;
+//                 return sizeof (*pRes);
+//             }
+
+// 			/*Validate the IPv6 address*/
+//         	if(0 != IsValidGlobalIPv6Addr((struct in6_addr*)&pSetLanReq->ConfigData.Destv6Addr.IPAddr))
+//          	{
+//             	TCRIT("Invalid Global IPv6 Address\n");
+//               	*pRes = CC_INV_DATA_FIELD;
+//               	return sizeof(INT8U);
+//          	}
+
+//             if (0 == pSetLanReq->ConfigData.Destv6Addr.SetSelect)
+//             {
+//                 LOCK_BMC_SHARED_MEM(BMCInst);
+//                 _fmemcpy (&pSharedMem->VolLANv6Dest,
+//                   &pSetLanReq->ConfigData.Destv6Addr, sizeof(LANDestv6Addr_T));
+
+//                 memset(pSharedMem->VolLANDest,0,sizeof(LANDestAddr_T));
+
+//                 UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             }
+//             else
+//             {
+//                 LOCK_BMC_SHARED_MEM(BMCInst);
+//                 _fmemcpy (&pBMCInfo->LANCfs[EthIndex].Destv6Addr[pSetLanReq->ConfigData.Destv6Addr.SetSelect - 1],
+//                   &pSetLanReq->ConfigData.Destv6Addr, sizeof(LANDestv6Addr_T));
+
+//                 memset(&pBMCInfo->LANCfs[EthIndex].DestAddr[pSetLanReq->ConfigData.DestAddr.SetSelect - 1],0,sizeof(LANDestAddr_T));
+
+//                 UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             }
+
+//             TDBG("\n SetLanconfig: Setting SNMPv6 configuration done..\n");
+
+//             break;
+
+//         case LAN_PARAMS_AMI_OEM_ENABLE_SET_MAC:	//194
+//             NIC_Count = g_coremacros.global_nic_count;
+//             if (ReqLen != 1)
+//             	pSetLanRes->CompletionCode = CC_REQ_INV_LEN;
+//             else if (pSetLanReq->ConfigData.EthIndex > ( NIC_Count- 1))
+//             	pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
+//             else
+//             {
+//             	enableSetMACAddr = TRUE;
+// 				macEthIndex = pSetLanReq->ConfigData.EthIndex;
+// 				pSetLanRes->CompletionCode = CC_NORMAL;
+//             }
+
+//         	return sizeof(*pSetLanRes);
+
+
+//         case LAN_PARAMS_AMI_OEM_IPV6_ENABLE:
+//             pendStatus = GetPendStatus(PEND_OP_SET_IPV6_ENABLE);
+//             if (pendStatus == PEND_STATUS_PENDING)
+//             {
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+            
+//             TDBG("\n Entered in LAN_PARAMS_AMI_OEM_IPV6_ENABLE \n");         
+//             if ( pBMCInfo->LANCfs[EthIndex].IPv6_Enable == pSetLanReq->ConfigData.IPv6_Enable)
+//             {
+//                 TCRIT("LAN or VLAN - the current state is the same \n");
+//                 break;
+//             }
+//             pBMCInfo->LANCfs[EthIndex].IPv6_Enable= pSetLanReq->ConfigData.IPv6_Enable;
+            
+//             NWConfig6.enable= pSetLanReq->ConfigData.IPv6_Enable;           
+//             SetPendStatus(PEND_OP_SET_IPV6_ENABLE,PEND_STATUS_PENDING);
+//             PostPendTask(PEND_OP_SET_IPV6_ENABLE,(INT8U*) &NWConfig6,sizeof(NWConfig6),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
+//             break;
+
+
+//         case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_SOURCE:
+//             pendStatus = GetPendStatus(PEND_OP_SET_IPV6_IP_ADDR_SOURCE);
+//             if (pendStatus == PEND_STATUS_PENDING)
+//             {
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+            
+//             TDBG("\n Entered in LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_SOURCE \n");
+//              /* check for IPv6 enable state */
+//             if ( pBMCInfo->LANCfs[EthIndex].IPv6_Enable != 1)
+//             {
+//                 TCRIT("IPv6 is not enabled yet... \n");
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+            
+//             if ((pSetLanReq->ConfigData.IPv6_IPAddrSrc > BMC_OTHER_SOURCE)
+//                 ||(pSetLanReq->ConfigData.IPv6_IPAddrSrc == UNSPECIFIED_IP_SOURCE))
+//             {
+//                 *pRes = CC_INV_DATA_FIELD;
+//                 return sizeof (INT8U);
+//             }
+//            else if((pSetLanReq->ConfigData.IPv6_IPAddrSrc == BIOS_IP_SOURCE)
+//                        || (pSetLanReq->ConfigData.IPv6_IPAddrSrc == BMC_OTHER_SOURCE))
+//            {
+//                 /* we only support DHCP and Static IP source */
+//                 *pRes = CC_INV_DATA_FIELD;
+//                 return sizeof (INT8U);
+//            }
+           
+//             if (pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == pSetLanReq->ConfigData.IPv6_IPAddrSrc )
+//             {
+//                 TCRIT("LAN or VLAN if current SRC is DHCP/Static and incoming SRC is DHCP/Static, do nothing\n");
+//                 break;
+//             }
+            
+//             pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc = pSetLanReq->ConfigData.IPv6_IPAddrSrc ;
+//             if ( (pSetLanReq->ConfigData.IPv6_IPAddrSrc == STATIC_IP_SOURCE ) || (pSetLanReq->ConfigData.IPv6_IPAddrSrc == DHCP_IP_SOURCE ) )
+//             {
+//                 NWConfig6.CfgMethod = pSetLanReq->ConfigData.IPv6_IPAddrSrc;
+//                 SetPendStatus(PEND_OP_SET_IPV6_IP_ADDR_SOURCE,PEND_STATUS_PENDING);
+//                 PostPendTask(PEND_OP_SET_IPV6_IP_ADDR_SOURCE,(INT8U*) &NWConfig6,sizeof(NWConfig6),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
+//             }
+//           break;            
+
+
+//         case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR:
+//             pendStatus = GetPendStatus(PEND_OP_SET_IPV6_IP_ADDR);
+//             if (pendStatus == PEND_STATUS_PENDING)
+//             {
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+            
+//             TDBG("\n Entered in LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR \n");
+//             /* check for IPv6 enable state */
+//             if ( pBMCInfo->LANCfs[EthIndex].IPv6_Enable != 1)
+//             {
+//                 TCRIT("IPv6 is not enabled yet... \n");
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+
+//             /* Do IP address source check */
+//             if( pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == DHCP_IP_SOURCE)
+//             {
+//                 TCRIT("IPv6 Address source is currently in DHCP \n");
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+
+//             /*Validate the Index value*/
+//             if(pSetLanReq->ConfigData.IPv6Addr.IPv6_Cntr & 0xF0)
+//             {
+//                 *pRes = CC_INV_DATA_FIELD;
+//                 return sizeof(INT8U);
+//             }
+
+//             /*Validate the IPv6 address*/
+//             if(0 != IsValidGlobalIPv6Addr((struct in6_addr*)&pSetLanReq->ConfigData.IPv6Addr.IPv6_IPAddr))
+//             {
+//                 TCRIT("Invalid Global IPv6 Address\n");
+//                 *pRes = CC_INV_DATA_FIELD;
+//                 return sizeof(INT8U);
+//             }
+
+//             /*Validate the duplicate IPv6 Address*/
+//             nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
+//             for(i=0;i<MAX_IPV6ADDRS;i++)
+//             {
+//                 /*Use can set the same IPv6 address for same index. To satisfy the WebServer*/
+//                 if((memcmp(NWConfig6.GlobalIPAddr[i],pSetLanReq->ConfigData.IPv6Addr.IPv6_IPAddr,IP6_ADDR_LEN) == 0) && pSetLanReq->ConfigData.IPv6Addr.IPv6_Cntr != i)
+//                 {
+//                     *pRes = CC_INV_DATA_FIELD;
+//                     return sizeof(INT8U);
+//                 }
+//             }
+
+//             _fmemcpy(pBMCInfo->LANCfs[EthIndex].IPv6_IPAddr[pSetLanReq->ConfigData.IPv6Addr.IPv6_Cntr], pSetLanReq->ConfigData.IPv6Addr.IPv6_IPAddr, IP6_ADDR_LEN );
+            
+//             SetPendStatus(PEND_OP_SET_IPV6_IP_ADDR,PEND_STATUS_PENDING);
+//             PostPendTask(PEND_OP_SET_IPV6_IP_ADDR, (INT8U*) &pSetLanReq->ConfigData.IPv6Addr,\
+//             sizeof (IPv6Addr_T),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
+//             break;
+
+
+//         case LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH:
+//             pendStatus = GetPendStatus(PEND_OP_SET_IPV6_PREFIX_LENGTH);
+//             if (pendStatus == PEND_STATUS_PENDING)
+//             {
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+            
+//             TDBG("\n Entered in LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH \n");
+//             /* check for IPv6 enable state */
+//             if ( pBMCInfo->LANCfs[EthIndex].IPv6_Enable != 1)
+//             {
+//                 TCRIT("IPv6 is not enabled yet... \n");
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+
+//             /* Do IP address source check */
+//             if( pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == DHCP_IP_SOURCE)
+//             {
+//                 TCRIT("IPv6 Address source is currently in DHCP \n");
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+
+//             /*Validate the Index value*/
+//             if(pSetLanReq->ConfigData.IPv6Prefix.IPv6_Prepos & 0xF0)
+//             {
+//                 *pRes = CC_INV_DATA_FIELD;
+//                 return sizeof(INT8U);
+//             }
+
+//             pBMCInfo->LANCfs[EthIndex].IPv6_PrefixLen[pSetLanReq->ConfigData.IPv6Prefix.IPv6_Prepos] = pSetLanReq->ConfigData.IPv6Prefix.IPv6_PrefixLen;
+            
+//             SetPendStatus(PEND_OP_SET_IPV6_PREFIX_LENGTH,PEND_STATUS_PENDING);
+//             PostPendTask(PEND_OP_SET_IPV6_PREFIX_LENGTH,(INT8U*) &pSetLanReq->ConfigData.IPv6Prefix, sizeof(IPv6Prefix_T),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
+//             break;
+
+//         case LAN_PARAMS_AMI_OEM_IPV6_GATEWAY_IP:
+//             pendStatus = GetPendStatus(PEND_OP_SET_IPV6_GATEWAY);
+//             if (pendStatus == PEND_STATUS_PENDING)
+//             {
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+            
+//             TDBG("\n Entered in LAN_PARAMS_AMI_OEM_IPV6_GATEWAY_IP \n");
+//             /* check for IPv6 enable state */
+//             if ( pBMCInfo->LANCfs[EthIndex].IPv6_Enable != 1)
+//             {
+//                 TCRIT("IPv6 is not enabled yet... \n");
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+
+//             /* Do IP address source check */
+//             if( pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == DHCP_IP_SOURCE)
+//             {
+//                 TCRIT("IPv6 Address source is currently in DHCP \n");
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+
+// 			/*Validate the IPv6 address*/
+//             if(0 != IsValidGlobalIPv6Addr((struct in6_addr*)&pSetLanReq->ConfigData.IPv6_GatewayIPAddr))
+//             {
+//                 TCRIT("Invalid Global IPv6 Address\n");
+//                 *pRes = CC_INV_DATA_FIELD;
+//                 return sizeof(INT8U);
+//             }
+            
+//             _fmemcpy( pBMCInfo->LANCfs[EthIndex].IPv6_GatewayIPAddr, pSetLanReq->ConfigData.IPv6_GatewayIPAddr, IP6_ADDR_LEN );
+            
+//             _fmemcpy( NWConfig6.Gateway, pSetLanReq->ConfigData.IPv6_GatewayIPAddr, IP6_ADDR_LEN );
+//             SetPendStatus(PEND_OP_SET_IPV6_GATEWAY,PEND_STATUS_PENDING);
+//             PostPendTask(PEND_OP_SET_IPV6_GATEWAY,(INT8U*) &NWConfig6,sizeof(NWConfig6),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
+//             break;
+
+//         case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_EUI64:
+
+//         /* The first byte is the index and it should contain atleast one byte of IPv6 address and it cannot exceed 8 bytes incase of EUI-64 algo */
+//         if((ReqLen < 2) || (ReqLen > 9)) 
+//         {
+//             *pRes = CC_REQ_INV_LEN;
+//             return sizeof(INT8U);
+//         }
+
+//         pendStatus = GetPendStatus(PEND_OP_SET_IPV6_IP_ADDR);
+//         if (pendStatus == PEND_STATUS_PENDING)
+//         {
+//             *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//             return sizeof (INT8U);
+//         }
+
+//         TDBG("\n Entered in LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_EUI64 \n");
+
+//         /* Check for IPv6 enabled state */
+//         if(pBMCInfo->LANCfs[EthIndex].IPv6_Enable != 1)
+//         {
+//             TCRIT("IPv6 is not enabled yet... \n");
+//             *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//             return sizeof(INT8U);
+//         }
+
+//         /* Do IP address source check */
+//         if(pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == DHCP_IP_SOURCE)
+//         {
+//             TCRIT("IPv6 Address source is currently in DHCP \n");
+//             *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//             return sizeof (INT8U);
+//         }
+
+//         /*Validate the Index value*/
+//         if(pSetLanReq->ConfigData.IPv6Addr.IPv6_Cntr & 0xF0)
+//         {
+//             TCRIT("Index of the given IPv6 Address is invalid. \n");
+//             *pRes = CC_INV_DATA_FIELD;
+//             return sizeof(INT8U);
+//         }
+
+//         /* The request may be of variable length, so fill the network prefix by appending zeros. This is to avoid garbage values */
+//         for(i = ReqLen-1; i<8; i++)
+//         {
+//             pSetLanReq->ConfigData.IPv6Addr.IPv6_IPAddr[i] = 0;
+//         }
+
+//         /* Generate the IPv6 address using EUI-64 algo */
+//         if(nwFormIPv6Addr_EUI64((INT8U*) &pSetLanReq->ConfigData.IPv6Addr.IPv6_IPAddr, netindex, g_corefeatures.global_ipv6) != 0)
+//         {
+//             *pRes = CC_INV_DATA_FIELD;
+//             return sizeof(INT8U);
+//         }
+
+//         /* Get the current network configuration settings */
+//         nwReadNWCfg_v4_v6(&NWConfig, &NWConfig6, netindex, g_corefeatures.global_ipv6);
+
+//         /*Validate the duplicate IPv6 Address*/
+//         for(i=0; i<MAX_IPV6ADDRS; i++)
+//         {
+//             /* User can set the same IPv6 address for same index to satisfy the WebServer */
+//             if((memcmp(NWConfig6.GlobalIPAddr[i], pSetLanReq->ConfigData.IPv6Addr.IPv6_IPAddr, IP6_ADDR_LEN) == 0) && pSetLanReq->ConfigData.IPv6Addr.IPv6_Cntr != i)
+//             {
+//                 TCRIT("\n Error in setting the IPv6 address - Duplicate :( \n");
+//                 *pRes = CC_INV_DATA_FIELD;
+//                 return sizeof(INT8U);
+//             }
+//         }
+
+//         _fmemcpy(pBMCInfo->LANCfs[EthIndex].IPv6_IPAddr[pSetLanReq->ConfigData.IPv6Addr.IPv6_Cntr], pSetLanReq->ConfigData.IPv6Addr.IPv6_IPAddr, IP6_ADDR_LEN);
+
+//         SetPendStatus(PEND_OP_SET_IPV6_IP_ADDR,PEND_STATUS_PENDING);
+//         PostPendTask(PEND_OP_SET_IPV6_IP_ADDR, (INT8U*) &pSetLanReq->ConfigData.IPv6Addr, sizeof(IPv6Addr_T), (pSetLanReq->ChannelNum & 0x0F), BMCInst);
+//         break;
+
+// 	case LAN_PARAMS_AMI_OEM_PHY_SETTINGS:
+
+//         if(ReqLen != 4)
+//         {
+//             pSetLanRes->CompletionCode = CC_REQ_INV_LEN;
+//             return sizeof(*pSetLanRes);
+//         }
+
+//         memset(IfcName, 0, sizeof(IfcName));
+
+//         if(GetIfcNameByIndex(EthIndex, IfcName) != 0)
+//         {
+//             TCRIT("Error in Getting Interface Name for the lan Index:%d\n",EthIndex);
+//             pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
+//             return sizeof(*pSetLanRes);
+//         }
+
+//         if(nwGetEthInformation(&PHYCfg, IfcName) == 0) 
+//         { 
+//             if(((PHYCfg.autoneg == pSetLanReq->ConfigData.PHYConfig.AutoNegotiationEnable)  && (PHYCfg.speed == pSetLanReq->ConfigData.PHYConfig.Speed)  
+//                 && (PHYCfg.duplex == pSetLanReq->ConfigData.PHYConfig.Duplex))) 
+//             { 
+//                 TDBG("There is no change in the link mode, ignoring the request for setting the speed/duplex.\n"); 
+//                 break; 
+//             } 
+//         } 
+//         else 
+//         { 
+//             pSetLanRes->CompletionCode = CC_UNSPECIFIED_ERR; 
+//             return sizeof(*pSetLanRes); 
+//         } 
+ 
+//         if(pSetLanReq->ConfigData.PHYConfig.Speed != 0xFFFF && pSetLanReq->ConfigData.PHYConfig.Duplex != 0xFF) 
+//         { 
+//             if(IsLinkModeSupported(&PHYCfg,pSetLanReq->ConfigData.PHYConfig.Speed,pSetLanReq->ConfigData.PHYConfig.Duplex) <= 0) 
+//             { 
+//                 TCRIT("Unsupported link mode \n"); 
+//                 pSetLanRes->CompletionCode = CC_INV_DATA_FIELD; 
+//                 return sizeof(*pSetLanRes); 
+//             } 
+//         }         
+        
+//         SetPendStatus(PEND_OP_SET_SPEED, PEND_STATUS_PENDING);
+//         PostPendTask(PEND_OP_SET_SPEED, (INT8U*) &(pSetLanReq->ConfigData.PHYConfig), sizeof(PHYConfig_T),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
+
+//         break;
+	
+// case LAN_PARAMS_AMI_OEM_MTU_SETTINGS:
+//             if(ReqLen != 2)
+//             {
+//                 pSetLanRes->CompletionCode = CC_REQ_INV_LEN;
+//                 return sizeof(*pSetLanRes);
+//             }
+
+//             /* Setting MTU values less than 1280 disables IPv6,
+//                RFC 1280 recommends MTU value should be greater than 1200 for IPV6.
+//                so restricting MTU value b/w 1280 to 1500.*/
+        			
+//             if( (pSetLanReq->ConfigData.MTU_size < 1280) || (pSetLanReq->ConfigData.MTU_size > 1500) )
+//             {
+//                 pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
+//                 return sizeof(*pSetLanRes);
+//             }
+
+//             SetPendStatus(PEND_OP_SET_MTU_SIZE, PEND_STATUS_PENDING);
+//             PostPendTask(PEND_OP_SET_MTU_SIZE, (INT8U*) &(pSetLanReq->ConfigData.MTU_size), sizeof(INT16U),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
+            
+//             break;
+
+//     case LAN_PARAMS_SSI_OEM_2ND_PRI_ETH_MAC_ADDR:
+//         if(g_corefeatures.ssi_support == ENABLED)
+//         {
+//             pendStatus = GetPendStatus(PEND_OP_SET_MAC_ADDRESS);
+//             if(pendStatus == PEND_STATUS_PENDING)
+//             {
+//                 *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
+//                 return sizeof (INT8U);
+//             }
+//             if (!enableSetMACAddr)
+//             {
+//                 pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
+//                 return sizeof(INT8U);
+//             }
+//             else
+//             {
+//                 EnableSetMACAddress_T macAddrEnabled;
+//                 memset(&macAddrEnabled, 0, sizeof(EnableSetMACAddress_T));
+//                 macAddrEnabled.EthIndex = 0x1; /* Specify the 2nd interface */
+//                 memcpy(&macAddrEnabled.MACAddress, pSetLanReq->ConfigData.SSI2ndPriEthMACAddr, MAC_ADDR_LEN);
+//                 SetPendStatus(PEND_OP_SET_MAC_ADDRESS, PEND_STATUS_PENDING);
+//                 PostPendTask(PEND_OP_SET_MAC_ADDRESS, (INT8U*)&macAddrEnabled, sizeof(EnableSetMACAddress_T), 0x1, BMCInst);
+//             }
+//             break;
+//           }
+//           else
+//           {
+//             pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//             return sizeof(INT8U);
+//           }
+
+//     case LAN_PARAMS_SSI_OEM_LINK_CTRL:
+//         if(g_corefeatures.ssi_support == ENABLED)
+//         {
+//             pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM; /* Read Only */
+//         }
+//         else
+//         {
+//             pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//         }
+//             return sizeof(INT8U);
+
+//     case LAN_PARAMS_SSI_OEM_CMM_IP_ADDR:
+//         if(g_corefeatures.ssi_support == ENABLED)
+//         {
+//             _fmemcpy(pBMCInfo->SSIConfig.CMMIPAddr, pSetLanReq->ConfigData.CMMIPAddr, IP_ADDR_LEN);
+//             FlushIPMI((INT8U*)&pBMCInfo->SSIConfig, (INT8U*)&pBMCInfo->SSIConfig, pBMCInfo->IPMIConfLoc.SSIConfigAddr,
+//                       sizeof(SSIConfig_T), BMCInst);
+//             break;
+//         }
+//         else
+//         {
+//             pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//             return sizeof(INT8U);
+//         }
+
+//     default:
+//         if(g_corefeatures.ncsi_cmd_support == ENABLED)
+//         {
+//             switch (pSetLanReq->ParameterSelect)
+//             {
+//                 case LAN_PARAMS_AMI_OEM_NCSI_CONFIG_NUM:
+//                     pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
+//                     return sizeof(*pSetLanRes);
+
+//                 case LAN_PARAMS_AMI_OEM_NCSI_SETTINGS:
+//                     NIC_Count=g_coremacros.global_nic_count;
+//                     if (ReqLen != 3)
+//                         pSetLanRes->CompletionCode = CC_REQ_INV_LEN;
+//                     else if (pSetLanReq->ConfigData.NCSIPortConfig.Interface >= NIC_Count)
+//                         pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
+//                     else
+//                     {
+//                         pendStatus = GetPendStatus(PEND_OP_SET_NCSI_CHANNEL_ID);
+//                         if(pendStatus == PEND_STATUS_PENDING)
+//                         {
+//                             *pRes = CC_NODE_BUSY;
+//                             return sizeof (INT8U);
+//                         }
+                        
+//                         NCSIConfig_T configData;
+//                         char interfaceName[8];
+//                         memset(&configData, 0, sizeof(NCSIConfig_T));
+//                         memset(interfaceName, 0, sizeof(interfaceName));
+
+//                         snprintf(interfaceName, sizeof(interfaceName), "%s%d", "eth", pSetLanReq->ConfigData.NCSIPortConfig.Interface);
+
+//                         if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
+//                             pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
+//                         else
+//                         {
+//                             configData.PackageId = pSetLanReq->ConfigData.NCSIPortConfig.PackageId;
+//                             configData.ChannelId = pSetLanReq->ConfigData.NCSIPortConfig.ChannelId;
+
+//                             if (NCSISetPortConfigByName(interfaceName, configData) != 0)
+//                                 pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
+//                             else
+//                             {
+//                                 SetPendStatus(PEND_OP_SET_NCSI_CHANNEL_ID, PEND_STATUS_PENDING);
+//                                 PostPendTask(PEND_OP_SET_NCSI_CHANNEL_ID, NULL, 0, 0, BMCInst);
+//                                 pSetLanRes->CompletionCode = CC_NORMAL;
+//                             }
+//                         }
+//                     }
+//                     return sizeof(*pSetLanRes);
+//                 case LAN_PARAMS_AMI_OEM_NCSI_MODE_CHANGE:
+//                     NIC_Count=g_coremacros.global_nic_count;
+//                     if (ReqLen != 2)
+//                         pSetLanRes->CompletionCode = CC_REQ_INV_LEN;
+//                     else if (pSetLanReq->ConfigData.NCSIModeConfig.Interface >= NIC_Count)
+//                         pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
+//                     else 
+//                     {
+//                         pendStatus = GetPendStatus(PEND_OP_SET_NCSI_MODE_CHANGE);
+//                         if(pendStatus == PEND_STATUS_PENDING)
+//                         {
+//                             *pRes = CC_NODE_BUSY;
+//                             return sizeof (INT8U);
+//                         }
+                    
+//                         NCSIConfig_T configData;
+//                         char interfaceName[8];
+//                         memset(&configData, 0, sizeof(NCSIConfig_T));
+//                         memset(interfaceName, 0, sizeof(interfaceName));
+
+//                         snprintf(interfaceName, sizeof(interfaceName), "%s%d", "eth", pSetLanReq->ConfigData.NCSIModeConfig.Interface);
+						
+//                         if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
+//                             pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
+//                         else
+//                         {
+//                             configData.AutoSelect = pSetLanReq->ConfigData.NCSIModeConfig.NCSIMode;
+//                             if (NCSISetPortConfigByName(interfaceName, configData) != 0)
+//                                 pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
+//                             else
+//                             {
+//                                 SetPendStatus(PEND_OP_SET_NCSI_MODE_CHANGE, PEND_STATUS_PENDING);
+//                                 PostPendTask(PEND_OP_SET_NCSI_MODE_CHANGE, NULL, 0, 0, BMCInst);
+//                                 pSetLanRes->CompletionCode = CC_NORMAL;                    	
+//                             }
+//                         }
+//                     }
+//                     return sizeof(*pSetLanRes);
+//                 case LAN_PARAMS_AMI_OEM_NCSI_EXTENSION:
+//                     if ((0x20 == pSetLanReq->ConfigData.NCSIPHYConfigSet.Command) && 
+//                         (g_corefeatures.ncsi_keep_phy_linkup_support == ENABLED))
+//                     {
+//                         NIC_Count=g_coremacros.global_nic_count;
+//                         if (ReqLen != 3)
+//                             pSetLanRes->CompletionCode = CC_REQ_INV_LEN;
+//                         else if (pSetLanReq->ConfigData.NCSIPHYConfigSet.Interface >= NIC_Count)
+//                             pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
+//                         else 
+//                         {
+//                             pendStatus = GetPendStatus(PEND_OP_SET_NCSI_VETOBIT);
+//                             if(pendStatus == PEND_STATUS_PENDING)
+//                             {
+//                                 *pRes = CC_NODE_BUSY;
+//                                 return sizeof (INT8U);
+//                             }
+
+//                             NCSIConfig_T configData;
+//                             char interfaceName[8];
+//                             memset(&configData, 0, sizeof(NCSIConfig_T));
+//                             memset(interfaceName, 0, sizeof(interfaceName));
+
+//                             snprintf(interfaceName, sizeof(interfaceName), "%s%d", "eth", pSetLanReq->ConfigData.NCSIPHYConfigSet.Interface);
+
+//                             if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
+//                                 pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
+//                             else
+//                             {
+//                                 configData.VetoBit= pSetLanReq->ConfigData.NCSIPHYConfigSet.VetoBit;
+//                                 if (NCSISetPortConfigByName(interfaceName, configData) != 0)
+//                                     pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
+//                                 else
+//                                 {
+//                                     SetPendStatus(PEND_OP_SET_NCSI_VETOBIT, PEND_STATUS_PENDING);
+//                                     PostPendTask(PEND_OP_SET_NCSI_VETOBIT, NULL, 0, 0, BMCInst);
+//                                     pSetLanRes->CompletionCode = CC_NORMAL;
+//                                 }
+//                             }
+//                         }
+//                     }
+//                     else
+//                     {
+//                          pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//                     }
+
+//                     return sizeof(*pSetLanRes);
+
+//                 default:
+//                     TDBG("In Valid Option\n");
+//             }
+//         }
+//         pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//         return sizeof(INT8U);
+//     }
+    
+//     pSetLanRes->CompletionCode = CC_NORMAL;
+    
+//     if(g_PDKHandle[PDK_POSTSETLANPARAM] != NULL)
+//     {
+//         ((int(*)(INT8U*, INT8U, int))(g_PDKHandle[PDK_POSTSETLANPARAM]))(pReq, ReqLen, BMCInst);
+//     }
+    
+//     FlushIPMI((INT8U*)&pBMCInfo->LANCfs[0],(INT8U*)&pBMCInfo->LANCfs[EthIndex],pBMCInfo->IPMIConfLoc.LANCfsAddr,
+//                       sizeof(LANConfig_T),BMCInst);
+//     return sizeof(*pSetLanRes);
+// }
+
+// /*
+//  *@fn IPAddrCheck function
+//  *@brief It will validate the IP Address and net Mask
+//  *@param Addr - IP Address or net Mask
+//  *@param params - parameter data to validate
+//   */
+// int IPAddrCheck(INT8U *Addr,int params)
+// {
+//     int i,maskcount=0,bitmask =0,j,bitcheck=0;
+
+//     for(i=0;i< IP_ADDR_LEN;i++)
+//     {
+//         if(Addr[i] == BRD_CAST_BIT_MASK)
+//         {
+//             maskcount++;
+//         }
+//     }
+
+//     if(maskcount == IP_ADDR_LEN)
+//     {
+//         return 1;
+//     }
+
+//     if(params == LAN_PARAM_SUBNET_MASK)
+//     {
+//         if(Addr[0] == BRD_CAST_BIT_MASK)
+//         {
+//             for(i=1;i< IP_ADDR_LEN;i++)
+//             {
+//                 if(Addr[i-1] == 0)
+//                 {
+//                     bitmask = 1;
+//                 }
+//                 if(Addr[i] != 0)
+//                 {
+//                     for(j=0;j<8;j++)
+//                     {
+//                         if((Addr[i]<<j) & SUBNET_MASK_BIT_CHECK)
+//                         {
+//                             if(bitcheck == 1)
+//                             {
+//                                 return 1;
+//                             }
+//                             continue;
+//                         }
+//                         bitcheck=1;
+//                     }
+//                     if((bitcheck == 1 && Addr[i-1] != BRD_CAST_BIT_MASK) || (Addr[i] > 0 && bitmask == 1))
+//                     {
+//                         return 1;
+//                     }
+//                 }                       
+//             }
+//             return 0;
+//         }
+//         return 1;
+//     }
+
+//     if(Addr[0] == LOOP_BACK_BIT_MASK || Addr[0] == BRD_CAST_BIT_MASK)
+//     {
+//         return 1;
+//     }
+
+//     return 0;
+// }
+
+// /*----------------------------------------------
+//  * GratuitousARPTask
+//  *----------------------------------------------*/
+// void* GratuitousARPTask (INT8U *Addr)
+// {
+//     INT8U               IntervalInSec;
+//     INT8U               Status;
+//     int                 nRet;
+//     NWCFG_STRUCT        NWConfig;
+//     NWCFG6_STRUCT       NWConfig6;
+//     INT8U               EthIndex,netindex= 0xFF;
+//     int BMCInst,i;
+//     char IfcName[16];
+//     BMCArg *GratArpArgs = (BMCArg *)Addr;
+//     BMCInst = GratArpArgs->BMCInst;
+//     BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+//     prctl(PR_SET_NAME,__FUNCTION__,0,0,0);
+
+//     memcpy(&EthIndex,GratArpArgs->Argument,GratArpArgs->Len);
+
+//     memset(IfcName,0,sizeof(IfcName));
+//     /*Get the EthIndex*/
+//     if(GetIfcName(EthIndex,IfcName, BMCInst) == -1)
+//     {
+//         TCRIT("Error in Getting Ifcname\n");
+//         return 0;
+//     }
+
+//     for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
+//     {
+//         if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
+//         {
+//             netindex= Ifcnametable[i].Index;
+//             break;
+//         }
+//     }
+
+//     if(netindex == 0xFF)
+//     {
+//         TCRIT("Error in gettting netindex\n");
+//         return 0;
+//     }
+
+//     if(Addr != NULL)
+//     {
+//      free(GratArpArgs->Argument);
+//      free(Addr);
+//     }
+
+//     TDBG ("Gratuitous ARP thread starts for ethindex : %x\n",EthIndex);
+//     while (1)
+//     {
+//         /*Is Gratiutous Arp Enabled */
+//         if (0 == (pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl & GRATIUTOUS_ENABLE_MASK))
+//         {
+//             TDBG("Gratuitous ARP thread exits : Disable BMC-generated Gratuitous ARPs invoked\n");
+//             break;
+//         }
+
+//         /*Is Gratiutous Arp Suspended */
+//         Status = BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex];
+
+// 		if ((0 != (Status & GRATIUTOUS_ENABLE_MASK)) && 
+// 			(BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning == TRUE))
+//         {
+//             // Gratuitous ARP Suspended.
+//             // sleep requested to access Shared memory for two different threads.
+//             usleep (20);
+//             continue;
+//         }
+
+//         nwReadNWCfg_v4_v6( &NWConfig,&NWConfig6, netindex,g_corefeatures.global_ipv6);
+//         if(GetIfcName(EthIndex, IfcName,BMCInst) != 0)
+//         {
+//             TCRIT("Error in getting Interface Name for the Lan Index :%d\n",EthIndex);
+            
+//         }
+//         if (NWConfig.IFName[0] == 0)
+//             sprintf((char *)&NWConfig.IFName, "%s",IfcName);
+
+//         TDBG ( "MAC is %2x:%2x:%2x:%2x:%2x:%2x \n", NWConfig.MAC [0], NWConfig.MAC [1],
+//                 NWConfig.MAC [2], NWConfig.MAC [3], NWConfig.MAC [4], NWConfig.MAC [5] );
+//         TDBG ( "IP is %d.%d.%d.%d\n", NWConfig.IPAddr[0], NWConfig.IPAddr[1],
+//                 NWConfig.IPAddr[2], NWConfig.IPAddr[3]);
+//         TDBG ( "Device Name : %s\n", (char *)&NWConfig.IFName);
+
+//         nRet = SendGratuitousARPPacket((char *)&NWConfig.IFName, NWConfig.IPAddr, NWConfig.MAC);
+//         if (0 != nRet)
+//         {
+//             TCRIT("Gratuitous ARP thread exits : Unable to Send Gratuitous ARP packet\n");
+//             break;
+//         }
+//         TDBG ("Send Gratuitous Packet\n");
+
+//         if (0 == pBMCInfo->LANCfs[EthIndex].GratitousARPInterval)
+//         {
+//             IntervalInSec = 2; //Default 2 secs
+//         } else {
+//             // Gratuitous ARP interval in 500 millisecond increments.
+//             IntervalInSec = (pBMCInfo->LANCfs[EthIndex].GratitousARPInterval * 500)/1000;
+//         }
+//         usleep( IntervalInSec * 1000 * 1000 );
+//     }
+//     return 0;
+// }
+
+
+// /*---------------------------------------------------
+//  * GetLanConfigParam
+//  *---------------------------------------------------*/
+// int
+// GetLanConfigParam (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
+// {
+//     _NEAR_  GetLanConfigReq_T*  pGetLanReq = (_NEAR_ GetLanConfigReq_T*) pReq;
+//     _NEAR_  GetLanConfigRes_T*  pGetLanRes = (_NEAR_ GetLanConfigRes_T*) pRes;
+//     _FAR_   BMCSharedMem_T*     pSharedMem = BMC_GET_SHARED_MEM (BMCInst);
+//     INT8U IsOemDefined = FALSE;
+//     NWCFG_STRUCT        NWConfig;
+//     NWCFG6_STRUCT        NWConfig6;
+// //    V6DNS_CONFIG v6dnsconfig;
+//     INT8U EthIndex,netindex= 0xFF,i;
+//     _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//     int ncsiPortConfigNum = 0;
+
+//     ETHCFG_STRUCT PHYCfg;
+//     ChannelInfo_T* pChannelInfo = NULL;
+
+//     char IfcName[16];  /* Eth interface name */
+//     INT8U               ComStrLen=MAX_COMM_STRING_SIZE;
+//     int retValue = 0,NIC_Count = 0;
+
+//     pGetLanRes->CCParamRev.CompletionCode = CC_NORMAL;
+//     pGetLanRes->CCParamRev.ParamRevision  = PARAMETER_REVISION_FORMAT;
+
+// //    printf("---> channel: %d, parameter: %#x, setslect: %#x, blockselect: %#x\n", pGetLanReq->ChannelNum, pGetLanReq->ParameterSelect, pGetLanReq->SetSelect, pGetLanReq->BlockSelect);
+//     if(pGetLanReq->ChannelNum & RESERVED_VALUE_70)
+//     {
+//         /* Alarm !!! Somebody is trying to set Reseved Bits */
+//         *pRes = CC_INV_DATA_FIELD;
+//         return sizeof (*pRes);
+//     }
+
+//     if((pGetLanReq->ParameterSelect >= MIN_LAN_OEM_CONF_PARAM) && 
+//             (pGetLanReq->ParameterSelect <= MAX_LAN_OEM_CONF_PARAM) )
+//     {
+//     	/* Converts OEM parameter value to equivalent AMI parameter value */
+//     	if (0 != GetLanAMIParamValue (&pGetLanReq->ParameterSelect, &IsOemDefined) )
+//     	{
+//             pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//             return sizeof(INT8U);
+//     	}
+
+//     	/* Hook for OEM to handle this parameter */
+//         if ( (IsOemDefined)  && (g_PDKHandle[PDK_GETLANOEMPARAM] != NULL) )
+//         {
+// 			return ((int(*)(INT8U *, INT8U, INT8U *,int))(g_PDKHandle[PDK_GETLANOEMPARAM]))(pReq, ReqLen, pRes, BMCInst);
+//     	}
+   	
+//     }
+
+//     if (g_PDKHandle[PDK_BEFOREGETLANPARM] != NULL)
+//     {
+//         retValue = ((int(*)(INT8U *, INT8U, INT8U *,int))(g_PDKHandle[PDK_BEFOREGETLANPARM]))(pReq, ReqLen, pRes, BMCInst);
+//         if(retValue != 0)
+//         {
+//               return retValue;
+//         }
+//     }
+
+//     //! Validate the SetSelector value. 
+//     if (  (0x00 != pGetLanReq->SetSelect) &&  
+//           (pGetLanReq->ParameterSelect != LAN_PARAM_SELECT_DEST_TYPE) &&  
+//           (pGetLanReq->ParameterSelect != LAN_PARAM_SELECT_DEST_ADDR) &&  
+//           (pGetLanReq->ParameterSelect != LAN_PARAM_VLAN_TAGS) &&
+//           (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR) && 
+//           (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR) &&
+//           (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_EUI64) &&
+//           (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH))
+//     {
+//     	printf("GetLanConfigParam log1\n");
+//         if( g_corefeatures.ncsi_cmd_support == ENABLED )
+//         {
+//             if ((pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_NCSI_SETTINGS) &&
+// 				(pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_NCSI_MODE_CHANGE) &&
+// 				(pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_NCSI_EXTENSION))
+//             {
+//                 *pRes = CC_INV_DATA_FIELD;  
+//                 return sizeof (*pRes);  
+//             }
+//         }
+//         else
+//         {
+//             *pRes = CC_INV_DATA_FIELD;  
+//             return sizeof (*pRes);  
+//         }
+//     }  
+
+//     //! Validate the BlockSelector value.  
+//     if (0x00 != pGetLanReq->BlockSelect)  
+//     {
+//     	printf("GetLanConfigParam log2\n");
+//         *pRes = CC_INV_DATA_FIELD;  
+//         return sizeof (*pRes);  
+//     }
+
+
+//     EthIndex= GetEthIndex(pGetLanReq->ChannelNum & 0x0F, BMCInst);
+//     if(0xff == EthIndex)
+//     {
+//     	printf("GetLanConfigParam log3\n");
+//         *pRes = CC_INV_DATA_FIELD;
+//         return sizeof (INT8U);
+//     }
+
+//     /*Get the EthIndex*/
+//     if(GetIfcName(EthIndex,IfcName, BMCInst) != 0)
+//     {
+//         TCRIT("Error in Getting IfcName\n");
+//         *pRes = CC_INV_DATA_FIELD;
+//         return sizeof (INT8U);
+//     }
+
+//     for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
+//     {
+//         if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
+//         {
+//             netindex= Ifcnametable[i].Index;
+//             break;
+//         }
+//     }
+
+//     if(netindex == 0xFF)
+//     {
+//         TCRIT("Error in Getting netindex %d %s\n",netindex,IfcName);
+//         *pRes = CC_INV_DATA_FIELD;
+//         return sizeof (INT8U);
+//     }
+    
+//     if ((pGetLanReq->ChannelNum & GET_PARAMETER_REVISION_MASK) != 0)
+//     {
+//         if((MAX_LAN_CONF_PARAM >= pGetLanReq->ParameterSelect) ||
+//                ((MIN_LAN_OEM_CONF_PARAM <= pGetLanReq->ParameterSelect) && (MAX_LAN_OEM_CONF_PARAM >= pGetLanReq->ParameterSelect)) ) 
+//         {
+//             return sizeof(GetLanCCRev_T);
+//         }
+//         else
+//         {
+//              *pRes = CC_PARAM_NOT_SUPPORTED;
+//              return sizeof (*pRes);  
+//         }
+
+//     }
+//     else
+//     {
+//     	printf("GetLanConfigParam log4\n");
+//             switch(pGetLanReq->ParameterSelect)
+//             {
+//             case LAN_PARAM_SET_IN_PROGRESS:
+
+//                 LOCK_BMC_SHARED_MEM(BMCInst);
+//                 pGetLanRes->ConfigData.SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_Lan_SetInProgress;
+//                 UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                 break;
+
+//             case LAN_PARAM_AUTH_TYPE_SUPPORT:
+
+//                 pGetLanRes->ConfigData.AuthTypeSupport = pBMCInfo->LANCfs[EthIndex].AuthTypeSupport;
+//                 break;
+
+//             case LAN_PARAM_AUTH_TYPE_ENABLES:
+
+//                 LOCK_BMC_SHARED_MEM(BMCInst);
+//                 _fmemcpy (&pGetLanRes->ConfigData.AuthTypeEnables,
+//                           &(pBMCInfo->LANCfs[EthIndex].AuthTypeEnables), sizeof(AuthTypeEnables_T));
+//                 UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                 break;
+
+//             case LAN_PARAM_IP_ADDRESS:
+//                 if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPAddrSrc == STATIC_IP_SOURCE))
+//                 {
+//                     if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
+//                     {
+//                         _fmemcpy (NWConfig.IPAddr,pBMCInfo->LANCfs[EthIndex].IPAddr, IP_ADDR_LEN);
+//                     }
+//                     else
+//                     {
+//                         memset(&NWConfig, 0, sizeof(NWConfig));
+//                     }
+//                 }
+//                 else
+//                 {
+//                     nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
+//                 }
+//                 _fmemcpy (pGetLanRes->ConfigData.IPAddr, NWConfig.IPAddr, IP_ADDR_LEN);
+
+
+//             break;
+
+//             case LAN_PARAM_IP_ADDRESS_SOURCE:
+//             if(g_corefeatures.delayed_lan_restart_support)
+//             {
+//                 if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
+//                 {
+//                     NWConfig.CfgMethod = pBMCInfo->LANCfs[EthIndex].IPAddrSrc;
+//                 }
+//                 else
+//                 {
+//                     memset(&NWConfig, 0, sizeof(NWConfig));
+//                 }
+//             }
+//             else
+//             {
+//                 nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
+//             }
+
+//             pGetLanRes->ConfigData.IPAddrSrc = NWConfig.CfgMethod;
+//               break;
+
+//             case LAN_PARAM_MAC_ADDRESS:
+//                 nwGetNWInformations(&NWConfig,IfcName);
+//                 _fmemcpy (pGetLanRes->ConfigData.MACAddr, NWConfig.MAC, MAC_ADDR_LEN);
+
+//                 break;
+
+//             case LAN_PARAM_SUBNET_MASK:
+//                 if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPAddrSrc == STATIC_IP_SOURCE))
+//                 {
+//                     if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
+//                     {
+//                         _fmemcpy (NWConfig.Mask,pBMCInfo->LANCfs[EthIndex].SubNetMask, IP_ADDR_LEN);
+//                     }
+//                     else
+//                     {
+//                         memset(&NWConfig, 0, sizeof(NWConfig));
+//                     }
+//                 }
+//                 else 
+//                 {
+//                     nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);	
+//                 }
+//                 _fmemcpy (pGetLanRes->ConfigData.SubNetMask, NWConfig.Mask, IP_ADDR_LEN);
+//                 break;
+
+//             case LAN_PARAM_IPv4_HEADER:
+
+//                 LOCK_BMC_SHARED_MEM(BMCInst);
+//                 _fmemcpy (&pGetLanRes->ConfigData.Ipv4HdrParam,
+//                           &(pBMCInfo->LANCfs[EthIndex].Ipv4HdrParam), sizeof(IPv4HdrParams_T));
+//                 UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                 break;
+
+//             case LAN_PARAM_PRI_RMCP_PORT:
+
+//                 pGetLanRes->ConfigData.PrimaryRMCPPort = htoipmi_u16(pBMCInfo->LANCfs[EthIndex].PrimaryRMCPPort);
+//                 break;
+
+//             case LAN_PARAM_SEC_RMCP_PORT:
+//                 /* Returning Invalid error message */
+//                 *pRes = CC_PARAM_NOT_SUPPORTED;
+//                 return sizeof (INT8U);
+//                 /*pGetLanRes->ConfigData.SecondaryPort = htoipmi_u16(pPMConfig->LANConfig[EthIndex].SecondaryPort);*/
+//                 break;
+
+//             case LAN_PARAM_BMC_GENERATED_ARP_CONTROL:
+
+//                 pGetLanRes->ConfigData.BMCGeneratedARPControl = pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl;
+//                 break;
+//             case LAN_PARAM_GRATITIOUS_ARP_INTERVAL:
+//                 pGetLanRes->ConfigData.GratitousARPInterval =
+//                         pBMCInfo->LANCfs[EthIndex].GratitousARPInterval;
+//                 break;
+
+//             case LAN_PARAM_DEFAULT_GATEWAY_IP:
+//                 if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPAddrSrc == STATIC_IP_SOURCE))
+//                 {
+//                     if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
+//                     {
+//                         _fmemcpy (NWConfig.Gateway, pBMCInfo->LANCfs[EthIndex].DefaultGatewayIPAddr, IP_ADDR_LEN);
+//                     }
+//                     else
+//                     {
+//                         memset(&NWConfig, 0, sizeof(NWConfig));
+//                     }
+//                 }
+//                 else 
+//                 {
+//                     nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);	
+//                 }
+//                 _fmemcpy (pGetLanRes->ConfigData.DefaultGatewayIPAddr, NWConfig.Gateway, IP_ADDR_LEN);
+//                 break;
+
+//             case LAN_PARAM_DEFAULT_GATEWAY_MAC:
+//                 nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
+//                 nwGetSrcMacAddr(&NWConfig.Gateway[0],netindex, &pGetLanRes->ConfigData.DefaultGatewayMACAddr[0]);
+//                 break;
+
+//             case LAN_PARAM_BACKUP_GATEWAY_IP:
+
+//                 LOCK_BMC_SHARED_MEM(BMCInst);
+//                 nwGetBkupGWyAddr(pGetLanRes->ConfigData.BackupGatewayIPAddr,netindex);
+//                 UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                 break;
+
+//             case LAN_PARAM_BACKUP_GATEWAY_MAC:
+
+//                 LOCK_BMC_SHARED_MEM(BMCInst);
+//                 _fmemcpy (pGetLanRes->ConfigData.BackupGatewayMACAddr,
+//                           pBMCInfo->LANCfs[EthIndex].BackupGatewayMACAddr, MAC_ADDR_LEN);
+//                 UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                 break;
+
+//             case LAN_PARAM_COMMUNITY_STRING:
+//                 if (g_PDKHandle[PDK_GETSNMPCOMMUNITYNAME] != NULL )
+//                 {
+//                     if(((int(*)(INT8U *, INT8U *,int))(g_PDKHandle[PDK_GETSNMPCOMMUNITYNAME]))(pGetLanRes->ConfigData.CommunityStr,&ComStrLen, BMCInst)==0)
+//                         break;
+//                 }
+//                 LOCK_BMC_SHARED_MEM(BMCInst);
+//                 _fmemcpy (pGetLanRes->ConfigData.CommunityStr,
+//                           pBMCInfo->LANCfs[EthIndex].CommunityStr, MAX_COMM_STRING_SIZE);
+//                 UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                 break;
+
+//             case LAN_PARAM_DEST_NUM:
+
+//                 pGetLanRes->ConfigData.NumDest = pBMCInfo->LANCfs[EthIndex].NumDest;
+//                 break;
+
+//             case LAN_PARAM_SELECT_DEST_TYPE:
+
+
+//                 //if (pGetLanReq->SetSelect > NUM_LAN_DESTINATION)
+//                 if ( pGetLanReq->SetSelect   > pBMCInfo->LANCfs[EthIndex].NumDest )
+//                 {
+//                     *pRes = CC_PARAM_OUT_OF_RANGE ;
+//                     return sizeof (*pRes);
+//                 }
+
+//                 if (0 == pGetLanReq->SetSelect)
+//                 {
+//                     LOCK_BMC_SHARED_MEM(BMCInst);
+//                     _fmemcpy (&pGetLanRes->ConfigData.DestType,
+//                               &pSharedMem->VolLANDestType[EthIndex], sizeof(LANDestType_T));
+//                     UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                 }
+//                 else
+//                 {
+//                     LOCK_BMC_SHARED_MEM(BMCInst);
+//                     _fmemcpy (&pGetLanRes->ConfigData.DestType,
+//                               &(pBMCInfo->LANCfs[EthIndex].DestType[pGetLanReq->SetSelect - 1]),
+//                               sizeof(LANDestType_T));
+//                     UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                 }
+//                 break;
+
+//             case LAN_PARAM_SELECT_DEST_ADDR:
+
+//                 //if (pGetLanReq->SetSelect > NUM_LAN_DESTINATION)
+//                 if ( pGetLanReq->SetSelect   > pBMCInfo->LANCfs[EthIndex].NumDest )
+//                 {
+//                     *pRes = CC_PARAM_OUT_OF_RANGE ;
+//                     return sizeof (*pRes);
+//                 }
+
+//                 if (0 == pGetLanReq->SetSelect)
+//                 {
+//                     LOCK_BMC_SHARED_MEM(BMCInst);
+//                     _fmemcpy (&pGetLanRes->ConfigData.DestAddr,
+//                               &pSharedMem->VolLANDest[EthIndex], sizeof(LANDestAddr_T));
+//                     UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                 }
+//                 else
+//                 {
+//                     LOCK_BMC_SHARED_MEM(BMCInst);
+//                     _fmemcpy (&pGetLanRes->ConfigData.DestAddr,
+//                               &(pBMCInfo->LANCfs[EthIndex].DestAddr[pGetLanReq->SetSelect - 1]),
+//                               sizeof(LANDestAddr_T));
+//                     UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                 }
+//                 break;
+
+//             case LAN_PARAM_VLAN_ID:
+
+//                 if( pBMCInfo->IpmiConfig.VLANIfcSupport == 1)
+//                 {
+//                     pGetLanRes->ConfigData.VLANID = pBMCInfo->LANCfs[EthIndex].VLANID;
+//                 }
+//                 break;
+
+//             case LAN_PARAM_VLAN_PRIORITY:
+
+//                 pGetLanRes->ConfigData.VLANPriority = pBMCInfo->LANCfs[EthIndex].VLANPriority;
+//                 break;
+
+//             case LAN_PARAM_CIPHER_SUITE_ENTRY_SUP:
+
+//                 pGetLanRes->ConfigData.CipherSuiteSup = N0_OF_CIPHER_SUITE_SUPPORTED;
+//                 break;
+
+//             case LAN_PARAM_CIPHER_SUITE_ENTRIES:
+//                 {
+//                     int i;
+//                     _fmemset (pGetLanRes->ConfigData.CipherSuiteEntries, 0,
+//                               sizeof (pGetLanRes->ConfigData.CipherSuiteEntries));
+//                     for (i = 0; i < (N0_OF_CIPHER_SUITE_SUPPORTED); i++)
+//                     {
+//                         pGetLanRes->ConfigData.CipherSuiteEntries[i+1] = g_CipherRec[1 + i * 5];
+//                     }
+//                 }
+//                 break;
+
+//             case LAN_PARAM_CIPHER_SUITE_PRIV_LEVELS:
+
+//                 LOCK_BMC_SHARED_MEM(BMCInst);
+//                 _fmemcpy (pGetLanRes->ConfigData.CipherSuitePrivLevels,
+//                           pBMCInfo->LANCfs[EthIndex].CipherSuitePrivLevels,
+//                           MAX_NUM_CIPHER_SUITE_PRIV_LEVELS);
+//                 UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                 break;
+
+//             case LAN_PARAM_VLAN_TAGS:
+
+//                 *((_NEAR_ INT8U*)&pGetLanRes->ConfigData) = pGetLanReq->SetSelect;
+//                 if (pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest)
+//                 {
+//                     pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_OUT_OF_RANGE;
+//                     return sizeof (GetLanCCRev_T);
+//                 }
+//                 if (0 == pGetLanReq->SetSelect)
+//                 {
+//                     LOCK_BMC_SHARED_MEM(BMCInst);
+//                     _fmemcpy (((_NEAR_ INT8U*) &pGetLanRes->ConfigData) + 1,&pSharedMem->VLANDestTag, sizeof(VLANDestTags_T));
+//                     UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                 }
+//                 else
+//                 {
+//                     if (pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest)
+//                     {
+//                         pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_OUT_OF_RANGE;
+//                         return sizeof(GetLanCCRev_T);
+//                     }
+
+//                     LOCK_BMC_SHARED_MEM(BMCInst);
+//                     _fmemcpy (((_NEAR_ INT8U*)&pGetLanRes->ConfigData) + 1,
+//                     &pBMCInfo->LANCfs[EthIndex].VLANDestTags[pGetLanReq->SetSelect - 1],
+//                     sizeof(VLANDestTags_T));
+//                     UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                 }
+//                 break;
+
+//             case LAN_PARAMS_BAD_PASSWORD_THRESHOLD:
+//                 LOCK_BMC_SHARED_MEM(BMCInst);
+//                 _fmemcpy(&pGetLanRes->ConfigData.BadPasswd,
+//                                 &pBMCInfo->LANCfs[EthIndex].BadPasswd,sizeof(BadPassword_T));
+//                 UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                 break;
+//             case LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR:
+
+//                 if ( pGetLanReq->SetSelect   > pBMCInfo->LANCfs[EthIndex].NumDest )
+//                 {
+//                     *pRes = CC_PARAM_OUT_OF_RANGE ;
+//                     return sizeof (*pRes);
+//                 }
+
+//                 if (0 == pGetLanReq->SetSelect)
+//                 {
+//                     LOCK_BMC_SHARED_MEM(BMCInst);
+//                     _fmemcpy (&pGetLanRes->ConfigData.Destv6Addr,
+//                               &pSharedMem->VolLANv6Dest[EthIndex], sizeof(LANDestv6Addr_T));
+//                     UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                 }
+//                 else
+//                 {
+//                     LOCK_BMC_SHARED_MEM(BMCInst);
+//                     _fmemcpy (&pGetLanRes->ConfigData.Destv6Addr,
+//                               &(pBMCInfo->LANCfs[EthIndex].Destv6Addr[pGetLanReq->SetSelect - 1]),
+//                               sizeof(LANDestv6Addr_T));
+//                     UNLOCK_BMC_SHARED_MEM(BMCInst);
+//                 }
+
+//                 TDBG("\n GetLanconfig: Getting SNMPv6 configuration done..\n");
+
+//                 return sizeof(GetLanConfigRes_T);
+
+//                 break;
+
+//             case LAN_PARAMS_AMI_OEM_ENABLE_SET_MAC:
+
+//             	pGetLanRes->ConfigData.ChangeMACEnabled = enableSetMACAddr;
+//             	return sizeof(GetLanCCRev_T) + sizeof(INT8U);
+
+//             case LAN_PARAMS_AMI_OEM_IPV6_ENABLE:
+//                 if(g_corefeatures.delayed_lan_restart_support) 
+//                 {
+//                     NWConfig6.enable = pBMCInfo->LANCfs[EthIndex].IPv6_Enable;
+//                 }
+//                 else
+//                 {
+//                     nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
+//                 }
+//                 pGetLanRes->ConfigData.IPv6_Enable = NWConfig6.enable;
+//                 return sizeof(GetLanCCRev_T) + sizeof(INT8U);
+                
+//                 break;
+
+//             case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_SOURCE:
+//                 if(g_corefeatures.delayed_lan_restart_support) 
+//                 {
+//                     if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
+//                     {
+//                         NWConfig6.CfgMethod = pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc;
+//                     }
+//                     else
+//                     {
+//                         memset(&NWConfig6, 0, sizeof(NWConfig6));
+//                     }
+//                 }
+//                 else
+//                 {
+//                     nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
+//                 }
+//                 pGetLanRes->ConfigData.IPv6_IPAddrSrc = NWConfig6.CfgMethod;
+//                 return sizeof(GetLanCCRev_T) + sizeof(INT8U);
+                
+//                 break;
+
+//             case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR:
+//             case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_EUI64:
+//                 if(pGetLanReq->SetSelect & 0xF0)
+//                 {
+//                     *pRes = CC_INV_DATA_FIELD;
+//                     return sizeof(INT8U);
+//                 }
+               
+//                 if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == STATIC_IP_SOURCE))
+//                 {
+//                     if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
+//                     {
+//                         _fmemcpy (NWConfig6.GlobalIPAddr,pBMCInfo->LANCfs[EthIndex].IPv6_IPAddr, IP6_ADDR_LEN*MAX_IPV6ADDRS);
+//                     }
+//                     else
+//                     {
+//                         memset(&NWConfig6, 0, sizeof(NWConfig6));
+//                     }
+//                 }
+//                 else
+//                 {
+//                     nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
+//                 }
+//                 _fmemcpy (pGetLanRes->ConfigData.IPv6_LinkAddr, NWConfig6.GlobalIPAddr[(pGetLanReq->SetSelect & 0x0F)], IP6_ADDR_LEN);
+//                 return sizeof(GetLanCCRev_T) + IP6_ADDR_LEN;
+                
+//                 break;
+//             case LAN_PARAMS_AMI_OEM_IPV6_LINK_ADDR:
+//                 nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
+//                 _fmemcpy (pGetLanRes->ConfigData.IPv6_LinkAddr, NWConfig6.LinkIPAddr, IP6_ADDR_LEN);
+//                 return sizeof(GetLanCCRev_T) + IP6_ADDR_LEN;
+
+//             case LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH:
+
+//                 if(pGetLanReq->SetSelect & 0xF0)
+//                 {
+//                     *pRes = CC_INV_DATA_FIELD;
+//                     return sizeof(INT8U);
+//                 }
+
+//                 if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == STATIC_IP_SOURCE))
+//                 {
+//                     if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
+//                     {
+//                         NWConfig6.GlobalPrefix[(pGetLanReq->SetSelect & 0x0F)] = pBMCInfo->LANCfs[EthIndex].IPv6_PrefixLen[(pGetLanReq->SetSelect & 0x0F)];
+//                     }
+//                     else
+//                     {
+//                         memset(&NWConfig6, 0, sizeof(NWConfig6));
+//                     }
+//                 }
+//                 else
+//                 {
+//                     nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
+//                 }
+//                 pGetLanRes->ConfigData.IPv6_LinkAddrPrefix = NWConfig6.GlobalPrefix[(pGetLanReq->SetSelect & 0x0F)];
+//                 return sizeof(GetLanCCRev_T) + sizeof(INT8U);
+                
+//                 break;
+
+//             case LAN_PARAMS_AMI_OEM_IPV6_LINK_ADDR_PREFIX:
+//                 nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
+//                 pGetLanRes->ConfigData.IPv6_LinkAddrPrefix = NWConfig6.LinkPrefix;
+//                 return sizeof(GetLanCCRev_T) + sizeof(INT8U);
+                
+//                 break;
+
+//             case LAN_PARAMS_AMI_OEM_IPV6_GATEWAY_IP:
+//                 if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == STATIC_IP_SOURCE))
+//                 {
+//                     if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
+//                     {
+//                         _fmemcpy (NWConfig6.Gateway,pBMCInfo->LANCfs[EthIndex].IPv6_GatewayIPAddr, IP6_ADDR_LEN);
+//                     }
+//                     else
+//                     {
+//                         memset(&NWConfig6, 0, sizeof(NWConfig6));
+//                     }
+//                 }
+//                 else
+//                 {
+//                     nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
+//                 }
+//                 _fmemcpy (pGetLanRes->ConfigData.IPv6_GatewayIPAddr, NWConfig6.Gateway, IP6_ADDR_LEN);
+//                 return sizeof(GetLanCCRev_T) + IP6_ADDR_LEN;
+                
+//                 break;
+
+//             case LAN_PARAMS_AMI_OEM_PHY_SETTINGS:
+//                 memset(IfcName, 0, sizeof(IfcName));
+//                 if(GetIfcNameByIndex(EthIndex, IfcName) != 0)
+//                 {
+//                     TCRIT("Error in Getting Interface Name for the lan Index:%d\n",EthIndex);
+//                 }
+//                 if(nwGetEthInformation(&PHYCfg, IfcName) !=0)
+//                 {
+//                     pGetLanRes->CCParamRev.CompletionCode = CC_UNSPECIFIED_ERR;
+//                     return sizeof(GetLanCCRev_T);
+//                 }
+//                 pGetLanRes->ConfigData.PHYConfig.Interface = EthIndex;
+//                 pGetLanRes->ConfigData.PHYConfig.AutoNegotiationEnable = PHYCfg.autoneg;
+//                 pGetLanRes->ConfigData.PHYConfig.Speed = PHYCfg.speed;
+//                 pGetLanRes->ConfigData.PHYConfig.Duplex = PHYCfg.duplex;
+//                 pGetLanRes->ConfigData.PHYConfig.CapabilitiesSupported = PHYCfg.supported;
+
+//                 return sizeof(GetLanCCRev_T) + sizeof(PHYConfig_T);
+
+//             case LAN_PARAMS_AMI_OEM_MTU_SETTINGS:
+//                         memset(IfcName,0,sizeof(IfcName));
+//                         if(GetIfcNameByIndex(EthIndex, IfcName) != 0)
+//                         {
+//                             TCRIT("Error in Getting Interface Name for the lan Index:%d\n",EthIndex);
+//                             pGetLanRes->CCParamRev.CompletionCode = CC_UNSPECIFIED_ERR;
+//                             return sizeof(GetLanCCRev_T);
+
+//                         }
+//                         if(nwGetEthInformation(&PHYCfg, IfcName) !=0)
+//                         {
+//                             pGetLanRes->CCParamRev.CompletionCode = CC_UNSPECIFIED_ERR;
+//                             return sizeof(GetLanCCRev_T);
+//                         }
+					
+//                         pGetLanRes->ConfigData.MTU_size = PHYCfg.maxtxpkt;
+//                         return sizeof(GetLanCCRev_T) + sizeof(INT16U);
+				
+//         case LAN_PARAMS_SSI_OEM_2ND_PRI_ETH_MAC_ADDR:
+//             if(g_corefeatures.ssi_support == ENABLED)
+//             {
+//                 netindex = 0x1; /* Specify the 2nd interface */
+//                 nwReadNWCfg_v4_v6(&NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
+//                 _fmemcpy(pGetLanRes->ConfigData.SSI2ndPriEthMACAddr, NWConfig.MAC, MAC_ADDR_LEN);
+//                 return sizeof(GetLanCCRev_T) + sizeof(pGetLanRes->ConfigData.SSI2ndPriEthMACAddr);
+//              }
+//              else
+//              {
+//                 pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//                 return sizeof(INT8U);
+//              }
+//             break;
+
+//         case LAN_PARAMS_SSI_OEM_LINK_CTRL:
+//             if(g_corefeatures.ssi_support == ENABLED)
+//             {
+//                 pGetLanRes->ConfigData.SSILinkControl = 0;
+
+//                 pChannelInfo = getChannelInfo(pBMCInfo->RMCPLAN1Ch, BMCInst);
+//                 if(NULL == pChannelInfo)
+//                 {
+//                     *pRes = CC_UNSPECIFIED_ERR;
+//                     return	sizeof (*pRes);
+//                 }
+
+//                 if (pChannelInfo->AccessMode == 0x02)		/* If 1st channal is available */
+//                     pGetLanRes->ConfigData.SSILinkControl |= BIT0;
+//                 NIC_Count = g_coremacros.global_nic_count;
+//                 if (NIC_Count == 2)
+//                 {
+//                     pChannelInfo = getChannelInfo(pBMCInfo->RMCPLAN2Ch, BMCInst);
+//                     if(NULL == pChannelInfo)
+//                     {
+//                         *pRes = CC_UNSPECIFIED_ERR;
+//                         return	sizeof (*pRes);
+//                     }
+
+//                     if (pChannelInfo->AccessMode == 0x02)	/* If 2nd channal is available */
+//                         pGetLanRes->ConfigData.SSILinkControl |= BIT1;
+//                 }
+//                 return sizeof(GetLanCCRev_T) + sizeof(pGetLanRes->ConfigData.SSILinkControl);
+//             }
+//             else
+//             {
+//                 pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//                 return sizeof(INT8U);
+//             }
+//             break;
+
+//         case LAN_PARAMS_SSI_OEM_CMM_IP_ADDR:
+//             if(g_corefeatures.ssi_support == ENABLED)
+//             {
+//                 _fmemcpy (pGetLanRes->ConfigData.CMMIPAddr, pBMCInfo->SSIConfig.CMMIPAddr, IP_ADDR_LEN);
+//                 return sizeof(GetLanCCRev_T) + sizeof(pGetLanRes->ConfigData.CMMIPAddr);
+//             }
+//             else
+//             {
+//                 pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//                 return sizeof(INT8U);
+//             }
+//             break;
+
+//         default:
+//             if(g_corefeatures.ncsi_cmd_support == ENABLED)
+//             {
+//                 switch(pGetLanReq->ParameterSelect)
+//                 {
+//                     case LAN_PARAMS_AMI_OEM_NCSI_CONFIG_NUM:
+//                         NCSIGetTotalPorts(&ncsiPortConfigNum);
+                        
+//                         if (ncsiPortConfigNum >= 0xFF)
+//                         {
+//                             pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
+//                             return sizeof(GetLanCCRev_T);
+//                         }
+//                         else
+//                         {
+//                             pGetLanRes->ConfigData.NumNCSIPortConfigs = ncsiPortConfigNum;
+//                             return sizeof(GetLanCCRev_T) + sizeof(INT8U);
+//                         }
+//                     break;
+                                
+//                     case LAN_PARAMS_AMI_OEM_NCSI_SETTINGS:
+//                     {
+//                         NIC_Count=g_coremacros.global_nic_count;
+//                         if (pGetLanReq->SetSelect >= NIC_Count)
+//                         {
+//                             pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
+//                             return sizeof(GetLanCCRev_T);
+//                         }
+//                         NCSIConfig_T configData;
+//                         char interfaceName[8];
+
+//                         memset(&configData, 0, sizeof(NCSIConfig_T));
+//                         memset(interfaceName, 0, sizeof(interfaceName));
+
+//                         snprintf(interfaceName, sizeof(interfaceName), "%s%d", "eth", pGetLanReq->SetSelect);
+                        
+//                         if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
+//                         {
+//                             pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
+//                             return sizeof(GetLanCCRev_T);
+//                         }
+
+//                         if (configData.PackageId >= 0xFF || configData.ChannelId >= 0xFF)
+//                         {
+//                             pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
+//                             return sizeof(GetLanCCRev_T);
+//                         }
+
+//                         pGetLanRes->ConfigData.NCSIPortConfig.Interface = pGetLanReq->SetSelect;
+//                         pGetLanRes->ConfigData.NCSIPortConfig.PackageId = configData.PackageId;
+//                         pGetLanRes->ConfigData.NCSIPortConfig.ChannelId = configData.ChannelId;
+
+//                         return sizeof(GetLanCCRev_T) + sizeof(NCSIPortConfig_T);
+//                     }
+//                     break;
+
+//                     case LAN_PARAMS_AMI_OEM_NCSI_MODE_CHANGE:
+//                     {
+//                         NIC_Count=g_coremacros.global_nic_count;
+//                         if (pGetLanReq->SetSelect >= NIC_Count)
+//                         		{
+//                         	printf("---> log5, SetSelect = %d, NIC_Count = %d\n",pGetLanReq->SetSelect, NIC_Count);
+//                            pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
+//                            return sizeof(GetLanCCRev_T);
+//                         		}
+						
+//                         NCSIConfig_T configData;
+//                         char interfaceName[8];
+//                         memset(&configData, 0, sizeof(NCSIConfig_T));
+//                         memset(interfaceName, 0, sizeof(interfaceName));
+				
+//                         snprintf(interfaceName, sizeof(interfaceName), "%s%d", "eth", pGetLanReq->SetSelect);
+				
+//                         if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
+//                         {
+//                             pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
+//                             return sizeof(GetLanCCRev_T);
+//                         }
+						
+//                         if (configData.AutoSelect>= 0xFF)
+//                         {
+//                             pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
+//                             return sizeof(GetLanCCRev_T);
+//                         }
+
+//                         pGetLanRes->ConfigData.NCSIModeConfig.Interface = pGetLanReq->SetSelect;
+//                         pGetLanRes->ConfigData.NCSIModeConfig.NCSIMode = configData.AutoSelect;
+
+//                         return sizeof(GetLanCCRev_T) + sizeof(NCSIModeConfig_T);
+//                     }
+//                     break;
+
+//                     case LAN_PARAMS_AMI_OEM_NCSI_EXTENSION:
+//                     {
+//                         char ncsi_default_ifc[IFNAMSIZ + 1] = "eth1";
+                        
+//                         if ((pGetLanReq->SetSelect == 0x20) && 
+//                             (g_corefeatures.ncsi_keep_phy_linkup_support == ENABLED))
+//                         {
+//                             NIC_Count=g_coremacros.global_nic_count;
+//                             NCSIConfig_T configData;
+//                             char interfaceName[8];
+//                             memset(&configData, 0, sizeof(NCSIConfig_T));
+//                             memset(interfaceName, 0, sizeof(interfaceName));
+
+//                             GetMacrodefine_string("CONFIG_SPX_FEATURE_NCSI_DEFAULT_INTERFACE", ncsi_default_ifc);
+//                             snprintf(interfaceName, sizeof(interfaceName), "%s", ncsi_default_ifc);
+
+//                             if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
+//                             {
+//                                 pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
+//                                 return sizeof(GetLanCCRev_T);
+//                             }
+
+//                             char Interface[2];
+//                             snprintf(Interface, sizeof(Interface), "%c", interfaceName[3]);
+//                             pGetLanRes->ConfigData.NCSIPHYConfigGet.Interface = atoi(Interface);
+//                             pGetLanRes->ConfigData.NCSIPHYConfigGet.VetoBit = configData.VetoBit;
+
+//                             return sizeof(GetLanCCRev_T) + sizeof(NCSIPHYConfigGet_T);
+//                     }
+//                     else
+//                     {
+//                         pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//                         return sizeof(GetLanCCRev_T);
+//                     }
+//                 	}
+//                     break;
+					
+//                     default:
+//                         TDBG("In Valid Option\n");
+                        
+//                 }
+//             }
+//             pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//             return sizeof(INT8U);
+//         }
+
+//     }
+
+    
+//     return sizeof(GetLanCCRev_T) + LanconfigParameterLength[pGetLanReq->ParameterSelect];
+// }
+
+
+// /*---------------------------------------------------
+//  * SuspendBMCArps
+//  *---------------------------------------------------*/
+// int
+// SuspendBMCArps (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
+// {
+//     _NEAR_  SuspendBMCArpsReq_T*    pArpReq = (_NEAR_ SuspendBMCArpsReq_T*) pReq;
+//     _NEAR_  SuspendBMCArpsRes_T*    pArpRes = (_NEAR_ SuspendBMCArpsRes_T*) pRes;
+//     INT8U EthIndex;
+
+//     /* Verify Channel ID */
+//     pArpRes->CompletionCode = CC_INV_DATA_FIELD;
+
+//     if(pArpReq->ChannelNo & RESERVED_BITS_SUSPENDBMCARPS) return sizeof(*pRes);
+
+//     if (!IsLANChannel(pArpReq->ChannelNo & CHANNEL_ID_MASK, BMCInst) )
+//     {
+//         return sizeof (*pRes);
+//     }
+
+//     EthIndex= GetEthIndex(pArpReq->ChannelNo & 0x0F,BMCInst);
+//     if(0xff == EthIndex)
+//     {
+//         return sizeof (*pRes);
+//     }
+
+//     /* Reserved Bits Validation */
+// 	if (0 != (SUSPEND_ARP_RSVD_BIT_MASK & pArpReq->ArpSuspend))
+//     {
+//         return sizeof (*pRes);
+//     }
+
+// 	if (BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning == TRUE)
+// 		BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex] = pArpReq->ArpSuspend;
+
+//     /* Update Response */
+//     pArpRes->CompletionCode   = CC_NORMAL;
+//     pArpRes->ArpSuspendStatus = UpdateArpStatus(EthIndex, BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning, BMCInst);
+
+//     return sizeof (SuspendBMCArpsRes_T);
+// }
+
+
+
+// /*---------------------------------------------------
+//  * GetIPUDPRMCPStats
+//  *---------------------------------------------------*/
+// int
+// GetIPUDPRMCPStats (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
+// {
+//     _NEAR_  GetIPUDPRMCPStatsReq_T*    pGetIPUDPRMCPStatsReq = (_NEAR_ GetIPUDPRMCPStatsReq_T*) pReq;
+//     _NEAR_  GetIPUDPRMCPStatsRes_T*    pGetIPUDPRMCPStatsRes = (_NEAR_ GetIPUDPRMCPStatsRes_T*) pRes;
+//     _FAR_	BMCSharedMem_T* 	pSharedMem = BMC_GET_SHARED_MEM (BMCInst);
+
+//     FILE *fptr;
+//     char FDRead[512], FSRead[512];
+//     char *result = NULL;
+//     char **StrArray;
+//     int count = 0;
+//     int cStrings =0;
+
+//     if(pGetIPUDPRMCPStatsReq->ChannelNo & RESERVED_BITS_GETIPUDPRMCPSTATS_CH)
+//     {
+//     	*pRes = CC_INV_DATA_FIELD;
+//     	return sizeof(*pRes);
+//     }
+
+//     if(pGetIPUDPRMCPStatsReq->ClearStatus & RESERVED_BITS_GETIPUDPRMCPSTATS_CLRSTATE)
+//     {
+//     	*pRes = CC_INV_DATA_FIELD;
+//     	return sizeof(*pRes);
+//     }
+
+//     //Channel number [3:0] is valid.
+//     if ( !IsLANChannel(pGetIPUDPRMCPStatsReq->ChannelNo & CHANNEL_ID_MASK, BMCInst) )
+//     {
+//         pGetIPUDPRMCPStatsRes->CompletionCode = CC_INV_DATA_FIELD;
+//         return sizeof (*pRes);
+//     }
+
+//     //Clear the statistics if 1 is given in request.
+//     if ( pGetIPUDPRMCPStatsReq->ClearStatus & 0x01 )
+//     {
+//         /* <TBD BalaT>
+//         * Have to clear the already stored statistics when clear req is 1.
+//         */
+//         pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
+//         return sizeof (INT8U);
+//     }
+
+//     //All Statistics values are initialised to 0.
+//     memset (pGetIPUDPRMCPStatsRes, 0, sizeof(GetIPUDPRMCPStatsRes_T) );
+
+//     //All the datas are taken from /proc/net/snmp file
+//     fptr = fopen ("/proc/net/snmp","r+");
+//     if (fptr == NULL)
+//     {
+//         pGetIPUDPRMCPStatsRes->CompletionCode = CC_COULD_NOT_PROVIDE_RESP;
+//         return sizeof (INT8U);
+//     }
+
+//     while( NULL != fgets(FDRead,512,fptr) )
+//     {
+//        if ( NULL != strstr (FDRead, "Ip: ") )
+//        {
+//           count++;
+//           if (count == 2)
+//           {
+//              //To find the no. of valid strings in a line.
+//              strcpy (FSRead, FDRead);
+//              result = strtok( FSRead, " " );
+//              while( result != NULL )
+//             {
+//                 cStrings++;
+//                 result = strtok( NULL, " " );
+//             }
+
+//             //Condition to check so that explode doesnt try to read the strings from unknown location.
+//             if ( cStrings == 20)
+//             {
+//                 StrArray = explode (' ', FDRead);
+//             }
+//             else
+//             {
+//                 pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
+//                 return sizeof (INT8U);
+//              }
+
+//              //All Statistics stops acumulating at FFFFh unless otherwise noted.
+//              //IP packets received.
+//             if ( atol((char *)StrArray[3]) > 0xffff)
+//                 pGetIPUDPRMCPStatsRes->IPPacketsRecv = ( ( atol((char *)StrArray[3]) ) % 65535);
+//             else
+//                 pGetIPUDPRMCPStatsRes->IPPacketsRecv = atoi((char *)StrArray[3]);
+
+//             //IP Header Error.
+//             pGetIPUDPRMCPStatsRes->IPHeaderErr = atoi((char *)StrArray[4]);
+
+//              //IP Address Error.
+//              if ( atol((char *)StrArray[5]) > 0xffff)
+//                 pGetIPUDPRMCPStatsRes->IPAddrErr = ( ( atol((char *)StrArray[5]) ) % 65535);
+//              else
+//                 pGetIPUDPRMCPStatsRes->IPAddrErr = atoi((char *)StrArray[5]);
+
+//             //Fragmented IP Packets received.
+//             if ( atol((char *)StrArray[17]) > 0xffff)
+//                 pGetIPUDPRMCPStatsRes->FragIPPacketsRecv = ( ( atol((char *)StrArray[17]) ) % 65535);
+//             else
+//                 pGetIPUDPRMCPStatsRes->FragIPPacketsRecv = atoi((char *)StrArray[17]);
+
+//             //IP packets Transmitted.
+//             if ( atol((char *)StrArray[10]) > 0xffff)
+//                 pGetIPUDPRMCPStatsRes->IPPacketsTrans = ( ( atol((char *)StrArray[10]) ) % 65535);
+//             else
+//                  pGetIPUDPRMCPStatsRes->IPPacketsTrans = atoi((char *)StrArray[10]);
+
+//              count = 0;
+//           }
+//        }
+       
+//         if ( NULL != strstr (FDRead, "Udp: ") )
+//         {
+//             count++;
+//             if (count == 2)
+//             {
+//                 //To find the no. of valid strings in a line.
+//                 cStrings = 0;
+//                 strcpy (FSRead, FDRead);
+//                 result = strtok( FSRead, " " );
+//                 while( result != NULL )
+//                 {
+//                     cStrings++;
+//                     result = strtok( NULL, " " );
+//                 }
+
+//                 //Condition to check so that explode doesnt try to read the strings beyond the valid location.
+//                 if ( cStrings == 5)
+//                 {
+//                     StrArray = explode (' ', FDRead);
+//                 }
+//                 else
+//                 {
+//                     pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
+//                     return sizeof (INT8U);
+//                 }
+
+//                 //UDP packets received.
+//                 if ( atol((char *)StrArray[1]) > 0xffff)
+//                     pGetIPUDPRMCPStatsRes->UDPPacketsRecv = ( ( atol((char *)StrArray[1]) ) % 65535);
+//                 else
+//                     pGetIPUDPRMCPStatsRes->UDPPacketsRecv = atoi((char *)StrArray[1]);
+
+//                 count = 0;
+//             }
+//         }
+//     }
+//     fclose(fptr);
+
+//     //Valid RMCP packets received.
+//     pGetIPUDPRMCPStatsRes->ValidRMCPPackets = pSharedMem->gIPUDPRMCPStats;
+
+//     //<TBD BalaT>To store the statistics across the system reset and power cycles
+
+//     pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
+//     return sizeof (GetIPUDPRMCPStatsRes_T);
+
+// }
+
+// /*-----------------------------------------------------
+//  * explode
+//  * Funntion to split the strings and store in an array
+//  *-----------------------------------------------------*/
+
+// char **explode(char separator, char *string)
+// {
+//     int start = 0, i, k = 1, count = 2;
+//     char **strarr;
+
+//     for (i = 0; string[i] != '\0'; i++)
+//         /* how many rows do we need for our array? */
+//         if (string[i] == separator)
+//             count++;
+
+//     /* count is at least 2 to make room for the entire string
+//  *      * and the ending NULL */
+//     strarr = malloc(count * sizeof(char*));
+//     i = 0;
+
+//     while (*string++ != '\0')
+//     {
+//         if (*string == separator)
+//         {
+//             strarr[i] = malloc(k - start + 2);
+//             strncpy(strarr[i], string - k + start, k - start + 1);
+//             strarr[i][k - start + 1] = '\0'; /* guarantee null termination */
+//             start = k;
+//             i++;
+//         }
+//         k++;
+//     }
+//     /* copy the last part of the string after the last separator */
+//     strarr[i] = malloc(k - start);
+//     strncpy(strarr[i], string - k + start, k - start - 1);
+//     strarr[i][k - start - 1] = '\0'; /* guarantee null termination */
+//     strarr[++i] = NULL;
+
+//     return strarr;
+// }
+
+// /*----------------------------------------------
+//  * UpdateArpStatus
+//  *----------------------------------------------*/
+// INT8U
+// UpdateArpStatus (INT8U EthIndex,BOOL IsTimerRunning, int BMCInst)
+// {
+//     INT8U GratArpSuspend;
+//     INT8U ArpSuspend;
+//     INT8U Status;
+//     BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+//     char Cmds[50]={0}; // command string to perform BMC-generated ARP
+//     char IfcName[16];
+
+//     IPMI_DBG_PRINT_1 ("Timer - %x", IsTimerRunning);
+//     GratArpSuspend = ArpSuspend = 1;
+
+//     // Check Gratuitous ARP is Enabled
+//     if (0 == (pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl & GRATIUTOUS_ENABLE_MASK))
+//     {
+//         GratArpSuspend = 0;
+//     }
+
+//     // Check ARP Response is Enabled
+//     if (0 == (pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl & ENABLE_ARP_RESPONSES))
+//     {
+//         ArpSuspend = 0;
+//     }
+
+//     /*Disable ARP */
+//     if (TRUE == IsTimerRunning)
+//     {
+// 		/* WDT is running, check and suspend ARP if necessary */	
+// 		if( (0 != (BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex] & SUSPEND_GRAT_ARP)) &&
+// 			(0 < GratArpSuspend) )
+//         {
+//             GratArpSuspend--;
+//         }
+
+// 		if( (0 != (BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex] & SUSPEND_ARP)) &&
+//             (0 < ArpSuspend) )
+//         {
+//             ArpSuspend--;
+//         }
+//     }
+    
+//     memset(IfcName,0,sizeof(IfcName));
+//     if(GetIfcName(EthIndex, IfcName, BMCInst) != 0)
+//     {
+//         TCRIT("Error in getting Interface Name for the Lan Index :%d\n", EthIndex);
+//     }
+//     else
+//     {
+//     	/* Perform commands for BMC-generated Arp */
+//     	memset(Cmds, 0, sizeof(Cmds));
+//     	sprintf(Cmds, "/usr/local/bin/ArpSwitch.sh %s %d", IfcName, (!ArpSuspend) ? ARP_IGNORE_ON : ARP_IGNORE_OFF);
+//     	safe_system (Cmds);	
+//     	/* Perform commands for BMC-generated Arp ends */
+//     }
+    
+//     /* Update Status */
+//     Status = ArpSuspend << 1;
+//     Status = Status | GratArpSuspend;
+
+//     return Status;
+// }
+
+
+// /**
+// *@fn NwInterfacePresenceCheck
+// *@brief This function is invoked to check network interface presence
+// *@param Interface - Char Pointer to Interface for which interface to check
+// *@return Returns 0 on success
+// */
+// static int
+// NwInterfacePresenceCheck (char * Interface)
+// {
+//     int r;
+//     int sockdes;
+//     struct ifreq Ifreq;
+//     unsigned char MAC[MAC_ADDR_LEN];
+
+//     IPMI_DBG_PRINT_1 ("Checking the presence of %s\n", Interface);
+
+//     sockdes = socket(PF_INET, SOCK_DGRAM, 0 );
+//     if ( sockdes < 0 )
+//     {
+//         IPMI_ERROR("can't open socket: %s\n",strerror(errno));
+//         return -1;
+//     }
+
+//     /* Get MAC address */
+//     memset(&Ifreq,0,sizeof(struct ifreq));
+//     memset(MAC, 0, MAC_ADDR_LEN);
+//     strcpy(Ifreq.ifr_name, Interface);
+//     Ifreq.ifr_hwaddr.sa_family = AF_INET;
+//     r = ioctl(sockdes, SIOCGIFHWADDR, &Ifreq);
+//     close (sockdes);
+//     if ( r < 0 )
+//     {
+//         //IPMI_ERROR("IOCTL to get MAC failed: %d\n",r);
+//         return -1;
+//     }
+//     IPMI_DBG_PRINT_1 (" %s Interface is present\n", Interface);
+
+//     return 0;
+// }
+
+

+ 619 - 0
app/bmc/msghndlr/Transport/SOLConfig.c

@@ -0,0 +1,619 @@
+// /*****************************************************************
+//  *****************************************************************
+//  ***                                                            **
+//  ***    (C)Copyright 2005-2006, American Megatrends Inc.        **
+//  ***                                                            **
+//  ***            All Rights Reserved.                            **
+//  ***                                                            **
+//  ***        6145-F, Northbelt Parkway, Norcross,                **
+//  ***                                                            **
+//  ***        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+//  ***                                                            **
+//  *****************************************************************
+//  ****************************************************************
+//  *
+//  * SOLConfig.c
+//  * SOL configuration 
+//  *
+//  *  Author: Govind kothandapani <govindk@ami.com>
+//  ****************************************************************/
+// #define ENABLE_DEBUG_MACROS 0
+// #include "Types.h"
+// #include "Debug.h"
+// #include "MsgHndlr.h"
+// #include "Support.h"
+// #include "IPMIDefs.h"
+// #include "SharedMem.h"
+// #include "PMConfig.h"
+// #include "IPMI_SOLConfig.h"
+// #include "NVRAccess.h"
+// #include "PDKDefs.h"
+// #include "PDKAccess.h"
+// #include"Ethaddr.h"
+// #include "IPMIConf.h"
+
+// /*** Local Definitions ***/
+// #define SOL_SET_IN_PROGRESS                 0
+// #define SOL_ENABLE_PARAM                    1
+// #define SOL_AUTHENTICATION_PARAM            2
+// #define SOL_ACCUM_THRESHOLD_PARAM           3
+// #define SOL_RETRY_PARAM                     4
+// #define SOL_NVOL_BIT_RATE_PARAM             5
+// #define SOL_VOL_BIT_RATE_PARAM              6
+// #define SOL_PAYLD_CHANNEL_PARAM             7
+// #define SOL_PAYLD_PORT_NUM_PARAM            8
+
+// #define SET_IN_PROGRESS                     0x01
+// #define SET_COMPLETE                        0x00
+// #define PARAM_REVISION                      0x11
+// #define GET_PARAM_REV_ONLY_MASK             0x80
+
+// #define BAUD_RATE_9600          			6
+// #define BAUD_RATE_19200         			7
+// #define BAUD_RATE_38400         			8
+// #define BAUD_RATE_57600         			9
+// #define BAUD_RATE_115200        			10
+
+
+
+
+// /* Reserved Bits table */
+// #define MAX_SOL_PARAMS_DATA  9
+// #define RESERVED_VALUE_70					0x70
+// #define RESERVED_VALUE_F0					0xF0
+// typedef struct
+// {
+//     INT8U	Params;
+//     INT8U	ReservedBits [MAX_SOL_PARAMS_DATA];
+//     INT8U	DataLen;
+
+// } SOLCfgRsvdBits_T;
+
+// static SOLCfgRsvdBits_T m_RsvdBitsCheck [] = {
+
+//     /* Param        Reserved Bits      Data Size   */
+//     { 0,	       { 0xFC }, 			0x1 },		
+//     { 1,		{ 0xFE }, 			0x1 },		
+//     { 2,		{ 0x30 },				0x1 },
+//     { 4,		 { 0xF8 },			 0x1 },	
+//     { 5,		 { 0xF0 },			 0x1 }
+
+// };
+
+
+
+
+// /*** Module Variables ***/
+
+// /**
+//  * @brief SOL Configuration Parameter Lengths
+// **/
+// static const INT8U  SOLConfigParamLengths [] = { 1,1,1,2,2,1,1,1,2 };
+
+// /**
+//  * IsBaudRateValid
+//  **/
+// static int IsBaudRateValid (INT8U BaudRate);
+
+// // Function to check if valid privileges
+// static int IsValidPrivilege(INT8U authtype);
+
+// #if SOL_ACTIVATING_COMMAND != UNIMPLEMENTED
+// /*---------------------------------------
+//  * SOLActivating
+//  *---------------------------------------*/
+// int
+// SOLActivating (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
+// {
+
+//     /**
+//      * Send SOL activating Message to Remote Application connected to
+//      * Connected to Serial port
+//     **/
+
+//     *pRes = CC_NORMAL;
+//     return sizeof (*pRes);
+// }
+// #endif /* SOL_ACTIVATING_COMMAND */
+
+
+// #if GET_SOL_CONFIGURATION != UNIMPLEMENTED
+// /*---------------------------------------
+//  * GetSOLConfig
+//  *---------------------------------------*/
+// int
+// GetSOLConfig (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
+// {
+//     _NEAR_ GetSOLConfigReq_T*   GetReq = (_NEAR_ GetSOLConfigReq_T*) pReq;
+//     _NEAR_ GetSOLConfigRes_T*   GetRes = (_NEAR_ GetSOLConfigRes_T*) pRes;
+//     _NEAR_ GetSOLConfigOEMRes_T*   GetOEMRes = (_NEAR_ GetSOLConfigOEMRes_T*) pRes;
+//     _FAR_  BMCSharedMem_T*      pSharedMem = BMC_GET_SHARED_MEM (BMCInst);
+//     BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+//     INT8U Size,*curchannel;
+//     INT8U ChannelNum, EthIndex;
+//     INT8U oem_len;
+//     unsigned long oem_addr;
+
+//     ChannelNum = GetReq->ChannelNum & 0x0F;
+
+//     if(GetReq->ChannelNum & RESERVED_VALUE_70)
+//     {
+//         /* Alarm !!! Somebody is trying to set Reseved Bits */
+//         *pRes = CC_INV_DATA_FIELD;
+//         return sizeof (*pRes);
+//     }
+
+//     if (ChannelNum > 0x0F)
+//     {
+//         *pRes =CC_INV_DATA_FIELD;
+//         return sizeof(*pRes);
+//     }
+
+//     if (0x0E == ChannelNum)
+//     {
+//         OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
+//         EthIndex = GetEthIndex (*curchannel  & 0xF, BMCInst);
+//     }
+//     else
+//     {
+//         EthIndex = GetEthIndex (ChannelNum, BMCInst);
+//     }
+
+//     if (0xFF == EthIndex)
+//     {
+//         *pRes = CC_INV_DATA_FIELD;
+//         return  sizeof (*pRes);
+//     }
+
+//     if((GetReq->SetSel != 0x00) ||(GetReq->BlkSEl != 0x00))
+//     {
+//          *pRes =CC_INV_DATA_FIELD;
+//          return sizeof(*pRes);    
+//     }
+
+//     GetRes->CompletionCode = CC_NORMAL;
+//     GetRes->ParamRev       = PARAM_REVISION;
+
+//     /* Check if only parameter revision is required */
+//     if (0 != (GetReq->ChannelNum & GET_PARAM_REV_ONLY_MASK))
+//     {
+//         if((MAX_SOL_CONF_PARAM >= GetReq->ParamSel))
+//         {
+//             return sizeof(GetSOLConfigRes_T);
+//         }
+//         else if(( NULL != g_PDKHandle[PDK_GETSOLOEMPARAM]) && 
+//                 ((MIN_SOL_OEM_CONF_PARAM <= GetReq->ParamSel) && (MAX_SOL_OEM_CONF_PARAM >= GetReq->ParamSel)))
+//         {
+//             oem_len = ((int(*)(INT8U, unsigned long*,int))(g_PDKHandle[PDK_GETSOLOEMPARAM]))(GetReq->ParamSel, &oem_addr ,BMCInst);
+//             if( oem_len == 0)
+//             {
+//                 GetRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//                 return sizeof(INT8U);
+//             }
+//             else
+//                 return sizeof(GetSOLConfigRes_T);
+//         }
+//         else
+//         {
+//             *pRes = CC_PARAM_NOT_SUPPORTED;
+//             return sizeof (*pRes);  
+//         }
+//     }
+
+//     Size = sizeof (GetSOLConfigRes_T);
+//     /* Load individual configurations */
+//     switch (GetReq->ParamSel)
+//     {
+//         case SOL_SET_IN_PROGRESS:
+
+//             LOCK_BMC_SHARED_MEM(BMCInst);
+//             (*(_NEAR_ INT8U*)(GetRes + 1)) = BMC_GET_SHARED_MEM(BMCInst)->m_SOL_SetInProgress;
+//             UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             Size = Size + sizeof (INT8U);
+//             break;
+
+//         case SOL_ENABLE_PARAM:
+
+//             (*(_NEAR_ INT8U*)(GetRes + 1)) = pBMCInfo->SOLCfg[EthIndex].SOLEnable;
+//             Size = Size + sizeof (INT8U);
+//             break;
+
+//         case SOL_AUTHENTICATION_PARAM:
+
+//             (*(_NEAR_ INT8U*)(GetRes + 1)) = pBMCInfo->SOLCfg[EthIndex].SOLAuth;
+//             Size = Size + sizeof (INT8U);
+//             break;
+
+//         case SOL_ACCUM_THRESHOLD_PARAM:
+
+//             _fmemcpy((INT8U *)(GetRes+1),(INT8U *)&pBMCInfo->SOLCfg[EthIndex].CharAccThresh,sizeof(INT16U));
+//             Size = Size + sizeof (INT16U);
+//             break;
+
+//         case SOL_RETRY_PARAM:
+
+//             (*((_NEAR_ INT8U*)(GetRes + 1))) = pBMCInfo->SOLCfg[EthIndex].SOLRetryCount;
+//             (*((_NEAR_ INT8U*)(GetRes + 1) + 1)) = pBMCInfo->SOLCfg[EthIndex].SOLRetryInterval;
+//             Size = Size + sizeof (INT16U);
+//             break;
+
+//         case SOL_NVOL_BIT_RATE_PARAM:
+
+//             (*(_NEAR_ INT8U*)(GetRes + 1)) = pBMCInfo->SOLCfg[EthIndex].NVBitRate;
+//             Size = Size + sizeof (INT8U);
+//             break;
+
+//         case SOL_VOL_BIT_RATE_PARAM:
+
+//             (*(_NEAR_ INT8U*)(GetRes + 1)) = pSharedMem->SOLBitRate[EthIndex];
+//             Size = Size + sizeof (INT8U);
+//             break;
+
+//         case SOL_PAYLD_CHANNEL_PARAM:
+
+//             (*(_NEAR_ INT8U*)(GetRes + 1)) = pBMCInfo->SOLCfg[EthIndex].PayldChannel;
+//             Size = Size + sizeof (INT8U);
+//             break;
+
+//         case SOL_PAYLD_PORT_NUM_PARAM:
+
+//             _fmemcpy((INT8U *)(GetRes+1),(INT8U *)&pBMCInfo->SOLCfg[EthIndex].PayldPortNum,sizeof(INT16U));
+//             Size = Size + sizeof (INT16U);
+//             break;
+
+//         default:
+//             if(g_PDKHandle[PDK_GETSOLOEMPARAM] != NULL &&
+//                 (GetReq->ParamSel >= 192 && GetReq->ParamSel <= 255))
+//             {
+//                 oem_len = ((int(*)(INT8U, unsigned long*,int))(g_PDKHandle[PDK_GETSOLOEMPARAM]))(GetReq->ParamSel, &oem_addr ,BMCInst);
+//                 if( oem_len == 0)
+//                 {
+//                     GetRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//                     return sizeof(INT8U);
+//                 }
+//                 else
+//                 {
+//                     //Acquire the OEM parameters
+//                     if( oem_len < MSG_PAYLOAD_SIZE - sizeof(GetSOLConfigOEMRes_T))
+//                     {
+//                         memcpy((char*)GetOEMRes + sizeof(GetSOLConfigOEMRes_T) ,\
+//                                     (unsigned int*)oem_addr , oem_len);
+//                     }
+//                     else
+//                     {
+//                         GetRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//                         return sizeof(INT8U);
+//                     }
+//                     return sizeof(GetSystemInfoParamOEMRes_T) + oem_len;
+//                 }
+//             }
+//             else
+//             {
+//                 GetRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
+//                 Size = sizeof (INT8U);
+//             }
+//     }
+
+//     return  Size;
+// }
+// #endif /* GET_SOL_CONFIGURATION */
+
+
+// #if SET_SOL_CONFIGURATION != UNIMPLEMENTED
+// /*---------------------------------------
+//  * SetSOLConfig
+//  *---------------------------------------*/
+// int
+// SetSOLConfig (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
+// {
+//     _NEAR_ SetSOLConfigReq_T*   SetReq = (_NEAR_ SetSOLConfigReq_T*) pReq;
+//     _NEAR_ SetSOLConfigOEMReq_T*   pSetOEMReq = (_NEAR_ SetSOLConfigOEMReq_T*) pReq;
+//     _FAR_  BMCSharedMem_T*      pSharedMem = BMC_GET_SHARED_MEM (BMCInst);
+//     BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+//     int i=0, j=0;
+//     INT8U ChannelNum, EthIndex,*curchannel;
+//     unsigned long oem_addr;
+//     int size;
+//     INT8U  m_SOL_SetInProgress; /**< Contains setting SOL configuration status */
+    
+//     ChannelNum = SetReq->ChannelNum & 0x0F;
+
+//     if (ChannelNum > 0x0F)
+//     {
+//         *pRes =CC_INV_DATA_FIELD;
+//         return sizeof(*pRes);
+//     }
+
+//     if (0x0E == ChannelNum)
+//     {
+//         OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
+//         EthIndex = GetEthIndex (*curchannel  & 0xF, BMCInst);
+//     }
+//     else
+//     {
+//         EthIndex = GetEthIndex (ChannelNum, BMCInst);
+//     }
+
+//     if (0xFF == EthIndex)
+//     {
+//         *pRes = CC_INV_DATA_FIELD;
+//         return  sizeof (*pRes);
+//     }
+
+//     if (SetReq->ParamSel >= sizeof (SOLConfigParamLengths))
+//     {
+//         *pRes = CC_PARAM_NOT_SUPPORTED;
+//         return sizeof (*pRes);
+//     }
+
+//     /* Validate Req Lengths */
+//     if (ReqLen != (sizeof (SetSOLConfigReq_T) +
+//                    SOLConfigParamLengths [SetReq->ParamSel]))
+//     {
+//         *pRes = CC_REQ_INV_LEN;
+//         return sizeof (*pRes);
+//     }
+
+//     if(SetReq->ChannelNum & RESERVED_VALUE_F0)
+//     {
+//         /* Alarm !!! Somebody is trying to set Reseved Bits */
+//         *pRes = CC_INV_DATA_FIELD;
+//         return sizeof (*pRes);
+//     }
+
+//     /* Check for Reserved Bits */
+//     for (i = 0; i < sizeof (m_RsvdBitsCheck)/ sizeof (m_RsvdBitsCheck[0]); i++)
+//     {
+//         /* Check if this Parameter Selector needs Reserved bit checking !! */
+//         if (m_RsvdBitsCheck[i].Params == SetReq->ParamSel )	
+//         {
+//             for (j = 0; j < m_RsvdBitsCheck[i].DataLen; j++)
+//             {
+//                 if ( 0 != (pReq[2+j] & m_RsvdBitsCheck[i].ReservedBits[j]))
+//                 {
+//                     /* Alarm !!! Somebody is trying to set Reseved Bits */
+//                     *pRes = CC_INV_DATA_FIELD;
+//                     return sizeof (*pRes);
+//                 }
+//             }
+//         }
+//     }
+
+//     *pRes = CC_NORMAL;
+//     switch (SetReq->ParamSel)
+//     {
+//         case SOL_SET_IN_PROGRESS:
+//             LOCK_BMC_SHARED_MEM(BMCInst);
+//             m_SOL_SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_SOL_SetInProgress;
+//             UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             /* Commit Write is optional and supported
+//              * only if rollback is supported */
+//             if ((SET_COMPLETE != (*(_NEAR_ INT8U*)(SetReq + 1))) &&
+//                 (SET_IN_PROGRESS != (*(_NEAR_ INT8U*)(SetReq + 1))))
+//             {
+//                 *pRes = CC_PARAM_NOT_SUPPORTED;
+//                 return sizeof (*pRes);
+//             }
+//             else if ((SET_IN_PROGRESS == m_SOL_SetInProgress) &&
+//                 (SET_IN_PROGRESS == (*(_NEAR_ INT8U*)(SetReq + 1))))
+//             {
+//                 /*Set In Progress already Set */
+//                 *pRes = CC_SET_IN_PROGRESS;
+//                 return sizeof (*pRes);
+//             }
+//             LOCK_BMC_SHARED_MEM(BMCInst);
+//             BMC_GET_SHARED_MEM(BMCInst)->m_SOL_SetInProgress = (*(_NEAR_ INT8U*)(SetReq + 1));
+//             UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             break;
+
+//         case SOL_ENABLE_PARAM:
+//             pBMCInfo->SOLCfg[EthIndex].SOLEnable = (*(_NEAR_ INT8U*)(SetReq + 1));
+//             break;
+
+//         case SOL_AUTHENTICATION_PARAM:
+//             /*
+//             #34323: Check if user is setting reserved bits. This cannot be handled at main logic
+//             of reserve bit checking.
+//             */
+//             if (0 != IsValidPrivilege((0x3F & (*(_NEAR_ INT8U*)(SetReq + 1)))))
+//             {
+//                 *pRes = CC_INV_DATA_FIELD;
+//                 return sizeof (*pRes);    
+//             }
+
+//             pBMCInfo->SOLCfg[EthIndex].SOLAuth = (*(_NEAR_ INT8U*)(SetReq + 1));
+//             break;
+
+//         case SOL_ACCUM_THRESHOLD_PARAM:
+//                 if(((*(_NEAR_ INT8U*)(SetReq + 1)) == 0) || ((*((_NEAR_ INT8U*)(SetReq +1)+1)) == 0))
+//                 {
+//                     *pRes = CC_INV_DATA_FIELD;
+//                     return sizeof (*pRes);           
+//                 }
+                    
+//                 pBMCInfo->SOLCfg[EthIndex].CharAccThresh = (*(_NEAR_ INT16U*)(SetReq + 1));
+//                 break;
+
+//         case SOL_RETRY_PARAM:
+
+//             pBMCInfo->SOLCfg[EthIndex].SOLRetryCount = (*((_NEAR_ INT8U*)(SetReq +1) ) );
+//             pBMCInfo->SOLCfg[EthIndex].SOLRetryInterval = (*((_NEAR_ INT8U*)(SetReq +1)+1));
+//             break;
+
+//         case SOL_NVOL_BIT_RATE_PARAM:
+
+//             if ( 0 != IsBaudRateValid (*(_NEAR_ INT8U*)(SetReq + 1)))
+//             {
+//                 /*Invalid baud rate setting */
+//                 *pRes = CC_INV_DATA_FIELD;
+//                 return sizeof (*pRes);
+//             }
+//             if((*(_NEAR_ INT8U*)(SetReq+1)) == 0)
+//             *(_NEAR_ INT8U*)(SetReq+1) = BAUD_RATE_9600;
+
+//             pBMCInfo->SOLCfg[EthIndex].NVBitRate = *(_NEAR_ INT8U*)(SetReq + 1);
+
+//             break;
+
+//         case SOL_VOL_BIT_RATE_PARAM:
+
+//             if ( 0 != IsBaudRateValid (*(_NEAR_ INT8U*)(SetReq + 1)))
+//             {
+//                 /*Invalid baud rate setting */
+//                 *pRes = CC_INV_DATA_FIELD;
+//                 return sizeof (*pRes);
+//             }
+//             if((*(_NEAR_ INT8U*)(SetReq+1)) == 0)
+//             *(_NEAR_ INT8U*)(SetReq+1) = BAUD_RATE_9600;
+
+//             pSharedMem->SOLBitRate[EthIndex] = *(_NEAR_ INT8U*)(SetReq + 1);
+
+//             break;
+
+//         case SOL_PAYLD_CHANNEL_PARAM:
+
+//             *pRes = CC_ATTEMPT_TO_SET_RO_PARAM;
+//             return sizeof (*pRes);
+//             break;
+
+//         case SOL_PAYLD_PORT_NUM_PARAM:
+
+//             *pRes = CC_ATTEMPT_TO_SET_RO_PARAM;
+//             return sizeof (*pRes);
+//             break;
+
+//         default:
+//             if(g_PDKHandle[PDK_SETSOLOEMPARAM] != NULL &&
+//                 (SetReq->ParamSel >= 192 && SetReq->ParamSel <= 255))
+//             {
+//                 oem_addr = (unsigned long)((char*)pSetOEMReq + sizeof(SetSOLConfigOEMReq_T));
+//                 size = ((int(*)(INT8U, unsigned long*,int))(g_PDKHandle[PDK_SETSOLOEMPARAM]))(SetReq->ParamSel, &oem_addr ,BMCInst);
+//                 if(size <= 0)
+//                 {
+//                     *pRes = CC_PARAM_NOT_SUPPORTED;
+//                     return sizeof(*pRes);
+//                 }
+//                 else
+//                 {
+//                     *pRes = CC_PARAM_NOT_SUPPORTED;
+//                     return sizeof(*pRes);
+//                 }
+//             }         
+//     }
+
+//     FlushIPMI((INT8U*)&pBMCInfo->SOLCfg[0],(INT8U*)&pBMCInfo->SOLCfg[EthIndex],pBMCInfo->IPMIConfLoc.SOLCfgAddr,
+//                       sizeof(SOLConfig_T),BMCInst);
+
+//     return sizeof (*pRes);
+// }
+// #endif /* SET_SOL_CONFIGURATION */
+
+// /**
+//  * IsBaudRateValid
+//  **/
+// int 
+// IsBaudRateValid (INT8U BaudRate)
+// {
+	
+//     /* Check against supported Baud Rates */
+//     if ((BaudRate == 0)  			  ||
+//         (BaudRate == BAUD_RATE_9600)  ||
+//         (BaudRate == BAUD_RATE_19200) || 
+//         (BaudRate == BAUD_RATE_38400) || 
+//         (BaudRate == BAUD_RATE_57600) || 
+//         (BaudRate == BAUD_RATE_115200))
+//     {
+//     //Baud rate is valid 
+//     return 0;	
+//     }
+
+//     //Baud rate is invvalid 
+//     return -1;	
+// }
+
+// /*
+// Check if user entered Auth type is valid
+// */
+
+//     int  IsValidPrivilege(INT8U  priv_lvl)
+//     {
+//         if ((priv_lvl == 02) ||
+//             (priv_lvl == 03) ||
+//             (priv_lvl == 04) ||
+//             (priv_lvl == 05))
+//         return 0; 
+//             else
+//         return -1; //// Invalid privilege
+//     }
+
+// #if 0
+// /**
+//  * InitSOLPort
+//  **/
+// int
+// InitSOLPort (INT8U BaudRate)
+// {
+//     int     status;
+//     int		fd;
+//     struct  termios tty_struct;
+
+//     if ((fd = open(SOL_IFC_PORT,O_RDONLY)) < 0)
+//     {
+//         IPMI_WARNING ("Can't open serial port..%s\n",strerror(errno));
+//         return -1;
+//     }
+
+//     status = tcgetattr(fd,&tty_struct);   			   /* get termios structure */
+
+//     switch (BaudRate) {
+//     case BAUD_RATE_9600:
+//         cfsetospeed(&tty_struct, B9600);
+//         cfsetispeed(&tty_struct, B9600);
+//         break;
+//     case BAUD_RATE_19200:
+//         cfsetospeed(&tty_struct, B19200);
+//         cfsetispeed(&tty_struct, B19200);
+//         break;
+//     case BAUD_RATE_38400:
+//         cfsetospeed(&tty_struct, B38400);
+//         cfsetispeed(&tty_struct, B38400);
+//         break;
+//     case BAUD_RATE_57600:
+//         cfsetospeed(&tty_struct, B57600);
+//         cfsetispeed(&tty_struct, B57600);
+//         break;
+//     case BAUD_RATE_115200:
+//         cfsetospeed(&tty_struct, B115200);
+//         cfsetispeed(&tty_struct, B115200);
+//         break;
+//     default:
+//         IPMI_ERROR ("SOLConfig.c : Invalid baud rate = %x\n", BaudRate);
+//     }
+
+//     tty_struct.c_cflag |= CS8;              /* Set 8bits/charecter          */
+//     tty_struct.c_cflag &= ~CSTOPB;          /* set framing to 1 stop bits   */
+//     tty_struct.c_cflag &= ~(PARENB);        /* set parity to NONE           */
+//     tty_struct.c_iflag &= ~(INPCK);
+
+//     /* Set Hardware flow control */
+//     tty_struct.c_cflag |= CRTSCTS;
+
+//     tty_struct.c_lflag &= ~(ICANON|ECHO|ECHOE|ISIG);     /* Raw input mode */
+//     tty_struct.c_oflag &= ~(OCRNL | ONOCR | ONLRET);
+//     tty_struct.c_iflag &= ~(IXON | IXOFF);     /* no sw flow ctrl */
+//     tty_struct.c_iflag &= ~INLCR;
+//     tty_struct.c_iflag &= ~ICRNL;
+//     tty_struct.c_iflag &= ~IGNCR;
+
+//     PDK_InitSOLPort (&tty_struct);	    /* OEM specific SOL initialization */
+
+//     /* set the new attributes in the tty driver */
+//     status = tcsetattr(fd, TCSANOW, &tty_struct);
+
+//     close (fd);
+
+//     return 0;
+// }
+
+// #endif /* #if 0 */
+

+ 1314 - 0
app/bmc/msghndlr/Transport/SerialModem.c

@@ -0,0 +1,1314 @@
+// /*****************************************************************
+//  *****************************************************************
+//  ***                                                            **
+//  ***    (C)Copyright 2005-2006, American Megatrends Inc.        **
+//  ***                                                            **
+//  ***            All Rights Reserved.                            **
+//  ***                                                            **
+//  ***        6145-F, Northbelt Parkway, Norcross,                **
+//  ***                                                            **
+//  ***        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+//  ***                                                            **
+//  ***************************************************************** ****************************************************************
+//  *
+//  * SerialModem.c
+//  * Serial/Modem configuration , Callback &  MUX
+//  *
+//  *  Author: Govindarajan <govindarajann@amiindia.co.in>
+//  *          Vinoth Kumar <vinothkumars@amiindia.co.in>
+//  ****************************************************************/
+// #define ENABLE_DEBUG_MACROS 0
+// #include "Types.h"
+// #include "Debug.h"
+// #include "IPMI_Main.h"
+// #include "MsgHndlr.h"
+// #include "Support.h"
+// #include "IPMIDefs.h"
+// #include "IPMI_SerialModem.h"
+// #include "SerialModem.h"
+// #include "SharedMem.h"
+// #include "AppDevice.h"
+// #include "Message.h"
+// #include "PMConfig.h"
+// #include "Util.h"
+// #include "SerialIfc.h"
+// #include "NVRAccess.h"
+// #include "IPMIConf.h"
+// #include "PDKDefs.h"
+// #include "PDKAccess.h"
+
+
+// /* Reserved bit macro definitions */
+// #define RESERVED_BITS_SETSERIALMODEMCONFIG_CH           0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+// #define RESERVED_BITS_SETSERIALMODEMCONFIG_SERINPRO     0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
+
+// #define RESERVED_BITS_GETSERIALMODEMCONFIG_REVCH        0X70 //(BIT6 | BIT5 | BIT4)
+
+// #define RESERVED_BITS_CALLBACK_CH                       0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+// #define RESERVED_BITS_CALLBACK_DESTSEL                  0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+
+// #define RESERVED_BITS_SETUSERCALLBACKOPT_USRID          0XC0 //(BIT7 | BIT6)
+// #define RESERVED_BITS_SETUSERCALLBACKOPT_CH             0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+// #define RESERVED_BITS_SETUSERCALLBACKOPT_USRCALLBAKCAP  0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
+// #define RESERVED_BITS_SETUSERCALLBACKOPT_CBCNEGOPT      0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+
+// #define RESERVED_BITS_GETUSERCALLBACKOPTIONS_USRID      0XC0 //(BIT7 | BIT6)
+
+// #define RESERVED_BITS_SETSERIALMODEMMUX_CH              0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+// #define RESERVED_BITS_SETSERIALMODEMMUX_MUXSETREQ       0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+
+// #define RESERVED_BITS_SERIALMODEMCONNECTACTIVE          0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+
+// #define RESERVED_BITS_GETTAPRESPONSECODES_CH            0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
+
+// /*** Local Typedefs ***/
+// /**
+//  * @struct SMConfigTable_T
+//  * @brief Serial Modem Configuration Table.
+// **/
+
+// #pragma pack( )
+// typedef struct
+// {
+//     INT8U   ParamFlags;
+//     INT8U   MaxSetSelector;
+//     INT8U   MaxBlockSelector;
+//     unsigned long  Offset;
+//     INT8U   Size;
+
+// } PACKED SMConfigTable_T;
+
+// #pragma pack( )
+
+// /**
+//  * @struct RsvdBitsTable_T
+//  * @brief Reserved Bits Table.
+// **/
+
+// #pragma pack (1)
+// typedef struct
+// {
+//     INT8U   Param;
+//     INT8U   Length;
+
+// } PACKED RsvdBitsTable_T;
+
+
+// #pragma pack( )
+
+
+// /*** Local Definitions ***/
+// #define PARAM_VOLATILE                  0x01
+// #define PARAM_NON_VOLATILE              0x02
+// #define PARAM_VOLATILE_NON_VOLATILE     0x04
+// #define PARAM_READ_ONLY                 0x08
+// #define PARAM_WRITE_ONLY                0x10
+// #define CHECK_RSVD_BITS                 0x20
+// #define BLOCK_SELECTOR_REQ              0x80
+
+// #define GET_PARAM_REV_ONLY              0x80
+// #define PARAM_REVISION                  0x11
+
+// #define SET_IN_PROGRESS                 1
+// #define SET_COMPLETE                    0
+// #define SET_BAUD_RATE                   7
+// #define SET_BAD_PWD_THRESHOLD           54
+
+// #define INIT_STR_PARAM                  10
+
+// /* Set Serial Port Mux */
+// #define REQ_CUR_MUX_SETTING             0
+// #define REQ_MUX_TO_SYS                  1
+// #define REQ_MUX_TO_BMC                  2
+// #define REQ_MUX_FORCE_TO_SYS            3
+// #define REQ_MUX_FORCE_TO_BMC            4
+// #define REQ_BLOCK_MUX_TO_SYS            5
+// #define REQ_ALLOW_MUX_TO_SYS            6
+// #define REQ_BLOCK_MUX_TO_BMC            7
+// #define REQ_ALLOW_MUX_TO_BMC            8
+
+// #define REQ_MUX_TO_SYS_MASK             0x80
+// #define REQ_MUX_TO_BMC_MASK             0x40
+
+// #define SET_MUX_TO_SYS_MASK             0xFE
+// #define SET_MUX_TO_BMC_MASK             0x1
+
+// #define ALLOW_MUX_TO_SYS_MASK           0x7F
+// #define BLOCK_MUX_TO_SYS_MASK           0x80
+// #define ALLOW_MUX_TO_BMC_MASK           0xBF
+// #define BLOCK_MUX_TO_BMC_MASK           0x40
+
+// #define MUX_REQ_ACCEPTED_MASK           0x02
+// #define MUX_REQ_REJECTED_MASK           0xFD
+// #define MUX_SESSION_ACTIVE_MASK         0x04
+// #define MUX_SESSION_ALERT_INACTIVE_MASK 0xF3
+// #define MUX_ALERT_IN_PROGRESS_MASK      0x08
+
+// #define SERIAL_PORT_SHARING_ENABLED     0x08
+
+// #define IPMI_CALLBACK_MASK              1
+// #define CBCP_CALLBACK_MASK              2
+
+// #define SESSION_STATE_ACTIVE            1
+// #define SESSION_STATE_INACTIVE          0
+// #define DIRECT_PING_ENABLE_MASK         2
+// #define MUX_SWITCHED_TO_SYS             2
+
+// #define PING_MSG_ACTIVE_BIT             0x01
+
+// #define BAUD_RATE_9600          		6
+// #define BAUD_RATE_19200         		7
+// #define BAUD_RATE_38400         		8
+// #define BAUD_RATE_57600         		9
+// #define BAUD_RATE_115200        		10
+
+// #define NO_FLOWCONTROL          		0
+// #define HARDWARE_FLOWCONTROL    		1
+// #define XON_XOFF_FLOWCONTRO     		2
+
+// #define SERIAL_BAUD_RATE            0x0F
+
+// #define SM_OFFSET(MEMBER)               (unsigned long)&(((SMConfig_T*) 0)->MEMBER)
+
+
+// /**
+//  * @brief SerialModem Validation Info Table
+// **/
+// const SMConfigTable_T SMConfigTable [] =
+// {
+//     { PARAM_VOLATILE,               0,                          0,                              SM_OFFSET (SetInProgress),          1                           },  // Set In Progress
+//     { PARAM_READ_ONLY,              0,                          0,                              SM_OFFSET (AuthTypeSupport),        1                           },  // Authentication Type Support
+//     { PARAM_NON_VOLATILE | \
+//                 CHECK_RSVD_BITS,    0,                          0,                              SM_OFFSET (AuthTypeEnable),         sizeof (AuthTypeEnable_T)   },  // Authetication Type enable
+//     { PARAM_NON_VOLATILE | \
+//                 CHECK_RSVD_BITS,    0,                          0,                              SM_OFFSET (ConnectionMode),         1,                          },  // Connection Mode
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (SessionInactivity),1                         },
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (ChannelCallBackCtrl),    sizeof (ChannelCallbackCtrl_T)  },
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (SessionTermination),     1                               },
+//     { PARAM_NON_VOLATILE | \
+//                 CHECK_RSVD_BITS,    0,                          0,                              SM_OFFSET (IpmiMsgCommSet),         sizeof (IpmiMsgCommSettings_T)  },
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (MUXSwitchCtrl),          sizeof (MuxSwitchCtrl_T)        },
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (RingTime),               sizeof (ModemRingTime_T)        },
+//     { PARAM_VOLATILE_NON_VOLATILE,  MAX_MODEM_INIT_STR_BLOCKS,  0,                              SM_OFFSET (ModemInitString [0] [0]),MAX_MODEM_INIT_STR_BLOCK_SIZE + 0x80    },
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (ModemEscapeSeq [0]),     MAX_MODEM_ESC_SEQ_SIZE      },
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (ModemHangup [0]),        MAX_MODEM_HANG_UP_SEQ_SIZE  },
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (ModemDialCmd [0]),       MAX_MODEM_DIAL_CMD_SIZE     },
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (PageBlockOut),           1                           },
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (CommunityString [0]),    MAX_COMM_STRING_SIZE        },
+//     { PARAM_READ_ONLY,              0,                          0,                              SM_OFFSET (TotalAlertDest),         1                           },
+//     { PARAM_VOLATILE_NON_VOLATILE,  MAX_SERIAL_ALERT_DESTINATIONS,0,                            SM_OFFSET (DestinationInfo [0]),        sizeof (DestInfo_T)         },
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (CallRetryInterval),      1                           },
+//     { PARAM_VOLATILE_NON_VOLATILE,  MAX_SERIAL_ALERT_DESTINATIONS,0,                            SM_OFFSET (DestComSet [0]),             sizeof (ModemDestCommSettings_T)    },
+//     { PARAM_READ_ONLY,              0,                          0,                              SM_OFFSET (TotalDialStr),           1                           },
+//     { PARAM_VOLATILE_NON_VOLATILE,  MAX_MODEM_DIAL_STRS + 0x80, MAX_MODEM_DIAL_STR_BLOCKS,      SM_OFFSET (DestDialStrings [0] [0] [0]),MAX_MODEM_DIAL_STR_BLOCK_SIZE + 0x80},
+//     { PARAM_READ_ONLY,              0,                          0,                              SM_OFFSET (TotalDestIP),            1                           },
+//     { PARAM_VOLATILE_NON_VOLATILE,  MAX_MODEM_ALERT_DEST_IP_ADDRS,0,                            SM_OFFSET (DestAddr [0]),           sizeof (DestIPAddr_T)       },
+//     { PARAM_READ_ONLY,              0,                          0,                              SM_OFFSET (TotalTAPAcc),            1                           },
+//     { PARAM_VOLATILE_NON_VOLATILE,  MAX_MODEM_TAP_ACCOUNTS,     0,                              SM_OFFSET (TAPAccountSelector[0]),  1                           },
+//     { PARAM_VOLATILE_NON_VOLATILE | \
+//                 PARAM_WRITE_ONLY,   MAX_MODEM_TAP_ACCOUNTS,     0,                              SM_OFFSET (TAPPasswd [0] [0]),      TAP_PASSWORD_SIZE           },
+//     { PARAM_NON_VOLATILE,           MAX_MODEM_TAP_ACCOUNTS,     0,                              SM_OFFSET (TAPPagerIDStrings [0] [0]),TAP_PAGER_ID_STRING_SIZE  },
+//     { PARAM_NON_VOLATILE,           MAX_MODEM_TAP_ACCOUNTS,     0,                              SM_OFFSET (TAPServiceSettings [0]), sizeof (TAPServiceSettings_T)},
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (Termconfig),             sizeof (TermConfig_T)       },
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (PPPProtocolOptions),     sizeof (PPPProtocolOptions_T)},
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (PPPPrimaryRMCPPort),     sizeof (INT16U)             },
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (PPPSecondaryRMCPPort),   sizeof (INT16U)             },
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (PPPLinkAuth),            1                           },
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (CHAPName [0]),           MAX_MODEM_CHAP_NAME_SIZE + 0x80},
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (PPPACCM),                sizeof (PPPAccm_T)          },
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (PPPSnoopACCM),           sizeof (PPPSnoopAccm_T)     },
+//     { PARAM_READ_ONLY,              0,                          0,                              SM_OFFSET (TotalPPPAcc),            1                           },
+//     { PARAM_VOLATILE_NON_VOLATILE,  MAX_MODEM_PPP_ACCOUNTS,     0,                              SM_OFFSET (PPPAccDialStrSel [0]),   1                           },
+//     { PARAM_VOLATILE_NON_VOLATILE,  MAX_MODEM_PPP_ACCOUNTS,     0,                              SM_OFFSET (PPPAccIPAddress [0] [0]),IP_ADDR_LEN         },
+//     { PARAM_VOLATILE_NON_VOLATILE,  MAX_MODEM_PPP_ACCOUNTS,     0,                              SM_OFFSET (PPPAccUserNames [0] [0]),PPP_ACC_USER_NAME_DOMAIN_PASSWD_SIZE + 0x80 },
+//     { PARAM_VOLATILE_NON_VOLATILE,  MAX_MODEM_PPP_ACCOUNTS,     0,                              SM_OFFSET (PPPAccUserDomain [0] [0]),PPP_ACC_USER_NAME_DOMAIN_PASSWD_SIZE + 0x80},
+//     { PARAM_VOLATILE_NON_VOLATILE | \
+//       PARAM_WRITE_ONLY,             MAX_MODEM_PPP_ACCOUNTS,     0,                              SM_OFFSET (PPPAccUserPasswd [0] [0]),PPP_ACC_USER_NAME_DOMAIN_PASSWD_SIZE + 0x80},
+//     { PARAM_VOLATILE_NON_VOLATILE,  MAX_MODEM_PPP_ACCOUNTS,     0,                              SM_OFFSET (PPPAccAuthSettings [0]), 1                           },
+//     { PARAM_VOLATILE_NON_VOLATILE,  MAX_MODEM_PPP_ACCOUNTS,     0,                              SM_OFFSET (PPPAccConnHoldTimes [0]),1                           },
+//     { PARAM_NON_VOLATILE,           0,                          0,                              SM_OFFSET (PPPUDPProxyIPHeadData),sizeof (PPPUDPProxyIPHeaderData_T)    },
+//     { PARAM_READ_ONLY,              0,                          0,                              SM_OFFSET (PPPUDPProxyTransmitBuffSize),2                       },
+//     { PARAM_READ_ONLY,              0,                          0,                              SM_OFFSET (PPPUDPProxyReceiveBuffSize),2                        },
+//     { PARAM_READ_ONLY,              0,                          0,                              SM_OFFSET (PPPRemoteConsoleIPAdd [0]),IP_ADDR_LEN           },
+//     {0,                             0,                          0,                                                                  0,                     0},
+//     {0,                             0,                          0,                                                                  0,                     0},
+//     {0,                             0,                          0,                                                                  0,                     0},
+//     {0,                             0,                          0,                                                                  0,                     0},
+//     {0,                             0,                          0,                                                                  0,                     0},
+//     { PARAM_NON_VOLATILE,             0,                          0,                              SM_OFFSET (BadPasswd),sizeof(BadPassword_T)          },
+
+// };
+
+
+// /**
+//  * @brief SerialModem Reserved Bits Validation Info Table
+// **/
+// const INT8U ReservedBitsTable [] =
+// {
+//     /*Param,    Length, ReservedBits Masks*/
+//      2,         5,      0xc8,0xc8,0xc8,0xc8,0xc8,
+//      3,         1,      0x78,
+//      7,         2,      0x0f,0xf0,
+// };
+
+
+// /*** Prototype Declarations ***/
+// static _FAR_ INT8U* getSMConfigAddr (_FAR_ const SMConfigTable_T* SMEntry,
+//                                                  INT8U            SetSelector,
+//                                                  INT8U            BlockSelector,
+//                                                  int			  BMCInst);
+// static _FAR_ ChannelUserInfo_T* GetCBChUserInfo (INT8U UserID, INT8U Channel );
+// static  int     SetSerialPort (int BMCInst);
+
+
+// /*---------------------------------------
+//  * SetSerialModemConfig
+//  *---------------------------------------*/
+// int
+// SetSerialModemConfig (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
+// {
+//     _NEAR_ SetSerialModemConfigReq_T* SetReq =
+//                               (_NEAR_ SetSerialModemConfigReq_T*) pReq;
+//     const  SMConfigTable_T*           SMEntry;
+//     _NEAR_ RsvdBitsTable_T*           RsvdEntry;
+//     INT8U                      SetSelector;
+//     INT8U                      BlockSelector;
+//     INT8U                      ReqStartOffset,i,tempdata;
+//     _FAR_  INT8U*                     SetStart;
+//     _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//     INT8U  m_Serial_SetInProgress; /**< Contains setting Serial configuration status */
+
+//     IPMI_DBG_PRINT ("Set SerialModem Configuration Cmd\n");
+
+// 	if(SetReq->ChannelNo & RESERVED_BITS_SETSERIALMODEMCONFIG_CH)
+// 	{
+// 		*pRes = CC_INV_DATA_FIELD;
+// 		return sizeof(*pRes);
+// 	}
+
+//     /* Verify if the Channel number & param selector is valid */
+//     if (SetReq->ChannelNo != pBMCInfo->SERIALch)
+//     {
+//         *pRes = CC_INV_DATA_FIELD;
+//         return sizeof (*pRes);
+//     }
+
+//     if (SetReq->ParamSel >= sizeof (SMConfigTable) / sizeof (SMConfigTable [0]))
+//     {
+//         *pRes = CC_PARAM_NOT_SUPPORTED;
+//         return sizeof (*pRes);
+//     }
+
+//     SMEntry = &(SMConfigTable [SetReq->ParamSel]);
+
+//     /*Adjust length if Set Selector Needed */
+//     if (0 != (SMEntry->MaxSetSelector & 0x7f))
+//     {
+//         ReqLen--;
+//     }
+
+//     /*Adjust length if Block Selector Needed */
+//     if (0 != (SMEntry->MaxSetSelector & BLOCK_SELECTOR_REQ))
+//     {
+//         ReqLen--;
+//     }
+
+//     /* Verify length */
+//     if (0 == (SMEntry->Size & 0x80))
+//     {
+//         if ((ReqLen - sizeof (SetSerialModemConfigReq_T)) != SMEntry->Size)
+//         {
+//             *pRes = CC_REQ_INV_LEN;
+//             return sizeof (*pRes);
+//         }
+//     }
+//     else
+//     {
+//         IPMI_DBG_PRINT_1 ("ReqLen = %d\n",ReqLen);
+//         if ((ReqLen - sizeof (SetSerialModemConfigReq_T)) > (SMEntry->Size & 0x7f))
+//         {
+//             *pRes = CC_REQ_INV_LEN;
+//             return sizeof (*pRes);
+//         }
+//     }
+
+//     LOCK_BMC_SHARED_MEM(BMCInst);
+//     m_Serial_SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_Serial_SetInProgress;
+//     UNLOCK_BMC_SHARED_MEM(BMCInst);
+//     /*Process Set In Progress parameter */
+//     if (SetReq->ParamSel == SET_IN_PROGRESS_PARAM)
+//     {
+// 		if((pReq[2] & RESERVED_BITS_SETSERIALMODEMCONFIG_SERINPRO))
+// 		{
+// 			*pRes = CC_INV_DATA_FIELD;
+// 			return sizeof(*pRes);
+// 		}
+
+//         /* Commit Write is optional and supported
+//          * only if rollback is supported */
+//         if ((SET_COMPLETE != pReq [2]) && (SET_IN_PROGRESS != pReq [2]))
+//         {
+//             *pRes = CC_PARAM_NOT_SUPPORTED;
+//             return sizeof (*pRes);
+//         }
+//         else if ((SET_IN_PROGRESS == m_Serial_SetInProgress) &&
+//                 (SET_IN_PROGRESS == pReq [2]))
+//         {
+//             /*Set In Progress already Set */
+//             *pRes = CC_SET_IN_PROGRESS;
+//             return sizeof (*pRes);
+//         }
+
+//         LOCK_BMC_SHARED_MEM(BMCInst);
+//         BMC_GET_SHARED_MEM(BMCInst)->m_Serial_SetInProgress = pReq [2];
+//         UNLOCK_BMC_SHARED_MEM(BMCInst);
+//         *pRes           = CC_NORMAL;
+//         return sizeof (*pRes);
+//     }
+
+
+//     /* Get the param selector & Block Selector */
+//     if (0 != (SMEntry->MaxSetSelector & BLOCK_SELECTOR_REQ))
+//     {
+//         SetSelector     = pReq [2];
+//         BlockSelector   = pReq [3];
+//         ReqStartOffset  = sizeof (SetSerialModemConfigReq_T) +
+//                           sizeof (SetSelector) + sizeof (BlockSelector);
+//     }
+//     else if (0 == (SMEntry->MaxSetSelector & 0x7f))
+//     {
+//         SetSelector     = 0;
+//         BlockSelector   = 0;
+//         ReqStartOffset  = sizeof (SetSerialModemConfigReq_T);
+//     }
+//     else
+//     {
+//         SetSelector     = pReq [2];
+//         BlockSelector   = 0;
+//         ReqStartOffset  = sizeof (SetSerialModemConfigReq_T) +
+//                           sizeof (SetSelector);
+//     }
+
+//     /*Check Reserved Bits */
+
+//     i = 0;
+//     while ((0 != (SMEntry->ParamFlags & CHECK_RSVD_BITS)) &&
+//                  (i < sizeof (ReservedBitsTable)))
+//     {
+//         RsvdEntry   = (_NEAR_ RsvdBitsTable_T*)&ReservedBitsTable [i];
+//         i = i + sizeof (RsvdBitsTable_T);
+//         if (RsvdEntry->Param == SetReq->ParamSel)
+//         {
+//             INT8U j;
+
+//             for (j=0; j < RsvdEntry->Length; j++)
+//             {
+//                 if (0 != (pReq [ReqStartOffset + j] & ReservedBitsTable [i + j]))
+//                 {
+//                     *pRes = CC_INV_DATA_FIELD;
+//                     return sizeof (*pRes);
+//                 }
+//             }
+//             break;
+//         }
+
+//         i =  i + RsvdEntry->Length;
+//     }
+
+//     /* Verify the set selector & block selector */
+//     if ((0 != (SMEntry->MaxSetSelector & 0x7f)) &&
+//         ((SMEntry->MaxSetSelector & 0x7f) < SetSelector))
+//     {
+//         *pRes = CC_PARAM_OUT_OF_RANGE;
+//         return sizeof (*pRes);
+//     }
+
+//     if ((0 != SMEntry->MaxBlockSelector) &&
+//         (SMEntry->MaxBlockSelector <= BlockSelector))
+//     {
+//         *pRes = CC_PARAM_OUT_OF_RANGE;
+//         return sizeof (*pRes);
+//     }
+
+//     /* Check read only access */
+//     if (0 != (SMEntry->ParamFlags & PARAM_READ_ONLY))
+//     {
+//         *pRes = CC_ATTEMPT_TO_SET_RO_PARAM;
+//         return sizeof (*pRes);
+//     }
+
+//    /* Get the address where we want to set */
+//     SetStart = getSMConfigAddr (SMEntry , SetSelector, BlockSelector,BMCInst);
+
+//     switch(SetReq->ParamSel)
+//     {
+//         case SET_BAUD_RATE:
+//             /*Check for Valid Baud Rate*/
+//             tempdata = GetBits (pReq[3], SERIAL_BAUD_RATE);
+//             if((tempdata > BAUD_RATE_115200)||(tempdata < BAUD_RATE_9600))
+//             {
+//             *pRes = CC_PARAM_OUT_OF_RANGE;
+//             return sizeof(*pRes);
+//             }
+//             LOCK_BMC_SHARED_MEM(BMCInst);
+//             _fmemcpy (SetStart, (_FAR_ INT8U*) (pReq + ReqStartOffset), (SMEntry->Size & 0x7f));
+//             UNLOCK_BMC_SHARED_MEM(BMCInst);
+
+//             /* if Set serial port setting, initlize the serial port */
+//             SetSerialPort (BMCInst);
+//             break;
+
+//         case SET_BAD_PWD_THRESHOLD:
+//             LOCK_BMC_SHARED_MEM(BMCInst);
+//             _fmemcpy (SetStart, (_FAR_ INT8U*) (pReq + ReqStartOffset), (SMEntry->Size & 0x7f));
+//             UNLOCK_BMC_SHARED_MEM(BMCInst);
+//             break;
+
+//         default:
+//             *pRes=CC_PARAM_NOT_SUPPORTED;
+//             return sizeof(INT8U);
+//    }
+
+//     FlushIPMI((INT8U*)&pBMCInfo->SMConfig,(INT8U*)&pBMCInfo->SMConfig,pBMCInfo->IPMIConfLoc.SMConfigAddr,
+//                       sizeof(SMConfig_T),BMCInst);
+
+//     *pRes = CC_NORMAL;
+//     return sizeof (*pRes);
+// }
+
+
+// /*---------------------------------------
+//  * GetSerialModemConfig
+//  *---------------------------------------*/
+// int
+// GetSerialModemConfig (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
+// {
+//     _NEAR_ GetSerialModemConfigReq_T* GetReq =
+//                               (_NEAR_ GetSerialModemConfigReq_T*) pReq;
+//     _NEAR_ GetSerialModemConfigRes_T* GetRes =
+//                               (_NEAR_ GetSerialModemConfigRes_T*) pRes;
+//     const  SMConfigTable_T*           SMEntry;
+//     _FAR_  INT8U*                     SetStart;
+//     INT8U                      ResStartOffset;
+//     _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//     INT8U  m_Serial_SetInProgress; /**< Contains setting Serial configuration status */
+
+// 	if(GetReq->ParamRevChannelNo & RESERVED_BITS_GETSERIALMODEMCONFIG_REVCH)
+// 	{
+// 		*pRes = CC_INV_DATA_FIELD;
+// 		return sizeof(*pRes);
+// 	}
+
+//     /* Verify if the Channel number & param selector is valid */
+//     if ((GetReq->ParamRevChannelNo & 0x7f) != pBMCInfo->SERIALch)
+//     {
+//         *pRes = CC_INV_DATA_FIELD;
+//         return sizeof (*pRes);
+//     }
+//     if (GetReq->ParamSel >= sizeof (SMConfigTable) / sizeof (SMConfigTable [0]))
+//     {
+//         *pRes = CC_PARAM_NOT_SUPPORTED;
+//         return sizeof (*pRes);
+//     }
+
+
+//     SMEntry = &(SMConfigTable [GetReq->ParamSel]);
+
+//     /* Verify length */
+//     if (ReqLen != sizeof (GetSerialModemConfigReq_T))
+//     {
+//         *pRes = CC_REQ_INV_LEN;
+//         return (*pRes);
+//     }
+
+//     GetRes->CompCode = CC_NORMAL;
+//     GetRes->ParamRev = PARAM_REVISION;
+
+//     /* Check if only parameter revision is required */
+//     if (0 != (GetReq->ParamRevChannelNo & GET_PARAM_REV_ONLY))
+//     {
+//         return sizeof (GetSerialModemConfigRes_T);
+//     }
+
+//     /* Get the param selector & Block Selector */
+//     if (0 != (SMEntry->MaxSetSelector & BLOCK_SELECTOR_REQ))
+//     {
+//         IPMI_DBG_PRINT ("Param With Set & BLock Selector \n");
+//         *(pRes + 2)    = GetReq->SetSel;
+//         *(pRes + 3)    = GetReq->BlockSel;
+//         ResStartOffset = sizeof (GetSerialModemConfigRes_T) +
+//                          sizeof (GetReq->SetSel) + sizeof (GetReq->BlockSel);
+//     }
+//     else if (0 == (SMEntry->MaxSetSelector & 0x7F))
+//     {
+//         IPMI_DBG_PRINT ("Param With No Set Selector \n");
+//         ResStartOffset  = sizeof (GetSerialModemConfigRes_T);
+//     }
+//     else
+//     {
+//         IPMI_DBG_PRINT ("Param With Set Selector \n");
+//         *(pRes + 2)    = GetReq->SetSel;
+//         ResStartOffset = sizeof (GetSerialModemConfigRes_T) +
+//                          sizeof (GetReq->SetSel);
+//     }
+
+//     /* Verify the set selector & block selector */
+//     *pRes = CC_PARAM_OUT_OF_RANGE;
+
+//     if (GetReq->ParamSel == INIT_STR_PARAM)
+//     {
+//         if (0 != GetReq->SetSel)
+//         {
+//             return sizeof (*pRes);
+//         }
+//         GetReq->SetSel   = GetReq->BlockSel;
+//         GetReq->BlockSel = 0;
+//         *(pRes + 2)      = GetReq->SetSel;
+//         ResStartOffset   = sizeof (GetSerialModemConfigRes_T) +
+//                            sizeof (GetReq->SetSel);
+//     }
+
+
+//     if ((0 != (SMEntry->MaxSetSelector & 0x7f)) &&
+//         ((SMEntry->MaxSetSelector & 0x7f) < GetReq->SetSel))
+//     {
+//         return sizeof (*pRes);
+//     }
+
+//     if ((0 != SMEntry->MaxBlockSelector) &&
+//         ((SMEntry->MaxBlockSelector <= GetReq->BlockSel) ||
+//          (0 == GetReq->BlockSel)))
+//     {
+//         return sizeof (*pRes);
+//     }
+
+//     if ((0 == (SMEntry->MaxSetSelector & 0x7f)) &&
+//         (0 != GetReq->SetSel))
+//     {
+//         return sizeof (*pRes);
+//     }
+
+//     if ((0 == SMEntry->MaxBlockSelector) &&
+//         (0 != GetReq->BlockSel))
+//     {
+//         return sizeof (*pRes);
+//     }
+
+//     if ((0 == GetReq->SetSel) && (GetReq->ParamSel == INIT_STR_PARAM))
+//     {
+//         return sizeof (*pRes);
+//     }
+
+//     /* Load Response */
+//     GetRes->CompCode = CC_NORMAL;
+
+//     /* Process Set In Progress parameter */
+//     if (GetReq->ParamSel == SET_IN_PROGRESS_PARAM)
+//     {
+//         LOCK_BMC_SHARED_MEM(BMCInst);
+//         m_Serial_SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_Serial_SetInProgress;
+//         UNLOCK_BMC_SHARED_MEM(BMCInst);
+//         *(pRes + 2) = m_Serial_SetInProgress;
+//         return (sizeof (GetSerialModemConfigRes_T) + sizeof (m_Serial_SetInProgress));
+//     }
+
+//     /* Check Write only access */
+//     if (0 != (SMEntry->ParamFlags & PARAM_WRITE_ONLY))
+//     {
+//         *pRes = CC_WRITE_ONLY_PARAM;
+//         return sizeof (*pRes);
+//     }
+
+//     /* Get the address where we want to set */
+//     SetStart = getSMConfigAddr (SMEntry, GetReq->SetSel, GetReq->BlockSel, BMCInst);
+
+//     LOCK_BMC_SHARED_MEM(BMCInst);
+//     _fmemcpy ( (pRes + ResStartOffset), SetStart,  (SMEntry->Size & 0x7f));
+//     UNLOCK_BMC_SHARED_MEM(BMCInst);
+
+//     return ( (SMEntry->Size & 0x7f) + ResStartOffset);
+// }
+
+
+// /*---------------------------------------
+//  * getSMConfigAddr
+//  *--------------------------------------*/
+// static _FAR_ INT8U*
+// getSMConfigAddr (_FAR_ const SMConfigTable_T* SMEntry,
+//                                 INT8U            SetSelector,
+//                                 INT8U            BlockSelector,
+//                                 int			  BMCInst)
+// {
+//     _FAR_ INT8U*        SetStart;
+//     INT8U         Size;
+//     INT8U         MaxBlockSel;
+//     BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+
+//     /* Get the NVRAM PM config address */
+//     SetStart = (_FAR_ INT8U*) &pBMCInfo->SMConfig;
+//     Size     = SMEntry->Size & 0x7f;
+
+//     if (0 == SMEntry->MaxBlockSelector)
+//     {
+//         MaxBlockSel = 1;
+//     }
+//     else
+//     {
+//         MaxBlockSel = SMEntry->MaxBlockSelector;
+//     }
+
+//     if (0 != (SMEntry->ParamFlags & PARAM_VOLATILE_NON_VOLATILE))
+//     {
+//         if (0 == SetSelector)
+//         {
+//             /*Get Shared Memory Info */
+//             SetStart = (_FAR_ INT8U*)&BMC_GET_SHARED_MEM (BMCInst)->SMConfig;
+//             SetStart = SetStart + SMEntry->Offset +
+//                        (Size * ((SetSelector * MaxBlockSel) + BlockSelector));
+//             return SetStart;
+//         }
+//         else
+//         {
+//             SetSelector--;
+//             if (0 != BlockSelector)
+//             {
+//                 BlockSelector--;
+//             }
+//         }
+//     }
+
+//     SetStart = SetStart + SMEntry->Offset +
+//                (Size * ((SetSelector * MaxBlockSel) + BlockSelector));
+
+//     return SetStart;
+// }
+
+
+// /*---------------------------------------
+//  * CallBack
+//  *---------------------------------------*/
+// int
+// CallBack (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
+// {
+//     _NEAR_  CallbackReq_T*  CallBackReq = (_NEAR_ CallbackReq_T*) pReq;
+//     _FAR_   SMConfig_T*     pVSMConfig  =
+//                  &(((_FAR_ BMCSharedMem_T*) BMC_GET_SHARED_MEM (BMCInst))->SMConfig);
+//     _FAR_   ChannelInfo_T*  pChannelInfo;
+//     _FAR_   DestInfo_T*     pDestInfo;
+//     INT8U           DestType,*curchannel;
+//     MsgPkt_T        MsgPkt;
+//     _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];			
+//     _FAR_   SMConfig_T*     pNVSMConfig = &pBMCInfo->SMConfig;
+//     INT32U *CurSesID;
+
+// 	if(CallBackReq->ChannelNum & RESERVED_BITS_CALLBACK_CH)
+// 	{
+// 		*pRes = CC_INV_DATA_FIELD;
+// 		return sizeof(*pRes);
+// 	}
+
+// 	if(CallBackReq->DestSel & RESERVED_BITS_CALLBACK_DESTSEL)
+// 	{
+// 		*pRes = CC_INV_DATA_FIELD;
+// 		return sizeof(*pRes);
+// 	}
+
+//     OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
+//     /* Check if Session Already exist */
+//     if ((pBMCInfo->SERIALch!= (*curchannel  & 0xF)) &&
+//         (TRUE == BMC_GET_SHARED_MEM (BMCInst)->SerialSessionActive))
+//     {
+//         *pRes = CC_CALLBACK_REJ_SESSION_ACTIVE;
+//         return sizeof (*pRes);
+//     }
+
+//     CallBackReq->DestSel &= 0x0f;
+
+//     /* Check the validity of Destination Selector */
+//     if (CallBackReq->DestSel > pNVSMConfig->TotalAlertDest)
+//     {
+//         *pRes = CC_DEST_UNAVAILABLE;
+//         return sizeof (*pRes);
+//     }
+
+//     if (0 == CallBackReq->DestSel)
+//     {
+//         /* Destination Info is volatile */
+//         pDestInfo = (_FAR_ DestInfo_T*) &pVSMConfig->DestinationInfo [0];
+//     }
+//     else
+//     {
+//         /* Destination Info is non-volatile */
+//         pDestInfo = (_FAR_ DestInfo_T*) &pNVSMConfig->DestinationInfo [CallBackReq->DestSel - 1];
+//     }
+
+//     /*Check if Destination if Configured & Enabled for CALLBACK */
+//     *pRes     = CC_INV_DATA_FIELD;
+//     DestType  = pDestInfo->DesType & MODEM_CFG_DEST_INFO_DEST_TYPE_MASK;
+
+
+//     if ((BASIC_MODE_CALLBACK != DestType) && (PPP_MODE_CALLBACK != DestType))
+//     {
+//         return sizeof (*pRes);
+//     }
+
+//     if (0 == (pNVSMConfig->ChannelCallBackCtrl.CallBackEnable & IPMI_CALLBACK_MASK))
+//     {
+//         return sizeof (*pRes);
+//     }
+
+//     OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
+//     /* If Current Channel is Session Based, Check is User is allowed for CallBack */
+//     pChannelInfo = getChannelInfo (*curchannel  & 0xF, BMCInst);
+//     if(NULL == pChannelInfo)
+//     {
+//         OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//         *pRes = CC_INV_DATA_FIELD;
+//         return	sizeof (*pRes);
+//     }
+
+//     /* Disable Ping during CallBack */
+//     pNVSMConfig->MUXSwitchCtrl.Data2  &=  ~DIRECT_PING_ENABLE_MASK;
+
+
+//     if (pChannelInfo->SessionSupport != SESSIONLESS_CHANNEL)
+//     {
+//         _FAR_ SessionInfo_T*     pSessionInfo;
+//         _FAR_ SessionTblInfo_T*  pSessionTblInfo =
+//                          &pBMCInfo->SessionTblInfo;
+//         _FAR_ ChannelUserInfo_T* pChUserInfo;
+//         INT8U              Index;
+
+//         IPMI_DBG_PRINT_1 ("Session Less ch  - %d\n",*curchannel  & 0xF);
+
+//         OS_THREAD_TLS_GET(g_tls.CurSessionID,CurSesID);
+//         OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SessionTblMutex,WAIT_INFINITE);
+//         pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID, BMCInst);
+//         if(pSessionInfo == NULL)
+//         {
+//             OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//             return sizeof (*pRes);
+//         }
+//         pChUserInfo = getChUserIdInfo (pSessionInfo->UserId,&Index,
+//                                        pChannelInfo->ChannelUserInfo, BMCInst);
+//         if(pChUserInfo == NULL)
+//         {
+//             OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//             return sizeof (*pRes);
+//         }
+
+//         if (0 == (pChUserInfo->UserCallbackCapabilities & 0x01))
+//         {
+//             OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//             return sizeof (*pRes);
+//         }
+
+//         /* For Serial Channel Existing Session should be deleted */
+//         if ((pBMCInfo->SERIALch!= (*curchannel  & 0xF)) &&
+//             (TRUE == BMC_GET_SHARED_MEM (BMCInst)->SerialSessionActive))
+//         {
+//             for (Index=0; Index < pBMCInfo->IpmiConfig.MaxSession; Index++)
+//             {
+//                 if (pBMCInfo->SERIALch == pSessionTblInfo->SessionTbl [Index].Channel)
+//                 {
+//                     pSessionTblInfo->SessionTbl [Index].TimeOutValue = 0;
+//                 }
+//             }
+//         }
+//     }
+
+//     OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//     /* Request to Initiate CallBack */
+//     MsgPkt.Channel  = pBMCInfo->SERIALch;
+//     MsgPkt.Param    = SERIAL_INIT_CALLBACK_REQUEST;
+//     MsgPkt.Size     = sizeof (CallBackReq->DestSel);
+//     MsgPkt.Data [0] = CallBackReq->DestSel;
+
+//     IPMI_DBG_PRINT ("Posting CallBack Request\n");
+//     if( 0 != PostMsg (&MsgPkt,SERIAL_IFC_Q,BMCInst ))
+//     {
+//            IPMI_WARNING ("SerialModem.c: Unable to post messages to hSerialIfc_Q\n");
+//     }    
+
+//     *pRes = CC_NORMAL;
+
+//     return sizeof (*pRes);
+// }
+
+
+// /*---------------------------------------
+//  * SetUserCallBackOptions
+//  *---------------------------------------*/
+// int
+// SetUserCallBackOptions (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
+// {
+//     _NEAR_ SetUserCallbackReq_T *Req = (_NEAR_ SetUserCallbackReq_T*) pReq;
+//     _FAR_  ChannelUserInfo_T    *pChUserInfo;
+//     BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+
+// 	if(Req->UserID & RESERVED_BITS_SETUSERCALLBACKOPT_USRID)
+// 	{
+// 		*pRes = CC_INV_DATA_FIELD;
+// 		return sizeof(*pRes);
+// 	}
+	
+// 	if(Req->ChannelNum & RESERVED_BITS_SETUSERCALLBACKOPT_CH)
+// 	{
+// 		*pRes = CC_INV_DATA_FIELD;
+// 		return sizeof(*pRes);
+// 	}
+
+// 	if(Req->UserCallbackCapabilities & RESERVED_BITS_SETUSERCALLBACKOPT_USRCALLBAKCAP)
+// 	{
+// 		*pRes = CC_INV_DATA_FIELD;
+// 		return sizeof(*pRes);
+// 	}
+	
+// 	if(Req->CBCPNegOptions & RESERVED_BITS_SETUSERCALLBACKOPT_CBCNEGOPT)
+// 	{
+// 		*pRes = CC_INV_DATA_FIELD;
+// 		return sizeof(*pRes);
+// 	}
+
+//     OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
+//     pChUserInfo = GetCBChUserInfo (Req->UserID, Req->ChannelNum, BMCInst);
+
+//     *pRes = CC_INV_DATA_FIELD;
+
+//     /*Check if the user info exits */
+//     if (NULL == pChUserInfo)
+//     {
+//         OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//         return sizeof (*pRes);
+//     }
+
+//     /*Set CallBack Options */
+//     pChUserInfo->UserAccessCallback       = (Req->UserCallbackCapabilities &
+//                                              IPMI_CALLBACK_MASK);
+//     pChUserInfo->UserAccessCBCPCallback   = (Req->UserCallbackCapabilities &
+//                                              CBCP_CALLBACK_MASK);
+//     pChUserInfo->UserCallbackCapabilities = Req->UserCallbackCapabilities;
+//     pChUserInfo->CBCPNegOptions           = Req->CBCPNegOptions;
+//     pChUserInfo->CallBack1                = Req->CallBack1;
+//     pChUserInfo->CallBack2                = Req->CallBack2;
+//     pChUserInfo->CallBack3                = Req->CallBack3;
+//     OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+
+//     *pRes = CC_NORMAL;
+//     return sizeof (*pRes);
+// }
+
+
+// /*---------------------------------------
+//  * SetUserCallBackOptions
+//  *---------------------------------------*/
+// int
+// GetUserCallBackOptions (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
+// {
+//     _NEAR_   GetUserCallbackReq_T* Req = ( _NEAR_ GetUserCallbackReq_T*) pReq;
+//     _NEAR_   GetUserCallbackRes_T* Res = ( _NEAR_ GetUserCallbackRes_T*) pRes;
+//     _FAR_    ChannelUserInfo_T*    pChUserInfo;
+//     BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
+
+// 	if(Req->UserID & RESERVED_BITS_GETUSERCALLBACKOPTIONS_USRID)
+// 	{
+// 		*pRes = CC_INV_DATA_FIELD;
+// 		return sizeof(*pRes);
+// 	}
+
+//     OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
+//     pChUserInfo  = GetCBChUserInfo (Req->UserID , Req->ChannelNum, BMCInst);
+
+//     *pRes = CC_INV_DATA_FIELD;
+
+//     /*Check if the user info exits */
+//     if (NULL == pChUserInfo  )
+//     {
+//         OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+//         return sizeof (*pRes);
+//     }
+
+//     /*Set CallBack Options */
+//     Res->CompletionCode           = CC_NORMAL;
+//     Res->UserCallbackCapabilities = pChUserInfo->UserCallbackCapabilities ;
+//     Res->CBCPNegOptions           = pChUserInfo->CBCPNegOptions;
+//     Res->CallBack1                = pChUserInfo->CallBack1;
+//     Res->CallBack2                = pChUserInfo->CallBack2;
+//     Res->CallBack3                = pChUserInfo->CallBack3;
+//     OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
+
+//     return sizeof (GetUserCallbackRes_T);
+// }
+
+
+// /*---------------------------------------
+//  * GetCBChUserInfo
+//  *---------------------------------------*/
+// static _FAR_ ChannelUserInfo_T*
+// GetCBChUserInfo (INT8U UserID, INT8U Channel )
+// {
+//     _FAR_   ChannelInfo_T* pChannelInfo;
+//     INT8U          Index;
+
+//     /*Get Channel Info */
+//     pChannelInfo = getChannelInfo (Channel, BMCInst);
+//     if (NULL == pChannelInfo )
+//     {
+//         return NULL;
+//     }
+
+//     /*Get the particular user entitled for callback */
+//     return getChUserIdInfo (UserID,&Index,pChannelInfo->ChannelUserInfo, BMCInst);
+// }
+
+
+// /*---------------------------------------
+//  * SetSerialModemMUX
+//  *---------------------------------------*/
+// int
+// SetSerialModemMUX (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
+// {
+//     _NEAR_ SetMuxReq_T* Req         = (_NEAR_   SetMuxReq_T*) pReq;
+//     _NEAR_ SetMuxRes_T* Res         = (_NEAR_   SetMuxRes_T*) pRes;
+//      INT8U        TSettings;
+//     ChannelInfo_T* pChannelInfo;
+//     _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//     _FAR_  SMConfig_T*  pNVSMConfig = &(pBMCInfo->SMConfig);
+
+//     Res->CompCode = CC_INV_DATA_FIELD;
+
+// 	if(Req->ChannelNo & RESERVED_BITS_SETSERIALMODEMMUX_CH) return sizeof(*pRes);
+// 	if(Req->MuxSettingReq & RESERVED_BITS_SETSERIALMODEMMUX_MUXSETREQ) return sizeof(*pRes);
+
+//     if (Req->ChannelNo != pBMCInfo->SERIALch)
+//     {
+//         return sizeof(*pRes);
+//     }
+
+//     TSettings = BMC_GET_SHARED_MEM (BMCInst)->SerialMuxSetting;
+//     /* No Session or Alert  In progress */
+//     TSettings = TSettings & MUX_SESSION_ALERT_INACTIVE_MASK;
+//     if (TRUE == BMC_GET_SHARED_MEM (BMCInst)->SerialSessionActive)
+//     {
+//         TSettings |= MUX_SESSION_ACTIVE_MASK;
+//     }
+
+//     /* Accept Request */
+//     TSettings = TSettings | MUX_REQ_ACCEPTED_MASK;
+
+//     Res->CompCode = CC_NORMAL;
+
+//     pChannelInfo = getChannelInfo(pBMCInfo->SERIALch, BMCInst);
+//     if(NULL == pChannelInfo)
+//     {
+//         Res->CompCode = CC_INV_DATA_FIELD;
+//         return	sizeof (*pRes);
+//     }
+
+//     /*Check if Serial Port Sharing Enabled */
+//     if ((0 == (pNVSMConfig->MUXSwitchCtrl.Data2 & SERIAL_PORT_SHARING_ENABLED)) ||
+//         (CHANNEL_ALWAYS_AVAILABLE == pChannelInfo->AccessMode))
+//     {
+
+//         if(Req->MuxSettingReq==0x0)
+//         {
+//             Res->MuxSetting = TSettings& MUX_REQ_REJECTED_MASK;
+//             return sizeof (SetMuxRes_T);
+//         }
+//         else
+//         {
+//             Res->CompCode = CC_COULD_NOT_PROVIDE_RESP;
+//             return sizeof(*pRes);
+//         }
+//     }
+
+//     switch (Req->MuxSettingReq)
+//     {
+//         case REQ_CUR_MUX_SETTING:
+//             break;
+
+//         case REQ_MUX_TO_SYS:
+
+//             if (0 == (REQ_MUX_TO_SYS_MASK & TSettings))
+//             {
+//                 IPMI_DBG_PRINT ("SYS HOLDS EMP\n");
+//                 if(g_PDKHandle[PDK_SWITCHEMPMUX] != NULL)
+//                 {
+//                     ((void(*)(INT8U,int))g_PDKHandle[PDK_SWITCHEMPMUX]) (MUX_2_SYS,BMCInst);
+//                 }
+//                 TSettings = (TSettings & SET_MUX_TO_SYS_MASK);
+//             }
+//             else
+//             {
+//                 TSettings &= MUX_REQ_REJECTED_MASK;
+//             }
+//             break;
+
+//         case REQ_MUX_TO_BMC:
+
+//             if (0 == (REQ_MUX_TO_BMC_MASK & TSettings))
+//             {
+//                 IPMI_DBG_PRINT ("BMC HOLDS EMP\n");
+//                 if(g_PDKHandle[PDK_SWITCHEMPMUX] != NULL)
+//                 {
+//                     ((void(*)(INT8U,int))g_PDKHandle[PDK_SWITCHEMPMUX]) (MUX_2_BMC,BMCInst);
+//                 }
+//                 TSettings = (TSettings | SET_MUX_TO_BMC_MASK);
+//             }
+//             else
+//             {
+//                 TSettings &= MUX_REQ_REJECTED_MASK;
+//             }
+//             break;
+
+//         case REQ_MUX_FORCE_TO_SYS:
+
+//             IPMI_DBG_PRINT ("SYS HOLDS EMP\n");
+//             if(g_PDKHandle[PDK_SWITCHEMPMUX] != NULL)
+//             {
+//                 ((void(*)(INT8U,int))g_PDKHandle[PDK_SWITCHEMPMUX]) (MUX_2_SYS,BMCInst);
+//             }
+//             TSettings = (TSettings & SET_MUX_TO_SYS_MASK);
+//             break;
+
+//         case REQ_MUX_FORCE_TO_BMC:
+
+//             IPMI_DBG_PRINT ("BMC HOLDS EMP\n");
+//             if(g_PDKHandle[PDK_SWITCHEMPMUX] != NULL)
+//             {
+//                 ((void(*)(INT8U,int))g_PDKHandle[PDK_SWITCHEMPMUX]) (MUX_2_BMC,BMCInst);
+//             }
+//             TSettings = (TSettings | SET_MUX_TO_BMC_MASK);
+//             break;
+
+//         case REQ_BLOCK_MUX_TO_SYS:
+
+//             TSettings = (TSettings | BLOCK_MUX_TO_SYS_MASK);
+//             break;
+
+//         case REQ_ALLOW_MUX_TO_SYS:
+
+//             TSettings = (TSettings & ALLOW_MUX_TO_SYS_MASK);
+//             break;
+
+//         case REQ_BLOCK_MUX_TO_BMC:
+
+//             TSettings = (TSettings | BLOCK_MUX_TO_BMC_MASK);
+//             break;
+
+//         case REQ_ALLOW_MUX_TO_BMC:
+
+//             TSettings = (TSettings & ALLOW_MUX_TO_BMC_MASK);
+//             break;
+
+//         default:
+
+//         return sizeof (*pRes);
+//     }
+
+//     Res->MuxSetting = TSettings;
+//     BMC_GET_SHARED_MEM (BMCInst)->SerialMuxSetting = TSettings;
+//     IPMI_DBG_PRINT_1 ("SerialMUXSetting = %X\n",TSettings);
+
+//     return sizeof (SetMuxRes_T);
+// }
+
+
+// /*---------------------------------------
+//  * SerialModemConnectActive
+//  *---------------------------------------*/
+// int
+// SerialModemConnectActive (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
+// {
+//     _NEAR_ SerialModemActivePingReq_T* Req = (_NEAR_ SerialModemActivePingReq_T*) pReq;
+
+//     if(Req->SessionState & RESERVED_BITS_SERIALMODEMCONNECTACTIVE)
+//     {
+//     	*pRes = CC_INV_DATA_FIELD;
+//     	return sizeof(*pRes);
+//     }
+
+//     *pRes = CC_NORMAL;
+
+//     if ((Req->SessionState != 0)    && /* No Session State      */
+//         (Req->SessionState != 1)    && /* Session State Active  */
+//         (Req->SessionState != 2)    && /* MUX Switch to SYS     */
+//         (Req->IPMIVersion  != 0x51))   /* IPMIVersion 1.5       */
+//     {
+//         *pRes = CC_INV_DATA_FIELD;
+//     }
+
+//     return sizeof (*pRes);
+// }
+
+
+// /*---------------------------------------
+//  * SerialModemPingTask
+//  *---------------------------------------*/
+// void
+// SerialModemPingTask ( int BMCInst )
+// {
+//       MsgPkt_T     MsgPkt;
+//     _FAR_ static INT8U MuxSwitchToSys;
+//     _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+//     _FAR_ SMConfig_T*  pNVSMConfig = &pBMCInfo->SMConfig;
+
+//     /* Check if Serial Port Sharing Enabled & Mux is switched to BMC */
+//     if (0 == (pNVSMConfig->MUXSwitchCtrl.Data2 & SERIAL_PORT_SHARING_ENABLED))
+//     {
+//         return;
+//     }
+
+//     /* Check if Serial Ping Message Enabled */
+//     if (0 == (pNVSMConfig->MUXSwitchCtrl.Data2 & DIRECT_PING_ENABLE_MASK))
+//     {
+//         return;
+//     }
+
+//     /* Update Session State */
+//     if (0 == (BMC_GET_SHARED_MEM (BMCInst)->SerialMuxSetting & SET_MUX_TO_BMC_MASK))
+//     {
+//         /* Ping should be generated Only once before Mux switch to System */
+//         if (1 == MuxSwitchToSys )
+//         {
+//             return;
+//         }
+
+//         MsgPkt.Data [0] = MUX_SWITCHED_TO_SYS;
+//         MuxSwitchToSys  = 1;
+//     }
+//     else
+//     {
+//         /* Check for periodical ping message active flag */
+//         if (0 == (pNVSMConfig->MUXSwitchCtrl.Data2 & PING_MSG_ACTIVE_BIT))
+//         {
+//             return;
+//         }
+
+//         MsgPkt.Data [0] = SESSION_STATE_INACTIVE;
+//         MuxSwitchToSys  = 0;
+
+//         if (TRUE == BMC_GET_SHARED_MEM (BMCInst)->SerialSessionActive)
+//         {
+//             MsgPkt.Data [0] = SESSION_STATE_ACTIVE;
+//         }
+//     }
+
+//     /* Request to give Ping Message */
+//     MsgPkt.Channel  = pBMCInfo->SERIALch;
+//     MsgPkt.Param    = SERIAL_PING_REQUEST;
+//     MsgPkt.Size     = 1;
+
+
+//     /* Post Ping Request */
+//     if( 0 != PostMsg (&MsgPkt,SERIAL_IFC_Q ,BMCInst))
+//     {
+//            IPMI_WARNING ("SerialModem.c: Unable to post messages to hSerialIfc_Q\n");
+//     }    
+    
+// }
+
+
+// /*---------------------------------------
+//  * GetTAPResponseCodes
+//  *---------------------------------------*/
+// int
+// GetTAPResponseCodes (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
+// {
+//     _NEAR_ GetTAPResCodeReq_T* Req      = (_NEAR_ GetTAPResCodeReq_T*) pReq;
+//     _NEAR_ GetTAPResCodeRes_T* Res      = (_NEAR_ GetTAPResCodeRes_T*) pRes;
+//     _FAR_  TAPResCode_T*       TAPCodes = &(((_FAR_ BMCSharedMem_T*) BMC_GET_SHARED_MEM (BMCInst))->TAPRes);
+//     _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+
+//     IPMI_DBG_PRINT ("Get TAP Respone Code CMD\n");
+
+//     if(Req->ChannelNo & RESERVED_BITS_GETTAPRESPONSECODES_CH)
+//     {
+//     	*pRes = CC_INV_DATA_FIELD;
+//     	return sizeof(*pRes);
+//     }
+
+//     /* Check Channel No */
+//     if (Req->ChannelNo != pBMCInfo->SERIALch)
+//     {
+//         Res->CompCode = CC_INV_DATA_FIELD;
+//         return sizeof (*pRes);
+//     }
+
+//     /*Load Response Codes*/
+//     Res->CompCode = CC_NORMAL;
+//     LOCK_BMC_SHARED_MEM(BMCInst);
+//     _fmemcpy (&pRes [1],TAPCodes,sizeof (TAPResCode_T));
+//     UNLOCK_BMC_SHARED_MEM(BMCInst);
+
+//     return sizeof (GetTAPResCodeRes_T);
+// }
+
+
+// /**
+//  * SetSerialPort
+//  * @brief Initilize the Serial port
+//  **/
+
+// int
+// SetSerialPort (int BMCInst)
+// {
+//     INT8U   BaudRate;
+//     //INT8U   FlowCtrl;
+//     //int     status;
+//     int		fd;
+//     struct  termios tty_struct;
+//     _FAR_  BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
+
+//     if ((fd = open(pBMCInfo->IpmiConfig.pSerialPort, O_RDONLY)) < 0)
+//     {
+//         IPMI_WARNING ("Can't open serial port..%s\n",strerror(errno));
+//         return -1;
+//     }
+
+//     /* Get the default Baudrate & FlowControl from Serial Modem configureation */
+//     BaudRate = pBMCInfo->SMConfig.IpmiMsgCommSet.BitRate;
+//     //FlowCtrl = pBMCInfo->SMConfig.IpmiMsgCommSet.FlowCtrl;
+
+//     tcgetattr(fd,&tty_struct);   			   /* get termios structure */
+
+//     switch (BaudRate) 
+//     {
+//         case BAUD_RATE_9600:
+//             cfsetospeed(&tty_struct, B9600);
+//             cfsetispeed(&tty_struct, B9600);
+//             break;
+//         case BAUD_RATE_19200:
+//             cfsetospeed(&tty_struct, B19200);
+//             cfsetispeed(&tty_struct, B19200);
+//             break;
+//         case BAUD_RATE_38400:
+//             cfsetospeed(&tty_struct, B38400);
+//             cfsetispeed(&tty_struct, B38400);
+//             break;
+//         case BAUD_RATE_57600:
+//             cfsetospeed(&tty_struct, B57600);
+//             cfsetispeed(&tty_struct, B57600);
+//             break;
+//         case BAUD_RATE_115200:
+//             cfsetospeed(&tty_struct, B115200);
+//             cfsetispeed(&tty_struct, B115200);
+//             break;
+//         default:
+//             IPMI_ERROR ("SerialIfc.c : Invalid baud rate\n");
+//     }
+
+//     tty_struct.c_cflag |= CS8;              /* Set 8bits/charecter          */
+//     tty_struct.c_cflag &= ~CSTOPB;          /* set framing to 1 stop bits   */
+//     tty_struct.c_cflag &= ~(PARENB);        /* set parity to NONE           */
+//     tty_struct.c_iflag &= ~(INPCK);
+
+//     /* set the new attributes in the tty driver */
+//     tcsetattr(fd, TCSANOW, &tty_struct);
+
+//     close (fd);
+
+//     return 0;
+// }
+
+

+ 901 - 631
app/bmc_server/libipmimsghndler/cmdselect.c → app/bmc/msghndlr/cmdselect.c

@@ -1,631 +1,901 @@
-/******************************************************************
- ******************************************************************
- ***                                                                                                           **
- ***    (C)Copyright 2011, American Megatrends Inc.                                     **
- ***                                                                                                           **
- ***    All Rights Reserved.                                                                          **
- ***                                                                                                           **
- ***    5555 , Oakbrook Pkwy, Norcross,                                                       **
- ***                                                                                                           **
- ***    Georgia - 30093, USA. Phone-(770)-246-8600.                                  **
- ***                                                                                                           **
- ******************************************************************
- ******************************************************************
- ******************************************************************
- *
- * cmdselect.c
- * OEM can enable or disable IPMI Command accoring to requirements
- *
- *  Author: Winston <winstonv@amiindia.co.in>
- ******************************************************************/
-
-#include "Types.h"
-//#include "Debug.h"
-#include "IPMI_App.h"
-#include "IPMI_Chassis.h"
-#include "IPMI_Bridge.h"
-#include "IPMI_SensorEvent.h"
-#include "IPMI_Storage.h"
-#include "IPMI_DeviceConfig.h"
-#include "IPMI_AMI.h"
-#include "IPMIDefs.h"
-//#include "IPMI_OPMA.h"
-//#include "Apml.h"
-//#include "Pnm.h"
-//#include "IPMI_GroupExtn.h"
-#include "cmdselect.h"
-//#include "IPMIConf.h"
-#include "IPMI_Oem.h"
-#include "bmc_main.h"
-
-
-const NetFnCmds_T g_App [] = 
-{
-	/* IPM Device Commands */
-	{CMD_GET_DEV_ID                                                 , ENABLED},
-	{CMD_BROADCAST_GET_DEV_ID                             ,DISABLED},
-	{CMD_COLD_RESET                                                 ,ENABLED},
-	{CMD_WARM_RESET                                                ,ENABLED},
-	{CMD_GET_SELF_TEST_RESULTS                              ,ENABLED},
-	{CMD_MFG_TEST_ON                                               ,ENABLED},
-	{CMD_SET_ACPI_PWR_STATE                                  ,ENABLED},
-	{CMD_GET_ACPI_PWR_STATE                                 ,ENABLED},
-	{CMD_GET_DEV_GUID                                            ,ENABLED},
-	{CMD_GET_NETFN_SUP                                           ,ENABLED},
-	{CMD_GET_CMD_SUP                                             ,ENABLED},
-	{CMD_GET_SUBFN_SUP                                          ,DISABLED},
-	{CMD_GET_CONFIG_CMDS                                     ,ENABLED},
-	{CMD_GET_CONFIG_SUB_FNS                                ,DISABLED},
-	{CMD_SET_CMD_ENABLES                                     ,ENABLED},
-	{CMD_GET_CMD_ENABLES                                     ,ENABLED},
-	{CMD_SET_SUBFN_ENABLES                                  ,DISABLED},
-	{CMD_GET_SUBFN_ENABLES                                  ,DISABLED},
-	{CMD_GET_OEM_NETFN_IANA_SUPPORT                 ,ENABLED},
-	/*    WatchDog Timer Commands  */
-	{CMD_RESET_WDT                                               ,ENABLED},
-	{CMD_SET_WDT                                                   ,ENABLED},
-	{CMD_GET_WDT                                                   ,ENABLED},
-
-	/*    BMC Device and Messaging Commands   */
-	{ CMD_SET_BMC_GBL_ENABLES                           ,ENABLED},
-	{ CMD_GET_BMC_GBL_ENABLES                           ,ENABLED},
-	{ CMD_CLR_MSG_FLAGS                                      ,ENABLED},
-	{ CMD_GET_MSG_FLAGS                                      ,ENABLED},
-	{ CMD_ENBL_MSG_CH_RCV                                  ,ENABLED},
-	{ CMD_GET_MSG                                                 ,ENABLED},
-	{ CMD_SEND_MSG                                               ,ENABLED},
-	{ CMD_READ_EVT_MSG_BUFFER                           ,ENABLED},
-	{ CMD_GET_BTIFC_CAP                                       ,ENABLED},
-	{ CMD_GET_SYSTEM_GUID                                  ,ENABLED},
-	{ CMD_GET_CH_AUTH_CAP                                  ,ENABLED},
-	{ CMD_GET_SESSION_CHALLENGE                       ,ENABLED},
-	{ CMD_ACTIVATE_SESSION                                 ,ENABLED},
-	{ CMD_SET_SESSION_PRIV_LEVEL                       ,ENABLED},
-	{ CMD_CLOSE_SESSION                                      ,ENABLED},
-	{ CMD_GET_SESSION_INFO                                 ,ENABLED},
-	{ CMD_GET_AUTH_CODE                                     ,ENABLED},
-	{ CMD_SET_CH_ACCESS                                     ,ENABLED},
-	{ CMD_GET_CH_ACCESS                                     ,ENABLED},
-	{ CMD_GET_CH_INFO                                          ,ENABLED},
-	{ CMD_SET_USER_ACCESS                                 ,ENABLED},
-	{ CMD_GET_USER_ACCESS                                 ,ENABLED},
-	{ CMD_SET_USER_NAME                                     ,ENABLED},
-	{ CMD_GET_USER_NAME                                     ,ENABLED},
-	{ CMD_SET_USER_PASSWORD                            ,ENABLED},
-	{ CMD_MASTER_WRITE_READ                             ,ENABLED},
-	{ CMD_SET_SYSTEM_INFO_PARAM                      ,ENABLED},
-	{ CMD_GET_SYSTEM_INFO_PARAM                      ,ENABLED},
-
-	/*------------------------ IPMI 2.0 specific Commands ------------------*/
-//	{ CMD_ACTIVATE_PAYLOAD                               ,ENABLED},
-//	{ CMD_DEACTIVATE_PAYLOAD                           ,ENABLED},
-//	{ CMD_GET_PAYLD_ACT_STATUS                       ,ENABLED},
-//	{ CMD_GET_PAYLD_INST_INFO                          ,ENABLED},
-//	{ CMD_SET_USR_PAYLOAD_ACCESS                  ,ENABLED},
-//	{ CMD_GET_USR_PAYLOAD_ACCESS                  ,ENABLED},
-//	{ CMD_GET_CH_PAYLOAD_SUPPORT                  ,ENABLED},
-//	{ CMD_GET_CH_PAYLOAD_VER                          ,ENABLED},
-//	{ CMD_GET_CH_OEM_PAYLOAD_INFO                 ,ENABLED},
-//	{ CMD_GET_CH_CIPHER_SUITES                        ,ENABLED},
-//	{ CMD_SUS_RES_PAYLOAD_ENCRYPT                 ,ENABLED},
-//	{ CMD_SET_CH_SECURITY_KEYS                       ,ENABLED},
-//	{ CMD_GET_SYS_IFC_CAPS                              ,ENABLED},
-	{0                                                                   ,0            },
-	
-};
-
-const NetFnCmds_T g_Chassis [] =
-{
-	/*--------------------- Chassis Commands ---------------------------------*/
-//	{ CMD_GET_CHASSIS_CAPABILITIES                          ,ENABLED},
-//	{ CMD_GET_CHASSIS_STATUS                                   ,ENABLED},
-//	{ CMD_CHASSIS_CONTROL                                        ,ENABLED},
-//	{ CMD_CHASSIS_RESET                                             ,DISABLED},
-//	{ CMD_CHASSIS_IDENTIFY                                        ,ENABLED},
-//	{ CMD_SET_CHASSIS_CAPABILITIES                          ,ENABLED},
-//	{ CMD_SET_POWER_RESTORE_POLICY                        ,ENABLED},
-//	{ CMD_GET_SYSTEM_RESTART_CAUSE                        ,ENABLED},
-//	{ CMD_SET_SYSTEM_BOOT_OPTIONS                          ,ENABLED},
-//	{ CMD_GET_SYSTEM_BOOT_OPTIONS                          ,ENABLED},
-//	{ CMD_GET_POH_COUNTER                                         ,ENABLED},
-//	{ CMD_SET_FP_BTN_ENABLES                                     ,ENABLED},
-//	{ CMD_SET_POWER_CYCLE_INTERVAL                         ,ENABLED},
-	{0,                                                                            0             }
-
-};
-
-const NetFnCmds_T g_Bridge [] = 
-{
-	/*----------------------- Bridge Management Commands --------------------------------*/
-	{ CMD_GET_BRIDGE_STATE                                        ,ENABLED},
-	{ CMD_SET_BRIDGE_STATE                                        ,ENABLED},
-	{ CMD_GET_ICMB_ADDR                                            ,ENABLED},
-	{ CMD_SET_ICMB_ADDR                                            ,ENABLED},
-	{ CMD_SET_BRIDGE_PROXY_ADDR                             ,ENABLED},
-	{ CMD_GET_BRIDGE_STATISTICS                               ,ENABLED},
-	{ CMD_GET_ICMB_CAPABILITIES                                ,ENABLED},
-	{ CMD_CLEAR_BRIDGE_STATISTICS                           ,ENABLED},
-	{ CMD_GET_BRIDGE_PROXY_ADDR                             ,ENABLED},
-	{ CMD_GET_ICMB_CONNECTOR_INFO                          ,ENABLED},
-	{ CMD_GET_ICMB_CONNECTION_ID                            ,DISABLED},
-	{ CMD_SEND_ICMB_CONNECTION_ID                          ,DISABLED},
-
-	/*---------------------- Bridge Discovery Commands -----------------------------------*/
-	{ CMD_PREPARE_FOR_DISCOVERY                              ,ENABLED},
-	{ CMD_GET_ADDRESSES                                            ,ENABLED},
-	{ CMD_SET_DISCOVERED                                           ,ENABLED},
-	{ CMD_GET_CHASSIS_DEVICE_ID                               ,ENABLED},
-	{ CMD_SET_CHASSIS_DEVICE_ID                               ,ENABLED},
-	
-	/*----------------------- Bridging Commands ------------------------------------------*/
-	{ CMD_BRIDGE_REQUEST                                           ,ENABLED},
-	{ CMD_BRIDGE_MESSAGE                                          ,ENABLED},
-	
-	/*---------------------- Bridge Event Commands ---------------------------------------*/
-	{ CMD_GET_EVENT_COUNT                                        ,ENABLED},
-	{ CMD_SET_EVENT_DESTINATION                              ,ENABLED},
-	{ CMD_SET_EVENT_RECEPTION_STATE                      ,ENABLED},
-	{ CMD_SEND_ICMB_EVENT_MESSAGE                        ,ENABLED},
-	{ CMD_GET_EVENT_DESTINATION                             ,ENABLED},
-	{ CMD_GET_EVENT_RECEPTION_STATE                      ,ENABLED},
-	{ 0                                                                           ,0           }
-
-};
-
-const NetFnCmds_T g_Sensor [] = 
-{
-
-	{ CMD_SET_EVENT_RECEIVER                                   ,ENABLED},
-	{ CMD_GET_EVENT_RECEIVER                                   ,ENABLED},
-	{ CMD_PLATFORM_EVENT                                          ,ENABLED},
-
-	{ CMD_GET_PEF_CAPABILITIES                                 ,ENABLED},
-	{ CMD_ARM_PEF_POSTPONE_TIMER                           ,ENABLED},
-	{ CMD_SET_PEF_CONFIG_PARAMS                             ,ENABLED},
-	{ CMD_GET_PEF_CONFIG_PARAMS                             ,ENABLED},
-	{ CMD_SET_LAST_PROCESSED_EVENT_ID                  ,ENABLED},
-	{ CMD_GET_LAST_PROCESSED_EVENT_ID                  ,ENABLED},
-	{ CMD_ALERT_IMMEDIATE                                         ,ENABLED},
-	{ CMD_PET_ACKNOWLEDGE                                      ,ENABLED},
-
-
-	{ CMD_GET_DEV_SDR_INFO                                     ,ENABLED},
-	{ CMD_GET_DEV_SDR                                              ,ENABLED},
-	{ CMD_RESERVE_DEV_SDR_REPOSITORY                  ,ENABLED},
-	{ CMD_GET_SENSOR_READING_FACTORS                 ,ENABLED},
-	{ CMD_SET_SENSOR_HYSTERISIS                             ,ENABLED},
-	{ CMD_GET_SENSOR_HYSTERISIS                             ,ENABLED},
-	{ CMD_SET_SENSOR_THRESHOLDS                           ,ENABLED},
-	{ CMD_GET_SENSOR_THRESHOLDS                           ,ENABLED},
-	{ CMD_SET_SENSOR_EVENT_ENABLE                         ,ENABLED},
-	{ CMD_GET_SENSOR_EVENT_ENABLE                         ,ENABLED},
-	{ CMD_REARM_SENSOR_EVENTS                               ,ENABLED},
-	{ CMD_GET_SENSOR_EVENT_STATUS                        ,ENABLED},
-	{ CMD_GET_SENSOR_READING                                 ,ENABLED},
-	{ CMD_SET_SENSOR_TYPE                                        ,ENABLED},
-	{ CMD_GET_SENSOR_TYPE                                        ,ENABLED},
-	{ CMD_SET_SENSOR_READING                                  ,ENABLED},
-	{0,                                                                           0             }
-};
-
-const NetFnCmds_T g_Storage [] = 
-{
-	/*--------------------- FRU Device Commands ---------------------------------*/
-	{ CMD_FRU_INVENTORY_AREA_INFO                           ,ENABLED},
-	{ CMD_READ_FRU_DATA                                            ,ENABLED},
-	{ CMD_WRITE_FRU_DATA                                           ,ENABLED},
-
-	/*--------------------- SDR Device Commands ---------------------------------*/
-	{ CMD_GET_SDR_REPOSITORY_INFO                           ,ENABLED},
-	{ CMD_GET_SDR_REPOSITORY_ALLOCATION_INFO       ,ENABLED},
-	{ CMD_RESERVE_SDR_REPOSITORY                             ,ENABLED},
-	{ CMD_GET_SDR                                                         ,ENABLED},
-	{ CMD_ADD_SDR                                                        ,ENABLED},
-	{ CMD_PARTIAL_ADD_SDR                                          ,ENABLED},
-	{ CMD_DELETE_SDR                                                    ,DISABLED},
-	{ CMD_CLEAR_SDR_REPOSITORY                                 ,ENABLED},
-	{ CMD_GET_SDR_REPOSITORY_TIME                            ,ENABLED},
-	{ CMD_SET_SDR_REPOSITORY_TIME                            ,DISABLED},
-	{ CMD_ENTER_SDR_REPOSITORY_UPDATE_MODE         ,DISABLED},
-	{ CMD_EXIT_SDR_REPOSITORY_UPDATE_MODE            ,DISABLED},
-	{ CMD_RUN_INITIALIZATION_AGENT                            ,ENABLED},
-
-	/*--------------------- SEL Device Commands ----------------------------------*/
-	{ CMD_GET_SEL_INFO                                                  ,ENABLED},
-	{ CMD_GET_SEL_ALLOCATION_INFO                              ,ENABLED},
-	{ CMD_RESERVE_SEL                                                    ,ENABLED},
-	{ CMD_GET_SEL_ENTRY                                                 ,ENABLED},
-	{ CMD_ADD_SEL_ENTRY                                                ,ENABLED},
-	{ CMD_PARTIAL_ADD_SEL_ENTRY                                  ,ENABLED},
-	{ CMD_DELETE_SEL_ENTRY                                            ,ENABLED},
-	{ CMD_CLEAR_SEL                                                        ,ENABLED},
-	{ CMD_GET_SEL_TIME                                                   ,ENABLED},
-	{ CMD_SET_SEL_TIME                                                   ,ENABLED},
-	{ CMD_GET_AUXILIARY_LOG_STATUS                            ,DISABLED},
-	{ CMD_SET_AUXILIARY_LOG_STATUS                            ,DISABLED},
-	{ CMD_GET_SEL_TIME_UTC_OFFSET                              ,ENABLED},
-	{ CMD_SET_SEL_TIME_UTC_OFFSET                              ,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 [] = 
-{
-	/* ---------------YAFU Commands -----------------------------*/
-//	{ CMD_AMI_YAFU_SWITCH_FLASH_DEVICE			    ,ENABLED},
-//	{ CMD_AMI_YAFU_RESTORE_FLASH_DEVICE			    ,ENABLED},
-//	{ CMD_AMI_YAFU_GET_FLASH_INFO                           ,ENABLED},
-//	{ CMD_AMI_YAFU_GET_FIRMWARE_INFO                    ,ENABLED},
-//	{ CMD_AMI_YAFU_GET_FMH_INFO                              ,ENABLED},
-//	{ CMD_AMI_YAFU_GET_STATUS                                 ,ENABLED},
-//	{ CMD_AMI_YAFU_ACTIVATE_FLASH                          ,ENABLED},
-//	{ CMD_AMI_YAFU_ALLOCATE_MEMORY                       ,ENABLED},
-//	{ CMD_AMI_YAFU_FREE_MEMORY                               ,ENABLED},
-//	{ CMD_AMI_YAFU_READ_FLASH                                 ,ENABLED},
-//	{ CMD_AMI_YAFU_WRITE_FLASH                                ,ENABLED},
-//	{ CMD_AMI_YAFU_ERASE_FLASH                                ,ENABLED},
-//	{ CMD_AMI_YAFU_PROTECT_FLASH                            ,ENABLED},
-//	{ CMD_AMI_YAFU_ERASE_COPY_FLASH                      ,ENABLED},
-//	{ CMD_AMI_YAFU_VERIFY_FLASH                               ,ENABLED},
-//	{ CMD_AMI_YAFU_READ_MEMORY                              ,ENABLED},
-//	{ CMD_AMI_YAFU_WRITE_MEMORY                             ,ENABLED},
-//	{ CMD_AMI_YAFU_COPY_MEMORY                              ,ENABLED},
-//	{ CMD_AMI_YAFU_COMPARE_MEMORY                        ,ENABLED},
-//	{ CMD_AMI_YAFU_CLEAR_MEMORY                            ,ENABLED},
-//	{ CMD_AMI_YAFU_GET_BOOT_CONFIG                       ,ENABLED},
-//	{ CMD_AMI_YAFU_SET_BOOT_CONFIG                       ,ENABLED},
-//	{ CMD_AMI_YAFU_GET_BOOT_VARS                          ,ENABLED},
-//	{ CMD_AMI_YAFU_DEACTIVATE_FLASH_MODE            ,ENABLED},
-//	{ CMD_AMI_YAFU_RESET_DEVICE                             ,ENABLED},
-//	{ CMD_AMI_YAFU_GET_ECF_STATUS                         ,ENABLED},
-//	{ CMD_AMI_YAFU_GET_VERIFY_STATUS                    ,ENABLED},
-//	{ CMD_AMI_YAFU_DUAL_IMAGE_SUP                        ,ENABLED},
-//	{ CMD_AMI_GET_CHANNEL_NUM                               ,ENABLED},
-//	{ CMD_AMI_GET_ETH_INDEX                                    ,ENABLED},
-//	{ CMD_AMI_YAFU_FIRMWARE_SELECT_FLASH            ,ENABLED},
-//	{ CMD_AMI_YAFU_SIGNIMAGEKEY_REPLACE              ,ENABLED},
-
-	/*-------------------- AMI Smtp Commands -----------------------*/
-//	{ CMD_SET_SMTP_CONFIG_PARAMS                         ,ENABLED},
-//	{ CMD_GET_SMTP_CONFIG_PARAMS                         ,ENABLED},
-//	{ CMD_AMI_GET_EMAIL_USER                                  ,ENABLED},
-//	{ CMD_AMI_SET_EMAIL_USER                                  ,ENABLED},
-//	{ CMD_AMI_GET_EMAILFORMAT_USER                      ,ENABLED},
-//	{ CMD_AMI_SET_EMAILFORMAT_USER                      ,ENABLED},
-//	{ CMD_AMI_RESET_PASS                                         ,ENABLED},
-//	{ CMD_AMI_RESTORE_DEF                                       ,ENABLED},
-//	{ CMD_AMI_GET_LOG_CONF                                     ,ENABLED},
-//	{ CMD_AMI_SET_LOG_CONF                                     ,ENABLED},
-
-	/*-------------------- AMI Get Bios Code Commands -----------------------------------------*/
-//	{ CMD_AMI_GET_BIOS_CODE                                   ,ENABLED},
-
-	/*-------------------- AMI SERVICE Commands -----------------------------------------*/
-//	{ CMD_AMI_GET_SERVICE_CONF                              ,ENABLED},
-//	{ CMD_AMI_SET_SERVICE_CONF                              ,ENABLED},
-//	{ CMD_AMI_LINK_DOWN_RESILENT                           ,ENABLED},
-
-	/*-------------------- AMI DNS Commands -----------------------------------------*/
-//	{ CMD_AMI_GET_DNS_CONF                                     ,ENABLED},
-//	{ CMD_AMI_SET_DNS_CONF                                     ,ENABLED},
-
-	/*-------------------- AMI Iface State Commands -----------------------------------------*/
-//	{ CMD_AMI_GET_IFACE_STATE                                 ,ENABLED},
-//	{ CMD_AMI_SET_IFACE_STATE                                 ,ENABLED},
-
-//	{ CMD_AMI_SET_FIREWALL                                      ,ENABLED},
-//	{ CMD_AMI_GET_FIREWALL                                      ,ENABLED},
-//	{ CMD_AMI_GET_FRU_DETAILS                                 ,ENABLED},
-//	{ CMD_AMI_GET_ROOT_USER_ACCESS                     ,ENABLED},
-//	{ CMD_AMI_SET_ROOT_PASSWORD                          ,ENABLED},
-//	{ CMD_AMI_GET_USER_SHELLTYPE                           ,DISABLED},
-//	{ CMD_AMI_SET_USER_SHELLTYPE                           ,DISABLED},
-//	{ CMD_AMI_SET_EXTENDED_PRIV                           ,ENABLED},
-//	{ CMD_AMI_GET_EXTENDED_PRIV                           ,ENABLED},
-//	{ CMD_AMI_SET_TIMEZONE                                   ,ENABLED},
-//	{ CMD_AMI_GET_TIMEZONE                                   ,ENABLED},
-//	{ CMD_AMI_GET_NTP_CFG                                 ,ENABLED},
-//	{ CMD_AMI_SET_NTP_CFG                                 ,ENABLED},
-//	{ CMD_AMI_SET_TRIGGER_EVT                                ,ENABLED},
-//	{ CMD_AMI_GET_TRIGGER_EVT                                ,ENABLED},
-//	{ CMD_AMI_GET_SOL_CONFIG_PARAMS                          ,ENABLED},
-//	{ CMD_AMI_SET_LOGIN_AUDIT_CFG,      ENABLED }, 
-//	{ CMD_AMI_GET_LOGIN_AUDIT_CFG,      ENABLED },
-//	{ CMD_AMI_GET_IPV6_ADDRESS,         ENABLED },
-//	{ CMD_AMI_SET_SNMP_CONF, ENABLED },
-//	{ CMD_AMI_GET_SNMP_CONF, ENABLED },
-//	{ CMD_AMI_SET_PAM_ORDER,            ENABLED },
-//	{ CMD_AMI_GET_PAM_ORDER,            ENABLED },
-//	{ CMD_AMI_GET_CHANNEL_TYPE,         ENABLED }, 
-
-	/*------------------------------ AMI SEL Commands ------------------------------*/
-//	{ CMD_AMI_GET_SEL_POLICY,           ENABLED },
-//	{ CMD_AMI_SET_SEL_POLICY,           ENABLED },
-//	{ CMD_AMI_SET_PRESERVE_CONF,        ENABLED }, 
-//	{ CMD_AMI_GET_PRESERVE_CONF,        ENABLED }, 
-//	{ CMD_AMI_GET_SEL_ENTIRES,          ENABLED },
-//	{ CMD_AMI_GET_SENSOR_INFO,          ENABLED },
-//	{ CMD_AMI_SET_ALL_PRESERVE_CONF,    ENABLED },
-//	{ CMD_AMI_GET_ALL_PRESERVE_CONF,    ENABLED },
-
-	/*------------------------------- TFTP Firmware Update -------------------------*/
-//	{ CMD_AMI_START_TFTP_FW_UPDATE,     ENABLED },
-//	{ CMD_AMI_GET_TFTP_FW_PROGRESS_STATUS, ENABLED },
-//	{ CMD_AMI_SET_FW_CONFIGURATION,     ENABLED },
-//	{ CMD_AMI_GET_FW_CONFIGURATION,     ENABLED },
-//	{ CMD_AMI_SET_FW_PROTOCOL,          ENABLED },
-//	{ CMD_AMI_GET_FW_PROTOCOL,          ENABLED },
-//	{ CMD_AMI_GET_IPMI_SESSION_TIMEOUT,  ENABLED},
-	
-	/*------------------------------- UDS Channel Info Command ---------------------*/
-//	{ CMD_AMI_GET_UDS_CHANNEL_INFO,     ENABLED },
-//	{ CMD_AMI_GET_UDS_SESSION_INFO,     ENABLED },
-	
-	/*-------------------------------AMI Dual Image Support Command-----------------*/
-//	{ CMD_AMI_DUAL_IMG_SUPPORT,            ENABLED },
-
-	/*---------- Password Encryption Key--------- */
-//	{ CMD_AMI_SET_PWD_ENCRYPTION_KEY,     ENABLED },
-
-	/*-------------------------------U-Boot Memory Test-----------------------------*/
-//	{ CMD_AMI_SET_UBOOT_MEMTEST,            ENABLED},
-//	{ CMD_AMI_GET_UBOOT_MEMTEST_STATUS,     ENABLED},
-
-	/*-------------------- AMI Remote Images serviceCommands ----------------------------*/
-//	{ CMD_AMI_GET_RIS_CONF                              ,ENABLED},
-//	{ CMD_AMI_SET_RIS_CONF                              ,ENABLED},
-//	{ CMD_AMI_RIS_START_STOP                              ,ENABLED},
-	/*---------------------AMI Control Debug Messages Commands-----------------------*/
-//	{ CMD_AMI_CTL_DBG_MSG,                   ENABLED },
-//	{ CMD_AMI_GET_DBG_MSG_STATUS,            ENABLED },
-//	{ CMD_AMI_VIRTUAL_DEVICE_SET_STATUS,	ENABLED },
-//	{ CMD_AMI_VIRTUAL_DEVICE_GET_STATUS,	ENABLED },
-	
-//	{ CMD_AMI_GET_LICENSE_VALIDITY,                                     ENABLED},
-//	{ CMD_AMI_ADD_LICENSE_KEY,                                          ENABLED},
-	{0                                                                           ,0            }
-};
-
-const NetFnCmds_T g_opma1 [] = 
-{
-//	{  CMD_OPMA_SET_SENSOR_RD_OFFSET                  ,ENABLED},
-//	{  CMD_OPMA_GET_SENSOR_RD_OFFSET                  ,ENABLED},
-	{  0                                                                         ,0             }
-
-};
-
-const NetFnCmds_T g_opma2 [] =
-{
-//	{  CMD_OPMA_SET_SYS_TYPE_ID                             ,ENABLED},
-//	{  CMD_OPMA_GET_SYS_TYPE_ID                             ,ENABLED},
-//	{  CMD_OPMA_GET_MCARD_CAP                              ,ENABLED},
-//	{  CMD_OPMA_CLR_CMOS                                        ,ENABLED},
-//	{  CMD_OPMA_SET_LOCAL_LOCKOUT                        ,ENABLED},
-//	{  CMD_OPMA_GET_LOCAL_LOCKOUT                        ,ENABLED},
-//	{  CMD_OPMA_GET_SUPPORTED_HOST_IDS               ,ENABLED},
-	{  0                                                                          ,0             }
-};
-
-const NetFnCmds_T g_apml [] = 
-{
-//	{CMD_APML_GET_INTERFACE_VERSION                     ,ENABLED },
-//	{CMD_APML_READ_RMI_REG                                     ,ENABLED},
-//	{CMD_APML_WRITE_RMI_REG                                   ,ENABLED},
-//	{CMD_APML_READ_CPUID                                        ,ENABLED},
-//	{CMD_APML_READ_HTC_REG                                    ,ENABLED},
-//	{CMD_APML_WRITE_HTC_REG                                   ,ENABLED},
-//	{CMD_APML_READ_PSTATE                                       ,ENABLED},
-//	{CMD_APML_READ_MAX_PSTATE                               ,ENABLED},
-//	{CMD_APML_READ_PSTATE_LIMIT                             ,ENABLED},
-//	{CMD_APML_WRITE_PSTATE_LIMIT                            ,ENABLED},
-//	{CMD_APML_READ_MCR                                            ,ENABLED},
-//	{CMD_APML_WRITE_MCR                                          ,ENABLED},
-//	{CMD_APML_READ_TSI_REG                                     ,ENABLED},
-//	{CMD_APML_WRITE_TSI_REG                                    ,ENABLED},
-//	{CMD_APML_READ_TDP_LIMIT_REG                               ,ENABLED}, 
-//	{CMD_APML_WRITE_TDP_LIMIT_REG                              ,ENABLED},
-//	{CMD_APML_READ_PROCESSOR_POWER_REG                         ,ENABLED},
-//	{CMD_APML_READ_POWER_AVERAGING_REG                         ,ENABLED},
-//	{CMD_APML_READ_DRAM_THROTTLE_REG                           ,ENABLED},
-//	{CMD_APML_WRITE_DRAM_THROTTLE_REG                          ,ENABLED},
-	{0                                                                            ,0           }
-
-};
-
-const NetFnCmds_T g_dcmi [] = 
-{
-	/* DCMI Commands */
-//	{ CMD_GET_DCMI_CAPABILITY_INFO                          ,ENABLED},
-//	{ CMD_GET_POWER_READING                                     ,ENABLED},
-//	{ CMD_GET_POWER_LIMIT                                           ,ENABLED},
-//	{ CMD_SET_POWER_LIMIT                                           ,ENABLED},
-//	{ CMD_ACTIVATE_POWER_LIMIT                                  ,ENABLED},
-//	{ CMD_GET_ASSET_TAG                                              ,ENABLED},
-//	{ CMD_GET_DCMI_SENSOR_INFO                                 ,ENABLED},
-//	{ CMD_SET_ASSET_TAG                                              ,ENABLED},
-//	{ CMD_GET_MANAGEMENT_CONTROLLER_ID_STRING   ,ENABLED},
-//	{ CMD_SET_MANAGEMENT_CONTROLLER_ID_STRING   ,ENABLED},
-//	{CMD_SET_THERMAL_LIMIT                                        ,ENABLED},
-//	{CMD_GET_THERMAL_LIMIT                                        ,ENABLED},
-//	{CMD_GET_TEMPERATURE_READING                           ,ENABLED},
-//	{CMD_SET_DCMI_CONF_PARAMS                                ,ENABLED},
-//	{CMD_GET_DCMI_CONF_PARAMS                                ,ENABLED},
-	{ 0                                                                             ,0          }
-
-};
-
-const NetFnCmds_T g_hpm [] = 
-{
-//	{ CMD_GET_TARGET_UPLD_CAPABLITIES,              ENABLED},
-//	{ CMD_GET_COMPONENT_PROPERTIES,                 ENABLED},
-//	{ CMD_INITIATE_UPG_ACTION,                      ENABLED},
-//	{ CMD_QUERY_SELF_TEST_RESULTS,                  ENABLED},
-//	{ CMD_ABORT_FIRMWARE_UPGRADE,                   ENABLED},
-//	{ CMD_UPLOAD_FIRMWARE_BLOCK,                    ENABLED},
-//	{ CMD_FINISH_FIRMWARE_UPLOAD,                   ENABLED},
-//	{ CMD_GET_UPGRADE_STATUS,                       ENABLED},
-//	{ CMD_ACTIVATE_FIRMWARE,                        ENABLED},
-//	{ CMD_QUERY_ROLLBACK_STATUS,                    ENABLED},
-//	{ CMD_INITIATE_MANUAL_ROLLBACK,                 ENABLED},
-	{ 0,                                            0      }
-
-};
-
-const NetFnCmds_T g_pnm [] =
-{
-//	{CMD_PNM_OEM_GET_READING                                 ,ENABLED},
-//	{CMD_PNM_OEM_ME_POWER_STATE_CHANGE             ,ENABLED},
-	{0                                                                             ,0           }
-
-};
-
-const NetFnCmds_T g_ssi [] =
-{
-//	{ CMD_SSICB_GET_COMPUTE_BLADE_PROPERTIES,   ENABLED},
-//	{ CMD_SSICB_GET_ADDR_INFO,                  ENABLED},
-//	{ CMD_SSICB_PLATFORM_EVENT_MESSAGE,         ENABLED},
-//	{ CMD_SSICB_MODULE_BMI_CONTROL,             ENABLED},
-//	{ CMD_SSICB_MODULE_PAYLOAD_CONTROL,         ENABLED},
-//	{ CMD_SSICB_SET_SYSTEM_EVENT_LOG_POLICY,    ENABLED},
-//	{ CMD_SSICB_SET_MODULE_ACTIVATION_POLICY,   ENABLED},
-//	{ CMD_SSICB_GET_MODULE_ACTIVATION_POLICY,   ENABLED},
-//	{ CMD_SSICB_SET_MODULE_ACTIVATION,          ENABLED},
-//	{ CMD_SSICB_SET_POWER_LEVEL,                ENABLED},
-//	{ CMD_SSICB_GET_POWER_LEVEL,                ENABLED},
-//	{ CMD_SSICB_RENEGOTIATE_POWER,              ENABLED},
-//	{ CMD_SSICB_GET_SERVICE_INFO,               ENABLED},
-//	{ CMD_SSICB_GET_APPLET_PACKAGE_URI,         ENABLED},
-//	{ CMD_SSICB_GET_SERVICE_ENABLE_STATE,       ENABLED},
-//	{ CMD_SSICB_SET_SERVICE_ENABLE_STATE,       ENABLED},
-//	{ CMD_SSICB_SET_SERVICE_TICKET,             ENABLED},
-//	{ CMD_SSICB_STOP_SERVICE_SESSION,           ENABLED},
-	{ 0,                                        0}
-};
-
-const NetFnCmds_T g_oem [] =			//jimbo add
-{
-	{ CMD_EXAMPLE_1,   				ENABLED},
-	{ CMD_EXAMPLE_2,		                ENABLED},
-	{ CMD_EXAMPLE_3,         			ENABLED},
-	{ CMD_EXAMPLE_4,  				ENABLED},
-	{ CMD_EXAMPLE_5,  				ENABLED},
-	{ CMD_EXAMPLE_6,  				ENABLED},
-	{ CMD_EXAMPLE_7,  				ENABLED},
-	{ CMD_EXAMPLE_8,  				ENABLED},
-	{ CMD_EXAMPLE_9,  				ENABLED},
-	{0,											0}
-};
-
-
-NETFNTable_T Netfntbl [] = 
-{
-	{ NETFN_APP,        GRPEXT_NA,      g_App       },
-	{ NETFN_CHASSIS,    GRPEXT_NA,      g_Chassis   },
-	{ NETFN_BRIDGE,     GRPEXT_NA,      g_Bridge    },
-	{ NETFN_SENSOR,     GRPEXT_NA,      g_Sensor    },
-	{ NETFN_STORAGE,    GRPEXT_NA,      g_Storage   },
-	{ NETFN_TRANSPORT,  GRPEXT_NA,      g_Transport },
-	{ NETFN_AMI,        GRPEXT_NA,      g_AMI       },
-	{ NETFN_OPMA1,      GRPEXT_NA,      g_opma1     },
-	{ NETFN_OPMA2,      GRPEXT_NA,      g_opma2     },
-	{ NETFN_APML,       GRPEXT_NA,      g_apml      },
-	{ NETFN_HPM,        GRPEXT_HPM,     g_hpm       },
-	{ NETFN_DCMI,       GRPEXT_DCMI,    g_dcmi      },
-	{ NETFN_PNM,        GRPEXT_NA,      g_pnm       },
-	{ NETFN_SSI,        GRPEXT_SSI,     g_ssi       },
-	{ NETFN_OEM,        GRPEXT_NA,     	g_oem       },	//jimbo add
-};
-
-/*
-*@fn GetCommanEnabledStatus
-*@brief This function finds whether the command is enabled by the OEM
-*@param NetFunction - Pointer to the structure of NetFnCmds_T
-*@param Cmd - Command Number
-*@return Returns 0 on Enabled commands
-*            Returns -1 on non-Enabled commands
-*/
-int GetCommanEnabledStatus(NETFNTable_T *NetFuntbl,INT8U Cmd)
-{
-	int i=0;
-
-	while(NetFuntbl->NetFunction[i].Status != 0)
-	{
-		if(NetFuntbl->NetFunction[i].CmdNum ==Cmd)
-		{
-			if(NetFuntbl->NetFunction[i].Status ==ENABLED)
-			{
-				return 0;
-			}
-			else
-			{
-				return -1;
-			}
-		}
-		i++;
-	}
-	return -1;
-}
-
-/*
-*@fn IsCommandEnabled
-*@brief This function gives the status of Command
-*@param NetFn         - Net Function 
-*@param GroupExtnCode - Group Extension Code
-*@param Cmd           - Command Number
-*@return Returns 0 if the command is Enabled
-*            Returns -1 if the command is Disabled
-*/
-int IsCommandEnabled(INT8U NetFn,INT8U Cmd)
-{
-	int i=0;
-	_FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;
-
-	while(i<(sizeof(Netfntbl)/sizeof(NETFNTable_T)))
-	{
-		if(NetFn == Netfntbl[i].NetFn)
-		{
-			break;
-		}
-		i++;
-	}
-
-	if(i != sizeof(Netfntbl)/sizeof(NETFNTable_T))
-	{
-		if(GetCommanEnabledStatus((NETFNTable_T*)&Netfntbl[i],Cmd) < 0)
-		{
-			return -1;
-		}
-	}
-	else
-	{
-		return -1;
-	}
-
-	return 0;
-}
-
-
+/******************************************************************
+ ******************************************************************
+ ***                                                                                                           **
+ ***    (C)Copyright 2011, American Megatrends Inc.                                     **
+ ***                                                                                                           **
+ ***    All Rights Reserved.                                                                          **
+ ***                                                                                                           **
+ ***    5555 , Oakbrook Pkwy, Norcross,                                                       **
+ ***                                                                                                           **
+ ***    Georgia - 30093, USA. Phone-(770)-246-8600.                                  **
+ ***                                                                                                           **
+ ******************************************************************
+ ******************************************************************
+ ******************************************************************
+ *
+ * cmdselect.c
+ * OEM can enable or disable IPMI Command accoring to requirements
+ *
+ *  Author: Winston <winstonv@amiindia.co.in>
+ ******************************************************************/
+#include <stdio.h>
+#include "com_BmcType.h"
+#include "cmdselect.h"
+
+#include "com_IPMI_App.h"
+#include "com_IPMI_Bridge.h"
+#include "com_IPMI_PICMG.h"
+#include "com_IPMI_Chassis.h"
+#include "com_IPMI_SensorEvent.h"
+#include "com_IPMI_Storage.h"
+#include "OemSMMCmds.h"
+//#include "IPMI_Transport.h"
+//#include "OemSMMCmds.h"
+//#include "main.h"
+
+#define ENABLED		0x01
+#define DISABLED	0xff
+
+const NetFnCmds_T g_App [] = 
+{
+	/* IPM Device Commands */
+	{CMD_GET_DEV_ID                                                 , ENABLED},
+	{CMD_BROADCAST_GET_DEV_ID                             ,DISABLED},
+	{CMD_COLD_RESET                                                 ,ENABLED},
+	{CMD_WARM_RESET                                                ,ENABLED},
+	{CMD_GET_SELF_TEST_RESULTS                              ,ENABLED},
+	{CMD_MFG_TEST_ON                                               ,ENABLED},
+	{CMD_SET_ACPI_PWR_STATE                                  ,ENABLED},
+	{CMD_GET_ACPI_PWR_STATE                                 ,ENABLED},
+	{CMD_GET_DEV_GUID                                            ,ENABLED},
+	{CMD_GET_NETFN_SUP                                           ,ENABLED},
+	{CMD_GET_CMD_SUP                                             ,ENABLED},
+	{CMD_GET_SUBFN_SUP                                          ,DISABLED},
+	{CMD_GET_CONFIG_CMDS                                     ,ENABLED},
+	{CMD_GET_CONFIG_SUB_FNS                                ,DISABLED},
+	{CMD_SET_CMD_ENABLES                                     ,ENABLED},
+	{CMD_GET_CMD_ENABLES                                     ,ENABLED},
+	{CMD_SET_SUBFN_ENABLES                                  ,DISABLED},
+	{CMD_GET_SUBFN_ENABLES                                  ,DISABLED},
+	{CMD_GET_OEM_NETFN_IANA_SUPPORT                 ,ENABLED},
+	/*    WatchDog Timer Commands  */
+	{CMD_RESET_WDT                                               ,ENABLED},
+	{CMD_SET_WDT                                                   ,ENABLED},
+	{CMD_GET_WDT                                                   ,ENABLED},
+
+	/*    BMC Device and Messaging Commands   */
+	{ CMD_SET_BMC_GBL_ENABLES                           ,ENABLED},
+	{ CMD_GET_BMC_GBL_ENABLES                           ,ENABLED},
+	{ CMD_CLR_MSG_FLAGS                                      ,ENABLED},
+	{ CMD_GET_MSG_FLAGS                                      ,ENABLED},
+	{ CMD_ENBL_MSG_CH_RCV                                  ,ENABLED},
+	{ CMD_GET_MSG                                                 ,ENABLED},
+	{ CMD_SEND_MSG                                               ,ENABLED},
+	{ CMD_READ_EVT_MSG_BUFFER                           ,ENABLED},
+	{ CMD_GET_BTIFC_CAP                                       ,ENABLED},
+	{ CMD_GET_SYSTEM_GUID                                  ,ENABLED},
+	{ CMD_GET_CH_AUTH_CAP                                  ,ENABLED},
+	{ CMD_GET_SESSION_CHALLENGE                       ,ENABLED},
+	{ CMD_ACTIVATE_SESSION                                 ,ENABLED},
+	{ CMD_SET_SESSION_PRIV_LEVEL                       ,ENABLED},
+	{ CMD_CLOSE_SESSION                                      ,ENABLED},
+	{ CMD_GET_SESSION_INFO                                 ,ENABLED},
+	{ CMD_GET_AUTH_CODE                                     ,ENABLED},
+	{ CMD_SET_CH_ACCESS                                     ,ENABLED},
+	{ CMD_GET_CH_ACCESS                                     ,ENABLED},
+	{ CMD_GET_CH_INFO                                          ,ENABLED},
+	{ CMD_SET_USER_ACCESS                                 ,ENABLED},
+	{ CMD_GET_USER_ACCESS                                 ,ENABLED},
+	{ CMD_SET_USER_NAME                                     ,ENABLED},
+	{ CMD_GET_USER_NAME                                     ,ENABLED},
+	{ CMD_SET_USER_PASSWORD                            ,ENABLED},
+	{ CMD_MASTER_WRITE_READ                             ,ENABLED},
+	{ CMD_SET_SYSTEM_INFO_PARAM                      ,ENABLED},
+	{ CMD_GET_SYSTEM_INFO_PARAM                      ,ENABLED},
+
+	/*------------------------ IPMI 2.0 specific Commands ------------------*/
+	{ CMD_ACTIVATE_PAYLOAD                               ,ENABLED},
+	{ CMD_DEACTIVATE_PAYLOAD                           ,ENABLED},
+	{ CMD_GET_PAYLD_ACT_STATUS                       ,ENABLED},
+	{ CMD_GET_PAYLD_INST_INFO                          ,ENABLED},
+	{ CMD_SET_USR_PAYLOAD_ACCESS                  ,ENABLED},
+	{ CMD_GET_USR_PAYLOAD_ACCESS                  ,ENABLED},
+	{ CMD_GET_CH_PAYLOAD_SUPPORT                  ,ENABLED},
+	{ CMD_GET_CH_PAYLOAD_VER                          ,ENABLED},
+	{ CMD_GET_CH_OEM_PAYLOAD_INFO                 ,ENABLED},
+	{ CMD_GET_CH_CIPHER_SUITES                        ,ENABLED},
+	{ CMD_SUS_RES_PAYLOAD_ENCRYPT                 ,ENABLED},
+	{ CMD_SET_CH_SECURITY_KEYS                       ,ENABLED},
+	{ CMD_GET_SYS_IFC_CAPS                              ,ENABLED},
+	{0                                                                   ,0            },
+	
+};
+
+const NetFnCmds_T g_Chassis [] =
+{
+	/*--------------------- Chassis Commands ---------------------------------*/
+	{ CMD_GET_CHASSIS_CAPABILITIES                          ,ENABLED},
+	{ CMD_GET_CHASSIS_STATUS                                   ,ENABLED},
+	{ CMD_CHASSIS_CONTROL                                        ,ENABLED},
+	{ CMD_CHASSIS_RESET                                             ,DISABLED},
+	{ CMD_CHASSIS_IDENTIFY                                        ,ENABLED},
+	{ CMD_SET_CHASSIS_CAPABILITIES                          ,ENABLED},
+	{ CMD_SET_POWER_RESTORE_POLICY                        ,ENABLED},
+	{ CMD_GET_SYSTEM_RESTART_CAUSE                        ,ENABLED},
+	{ CMD_SET_SYSTEM_BOOT_OPTIONS                          ,ENABLED},
+	{ CMD_GET_SYSTEM_BOOT_OPTIONS                          ,ENABLED},
+	{ CMD_GET_POH_COUNTER                                         ,ENABLED},
+	{ CMD_SET_FP_BTN_ENABLES                                     ,ENABLED},
+	{ CMD_SET_POWER_CYCLE_INTERVAL                         ,ENABLED},
+	{0,                                                                            0             }
+
+};
+
+const NetFnCmds_T g_Bridge [] = 
+{
+	/*----------------------- Bridge Management Commands --------------------------------*/
+	{ CMD_GET_BRIDGE_STATE                                        ,ENABLED},
+	{ CMD_SET_BRIDGE_STATE                                        ,ENABLED},
+	{ CMD_GET_ICMB_ADDR                                            ,ENABLED},
+	{ CMD_SET_ICMB_ADDR                                            ,ENABLED},
+	{ CMD_SET_BRIDGE_PROXY_ADDR                             ,ENABLED},
+	{ CMD_GET_BRIDGE_STATISTICS                               ,ENABLED},
+	{ CMD_GET_ICMB_CAPABILITIES                                ,ENABLED},
+	{ CMD_CLEAR_BRIDGE_STATISTICS                           ,ENABLED},
+	{ CMD_GET_BRIDGE_PROXY_ADDR                             ,ENABLED},
+	{ CMD_GET_ICMB_CONNECTOR_INFO                          ,ENABLED},
+	{ CMD_GET_ICMB_CONNECTION_ID                            ,DISABLED},
+	{ CMD_SEND_ICMB_CONNECTION_ID                          ,DISABLED},
+
+	/*---------------------- Bridge Discovery Commands -----------------------------------*/
+	{ CMD_PREPARE_FOR_DISCOVERY                              ,ENABLED},
+	{ CMD_GET_ADDRESSES                                            ,ENABLED},
+	{ CMD_SET_DISCOVERED                                           ,ENABLED},
+	{ CMD_GET_CHASSIS_DEVICE_ID                               ,ENABLED},
+	{ CMD_SET_CHASSIS_DEVICE_ID                               ,ENABLED},
+	
+	/*----------------------- Bridging Commands ------------------------------------------*/
+	{ CMD_BRIDGE_REQUEST                                           ,ENABLED},
+	{ CMD_BRIDGE_MESSAGE                                          ,ENABLED},
+	
+	/*---------------------- Bridge Event Commands ---------------------------------------*/
+	{ CMD_GET_EVENT_COUNT                                        ,ENABLED},
+	{ CMD_SET_EVENT_DESTINATION                              ,ENABLED},
+	{ CMD_SET_EVENT_RECEPTION_STATE                      ,ENABLED},
+	{ CMD_SEND_ICMB_EVENT_MESSAGE                        ,ENABLED},
+	{ CMD_GET_EVENT_DESTINATION                             ,ENABLED},
+	{ CMD_GET_EVENT_RECEPTION_STATE                      ,ENABLED},
+	{ 0                                                                           ,0           }
+
+};
+
+const NetFnCmds_T g_Sensor [] = 
+{
+
+	{ CMD_SET_EVENT_RECEIVER                                   ,ENABLED},
+	{ CMD_GET_EVENT_RECEIVER                                   ,ENABLED},
+	{ CMD_PLATFORM_EVENT                                          ,ENABLED},
+
+	{ CMD_GET_PEF_CAPABILITIES                                 ,ENABLED},
+	{ CMD_ARM_PEF_POSTPONE_TIMER                           ,ENABLED},
+	{ CMD_SET_PEF_CONFIG_PARAMS                             ,ENABLED},
+	{ CMD_GET_PEF_CONFIG_PARAMS                             ,ENABLED},
+	{ CMD_SET_LAST_PROCESSED_EVENT_ID                  ,ENABLED},
+	{ CMD_GET_LAST_PROCESSED_EVENT_ID                  ,ENABLED},
+	{ CMD_ALERT_IMMEDIATE                                         ,ENABLED},
+	{ CMD_PET_ACKNOWLEDGE                                      ,ENABLED},
+
+
+	{ CMD_GET_DEV_SDR_INFO                                     ,ENABLED},
+	{ CMD_GET_DEV_SDR                                              ,ENABLED},
+	{ CMD_RESERVE_DEV_SDR_REPOSITORY                  ,ENABLED},
+	{ CMD_GET_SENSOR_READING_FACTORS                 ,ENABLED},
+	{ CMD_SET_SENSOR_HYSTERISIS                             ,ENABLED},
+	{ CMD_GET_SENSOR_HYSTERISIS                             ,ENABLED},
+	{ CMD_SET_SENSOR_THRESHOLDS                           ,ENABLED},
+	{ CMD_GET_SENSOR_THRESHOLDS                           ,ENABLED},
+	{ CMD_SET_SENSOR_EVENT_ENABLE                         ,ENABLED},
+	{ CMD_GET_SENSOR_EVENT_ENABLE                         ,ENABLED},
+	{ CMD_REARM_SENSOR_EVENTS                               ,ENABLED},
+	{ CMD_GET_SENSOR_EVENT_STATUS                        ,ENABLED},
+	{ CMD_GET_SENSOR_READING                                 ,ENABLED},
+	{ CMD_SET_SENSOR_TYPE                                        ,ENABLED},
+	{ CMD_GET_SENSOR_TYPE                                        ,ENABLED},
+	{ CMD_SET_SENSOR_READING                                  ,ENABLED},
+	{0,                                                                           0             }
+};
+
+const NetFnCmds_T g_Storage [] = 
+{
+	/*--------------------- FRU Device Commands ---------------------------------*/
+	{ CMD_FRU_INVENTORY_AREA_INFO                           ,ENABLED},
+	{ CMD_READ_FRU_DATA                                            ,ENABLED},
+	{ CMD_WRITE_FRU_DATA                                           ,ENABLED},
+
+	/*--------------------- SDR Device Commands ---------------------------------*/
+	{ CMD_GET_SDR_REPOSITORY_INFO                           ,ENABLED},
+	{ CMD_GET_SDR_REPOSITORY_ALLOCATION_INFO       ,ENABLED},
+	{ CMD_RESERVE_SDR_REPOSITORY                             ,ENABLED},
+	{ CMD_GET_SDR                                                         ,ENABLED},
+	{ CMD_ADD_SDR                                                        ,ENABLED},
+	{ CMD_PARTIAL_ADD_SDR                                          ,ENABLED},
+	{ CMD_DELETE_SDR                                                    ,DISABLED},
+	{ CMD_CLEAR_SDR_REPOSITORY                                 ,ENABLED},
+	{ CMD_GET_SDR_REPOSITORY_TIME                            ,ENABLED},
+	{ CMD_SET_SDR_REPOSITORY_TIME                            ,DISABLED},
+	{ CMD_ENTER_SDR_REPOSITORY_UPDATE_MODE         ,DISABLED},
+	{ CMD_EXIT_SDR_REPOSITORY_UPDATE_MODE            ,DISABLED},
+	{ CMD_RUN_INITIALIZATION_AGENT                            ,ENABLED},
+
+	/*--------------------- SEL Device Commands ----------------------------------*/
+	{ CMD_GET_SEL_INFO                                                  ,ENABLED},
+	{ CMD_GET_SEL_ALLOCATION_INFO                              ,ENABLED},
+	{ CMD_RESERVE_SEL                                                    ,ENABLED},
+	{ CMD_GET_SEL_ENTRY                                                 ,ENABLED},
+	{ CMD_ADD_SEL_ENTRY                                                ,ENABLED},
+	{ CMD_PARTIAL_ADD_SEL_ENTRY                                  ,ENABLED},
+	{ CMD_DELETE_SEL_ENTRY                                            ,ENABLED},
+	{ CMD_CLEAR_SEL                                                        ,ENABLED},
+	{ CMD_GET_SEL_TIME                                                   ,ENABLED},
+	{ CMD_SET_SEL_TIME                                                   ,ENABLED},
+	{ CMD_GET_AUXILIARY_LOG_STATUS                            ,DISABLED},
+	{ CMD_SET_AUXILIARY_LOG_STATUS                            ,DISABLED},
+	{ CMD_GET_SEL_TIME_UTC_OFFSET                              ,ENABLED},
+	{ CMD_SET_SEL_TIME_UTC_OFFSET                              ,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 [] = 
+//{
+//	/* ---------------YAFU Commands -----------------------------*/
+//	{ CMD_AMI_YAFU_SWITCH_FLASH_DEVICE			    ,ENABLED},
+//	{ CMD_AMI_YAFU_RESTORE_FLASH_DEVICE			    ,ENABLED},
+//	{ CMD_AMI_YAFU_GET_FLASH_INFO                           ,ENABLED},
+//	{ CMD_AMI_YAFU_GET_FIRMWARE_INFO                    ,ENABLED},
+//	{ CMD_AMI_YAFU_GET_FMH_INFO                              ,ENABLED},
+//	{ CMD_AMI_YAFU_GET_STATUS                                 ,ENABLED},
+//	{ CMD_AMI_YAFU_ACTIVATE_FLASH                          ,ENABLED},
+//	{ CMD_AMI_YAFU_ALLOCATE_MEMORY                       ,ENABLED},
+//	{ CMD_AMI_YAFU_FREE_MEMORY                               ,ENABLED},
+//	{ CMD_AMI_YAFU_READ_FLASH                                 ,ENABLED},
+//	{ CMD_AMI_YAFU_WRITE_FLASH                                ,ENABLED},
+//	{ CMD_AMI_YAFU_ERASE_FLASH                                ,ENABLED},
+//	{ CMD_AMI_YAFU_PROTECT_FLASH                            ,ENABLED},
+//	{ CMD_AMI_YAFU_ERASE_COPY_FLASH                      ,ENABLED},
+//	{ CMD_AMI_YAFU_VERIFY_FLASH                               ,ENABLED},
+//	{ CMD_AMI_YAFU_READ_MEMORY                              ,ENABLED},
+//	{ CMD_AMI_YAFU_WRITE_MEMORY                             ,ENABLED},
+//	{ CMD_AMI_YAFU_COPY_MEMORY                              ,ENABLED},
+//	{ CMD_AMI_YAFU_COMPARE_MEMORY                        ,ENABLED},
+//	{ CMD_AMI_YAFU_CLEAR_MEMORY                            ,ENABLED},
+//	{ CMD_AMI_YAFU_GET_BOOT_CONFIG                       ,ENABLED},
+//	{ CMD_AMI_YAFU_SET_BOOT_CONFIG                       ,ENABLED},
+//	{ CMD_AMI_YAFU_GET_BOOT_VARS                          ,ENABLED},
+//	{ CMD_AMI_YAFU_DEACTIVATE_FLASH_MODE            ,ENABLED},
+//	{ CMD_AMI_YAFU_RESET_DEVICE                             ,ENABLED},
+//	{ CMD_AMI_YAFU_GET_ECF_STATUS                         ,ENABLED},
+//	{ CMD_AMI_YAFU_GET_VERIFY_STATUS                    ,ENABLED},
+//	{ CMD_AMI_YAFU_DUAL_IMAGE_SUP                        ,ENABLED},
+//	{ CMD_AMI_GET_CHANNEL_NUM                               ,ENABLED},
+//	{ CMD_AMI_GET_ETH_INDEX                                    ,ENABLED},
+//	{ CMD_AMI_YAFU_FIRMWARE_SELECT_FLASH            ,ENABLED},
+//	{ CMD_AMI_YAFU_SIGNIMAGEKEY_REPLACE              ,ENABLED},
+
+//	/*-------------------- AMI Smtp Commands -----------------------*/
+//	{ CMD_SET_SMTP_CONFIG_PARAMS                         ,ENABLED},
+//	{ CMD_GET_SMTP_CONFIG_PARAMS                         ,ENABLED},
+//	{ CMD_AMI_GET_EMAIL_USER                                  ,ENABLED},
+//	{ CMD_AMI_SET_EMAIL_USER                                  ,ENABLED},
+//	{ CMD_AMI_GET_EMAILFORMAT_USER                      ,ENABLED},
+//	{ CMD_AMI_SET_EMAILFORMAT_USER                      ,ENABLED},
+//	{ CMD_AMI_RESET_PASS                                         ,ENABLED},
+//	{ CMD_AMI_RESTORE_DEF                                       ,ENABLED},
+//	{ CMD_AMI_GET_LOG_CONF                                     ,ENABLED},
+//	{ CMD_AMI_SET_LOG_CONF                                     ,ENABLED},
+
+//	/*-------------------- AMI Get Bios Code Commands -----------------------------------------*/
+//	{ CMD_AMI_GET_BIOS_CODE                                   ,ENABLED},
+
+//	/*-------------------- AMI SERVICE Commands -----------------------------------------*/
+//	{ CMD_AMI_GET_SERVICE_CONF                              ,ENABLED},
+//	{ CMD_AMI_SET_SERVICE_CONF                              ,ENABLED},
+//	{ CMD_AMI_LINK_DOWN_RESILENT                           ,ENABLED},
+
+//	/*-------------------- AMI DNS Commands -----------------------------------------*/
+//	{ CMD_AMI_GET_DNS_CONF                                     ,ENABLED},
+//	{ CMD_AMI_SET_DNS_CONF                                     ,ENABLED},
+
+//	/*-------------------- AMI Iface State Commands -----------------------------------------*/
+//	{ CMD_AMI_GET_IFACE_STATE                                 ,ENABLED},
+//	{ CMD_AMI_SET_IFACE_STATE                                 ,ENABLED},
+
+//	{ CMD_AMI_SET_FIREWALL                                      ,ENABLED},
+//	{ CMD_AMI_GET_FIREWALL                                      ,ENABLED},
+//	{ CMD_AMI_GET_FRU_DETAILS                                 ,ENABLED},
+//	{ CMD_AMI_GET_ROOT_USER_ACCESS                     ,ENABLED},
+//	{ CMD_AMI_SET_ROOT_PASSWORD                          ,ENABLED},
+//	{ CMD_AMI_GET_USER_SHELLTYPE                           ,DISABLED},
+//	{ CMD_AMI_SET_USER_SHELLTYPE                           ,DISABLED},
+//	{ CMD_AMI_SET_EXTENDED_PRIV                           ,ENABLED},
+//	{ CMD_AMI_GET_EXTENDED_PRIV                           ,ENABLED},
+//	{ CMD_AMI_SET_TIMEZONE                                   ,ENABLED},
+//	{ CMD_AMI_GET_TIMEZONE                                   ,ENABLED},
+//	{ CMD_AMI_GET_NTP_CFG                                 ,ENABLED},
+//	{ CMD_AMI_SET_NTP_CFG                                 ,ENABLED},
+//	{ CMD_AMI_SET_TRIGGER_EVT                                ,ENABLED},
+//	{ CMD_AMI_GET_TRIGGER_EVT                                ,ENABLED},
+//	{ CMD_AMI_GET_SOL_CONFIG_PARAMS                          ,ENABLED},
+//	{ CMD_AMI_SET_LOGIN_AUDIT_CFG,      ENABLED }, 
+//	{ CMD_AMI_GET_LOGIN_AUDIT_CFG,      ENABLED },
+//	{ CMD_AMI_GET_IPV6_ADDRESS,         ENABLED },
+//	{ CMD_AMI_SET_SNMP_CONF, ENABLED },
+//	{ CMD_AMI_GET_SNMP_CONF, ENABLED },
+//	{ CMD_AMI_SET_PAM_ORDER,            ENABLED },
+//	{ CMD_AMI_GET_PAM_ORDER,            ENABLED },
+//	{ CMD_AMI_GET_CHANNEL_TYPE,         ENABLED }, 
+
+//	/*------------------------------ AMI SEL Commands ------------------------------*/
+//	{ CMD_AMI_GET_SEL_POLICY,           ENABLED },
+//	{ CMD_AMI_SET_SEL_POLICY,           ENABLED },
+//	{ CMD_AMI_SET_PRESERVE_CONF,        ENABLED }, 
+//	{ CMD_AMI_GET_PRESERVE_CONF,        ENABLED }, 
+//	{ CMD_AMI_GET_SEL_ENTIRES,          ENABLED },
+//	{ CMD_AMI_GET_SENSOR_INFO,          ENABLED },
+//	{ CMD_AMI_SET_ALL_PRESERVE_CONF,    ENABLED },
+//	{ CMD_AMI_GET_ALL_PRESERVE_CONF,    ENABLED },
+
+//	/*------------------------------- TFTP Firmware Update -------------------------*/
+//	{ CMD_AMI_START_TFTP_FW_UPDATE,     ENABLED },
+//	{ CMD_AMI_GET_TFTP_FW_PROGRESS_STATUS, ENABLED },
+//	{ CMD_AMI_SET_FW_CONFIGURATION,     ENABLED },
+//	{ CMD_AMI_GET_FW_CONFIGURATION,     ENABLED },
+//	{ CMD_AMI_SET_FW_PROTOCOL,          ENABLED },
+//	{ CMD_AMI_GET_FW_PROTOCOL,          ENABLED },
+//	{ CMD_AMI_GET_IPMI_SESSION_TIMEOUT,  ENABLED},
+//	
+//	/*------------------------------- UDS Channel Info Command ---------------------*/
+//	{ CMD_AMI_GET_UDS_CHANNEL_INFO,     ENABLED },
+//	{ CMD_AMI_GET_UDS_SESSION_INFO,     ENABLED },
+//	
+//	/*-------------------------------AMI Dual Image Support Command-----------------*/
+//	{ CMD_AMI_DUAL_IMG_SUPPORT,            ENABLED },
+
+//	/*---------- Password Encryption Key--------- */
+//	{ CMD_AMI_SET_PWD_ENCRYPTION_KEY,     ENABLED },
+
+//	/*-------------------------------U-Boot Memory Test-----------------------------*/
+//	{ CMD_AMI_SET_UBOOT_MEMTEST,            ENABLED},
+//	{ CMD_AMI_GET_UBOOT_MEMTEST_STATUS,     ENABLED},
+
+//	/*-------------------- AMI Remote Images serviceCommands ----------------------------*/
+//	{ CMD_AMI_GET_RIS_CONF                              ,ENABLED},
+//	{ CMD_AMI_SET_RIS_CONF                              ,ENABLED},
+//	{ CMD_AMI_RIS_START_STOP                              ,ENABLED},
+//	/*---------------------AMI Control Debug Messages Commands-----------------------*/
+//	{ CMD_AMI_CTL_DBG_MSG,                   ENABLED },
+//	{ CMD_AMI_GET_DBG_MSG_STATUS,            ENABLED },
+//	{ CMD_AMI_VIRTUAL_DEVICE_SET_STATUS,	ENABLED },
+//	{ CMD_AMI_VIRTUAL_DEVICE_GET_STATUS,	ENABLED },
+//	
+//	{ CMD_AMI_GET_LICENSE_VALIDITY,                                     ENABLED},
+//	{ CMD_AMI_ADD_LICENSE_KEY,                                          ENABLED},
+//	{0                                                                           ,0            }
+//};
+
+//const NetFnCmds_T g_opma1 [] = 
+//{
+//	{  CMD_OPMA_SET_SENSOR_RD_OFFSET                  ,ENABLED},
+//	{  CMD_OPMA_GET_SENSOR_RD_OFFSET                  ,ENABLED},
+//	{  0                                                                         ,0             }
+
+//};
+
+//const NetFnCmds_T g_opma2 [] =
+//{
+//	{  CMD_OPMA_SET_SYS_TYPE_ID                             ,ENABLED},
+//	{  CMD_OPMA_GET_SYS_TYPE_ID                             ,ENABLED},
+//	{  CMD_OPMA_GET_MCARD_CAP                              ,ENABLED},
+//	{  CMD_OPMA_CLR_CMOS                                        ,ENABLED},
+//	{  CMD_OPMA_SET_LOCAL_LOCKOUT                        ,ENABLED},
+//	{  CMD_OPMA_GET_LOCAL_LOCKOUT                        ,ENABLED},
+//	{  CMD_OPMA_GET_SUPPORTED_HOST_IDS               ,ENABLED},
+//	{  0                                                                          ,0             }
+//};
+
+//const NetFnCmds_T g_apml [] = 
+//{
+//	{CMD_APML_GET_INTERFACE_VERSION                     ,ENABLED },
+//	{CMD_APML_READ_RMI_REG                                     ,ENABLED},
+//	{CMD_APML_WRITE_RMI_REG                                   ,ENABLED},
+//	{CMD_APML_READ_CPUID                                        ,ENABLED},
+//	{CMD_APML_READ_HTC_REG                                    ,ENABLED},
+//	{CMD_APML_WRITE_HTC_REG                                   ,ENABLED},
+//	{CMD_APML_READ_PSTATE                                       ,ENABLED},
+//	{CMD_APML_READ_MAX_PSTATE                               ,ENABLED},
+//	{CMD_APML_READ_PSTATE_LIMIT                             ,ENABLED},
+//	{CMD_APML_WRITE_PSTATE_LIMIT                            ,ENABLED},
+//	{CMD_APML_READ_MCR                                            ,ENABLED},
+//	{CMD_APML_WRITE_MCR                                          ,ENABLED},
+//	{CMD_APML_READ_TSI_REG                                     ,ENABLED},
+//	{CMD_APML_WRITE_TSI_REG                                    ,ENABLED},
+//	{CMD_APML_READ_TDP_LIMIT_REG                               ,ENABLED}, 
+//	{CMD_APML_WRITE_TDP_LIMIT_REG                              ,ENABLED},
+//	{CMD_APML_READ_PROCESSOR_POWER_REG                         ,ENABLED},
+//	{CMD_APML_READ_POWER_AVERAGING_REG                         ,ENABLED},
+//	{CMD_APML_READ_DRAM_THROTTLE_REG                           ,ENABLED},
+//	{CMD_APML_WRITE_DRAM_THROTTLE_REG                          ,ENABLED},
+//	{0                                                                            ,0           }
+
+//};
+
+//const NetFnCmds_T g_dcmi [] = 
+//{
+//	/* DCMI Commands */
+//	{ CMD_GET_DCMI_CAPABILITY_INFO                          ,ENABLED},
+//	{ CMD_GET_POWER_READING                                     ,ENABLED},
+//	{ CMD_GET_POWER_LIMIT                                           ,ENABLED},
+//	{ CMD_SET_POWER_LIMIT                                           ,ENABLED},
+//	{ CMD_ACTIVATE_POWER_LIMIT                                  ,ENABLED},
+//	{ CMD_GET_ASSET_TAG                                              ,ENABLED},
+//	{ CMD_GET_DCMI_SENSOR_INFO                                 ,ENABLED},
+//	{ CMD_SET_ASSET_TAG                                              ,ENABLED},
+//	{ CMD_GET_MANAGEMENT_CONTROLLER_ID_STRING   ,ENABLED},
+//	{ CMD_SET_MANAGEMENT_CONTROLLER_ID_STRING   ,ENABLED},
+//	{CMD_SET_THERMAL_LIMIT                                        ,ENABLED},
+//	{CMD_GET_THERMAL_LIMIT                                        ,ENABLED},
+//	{CMD_GET_TEMPERATURE_READING                           ,ENABLED},
+//	{CMD_SET_DCMI_CONF_PARAMS                                ,ENABLED},
+//	{CMD_GET_DCMI_CONF_PARAMS                                ,ENABLED},
+//	{ 0                                                                             ,0          }
+
+//};
+
+//const NetFnCmds_T g_hpm [] = 
+//{
+//	//PICMG
+//	{CMD_GET_PICMG_PROPERTIES                       ,ENABLED},
+//	{CMD_GET_ADDR_INFO                             	,ENABLED},
+//	{CMD_GET_DEV_LOCATOR_REC_ID                 		,ENABLED},	
+//		
+//	//hpm
+//	{ CMD_GET_TARGET_UPLD_CAPABLITIES,              ENABLED},
+//	{ CMD_GET_COMPONENT_PROPERTIES,                 ENABLED},
+//	{ CMD_INITIATE_UPG_ACTION,                      ENABLED},
+//	{ CMD_QUERY_SELF_TEST_RESULTS,                  ENABLED},
+//	{ CMD_ABORT_FIRMWARE_UPGRADE,                   ENABLED},
+//	{ CMD_UPLOAD_FIRMWARE_BLOCK,                    ENABLED},
+//	{ CMD_FINISH_FIRMWARE_UPLOAD,                   ENABLED},
+//	{ CMD_GET_UPGRADE_STATUS,                       ENABLED},
+//	{ CMD_ACTIVATE_FIRMWARE,                        ENABLED},
+//	{ CMD_QUERY_ROLLBACK_STATUS,                    ENABLED},
+//	{ CMD_INITIATE_MANUAL_ROLLBACK,                 ENABLED},
+//	{ 0,                                            0      }
+
+//};
+
+//const NetFnCmds_T g_pnm [] =
+//{
+//	{CMD_PNM_OEM_GET_READING                                 ,ENABLED},
+//	{CMD_PNM_OEM_ME_POWER_STATE_CHANGE             ,ENABLED},
+//	{0                                                                             ,0           }
+
+//};
+
+//const NetFnCmds_T g_ssi [] =
+//{
+//	{ CMD_SSICB_GET_COMPUTE_BLADE_PROPERTIES,   ENABLED},
+//	{ CMD_SSICB_GET_ADDR_INFO,                  ENABLED},
+//	{ CMD_SSICB_PLATFORM_EVENT_MESSAGE,         ENABLED},
+//	{ CMD_SSICB_MODULE_BMI_CONTROL,             ENABLED},
+//	{ CMD_SSICB_MODULE_PAYLOAD_CONTROL,         ENABLED},
+//	{ CMD_SSICB_SET_SYSTEM_EVENT_LOG_POLICY,    ENABLED},
+//	{ CMD_SSICB_SET_MODULE_ACTIVATION_POLICY,   ENABLED},
+//	{ CMD_SSICB_GET_MODULE_ACTIVATION_POLICY,   ENABLED},
+//	{ CMD_SSICB_SET_MODULE_ACTIVATION,          ENABLED},
+//	{ CMD_SSICB_SET_POWER_LEVEL,                ENABLED},
+//	{ CMD_SSICB_GET_POWER_LEVEL,                ENABLED},
+//	{ CMD_SSICB_RENEGOTIATE_POWER,              ENABLED},
+//	{ CMD_SSICB_GET_SERVICE_INFO,               ENABLED},
+//	{ CMD_SSICB_GET_APPLET_PACKAGE_URI,         ENABLED},
+//	{ CMD_SSICB_GET_SERVICE_ENABLE_STATE,       ENABLED},
+//	{ CMD_SSICB_SET_SERVICE_ENABLE_STATE,       ENABLED},
+//	{ CMD_SSICB_SET_SERVICE_TICKET,             ENABLED},
+//	{ CMD_SSICB_STOP_SERVICE_SESSION,           ENABLED},
+//	{ 0,                                        0}
+//};
+
+const NetFnCmds_T g_oem[] =			//jimbo add
+{
+	{ CMD_EXAMPLE_0h   ,  ENABLED},
+    { CMD_EXAMPLE_1h   ,  ENABLED},
+    { CMD_EXAMPLE_1h   ,  ENABLED},
+    { CMD_EXAMPLE_2h   ,  ENABLED},
+    { CMD_EXAMPLE_3h   ,  ENABLED},
+    { CMD_EXAMPLE_4h   ,  ENABLED},
+    { CMD_EXAMPLE_5h   ,  ENABLED},
+    { CMD_EXAMPLE_6h   ,  ENABLED},
+    { CMD_EXAMPLE_7h   ,  ENABLED},
+    { CMD_EXAMPLE_8h   ,  ENABLED},
+    { CMD_EXAMPLE_9h   ,  ENABLED},
+    { CMD_EXAMPLE_ah   ,  ENABLED},
+    { CMD_EXAMPLE_bh   ,  ENABLED},
+    { CMD_EXAMPLE_ch   ,  ENABLED},
+    { CMD_EXAMPLE_dh   ,  ENABLED},
+    { CMD_EXAMPLE_eh   ,  ENABLED},
+    { CMD_EXAMPLE_fh   ,  ENABLED},
+    { CMD_EXAMPLE_10h   ,  ENABLED},
+    { CMD_EXAMPLE_11h   ,  ENABLED},
+    { CMD_EXAMPLE_12h   ,  ENABLED},
+    { CMD_EXAMPLE_13h   ,  ENABLED},
+    { CMD_EXAMPLE_14h   ,  ENABLED},
+    { CMD_EXAMPLE_15h   ,  ENABLED},
+    { CMD_EXAMPLE_16h   ,  ENABLED},
+    { CMD_EXAMPLE_17h   ,  ENABLED},
+    { CMD_EXAMPLE_18h   ,  ENABLED},
+    { CMD_EXAMPLE_19h   ,  ENABLED},
+    { CMD_EXAMPLE_1ah   ,  ENABLED},
+    { CMD_EXAMPLE_1bh   ,  ENABLED},
+    { CMD_EXAMPLE_1ch   ,  ENABLED},
+    { CMD_EXAMPLE_1dh   ,  ENABLED},
+    { CMD_EXAMPLE_1eh   ,  ENABLED},
+    { CMD_EXAMPLE_1fh   ,  ENABLED},
+    { CMD_EXAMPLE_20h   ,  ENABLED},
+    { CMD_EXAMPLE_21h   ,  ENABLED},
+    { CMD_EXAMPLE_22h   ,  ENABLED},
+    { CMD_EXAMPLE_23h   ,  ENABLED},
+    { CMD_EXAMPLE_24h   ,  ENABLED},
+    { CMD_EXAMPLE_25h   ,  ENABLED},
+    { CMD_EXAMPLE_26h   ,  ENABLED},
+    { CMD_EXAMPLE_27h   ,  ENABLED},
+    { CMD_EXAMPLE_28h   ,  ENABLED},
+    { CMD_EXAMPLE_29h   ,  ENABLED},
+    { CMD_EXAMPLE_2ah   ,  ENABLED},
+    { CMD_EXAMPLE_2bh   ,  ENABLED},
+    { CMD_EXAMPLE_2ch   ,  ENABLED},
+    { CMD_EXAMPLE_2dh   ,  ENABLED},
+    { CMD_EXAMPLE_2eh   ,  ENABLED},
+    { CMD_EXAMPLE_2fh   ,  ENABLED},
+    { CMD_EXAMPLE_30h   ,  ENABLED},
+    { CMD_EXAMPLE_31h   ,  ENABLED},
+    { CMD_EXAMPLE_32h   ,  ENABLED},
+    { CMD_EXAMPLE_33h   ,  ENABLED},
+    { CMD_EXAMPLE_34h   ,  ENABLED},
+    { CMD_EXAMPLE_35h   ,  ENABLED},
+    { CMD_EXAMPLE_36h   ,  ENABLED},
+    { CMD_EXAMPLE_37h   ,  ENABLED},
+    { CMD_EXAMPLE_38h   ,  ENABLED},
+    { CMD_EXAMPLE_39h   ,  ENABLED},
+    { CMD_EXAMPLE_3ah   ,  ENABLED},
+    { CMD_EXAMPLE_3bh   ,  ENABLED},
+    { CMD_EXAMPLE_3ch   ,  ENABLED},
+    { CMD_EXAMPLE_3dh   ,  ENABLED},
+    { CMD_EXAMPLE_3eh   ,  ENABLED},
+    { CMD_EXAMPLE_3fh   ,  ENABLED},
+    { CMD_EXAMPLE_40h   ,  ENABLED},
+    { CMD_EXAMPLE_41h   ,  ENABLED},
+    { CMD_EXAMPLE_42h   ,  ENABLED},
+    { CMD_EXAMPLE_43h   ,  ENABLED},
+    { CMD_EXAMPLE_44h   ,  ENABLED},
+    { CMD_EXAMPLE_45h   ,  ENABLED},
+    { CMD_EXAMPLE_46h   ,  ENABLED},
+    { CMD_EXAMPLE_47h   ,  ENABLED},
+    { CMD_EXAMPLE_48h   ,  ENABLED},
+    { CMD_EXAMPLE_49h   ,  ENABLED},
+    { CMD_EXAMPLE_4ah   ,  ENABLED},
+    { CMD_EXAMPLE_4bh   ,  ENABLED},
+    { CMD_EXAMPLE_4ch   ,  ENABLED},
+    { CMD_EXAMPLE_4dh   ,  ENABLED},
+    { CMD_EXAMPLE_4eh   ,  ENABLED},
+    { CMD_EXAMPLE_4fh   ,  ENABLED},
+    { CMD_EXAMPLE_50h   ,  ENABLED},
+    { CMD_EXAMPLE_51h   ,  ENABLED},
+    { CMD_EXAMPLE_52h   ,  ENABLED},
+    { CMD_EXAMPLE_53h   ,  ENABLED},
+    { CMD_EXAMPLE_54h   ,  ENABLED},
+    { CMD_EXAMPLE_55h   ,  ENABLED},
+    { CMD_EXAMPLE_56h   ,  ENABLED},
+    { CMD_EXAMPLE_57h   ,  ENABLED},
+    { CMD_EXAMPLE_58h   ,  ENABLED},
+    { CMD_EXAMPLE_59h   ,  ENABLED},
+    { CMD_EXAMPLE_5ah   ,  ENABLED},
+    { CMD_EXAMPLE_5bh   ,  ENABLED},
+    { CMD_EXAMPLE_5ch   ,  ENABLED},
+    { CMD_EXAMPLE_5dh   ,  ENABLED},
+    { CMD_EXAMPLE_5eh   ,  ENABLED},
+    { CMD_EXAMPLE_5fh   ,  ENABLED},
+    { CMD_EXAMPLE_60h   ,  ENABLED},
+    { CMD_EXAMPLE_61h   ,  ENABLED},
+    { CMD_EXAMPLE_62h   ,  ENABLED},
+    { CMD_EXAMPLE_63h   ,  ENABLED},
+    { CMD_EXAMPLE_64h   ,  ENABLED},
+    { CMD_EXAMPLE_65h   ,  ENABLED},
+    { CMD_EXAMPLE_66h   ,  ENABLED},
+    { CMD_EXAMPLE_67h   ,  ENABLED},
+    { CMD_EXAMPLE_68h   ,  ENABLED},
+    { CMD_EXAMPLE_69h   ,  ENABLED},
+    { CMD_EXAMPLE_6ah   ,  ENABLED},
+    { CMD_EXAMPLE_6bh   ,  ENABLED},
+    { CMD_EXAMPLE_6ch   ,  ENABLED},
+    { CMD_EXAMPLE_6dh   ,  ENABLED},
+    { CMD_EXAMPLE_6eh   ,  ENABLED},
+    { CMD_EXAMPLE_6fh   ,  ENABLED},
+    { CMD_EXAMPLE_70h   ,  ENABLED},
+    { CMD_EXAMPLE_71h   ,  ENABLED},
+    { CMD_EXAMPLE_72h   ,  ENABLED},
+    { CMD_EXAMPLE_73h   ,  ENABLED},
+    { CMD_EXAMPLE_74h   ,  ENABLED},
+    { CMD_EXAMPLE_75h   ,  ENABLED},
+    { CMD_EXAMPLE_76h   ,  ENABLED},
+    { CMD_EXAMPLE_77h   ,  ENABLED},
+    { CMD_EXAMPLE_78h   ,  ENABLED},
+    { CMD_EXAMPLE_79h   ,  ENABLED},
+    { CMD_EXAMPLE_7ah   ,  ENABLED},
+    { CMD_EXAMPLE_7bh   ,  ENABLED},
+    { CMD_EXAMPLE_7ch   ,  ENABLED},
+    { CMD_EXAMPLE_7dh   ,  ENABLED},
+    { CMD_EXAMPLE_7eh   ,  ENABLED},
+    { CMD_EXAMPLE_7fh   ,  ENABLED},
+/********* storlead oem command ***********/
+    { CMD_EXAMPLE_80h   ,  ENABLED},
+    { CMD_EXAMPLE_81h   ,  ENABLED},
+    { CMD_EXAMPLE_82h   ,  ENABLED},
+    { CMD_EXAMPLE_83h   ,  ENABLED},
+    { CMD_EXAMPLE_84h   ,  ENABLED},
+    { CMD_EXAMPLE_85h   ,  ENABLED},
+    { CMD_EXAMPLE_86h   ,  ENABLED},
+    { CMD_EXAMPLE_87h   ,  ENABLED},
+    { CMD_EXAMPLE_88h   ,  ENABLED},
+    { CMD_EXAMPLE_89h   ,  ENABLED},
+    { CMD_EXAMPLE_8ah   ,  ENABLED},
+    { CMD_EXAMPLE_8bh   ,  ENABLED},
+    { CMD_EXAMPLE_8ch   ,  ENABLED},
+    { CMD_EXAMPLE_8dh   ,  ENABLED},
+    { CMD_EXAMPLE_8eh   ,  ENABLED},
+    { CMD_EXAMPLE_8fh   ,  ENABLED},
+    { CMD_EXAMPLE_90h   ,  ENABLED},
+    { CMD_EXAMPLE_91h   ,  ENABLED},
+    { CMD_EXAMPLE_92h   ,  ENABLED},
+    { CMD_EXAMPLE_93h   ,  ENABLED},
+    { CMD_EXAMPLE_94h   ,  ENABLED},
+    { CMD_EXAMPLE_95h   ,  ENABLED},
+    { CMD_EXAMPLE_96h   ,  ENABLED},
+    { CMD_EXAMPLE_97h   ,  ENABLED},
+    { CMD_EXAMPLE_98h   ,  ENABLED},
+    { CMD_EXAMPLE_99h   ,  ENABLED},
+    { CMD_EXAMPLE_9ah   ,  ENABLED},
+    { CMD_EXAMPLE_9bh   ,  ENABLED},
+    { CMD_EXAMPLE_9ch   ,  ENABLED},
+    { CMD_EXAMPLE_9dh   ,  ENABLED},
+    { CMD_EXAMPLE_9eh   ,  ENABLED},
+    { CMD_EXAMPLE_9fh   ,  ENABLED},
+/************************************************************/
+    { CMD_EXAMPLE_a0h   ,  ENABLED},
+    { CMD_EXAMPLE_a1h   ,  ENABLED},
+    { CMD_EXAMPLE_a2h   ,  ENABLED},
+    { CMD_EXAMPLE_a3h   ,  ENABLED},
+    { CMD_EXAMPLE_a4h   ,  ENABLED},
+    { CMD_EXAMPLE_a5h   ,  ENABLED},
+    { CMD_EXAMPLE_a6h   ,  ENABLED},
+    { CMD_EXAMPLE_a7h   ,  ENABLED},
+    { CMD_EXAMPLE_a8h   ,  ENABLED},
+    { CMD_EXAMPLE_a9h   ,  ENABLED},
+    { CMD_EXAMPLE_aah   ,  ENABLED},
+    { CMD_EXAMPLE_abh   ,  ENABLED},
+    { CMD_EXAMPLE_ach   ,  ENABLED},
+    { CMD_EXAMPLE_adh   ,  ENABLED},
+    { CMD_EXAMPLE_aeh   ,  ENABLED},
+    { CMD_EXAMPLE_afh   ,  ENABLED},
+    { CMD_EXAMPLE_b0h   ,  ENABLED},
+    { CMD_EXAMPLE_b1h   ,  ENABLED},
+    { CMD_EXAMPLE_b2h   ,  ENABLED},
+    { CMD_EXAMPLE_b3h   ,  ENABLED},
+    { CMD_EXAMPLE_b4h   ,  ENABLED},
+    { CMD_EXAMPLE_b5h   ,  ENABLED},
+    { CMD_EXAMPLE_b6h   ,  ENABLED},
+    { CMD_EXAMPLE_b7h   ,  ENABLED},
+    { CMD_EXAMPLE_b8h   ,  ENABLED},
+    { CMD_EXAMPLE_b9h   ,  ENABLED},
+    { CMD_EXAMPLE_bah   ,  ENABLED},
+    { CMD_EXAMPLE_bbh   ,  ENABLED},
+    { CMD_EXAMPLE_bch   ,  ENABLED},
+    { CMD_EXAMPLE_bdh   ,  ENABLED},
+    { CMD_EXAMPLE_beh   ,  ENABLED},
+    { CMD_EXAMPLE_bfh   ,  ENABLED},
+    { CMD_EXAMPLE_c0h   ,  ENABLED},
+    { CMD_EXAMPLE_c1h   ,  ENABLED},
+    { CMD_EXAMPLE_c2h   ,  ENABLED},
+    { CMD_EXAMPLE_c3h   ,  ENABLED},
+    { CMD_EXAMPLE_c4h   ,  ENABLED},
+    { CMD_EXAMPLE_c5h   ,  ENABLED},
+    { CMD_EXAMPLE_c6h   ,  ENABLED},
+    { CMD_EXAMPLE_c7h   ,  ENABLED},
+    { CMD_EXAMPLE_c8h   ,  ENABLED},
+    { CMD_EXAMPLE_c9h   ,  ENABLED},
+    { CMD_EXAMPLE_cah   ,  ENABLED},
+    { CMD_EXAMPLE_cbh   ,  ENABLED},
+    { CMD_EXAMPLE_cch   ,  ENABLED},
+    { CMD_EXAMPLE_cdh   ,  ENABLED},
+    { CMD_EXAMPLE_ceh   ,  ENABLED},
+    { CMD_EXAMPLE_cfh   ,  ENABLED},
+    { CMD_EXAMPLE_d0h   ,  ENABLED},
+    { CMD_EXAMPLE_d1h   ,  ENABLED},
+    { CMD_EXAMPLE_d2h   ,  ENABLED},
+    { CMD_EXAMPLE_d3h   ,  ENABLED},
+    { CMD_EXAMPLE_d4h   ,  ENABLED},
+    { CMD_EXAMPLE_d5h   ,  ENABLED},
+    { CMD_EXAMPLE_d6h   ,  ENABLED},
+    { CMD_EXAMPLE_d7h   ,  ENABLED},
+    { CMD_EXAMPLE_d8h   ,  ENABLED},
+    { CMD_EXAMPLE_d9h   ,  ENABLED},
+    { CMD_EXAMPLE_dah   ,  ENABLED},
+    { CMD_EXAMPLE_dbh   ,  ENABLED},
+    { CMD_EXAMPLE_dch   ,  ENABLED},
+    { CMD_EXAMPLE_ddh   ,  ENABLED},
+    { CMD_EXAMPLE_deh   ,  ENABLED},
+    { CMD_EXAMPLE_dfh   ,  ENABLED},
+    { CMD_EXAMPLE_e0h   ,  ENABLED},
+    { CMD_EXAMPLE_e1h   ,  ENABLED},
+    { CMD_EXAMPLE_e2h   ,  ENABLED},
+    { CMD_EXAMPLE_e3h   ,  ENABLED},
+    { CMD_EXAMPLE_e4h   ,  ENABLED},
+    { CMD_EXAMPLE_e5h   ,  ENABLED},
+    { CMD_EXAMPLE_e6h   ,  ENABLED},
+    { CMD_EXAMPLE_e7h   ,  ENABLED},
+    { CMD_EXAMPLE_e8h   ,  ENABLED},
+    { CMD_EXAMPLE_e9h   ,  ENABLED},
+    { CMD_EXAMPLE_eah   ,  ENABLED},
+    { CMD_EXAMPLE_ebh   ,  ENABLED},
+    { CMD_EXAMPLE_ech   ,  ENABLED},
+    { CMD_EXAMPLE_edh   ,  ENABLED},
+    { CMD_EXAMPLE_eeh   ,  ENABLED},
+    { CMD_EXAMPLE_efh   ,  ENABLED},
+    { CMD_EXAMPLE_f0h   ,  ENABLED},
+    { CMD_EXAMPLE_f1h   ,  ENABLED},
+    { CMD_EXAMPLE_f2h   ,  ENABLED},
+    { CMD_EXAMPLE_f3h   ,  ENABLED},
+    { CMD_EXAMPLE_f4h   ,  ENABLED},
+    { CMD_EXAMPLE_f5h   ,  ENABLED},
+    { CMD_EXAMPLE_f6h   ,  ENABLED},
+    { CMD_EXAMPLE_f7h   ,  ENABLED},
+    { CMD_EXAMPLE_f8h   ,  ENABLED},
+    { CMD_EXAMPLE_f9h   ,  ENABLED},
+    { CMD_EXAMPLE_fah   ,  ENABLED},
+    { CMD_EXAMPLE_fbh   ,  ENABLED},
+    { CMD_EXAMPLE_fch   ,  ENABLED},
+    { CMD_EXAMPLE_fdh   ,  ENABLED},
+    { CMD_EXAMPLE_feh   ,  ENABLED},
+    { CMD_EXAMPLE_ffh   ,  ENABLED},
+	{0,											0}
+};
+
+NETFNTable_T Netfntbl [] = 
+{
+	{ NETFN_APP,        GRPEXT_NA,      g_App       },
+	{ NETFN_CHASSIS,    GRPEXT_NA,      g_Chassis   },
+	{ NETFN_BRIDGE,     GRPEXT_NA,      g_Bridge    },
+	{ NETFN_SENSOR,     GRPEXT_NA,      g_Sensor    },
+	{ NETFN_STORAGE,    GRPEXT_NA,      g_Storage   },
+//	{ NETFN_TRANSPORT,  GRPEXT_NA,      g_Transport },
+//	{ NETFN_AMI,        GRPEXT_NA,      g_AMI       },
+//	{ NETFN_OPMA1,      GRPEXT_NA,      g_opma1     },
+//	{ NETFN_OPMA2,      GRPEXT_NA,      g_opma2     },
+//	{ NETFN_APML,       GRPEXT_NA,      g_apml      },
+//	{ NETFN_HPM,        GRPEXT_HPM,     g_hpm       },	//jimbo add picmg
+//	{ NETFN_DCMI,       GRPEXT_DCMI,    g_dcmi      },
+//	{ NETFN_PNM,        GRPEXT_NA,      g_pnm       },
+//	{ NETFN_SSI,        GRPEXT_SSI,     g_ssi       },
+	{ NETFN_OEM,        GRPEXT_NA,     	g_oem       },	//jimbo add
+//	{ NETFN_PICMG,      GRPEXT_PICMG,	g_picmg		}, //jimbo add
+};
+
+/*
+*@fn GetCommanEnabledStatus
+*@brief This function finds whether the command is enabled by the OEM
+*@param NetFunction - Pointer to the structure of NetFnCmds_T
+*@param Cmd - Command Number
+*@return Returns 0 on Enabled commands
+*            Returns -1 on non-Enabled commands
+*/
+int GetCommanEnabledStatus(NETFNTable_T *NetFuntbl,uint8_t Cmd)
+{
+	int i=0;
+
+	while(NetFuntbl->NetFunction[i].Status != 0)
+	{
+		if(NetFuntbl->NetFunction[i].CmdNum == Cmd)
+		{
+			if(NetFuntbl->NetFunction[i].Status == ENABLED)
+			{
+				return 0;
+			}
+			else
+			{
+				return -1;
+			}
+		}
+		i++;
+	}
+	return -1;
+}
+
+/*
+*@fn IsCommandEnabled
+*@brief This function gives the status of Command
+*@param NetFn         - Net Function 
+*@param GroupExtnCode - Group Extension Code
+*@param Cmd           - Command Number
+*@return Returns 0 if the command is Enabled
+*            Returns -1 if the command is Disabled
+*/
+int IsCommandEnabled(uint8_t NetFn,uint8_t* GroupExtnCode,uint8_t Cmd)
+{
+	int i=0;
+
+	while(i<(sizeof(Netfntbl)/sizeof(NETFNTable_T)))
+	{
+		if(NetFn == Netfntbl[i].NetFn)
+		{
+			if (Netfntbl[i].NetFn == NETFN_DCMI)
+			{
+				//printf("---> i=%d, NetFn = %#x\n", i, Netfntbl[i].NetFn);
+				   if(GroupExtnCode != NULL)
+					{
+					  if (Netfntbl[i].GroupExtCode == *GroupExtnCode)
+					   {
+						  //printf("---> i = %d, GroupExtnCode = %#x\n", i, *GroupExtnCode);
+						 break;
+						}
+					 }
+			}
+			else
+			{
+				//printf("---> netfn log\n");
+				break;
+			}
+		}
+		i++;
+	}
+
+	if(i != sizeof(Netfntbl)/sizeof(NETFNTable_T))
+	{
+		if(GetCommanEnabledStatus((NETFNTable_T*)&Netfntbl[i],Cmd) < 0)
+		{
+			printf("---> invalid command\n");
+			return -1;
+		}
+	}
+	else
+	{
+		printf("---> not find netfn\n");
+		return -1;
+	}
+
+	return 0;
+}
+
+

+ 57 - 0
app/bmc/msghndlr/cmdselect.h

@@ -0,0 +1,57 @@
+/*
+* Brief:	The header file of cmdselect.h.
+			Get cmd is enable or disable.
+* Author:	Jimbo_Zhang@outlook.com
+* Date:		2019-9-13, the Mid-autumn Festival;
+*/
+
+#ifndef __CMD_SELECT_H__
+#define __CMD_SELECT_H__
+
+#include <stdio.h>
+#include <stdint.h>
+
+#define NETFN_SSI       0x2c
+#define NETFN_DCMI      0x2c
+#define NETFN_HPM       0x2c
+
+#define NETFN_PNM       0x30
+#define NETFN_APML      0x36
+
+/*CMM Specific Netfn and GrpExt*/
+#define NETFN_CMM		0x38
+#define NETFN_OBSM		0x2C
+#define GRPEXT_OBSM		0x02
+
+#define GRPEXT_NA       0x00
+#define GRPEXT_HPM      0x00
+#define GRPEXT_SSI      0x02
+#define GRPEXT_DCMI     0xDC
+//#define GRPEXT_PICMG		0x00
+
+typedef struct
+{
+    uint8_t CmdNum;
+    uint8_t Status;
+}NetFnCmds_T;
+
+typedef struct
+{
+    uint8_t NetFn;
+    uint8_t GroupExtCode;
+    const NetFnCmds_T *NetFunction;
+}NETFNTable_T;
+
+/*
+*@fn IsCommandEnabled
+*@brief This function gives the status of Command
+*@param NetFn         - Net Function 
+*@param GroupExtnCode - Group Extension Code
+*@param Cmd           - Command Number
+*@return Returns 0 if the command is Enabled
+*            Returns -1 if the command is Disabled
+*/
+int IsCommandEnabled(uint8_t NetFn, uint8_t* GroupExtnCode,uint8_t Cmd);
+
+
+#endif

+ 7 - 0
app/bmc/readme.txt

@@ -0,0 +1,7 @@
+
+
+1. Add sensors
+	- sensor_driveer.c		Add new driver
+	- sensor_sdr.c			Add new SDR
+	- main.h				SENSOR_NUMBERS = ?
+

+ 426 - 0
app/bmc/sensor_driver.c

@@ -0,0 +1,426 @@
+/*
+ * Implement sensor driver function in here.
+ * Every sensor include init,write,read function.
+ * Author:Jimbo
+ */
+
+#include <stdint.h>
+#include <stdio.h>
+#include "sensor_tbl.h"
+#include "hal_interface_api.h"
+#include "linux/fcntl.h"
+
+/* 
+ * sensor number: 1
+ * sensor name: +12V
+ * brief: ltc4280
+ */
+int sensor_1_init(void)
+{
+	return 0;	
+}
+
+int sensor_1_write(void)
+{
+	return 0;
+}
+
+int sensor_1_read(uint8_t *reading)
+{
+	uint8_t buf = 5;
+	int fd = open("/dev/i2c3", O_RDWR);
+	stm32_i2c_master_write(fd, 0xAA, &buf, 1);
+	stm32_i2c_master_read(fd, 0xAA, &buf, 1);
+	close(fd);
+	//printf("read sensor 1: %#x!\n", buf);
+	*reading = buf;
+	return 0;
+}
+
+/* 
+ * sensor number: 2
+ * sensor name: +12V_Current
+ * brief:  ltc4280
+ */
+int sensor_2_init(void)
+{
+//	log("init sensor 2!\r\n");
+	return 0;	
+}
+
+int sensor_2_write(void)
+{
+//	log("write sensor 2!\r\n");
+	return 0;
+}
+
+int sensor_2_read(uint8_t *reading)
+{
+	uint8_t buf = 4;
+	int fd = open("/dev/i2c3", O_RDWR);
+	stm32_i2c_master_write(fd, 0xAA, &buf, 1);
+	stm32_i2c_master_read(fd, 0xAA, &buf, 1);
+	close(fd);
+	*reading = buf;
+	return 0;
+}
+
+/* 
+ * sensor number: 3
+ * sensor name: Temp_Board
+ * brief: G780 local 
+ */
+int sensor_3_init(void)
+{
+//	log("init sensor 2!\r\n");
+	return 0;	
+}
+
+int sensor_3_write(void)
+{
+//	log("write sensor 2!\r\n");
+	return 0;
+}
+
+int sensor_3_read(uint8_t *reading)
+{
+	uint8_t buf = 0;
+	int fd = open("/dev/i2c3", O_RDWR);
+	stm32_i2c_master_write(fd, 0x98, &buf, 1);
+	stm32_i2c_master_read(fd, 0x98, &buf, 1);
+	close(fd);
+	*reading = buf;
+	return 0;
+}
+
+
+/* 
+ * sensor number: 4
+ * sensor name: Temp_FPGA
+ * brief: G780 remote 
+ */
+int sensor_4_init(void)
+{
+//	log("init sensor 2!\r\n");
+	return 0;	
+}
+
+int sensor_4_write(void)
+{
+//	log("write sensor 2!\r\n");
+	return 0;
+}
+
+int sensor_4_read(uint8_t *reading)
+{
+	uint8_t buf = 1;
+	int fd = open("/dev/i2c3", O_RDWR);
+	stm32_i2c_master_write(fd, 0x98, &buf, 1);
+	stm32_i2c_master_read(fd, 0x98, &buf, 1);
+	close(fd);
+	*reading = buf;
+	return 0;
+}
+
+/* 
+ * sensor number: 5
+ * sensor name: +1.5V
+ * brief: adc_ch1
+ */
+int sensor_5_init(void)
+{
+	return 0;	
+}
+
+int sensor_5_write(void)
+{
+	return 0;
+}
+
+int sensor_5_read(uint8_t *reading)
+{
+	uint16_t buf;
+	stm32_adc_get_value(1, &buf);
+	*reading = buf>>4;
+	return 0;
+}
+
+/* 
+ * sensor number: 6
+ * sensor name: +0.75V
+ * brief: adc_ch2
+ */
+int sensor_6_init(void)
+{
+	return 0;	
+}
+
+int sensor_6_write(void)
+{
+	return 0;
+}
+
+int sensor_6_read(uint8_t *reading)
+{
+	uint16_t buf;
+	stm32_adc_get_value(2, &buf);
+	*reading = buf>>4;
+	return 0;
+}
+
+/* 
+ * sensor number: 7
+ * sensor name: +1.8V
+ * brief: adc_ch3
+ */
+int sensor_7_init(void)
+{
+	return 0;	
+}
+
+int sensor_7_write(void)
+{
+	return 0;
+}
+
+int sensor_7_read(uint8_t *reading)
+{
+	uint16_t buf;
+	stm32_adc_get_value(3, &buf);
+	*reading = buf>>4;
+	return 0;
+}
+
+/* 
+ * sensor number: 8
+ * sensor name: +1.2V
+ * brief: adc_ch4
+ */
+int sensor_8_init(void)
+{
+	return 0;	
+}
+
+int sensor_8_write(void)
+{
+	return 0;
+}
+
+int sensor_8_read(uint8_t *reading)
+{
+	uint16_t buf;
+	stm32_adc_get_value(4, &buf);
+	*reading = buf>>4;
+	return 0;
+}
+
+/* 
+ * sensor number: 9
+ * sensor name: +1.0V
+ * brief: adc_ch5
+ */
+int sensor_9_init(void)
+{
+	return 0;	
+}
+
+int sensor_9_write(void)
+{
+	return 0;
+}
+
+int sensor_9_read(uint8_t *reading)
+{
+	uint16_t buf;
+	stm32_adc_get_value(5, &buf);
+	*reading = buf>>4;
+	return 0;
+}
+
+/* 
+ * sensor number: 10
+ * sensor name: +2.5V
+ * brief: adc_ch6
+ */
+int sensor_10_init(void)
+{
+	return 0;	
+}
+
+int sensor_10_write(void)
+{
+	return 0;
+}
+
+int sensor_10_read(uint8_t *reading)
+{
+	uint16_t buf;
+	stm32_adc_get_value(6, &buf);
+	*reading = buf>>4;
+	return 0;
+}
+
+/* 
+ * sensor number: 11
+ * sensor name: +3.3V
+ * brief: adc_ch7
+ */
+int sensor_11_init(void)
+{
+	return 0;	
+}
+
+int sensor_11_write(void)
+{
+	return 0;
+}
+
+int sensor_11_read(uint8_t *reading)
+{
+	uint16_t buf;
+	stm32_adc_get_value(7, &buf);
+	*reading = buf>>4;
+	return 0;
+}
+
+sensor_tbl_t sensor_tbl[]=
+{
+	{
+		1,		//sensor number
+		0,		//power on delay
+		0,		//reset delay
+		3,		//Monitor interval
+		MonitorOnStandby,	//monitor states
+		sensor_1_read,	//read function
+		sensor_1_write,	//write functon
+		sensor_1_init,	//init function
+	},
+	
+	{
+		2,		//sensor number
+		0,		//power on delay
+		0,		//reset delay
+		3,		//Monitor interval
+		MonitorOnStandby,	//monitor states
+		sensor_2_read,
+		sensor_2_write,
+		sensor_2_init,
+	},
+	
+	{	
+		3,		//sensor number
+		0,		//power on delay
+		0,		//reset delay
+		3,		//Monitor interval
+		MonitorOnStandby,	//monitor states
+		sensor_3_read,
+		sensor_3_write,
+		sensor_3_init,
+	},
+	
+	{	
+		4,		//sensor number
+		0,		//power on delay
+		0,		//reset delay
+		3,		//Monitor interval
+		MonitorOnStandby,	//monitor states
+		sensor_4_read,
+		sensor_4_write,
+		sensor_4_init,
+	},
+	
+	{	
+		5,		//sensor number
+		0,		//power on delay
+		0,		//reset delay
+		3,		//Monitor interval
+		MonitorOnStandby,	//monitor states
+		sensor_5_read,
+		sensor_5_write,
+		sensor_5_init,
+	},
+	
+	{	
+		6,		//sensor number
+		0,		//power on delay
+		0,		//reset delay
+		3,		//Monitor interval
+		MonitorOnStandby,	//monitor states
+		sensor_6_read,
+		sensor_6_write,
+		sensor_6_init,
+	},
+	
+	{	
+		7,		//sensor number
+		0,		//power on delay
+		0,		//reset delay
+		3,		//Monitor interval
+		MonitorOnStandby,	//monitor states
+		sensor_7_read,
+		sensor_7_write,
+		sensor_7_init,
+	},
+	
+	{	
+		8,		//sensor number
+		0,		//power on delay
+		0,		//reset delay
+		3,		//Monitor interval
+		MonitorOnStandby,	//monitor states
+		sensor_8_read,
+		sensor_8_write,
+		sensor_8_init,
+	},
+	
+	{	
+		9,		//sensor number
+		0,		//power on delay
+		0,		//reset delay
+		3,		//Monitor interval
+		MonitorOnStandby,	//monitor states
+		sensor_9_read,
+		sensor_9_write,
+		sensor_9_init,
+	},
+	
+	{	
+		10,		//sensor number
+		0,		//power on delay
+		0,		//reset delay
+		3,		//Monitor interval
+		MonitorOnStandby,	//monitor states
+		sensor_10_read,
+		sensor_10_write,
+		sensor_10_init,
+	},
+	
+	{	
+		11,		//sensor number
+		0,		//power on delay
+		0,		//reset delay
+		3,		//Monitor interval
+		MonitorOnStandby,	//monitor states
+		sensor_11_read,
+		sensor_11_write,
+		sensor_11_init,
+	}
+	
+};
+
+
+sensor_tbl_t *getSensorDev(uint8_t sensorNum)
+{
+	uint16_t i = 0;
+	uint16_t sensorCnt=0;
+	sensorCnt = sizeof(sensor_tbl)/sizeof(sensor_tbl_t);
+	
+	for(i=0; i<sensorCnt; i++)
+	{
+		if(sensor_tbl[i].sensor_number == sensorNum)	
+			return &sensor_tbl[i];
+	}
+	
+	printf("Error: Can't find sensor, sensorNum = %#x\r\n", sensorNum);
+	return NULL;
+}

+ 1133 - 0
app/bmc/sensor_sdr.c

@@ -0,0 +1,1133 @@
+/*
+ * config sensor sdr in here.
+ * Author:Jimbo
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include "com_IPMI_SDRRecord.h"
+
+/*
+ * sdr table
+ */
+const MgmtCtrlrDevLocator_T bmc_sdr = {
+		/* SDR Record Header */
+		{
+			0x01,	//Record ID
+			0x51,	//SDR Version
+			MGMT_CTRL_DEV_LOCATOR_SDR_REC,	//Record Type
+			11+MAX_ID_STR_LEN,	//Record Length = 11+string length
+		},
+		/* Record Key Bytes*/            
+		0x20,                        /* Slave address - 0x20 Primary BMC */
+		0x00,                        /* ChannelNumber - 0x00 Primary BMC */
+											
+		/* Record Body Bytes*/
+		0x0,       /* power state notification         */
+		0xff,       /* Device Capablities               */
+		{0,    0,   0,},                          /* RESERVED                         */
+		0x0,                   /* Entity ID                        */
+		0x1,                 /* Entity Instance                  */
+		0x0,                      /* OEM                              */
+		0xc0 +MAX_ID_STR_LEN,   /* ID String Type / Length Code     */
+		"STM32F429_BMC"
+	};
+ 
+	
+/***************** Attation ************************
+* <Record ID>,	<Sensor Number>  must be modified!!!
+**************************************************/
+	
+const FullSensorRec_T full_sdr_tbl[] = {
+/*
+ * sensor number: 1
+ * sensor name:	+12V
+ * brief:	ltc4280
+ */
+	{
+		/* SDR Record Header */
+		{
+			0x02,	//Record ID
+			0x51,	//SDR Version
+			FULL_SDR_REC,	//Record Type
+			43+MAX_ID_STR_LEN,	//Record Length = 43+string length
+		},
+		/* Record Key Bytes */
+		0x20,	//Sensor Owner ID
+		0x0,	//Sensor Owner LUN
+		0x01,	//Sensor Number
+		/* Record Body Bytes */
+		0x7,	//Entity ID
+		0x1,	//Entity Instance	
+		0x7f,	//Entity Initialization
+		0x68,	//Sensor Capabilities
+		0x02,	//Sensor Type: 01-temperature, 02-voltage, 03-current, 04-fan
+		0x01,	//Event / Reading Type
+		0x7a95,	//Lower Threshold Reading Mask
+		0x7a95, //Upper Threshold Reading Mask
+		0x3f3f,	//Settable / Readable Threshold Mask
+
+		/*
+			[7:6] - Analog (numeric) Data Format**
+			00b = unsigned
+			01b = 1's complement(singed)
+			10b = 2's complement(singed)
+			11b = Does not return analog (numeric) reading
+			[5:3] - Rate unit
+			000b = none
+			001b = per µS
+			010b = per ms
+			011b = per s
+			100b = per minute
+			101b = per hour
+			110b = per day
+			111b = reserved
+			[2:1] - Modifier unit
+			00b = none
+			01b = Basic Unit / Modifier Unit
+			10b = Basic Unit * Modifier Unit
+			11b = reserved
+			[0] - Percentage 0b = no, 1b = yes
+		*/
+		(0x0<<6)+(0x0<<3)+(0x0<<1)+0x0,	//Sensor Units 1
+		/*
+			0 unspecified 
+			1 degrees C 
+			2 degrees F 
+			3 degrees K 
+			4 Volts 
+			5 Amps
+		*/
+		0x4,	//Sensor Units 2 - Base Unit
+		0x0,	//Sensor Units 3 - Modifier Unit
+		0x0,	//Linerization
+		/* M = 0x12e x 10^-4 */
+		0x3d,	//M_LSB
+		/*
+			[7:6] - M: MS 2 bits
+			[5:0] - Tolerance: 6 bits, unsigned (Tolerance in +/- ½ raw counts)
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//M,Tolerance
+		0x0,	//B_LSB
+		/*
+			[7:6] - B: MS 2 bits
+			Unsigned, 10-bit Basic Sensor Accuracy in 1/100 percent scaled up by unsigned
+			Accuracy exponent:
+			[5:0] - Accuracy: LS 6 bits
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//B,Accuracy
+		((0x0>>2)&0xF0)+(0x0&0x0C)+0x0,	//Accuracy,Accuracy exponent
+		(uint8_t)(0xfd<<4)+(0x0&0x0F),		//R exponent,B exponent
+		0x0,	//Analog Characteristics Flags
+		0x7f,	//Nominal Reading
+		0xff,	//Normal Maximum
+		0x00,	//Normal Minimum
+		0xff,	//Sensor Maximum Reading
+		0x00,	//Sensor Minimum Reading
+		0xff,	//Upper Non-Recoverable Threshold
+		0xff,	//Upper Critical Threshold
+		0xff,	//Upper Non-Critical Threshold
+		0x00,	//Lower Non-Recoverable Threshold
+		0x00,	//Lower Critical Threshold
+		0x00,	//Lower Non-Critical threshold
+		0x0,	//Positive - threshold Hysteresis value
+		0x0,	//Negative - threshold Hysteresis value
+		0x0,	//Reserved
+		0x0,	//Reserved
+		0x0,	//OEM
+		0xC0+MAX_ID_STR_LEN,	//ID String Type / Length Code
+		"+12V"
+	},
+/*
+ * sensor number: 2
+ * sensor name:	+12V_Current
+ * brief:	ltc4280
+ */
+	{
+		/* SDR Record Header */
+		{
+			0x03,	//Record ID
+			0x51,	//SDR Version
+			FULL_SDR_REC,	//Record Type
+			43+MAX_ID_STR_LEN,	//Record Length = 43+string length
+		},
+		/* Record Key Bytes */
+		0x20,	//Sensor Owner ID
+		0x0,	//Sensor Owner LUN
+		0x02,	//Sensor Number
+		/* Record Body Bytes */
+		0x7,	//Entity ID
+		0x1,	//Entity Instance	
+		0x7f,	//Entity Initialization
+		0x68,	//Sensor Capabilities
+		0x02,	//Sensor Type: 01-temperature, 02-voltage, 03-current, 04-fan
+		0x01,	//Event / Reading Type
+		0x7a95,	//Lower Threshold Reading Mask
+		0x7a95, //Upper Threshold Reading Mask
+		0x3f3f,	//Settable / Readable Threshold Mask
+
+		/*
+			[7:6] - Analog (numeric) Data Format**
+			00b = unsigned
+			01b = 1's complement(singed)
+			10b = 2's complement(singed)
+			11b = Does not return analog (numeric) reading
+			[5:3] - Rate unit
+			000b = none
+			001b = per µS
+			010b = per ms
+			011b = per s
+			100b = per minute
+			101b = per hour
+			110b = per day
+			111b = reserved
+			[2:1] - Modifier unit
+			00b = none
+			01b = Basic Unit / Modifier Unit
+			10b = Basic Unit * Modifier Unit
+			11b = reserved
+			[0] - Percentage 0b = no, 1b = yes
+		*/
+		(0x0<<6)+(0x0<<3)+(0x0<<1)+0x0,	//Sensor Units 1
+		/*
+			0 unspecified 
+			1 degrees C 
+			2 degrees F 
+			3 degrees K 
+			4 Volts 
+			5 Amps
+		*/
+		0x5,	//Sensor Units 2 - Base Unit
+		0x0,	//Sensor Units 3 - Modifier Unit
+		0x0,	//Linerization
+		/* M = 0x12e x 10^-4 */
+		0x2e,	//M_LSB
+		/*
+			[7:6] - M: MS 2 bits
+			[5:0] - Tolerance: 6 bits, unsigned (Tolerance in +/- ½ raw counts)
+		*/
+		((0x12e>>2)&0xC0)+(0x0&0x3F),	//M,Tolerance
+		0x0,	//B_LSB
+		/*
+			[7:6] - B: MS 2 bits
+			Unsigned, 10-bit Basic Sensor Accuracy in 1/100 percent scaled up by unsigned
+			Accuracy exponent:
+			[5:0] - Accuracy: LS 6 bits
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//B,Accuracy
+		((0x0>>2)&0xF0)+(0x0&0x0C)+0x0,	//Accuracy,Accuracy exponent
+		(uint8_t)(0xfc<<4)+(0x0&0x0F),		//R exponent,B exponent
+		0x0,	//Analog Characteristics Flags
+		0x7f,	//Nominal Reading
+		0xff,	//Normal Maximum
+		0x00,	//Normal Minimum
+		0xff,	//Sensor Maximum Reading
+		0x00,	//Sensor Minimum Reading
+		0xff,	//Upper Non-Recoverable Threshold
+		0xff,	//Upper Critical Threshold
+		0xff,	//Upper Non-Critical Threshold
+		0x00,	//Lower Non-Recoverable Threshold
+		0x00,	//Lower Critical Threshold
+		0x00,	//Lower Non-Critical threshold
+		0x0,	//Positive - threshold Hysteresis value
+		0x0,	//Negative - threshold Hysteresis value
+		0x0,	//Reserved
+		0x0,	//Reserved
+		0x0,	//OEM
+		0xC0+MAX_ID_STR_LEN,	//ID String Type / Length Code
+		"+12V_Current"
+	},
+	
+/*
+ * sensor number: 3
+ * sensor name:	Temp_Board
+ * brief:	G780 local
+ */
+	{
+		/* SDR Record Header */
+		{
+			0x04,	//Record ID
+			0x51,	//SDR Version
+			FULL_SDR_REC,	//Record Type
+			43+MAX_ID_STR_LEN,	//Record Length = 43+string length
+		},
+		/* Record Key Bytes */
+		0x20,	//Sensor Owner ID
+		0x0,	//Sensor Owner LUN
+		0x03,	//Sensor Number
+		/* Record Body Bytes */
+		0x7,	//Entity ID
+		0x1,	//Entity Instance	
+		0x7f,	//Entity Initialization
+		0x68,	//Sensor Capabilities
+		0x01,	//Sensor Type: 01-temperature, 02-voltage, 03-current, 04-fan
+		0x01,	//Event / Reading Type
+		0x7a95,	//Lower Threshold Reading Mask
+		0x7a95, //Upper Threshold Reading Mask
+		0x3f3f,	//Settable / Readable Threshold Mask
+
+		/*
+			[7:6] - Analog (numeric) Data Format**
+			00b = unsigned
+			01b = 1's complement(singed)
+			10b = 2's complement(singed)
+			11b = Does not return analog (numeric) reading
+			[5:3] - Rate unit
+			000b = none
+			001b = per µS
+			010b = per ms
+			011b = per s
+			100b = per minute
+			101b = per hour
+			110b = per day
+			111b = reserved
+			[2:1] - Modifier unit
+			00b = none
+			01b = Basic Unit / Modifier Unit
+			10b = Basic Unit * Modifier Unit
+			11b = reserved
+			[0] - Percentage 0b = no, 1b = yes
+		*/
+		(0x2<<6)+(0x0<<3)+(0x0<<1)+0x0,	//Sensor Units 1
+		/*
+			0 unspecified 
+			1 degrees C 
+			2 degrees F 
+			3 degrees K 
+			4 Volts 
+			5 Amps
+		*/
+		0x1,	//Sensor Units 2 - Base Unit
+		0x0,	//Sensor Units 3 - Modifier Unit
+		0x0,	//Linerization
+		0x1,	//M_LSB
+		/*
+			[7:6] - M: MS 2 bits
+			[5:0] - Tolerance: 6 bits, unsigned (Tolerance in +/- ½ raw counts)
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//M,Tolerance
+		0x0,	//B_LSB
+		/*
+			[7:6] - B: MS 2 bits
+			Unsigned, 10-bit Basic Sensor Accuracy in 1/100 percent scaled up by unsigned
+			Accuracy exponent:
+			[5:0] - Accuracy: LS 6 bits
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//B,Accuracy
+		((0x0>>2)&0xF0)+(0x0&0x0C)+0x0,	//Accuracy,Accuracy exponent
+		(0x0<<4)+(0x0&0x0F),		//R exponent,B exponent
+		0x0,	//Analog Characteristics Flags
+		0x7f,	//Nominal Reading
+		0x7f,	//Normal Maximum
+		0x80,	//Normal Minimum
+		0x7f,	//Sensor Maximum Reading
+		0x80,	//Sensor Minimum Reading
+		0x7f,	//Upper Non-Recoverable Threshold
+		0x7f,	//Upper Critical Threshold
+		0x7f,	//Upper Non-Critical Threshold
+		0x80,	//Lower Non-Recoverable Threshold
+		0x80,	//Lower Critical Threshold
+		0x80,	//Lower Non-Critical threshold
+		0x0,	//Positive - threshold Hysteresis value
+		0x0,	//Negative - threshold Hysteresis value
+		0x0,	//Reserved
+		0x0,	//Reserved
+		0x0,	//OEM
+		0xC0+MAX_ID_STR_LEN,	//ID String Type / Length Code
+		"Temp_Board"
+	},
+
+	/*
+ * sensor number: 4
+ * sensor name:	Temp_FPGA
+ * brief:	G780 remote
+ */
+	{
+		/* SDR Record Header */
+		{
+			0x05,	//Record ID
+			0x51,	//SDR Version
+			FULL_SDR_REC,	//Record Type
+			43+MAX_ID_STR_LEN,	//Record Length = 43+string length
+		},
+		/* Record Key Bytes */
+		0x20,	//Sensor Owner ID
+		0x0,	//Sensor Owner LUN
+		0x04,	//Sensor Number
+		/* Record Body Bytes */
+		0x7,	//Entity ID
+		0x1,	//Entity Instance	
+		0x7f,	//Entity Initialization
+		0x68,	//Sensor Capabilities
+		0x01,	//Sensor Type: 01-temperature, 02-voltage, 03-current, 04-fan
+		0x01,	//Event / Reading Type
+		0x7a95,	//Lower Threshold Reading Mask
+		0x7a95, //Upper Threshold Reading Mask
+		0x3f3f,	//Settable / Readable Threshold Mask
+
+		/*
+			[7:6] - Analog (numeric) Data Format**
+			00b = unsigned
+			01b = 1's complement(singed)
+			10b = 2's complement(singed)
+			11b = Does not return analog (numeric) reading
+			[5:3] - Rate unit
+			000b = none
+			001b = per µS
+			010b = per ms
+			011b = per s
+			100b = per minute
+			101b = per hour
+			110b = per day
+			111b = reserved
+			[2:1] - Modifier unit
+			00b = none
+			01b = Basic Unit / Modifier Unit
+			10b = Basic Unit * Modifier Unit
+			11b = reserved
+			[0] - Percentage 0b = no, 1b = yes
+		*/
+		(0x2<<6)+(0x0<<3)+(0x0<<1)+0x0,	//Sensor Units 1
+		/*
+			0 unspecified 
+			1 degrees C 
+			2 degrees F 
+			3 degrees K 
+			4 Volts 
+			5 Amps
+		*/
+		0x1,	//Sensor Units 2 - Base Unit
+		0x0,	//Sensor Units 3 - Modifier Unit
+		0x0,	//Linerization
+		0x1,	//M_LSB
+		/*
+			[7:6] - M: MS 2 bits
+			[5:0] - Tolerance: 6 bits, unsigned (Tolerance in +/- ½ raw counts)
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//M,Tolerance
+		0x0,	//B_LSB
+		/*
+			[7:6] - B: MS 2 bits
+			Unsigned, 10-bit Basic Sensor Accuracy in 1/100 percent scaled up by unsigned
+			Accuracy exponent:
+			[5:0] - Accuracy: LS 6 bits
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//B,Accuracy
+		((0x0>>2)&0xF0)+(0x0&0x0C)+0x0,	//Accuracy,Accuracy exponent
+		(0x0<<4)+(0x0&0x0F),		//R exponent,B exponent
+		0x0,	//Analog Characteristics Flags
+		0x7f,	//Nominal Reading
+		0x7f,	//Normal Maximum
+		0x80,	//Normal Minimum
+		0x7f,	//Sensor Maximum Reading
+		0x80,	//Sensor Minimum Reading
+		0x7f,	//Upper Non-Recoverable Threshold
+		0x7f,	//Upper Critical Threshold
+		0x7f,	//Upper Non-Critical Threshold
+		0x80,	//Lower Non-Recoverable Threshold
+		0x80,	//Lower Critical Threshold
+		0x80,	//Lower Non-Critical threshold
+		0x0,	//Positive - threshold Hysteresis value
+		0x0,	//Negative - threshold Hysteresis value
+		0x0,	//Reserved
+		0x0,	//Reserved
+		0x0,	//OEM
+		0xC0+MAX_ID_STR_LEN,	//ID String Type / Length Code
+		"Temp_FPGA"
+	},
+/*
+ * sensor number: 5
+ * sensor name:	+1.5V
+ * brief:	adc_ch1
+ */
+	{
+		/* SDR Record Header */
+		{
+			0x06,	//Record ID
+			0x51,	//SDR Version
+			FULL_SDR_REC,	//Record Type
+			43+MAX_ID_STR_LEN,	//Record Length = 43+string length
+		},
+		/* Record Key Bytes */
+		0x20,	//Sensor Owner ID
+		0x0,	//Sensor Owner LUN
+		0x05,	//Sensor Number
+		/* Record Body Bytes */
+		0x7,	//Entity ID
+		0x1,	//Entity Instance	
+		0x7f,	//Entity Initialization
+		0x68,	//Sensor Capabilities
+		0x02,	//Sensor Type: 01-temperature, 02-voltage, 03-current, 04-fan
+		0x01,	//Event / Reading Type
+		0x7a95,	//Lower Threshold Reading Mask
+		0x7a95, //Upper Threshold Reading Mask
+		0x3f3f,	//Settable / Readable Threshold Mask
+
+		/*
+			[7:6] - Analog (numeric) Data Format**
+			00b = unsigned
+			01b = 1's complement(singed)
+			10b = 2's complement(singed)
+			11b = Does not return analog (numeric) reading
+			[5:3] - Rate unit
+			000b = none
+			001b = per µS
+			010b = per ms
+			011b = per s
+			100b = per minute
+			101b = per hour
+			110b = per day
+			111b = reserved
+			[2:1] - Modifier unit
+			00b = none
+			01b = Basic Unit / Modifier Unit
+			10b = Basic Unit * Modifier Unit
+			11b = reserved
+			[0] - Percentage 0b = no, 1b = yes
+		*/
+		(0x0<<6)+(0x0<<3)+(0x0<<1)+0x0,	//Sensor Units 1
+		/*
+			0 unspecified 
+			1 degrees C 
+			2 degrees F 
+			3 degrees K 
+			4 Volts 
+			5 Amps
+		*/
+		0x4,	//Sensor Units 2 - Base Unit
+		0x0,	//Sensor Units 3 - Modifier Unit
+		0x0,	//Linerization
+		0x81,	//M_LSB
+		/*
+			[7:6] - M: MS 2 bits
+			[5:0] - Tolerance: 6 bits, unsigned (Tolerance in +/- ½ raw counts)
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//M,Tolerance
+		0x0,	//B_LSB
+		/*
+			[7:6] - B: MS 2 bits
+			Unsigned, 10-bit Basic Sensor Accuracy in 1/100 percent scaled up by unsigned
+			Accuracy exponent:
+			[5:0] - Accuracy: LS 6 bits
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//B,Accuracy
+		((0x0>>2)&0xF0)+(0x0&0x0C)+0x0,	//Accuracy,Accuracy exponent
+		(uint8_t)(0xfc<<4)+(0x0&0x0F),		//R exponent,B exponent
+		0x0,	//Analog Characteristics Flags
+		0x7f,	//Nominal Reading
+		0xff,	//Normal Maximum
+		0x00,	//Normal Minimum
+		0xff,	//Sensor Maximum Reading
+		0x00,	//Sensor Minimum Reading
+		0xff,	//Upper Non-Recoverable Threshold
+		0xff,	//Upper Critical Threshold
+		0xff,	//Upper Non-Critical Threshold
+		0x00,	//Lower Non-Recoverable Threshold
+		0x00,	//Lower Critical Threshold
+		0x00,	//Lower Non-Critical threshold
+		0x0,	//Positive - threshold Hysteresis value
+		0x0,	//Negative - threshold Hysteresis value
+		0x0,	//Reserved
+		0x0,	//Reserved
+		0x0,	//OEM
+		0xC0+MAX_ID_STR_LEN,	//ID String Type / Length Code
+		"+1.5V"
+	},
+/*
+ * sensor number: 6
+ * sensor name:	+0.75V
+ * brief:	adc_ch2
+ */
+	{
+		/* SDR Record Header */
+		{
+			0x07,	//Record ID
+			0x51,	//SDR Version
+			FULL_SDR_REC,	//Record Type
+			43+MAX_ID_STR_LEN,	//Record Length = 43+string length
+		},
+		/* Record Key Bytes */
+		0x20,	//Sensor Owner ID
+		0x0,	//Sensor Owner LUN
+		0x06,	//Sensor Number
+		/* Record Body Bytes */
+		0x7,	//Entity ID
+		0x1,	//Entity Instance	
+		0x7f,	//Entity Initialization
+		0x68,	//Sensor Capabilities
+		0x02,	//Sensor Type: 01-temperature, 02-voltage, 03-current, 04-fan
+		0x01,	//Event / Reading Type
+		0x7a95,	//Lower Threshold Reading Mask
+		0x7a95, //Upper Threshold Reading Mask
+		0x3f3f,	//Settable / Readable Threshold Mask
+
+		/*
+			[7:6] - Analog (numeric) Data Format**
+			00b = unsigned
+			01b = 1's complement(singed)
+			10b = 2's complement(singed)
+			11b = Does not return analog (numeric) reading
+			[5:3] - Rate unit
+			000b = none
+			001b = per µS
+			010b = per ms
+			011b = per s
+			100b = per minute
+			101b = per hour
+			110b = per day
+			111b = reserved
+			[2:1] - Modifier unit
+			00b = none
+			01b = Basic Unit / Modifier Unit
+			10b = Basic Unit * Modifier Unit
+			11b = reserved
+			[0] - Percentage 0b = no, 1b = yes
+		*/
+		(0x0<<6)+(0x0<<3)+(0x0<<1)+0x0,	//Sensor Units 1
+		/*
+			0 unspecified 
+			1 degrees C 
+			2 degrees F 
+			3 degrees K 
+			4 Volts 
+			5 Amps
+		*/
+		0x4,	//Sensor Units 2 - Base Unit
+		0x0,	//Sensor Units 3 - Modifier Unit
+		0x0,	//Linerization
+		0x81,	//M_LSB
+		/*
+			[7:6] - M: MS 2 bits
+			[5:0] - Tolerance: 6 bits, unsigned (Tolerance in +/- ½ raw counts)
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//M,Tolerance
+		0x0,	//B_LSB
+		/*
+			[7:6] - B: MS 2 bits
+			Unsigned, 10-bit Basic Sensor Accuracy in 1/100 percent scaled up by unsigned
+			Accuracy exponent:
+			[5:0] - Accuracy: LS 6 bits
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//B,Accuracy
+		((0x0>>2)&0xF0)+(0x0&0x0C)+0x0,	//Accuracy,Accuracy exponent
+		(uint8_t)(0xfc<<4)+(0x0&0x0F),		//R exponent,B exponent
+		0x0,	//Analog Characteristics Flags
+		0x7f,	//Nominal Reading
+		0xff,	//Normal Maximum
+		0x00,	//Normal Minimum
+		0xff,	//Sensor Maximum Reading
+		0x00,	//Sensor Minimum Reading
+		0xff,	//Upper Non-Recoverable Threshold
+		0xff,	//Upper Critical Threshold
+		0xff,	//Upper Non-Critical Threshold
+		0x00,	//Lower Non-Recoverable Threshold
+		0x00,	//Lower Critical Threshold
+		0x00,	//Lower Non-Critical threshold
+		0x0,	//Positive - threshold Hysteresis value
+		0x0,	//Negative - threshold Hysteresis value
+		0x0,	//Reserved
+		0x0,	//Reserved
+		0x0,	//OEM
+		0xC0+MAX_ID_STR_LEN,	//ID String Type / Length Code
+		"+0.75V"
+	},
+/*
+ * sensor number: 7
+ * sensor name:	+1.8V
+ * brief:	adc_ch3
+ */
+	{
+		/* SDR Record Header */
+		{
+			0x08,	//Record ID
+			0x51,	//SDR Version
+			FULL_SDR_REC,	//Record Type
+			43+MAX_ID_STR_LEN,	//Record Length = 43+string length
+		},
+		/* Record Key Bytes */
+		0x20,	//Sensor Owner ID
+		0x0,	//Sensor Owner LUN
+		0x07,	//Sensor Number
+		/* Record Body Bytes */
+		0x7,	//Entity ID
+		0x1,	//Entity Instance	
+		0x7f,	//Entity Initialization
+		0x68,	//Sensor Capabilities
+		0x02,	//Sensor Type: 01-temperature, 02-voltage, 03-current, 04-fan
+		0x01,	//Event / Reading Type
+		0x7a95,	//Lower Threshold Reading Mask
+		0x7a95, //Upper Threshold Reading Mask
+		0x3f3f,	//Settable / Readable Threshold Mask
+
+		/*
+			[7:6] - Analog (numeric) Data Format**
+			00b = unsigned
+			01b = 1's complement(singed)
+			10b = 2's complement(singed)
+			11b = Does not return analog (numeric) reading
+			[5:3] - Rate unit
+			000b = none
+			001b = per µS
+			010b = per ms
+			011b = per s
+			100b = per minute
+			101b = per hour
+			110b = per day
+			111b = reserved
+			[2:1] - Modifier unit
+			00b = none
+			01b = Basic Unit / Modifier Unit
+			10b = Basic Unit * Modifier Unit
+			11b = reserved
+			[0] - Percentage 0b = no, 1b = yes
+		*/
+		(0x0<<6)+(0x0<<3)+(0x0<<1)+0x0,	//Sensor Units 1
+		/*
+			0 unspecified 
+			1 degrees C 
+			2 degrees F 
+			3 degrees K 
+			4 Volts 
+			5 Amps
+		*/
+		0x4,	//Sensor Units 2 - Base Unit
+		0x0,	//Sensor Units 3 - Modifier Unit
+		0x0,	//Linerization
+		0x81,	//M_LSB
+		/*
+			[7:6] - M: MS 2 bits
+			[5:0] - Tolerance: 6 bits, unsigned (Tolerance in +/- ½ raw counts)
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//M,Tolerance
+		0x0,	//B_LSB
+		/*
+			[7:6] - B: MS 2 bits
+			Unsigned, 10-bit Basic Sensor Accuracy in 1/100 percent scaled up by unsigned
+			Accuracy exponent:
+			[5:0] - Accuracy: LS 6 bits
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//B,Accuracy
+		((0x0>>2)&0xF0)+(0x0&0x0C)+0x0,	//Accuracy,Accuracy exponent
+		(uint8_t)(0xfc<<4)+(0x0&0x0F),		//R exponent,B exponent
+		0x0,	//Analog Characteristics Flags
+		0x7f,	//Nominal Reading
+		0xff,	//Normal Maximum
+		0x00,	//Normal Minimum
+		0xff,	//Sensor Maximum Reading
+		0x00,	//Sensor Minimum Reading
+		0xff,	//Upper Non-Recoverable Threshold
+		0xff,	//Upper Critical Threshold
+		0xff,	//Upper Non-Critical Threshold
+		0x00,	//Lower Non-Recoverable Threshold
+		0x00,	//Lower Critical Threshold
+		0x00,	//Lower Non-Critical threshold
+		0x0,	//Positive - threshold Hysteresis value
+		0x0,	//Negative - threshold Hysteresis value
+		0x0,	//Reserved
+		0x0,	//Reserved
+		0x0,	//OEM
+		0xC0+MAX_ID_STR_LEN,	//ID String Type / Length Code
+		"+1.8V"
+	},
+/*
+ * sensor number: 8
+ * sensor name:	+1.2V
+ * brief:	adc_ch4
+ */
+	{
+		/* SDR Record Header */
+		{
+			0x09,	//Record ID
+			0x51,	//SDR Version
+			FULL_SDR_REC,	//Record Type
+			43+MAX_ID_STR_LEN,	//Record Length = 43+string length
+		},
+		/* Record Key Bytes */
+		0x20,	//Sensor Owner ID
+		0x0,	//Sensor Owner LUN
+		0x08,	//Sensor Number
+		/* Record Body Bytes */
+		0x7,	//Entity ID
+		0x1,	//Entity Instance	
+		0x7f,	//Entity Initialization
+		0x68,	//Sensor Capabilities
+		0x02,	//Sensor Type: 01-temperature, 02-voltage, 03-current, 04-fan
+		0x01,	//Event / Reading Type
+		0x7a95,	//Lower Threshold Reading Mask
+		0x7a95, //Upper Threshold Reading Mask
+		0x3f3f,	//Settable / Readable Threshold Mask
+
+		/*
+			[7:6] - Analog (numeric) Data Format**
+			00b = unsigned
+			01b = 1's complement(singed)
+			10b = 2's complement(singed)
+			11b = Does not return analog (numeric) reading
+			[5:3] - Rate unit
+			000b = none
+			001b = per µS
+			010b = per ms
+			011b = per s
+			100b = per minute
+			101b = per hour
+			110b = per day
+			111b = reserved
+			[2:1] - Modifier unit
+			00b = none
+			01b = Basic Unit / Modifier Unit
+			10b = Basic Unit * Modifier Unit
+			11b = reserved
+			[0] - Percentage 0b = no, 1b = yes
+		*/
+		(0x0<<6)+(0x0<<3)+(0x0<<1)+0x0,	//Sensor Units 1
+		/*
+			0 unspecified 
+			1 degrees C 
+			2 degrees F 
+			3 degrees K 
+			4 Volts 
+			5 Amps
+		*/
+		0x4,	//Sensor Units 2 - Base Unit
+		0x0,	//Sensor Units 3 - Modifier Unit
+		0x0,	//Linerization
+		0x81,	//M_LSB
+		/*
+			[7:6] - M: MS 2 bits
+			[5:0] - Tolerance: 6 bits, unsigned (Tolerance in +/- ½ raw counts)
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//M,Tolerance
+		0x0,	//B_LSB
+		/*
+			[7:6] - B: MS 2 bits
+			Unsigned, 10-bit Basic Sensor Accuracy in 1/100 percent scaled up by unsigned
+			Accuracy exponent:
+			[5:0] - Accuracy: LS 6 bits
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//B,Accuracy
+		((0x0>>2)&0xF0)+(0x0&0x0C)+0x0,	//Accuracy,Accuracy exponent
+		(uint8_t)(0xfc<<4)+(0x0&0x0F),		//R exponent,B exponent
+		0x0,	//Analog Characteristics Flags
+		0x7f,	//Nominal Reading
+		0xff,	//Normal Maximum
+		0x00,	//Normal Minimum
+		0xff,	//Sensor Maximum Reading
+		0x00,	//Sensor Minimum Reading
+		0xff,	//Upper Non-Recoverable Threshold
+		0xff,	//Upper Critical Threshold
+		0xff,	//Upper Non-Critical Threshold
+		0x00,	//Lower Non-Recoverable Threshold
+		0x00,	//Lower Critical Threshold
+		0x00,	//Lower Non-Critical threshold
+		0x0,	//Positive - threshold Hysteresis value
+		0x0,	//Negative - threshold Hysteresis value
+		0x0,	//Reserved
+		0x0,	//Reserved
+		0x0,	//OEM
+		0xC0+MAX_ID_STR_LEN,	//ID String Type / Length Code
+		"+1.2V"
+	},
+/*
+ * sensor number: 9
+ * sensor name:	+1.0V
+ * brief:	adc_ch5
+ */
+	{
+		/* SDR Record Header */
+		{
+			0x0A,	//Record ID
+			0x51,	//SDR Version
+			FULL_SDR_REC,	//Record Type
+			43+MAX_ID_STR_LEN,	//Record Length = 43+string length
+		},
+		/* Record Key Bytes */
+		0x20,	//Sensor Owner ID
+		0x0,	//Sensor Owner LUN
+		0x09,	//Sensor Number
+		/* Record Body Bytes */
+		0x7,	//Entity ID
+		0x1,	//Entity Instance	
+		0x7f,	//Entity Initialization
+		0x68,	//Sensor Capabilities
+		0x02,	//Sensor Type: 01-temperature, 02-voltage, 03-current, 04-fan
+		0x01,	//Event / Reading Type
+		0x7a95,	//Lower Threshold Reading Mask
+		0x7a95, //Upper Threshold Reading Mask
+		0x3f3f,	//Settable / Readable Threshold Mask
+
+		/*
+			[7:6] - Analog (numeric) Data Format**
+			00b = unsigned
+			01b = 1's complement(singed)
+			10b = 2's complement(singed)
+			11b = Does not return analog (numeric) reading
+			[5:3] - Rate unit
+			000b = none
+			001b = per µS
+			010b = per ms
+			011b = per s
+			100b = per minute
+			101b = per hour
+			110b = per day
+			111b = reserved
+			[2:1] - Modifier unit
+			00b = none
+			01b = Basic Unit / Modifier Unit
+			10b = Basic Unit * Modifier Unit
+			11b = reserved
+			[0] - Percentage 0b = no, 1b = yes
+		*/
+		(0x0<<6)+(0x0<<3)+(0x0<<1)+0x0,	//Sensor Units 1
+		/*
+			0 unspecified 
+			1 degrees C 
+			2 degrees F 
+			3 degrees K 
+			4 Volts 
+			5 Amps
+		*/
+		0x4,	//Sensor Units 2 - Base Unit
+		0x0,	//Sensor Units 3 - Modifier Unit
+		0x0,	//Linerization
+		0x81,	//M_LSB
+		/*
+			[7:6] - M: MS 2 bits
+			[5:0] - Tolerance: 6 bits, unsigned (Tolerance in +/- ½ raw counts)
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//M,Tolerance
+		0x0,	//B_LSB
+		/*
+			[7:6] - B: MS 2 bits
+			Unsigned, 10-bit Basic Sensor Accuracy in 1/100 percent scaled up by unsigned
+			Accuracy exponent:
+			[5:0] - Accuracy: LS 6 bits
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//B,Accuracy
+		((0x0>>2)&0xF0)+(0x0&0x0C)+0x0,	//Accuracy,Accuracy exponent
+		(uint8_t)(0xfc<<4)+(0x0&0x0F),		//R exponent,B exponent
+		0x0,	//Analog Characteristics Flags
+		0x7f,	//Nominal Reading
+		0xff,	//Normal Maximum
+		0x00,	//Normal Minimum
+		0xff,	//Sensor Maximum Reading
+		0x00,	//Sensor Minimum Reading
+		0xff,	//Upper Non-Recoverable Threshold
+		0xff,	//Upper Critical Threshold
+		0xff,	//Upper Non-Critical Threshold
+		0x00,	//Lower Non-Recoverable Threshold
+		0x00,	//Lower Critical Threshold
+		0x00,	//Lower Non-Critical threshold
+		0x0,	//Positive - threshold Hysteresis value
+		0x0,	//Negative - threshold Hysteresis value
+		0x0,	//Reserved
+		0x0,	//Reserved
+		0x0,	//OEM
+		0xC0+MAX_ID_STR_LEN,	//ID String Type / Length Code
+		"+1.0V"
+	},
+/*
+ * sensor number: 10
+ * sensor name:	+2.5V
+ * brief:	adc_ch6
+ */
+	{
+		/* SDR Record Header */
+		{
+			0x0B,	//Record ID
+			0x51,	//SDR Version
+			FULL_SDR_REC,	//Record Type
+			43+MAX_ID_STR_LEN,	//Record Length = 43+string length
+		},
+		/* Record Key Bytes */
+		0x20,	//Sensor Owner ID
+		0x0,	//Sensor Owner LUN
+		0x0A,	//Sensor Number
+		/* Record Body Bytes */
+		0x7,	//Entity ID
+		0x1,	//Entity Instance	
+		0x7f,	//Entity Initialization
+		0x68,	//Sensor Capabilities
+		0x02,	//Sensor Type: 01-temperature, 02-voltage, 03-current, 04-fan
+		0x01,	//Event / Reading Type
+		0x7a95,	//Lower Threshold Reading Mask
+		0x7a95, //Upper Threshold Reading Mask
+		0x3f3f,	//Settable / Readable Threshold Mask
+
+		/*
+			[7:6] - Analog (numeric) Data Format**
+			00b = unsigned
+			01b = 1's complement(singed)
+			10b = 2's complement(singed)
+			11b = Does not return analog (numeric) reading
+			[5:3] - Rate unit
+			000b = none
+			001b = per µS
+			010b = per ms
+			011b = per s
+			100b = per minute
+			101b = per hour
+			110b = per day
+			111b = reserved
+			[2:1] - Modifier unit
+			00b = none
+			01b = Basic Unit / Modifier Unit
+			10b = Basic Unit * Modifier Unit
+			11b = reserved
+			[0] - Percentage 0b = no, 1b = yes
+		*/
+		(0x0<<6)+(0x0<<3)+(0x0<<1)+0x0,	//Sensor Units 1
+		/*
+			0 unspecified 
+			1 degrees C 
+			2 degrees F 
+			3 degrees K 
+			4 Volts 
+			5 Amps
+		*/
+		0x4,	//Sensor Units 2 - Base Unit
+		0x0,	//Sensor Units 3 - Modifier Unit
+		0x0,	//Linerization
+		0x81,	//M_LSB
+		/*
+			[7:6] - M: MS 2 bits
+			[5:0] - Tolerance: 6 bits, unsigned (Tolerance in +/- ½ raw counts)
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//M,Tolerance
+		0x0,	//B_LSB
+		/*
+			[7:6] - B: MS 2 bits
+			Unsigned, 10-bit Basic Sensor Accuracy in 1/100 percent scaled up by unsigned
+			Accuracy exponent:
+			[5:0] - Accuracy: LS 6 bits
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//B,Accuracy
+		((0x0>>2)&0xF0)+(0x0&0x0C)+0x0,	//Accuracy,Accuracy exponent
+		(uint8_t)(0xfc<<4)+(0x0&0x0F),		//R exponent,B exponent
+		0x0,	//Analog Characteristics Flags
+		0x7f,	//Nominal Reading
+		0xff,	//Normal Maximum
+		0x00,	//Normal Minimum
+		0xff,	//Sensor Maximum Reading
+		0x00,	//Sensor Minimum Reading
+		0xff,	//Upper Non-Recoverable Threshold
+		0xff,	//Upper Critical Threshold
+		0xff,	//Upper Non-Critical Threshold
+		0x00,	//Lower Non-Recoverable Threshold
+		0x00,	//Lower Critical Threshold
+		0x00,	//Lower Non-Critical threshold
+		0x0,	//Positive - threshold Hysteresis value
+		0x0,	//Negative - threshold Hysteresis value
+		0x0,	//Reserved
+		0x0,	//Reserved
+		0x0,	//OEM
+		0xC0+MAX_ID_STR_LEN,	//ID String Type / Length Code
+		"+2.5V"
+	},
+/*
+ * sensor number: 11
+ * sensor name:	+3.3V
+ * brief:	adc_ch7
+ */
+	{
+		/* SDR Record Header */
+		{
+			0x0C,	//Record ID
+			0x51,	//SDR Version
+			FULL_SDR_REC,	//Record Type
+			43+MAX_ID_STR_LEN,	//Record Length = 43+string length
+		},
+		/* Record Key Bytes */
+		0x20,	//Sensor Owner ID
+		0x0,	//Sensor Owner LUN
+		0x0B,	//Sensor Number
+		/* Record Body Bytes */
+		0x7,	//Entity ID
+		0x1,	//Entity Instance	
+		0x7f,	//Entity Initialization
+		0x68,	//Sensor Capabilities
+		0x02,	//Sensor Type: 01-temperature, 02-voltage, 03-current, 04-fan
+		0x01,	//Event / Reading Type
+		0x7a95,	//Lower Threshold Reading Mask
+		0x7a95, //Upper Threshold Reading Mask
+		0x3f3f,	//Settable / Readable Threshold Mask
+
+		/*
+			[7:6] - Analog (numeric) Data Format**
+			00b = unsigned
+			01b = 1's complement(singed)
+			10b = 2's complement(singed)
+			11b = Does not return analog (numeric) reading
+			[5:3] - Rate unit
+			000b = none
+			001b = per µS
+			010b = per ms
+			011b = per s
+			100b = per minute
+			101b = per hour
+			110b = per day
+			111b = reserved
+			[2:1] - Modifier unit
+			00b = none
+			01b = Basic Unit / Modifier Unit
+			10b = Basic Unit * Modifier Unit
+			11b = reserved
+			[0] - Percentage 0b = no, 1b = yes
+		*/
+		(0x0<<6)+(0x0<<3)+(0x0<<1)+0x0,	//Sensor Units 1
+		/*
+			0 unspecified 
+			1 degrees C 
+			2 degrees F 
+			3 degrees K 
+			4 Volts 
+			5 Amps
+		*/
+		0x4,	//Sensor Units 2 - Base Unit
+		0x0,	//Sensor Units 3 - Modifier Unit
+		0x0,	//Linerization
+		/* M = 0x103 */
+		(0x103 & 0xff),	//M_LSB
+		/*
+			[7:6] - M: MS 2 bits
+			[5:0] - Tolerance: 6 bits, unsigned (Tolerance in +/- ½ raw counts)
+		*/
+		((0x103>>2)&0xC0)+(0x0&0x3F),	//M,Tolerance
+		0x0,	//B_LSB
+		/*
+			[7:6] - B: MS 2 bits
+			Unsigned, 10-bit Basic Sensor Accuracy in 1/100 percent scaled up by unsigned
+			Accuracy exponent:
+			[5:0] - Accuracy: LS 6 bits
+		*/
+		((0x0>>2)&0xC0)+(0x0&0x3F),	//B,Accuracy
+		((0x0>>2)&0xF0)+(0x0&0x0C)+0x0,	//Accuracy,Accuracy exponent
+		(uint8_t)(0xfc<<4)+(0x0&0x0F),		//R exponent,B exponent
+		0x0,	//Analog Characteristics Flags
+		0x7f,	//Nominal Reading
+		0xff,	//Normal Maximum
+		0x00,	//Normal Minimum
+		0xff,	//Sensor Maximum Reading
+		0x00,	//Sensor Minimum Reading
+		0xff,	//Upper Non-Recoverable Threshold
+		0xff,	//Upper Critical Threshold
+		0xff,	//Upper Non-Critical Threshold
+		0x00,	//Lower Non-Recoverable Threshold
+		0x00,	//Lower Critical Threshold
+		0x00,	//Lower Non-Critical threshold
+		0x0,	//Positive - threshold Hysteresis value
+		0x0,	//Negative - threshold Hysteresis value
+		0x0,	//Reserved
+		0x0,	//Reserved
+		0x0,	//OEM
+		0xC0+MAX_ID_STR_LEN,	//ID String Type / Length Code
+		"+3.3V"
+	},
+
+};
+
+const CompactSensorRec_T Compact_sdr_tbl[]	=	{
+	{0},	//dummy sensor, make compiler happy.	
+};
+
+
+

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно