Bladeren bron

Add cJSON, add some libipmi

zhangbo 5 jaren geleden
bovenliggende
commit
5d19e819d0
100 gewijzigde bestanden met toevoegingen van 14775 en 4 verwijderingen
  1. 8 1
      .gitignore
  2. 2 2
      app/Makefile
  3. BIN
      app/bmc_server/ipmi_dev/.IPMI_AppDevice.h.swp
  4. 359 0
      app/common_include/com_IPMIDefs.h
  5. 95 0
      app/common_include/com_IPMI_App.h
  6. 619 0
      app/common_include/com_IPMI_AppDevice.h
  7. 307 0
      app/common_include/com_IPMI_IPM.h
  8. 43 0
      app/common_include/com_UDSIfc.h
  9. BIN
      app/driver/FMC/fmc.mod.o
  10. BIN
      app/driver/FMC/fmc.o
  11. BIN
      app/driver/FMC/fmc_main.o
  12. BIN
      app/driver/I2C/.i2c_main.c.swp
  13. BIN
      app/driver/I2C/.stm32f429_hw.h.swp
  14. BIN
      app/driver/Platform/platform_STM32F429.mod.o
  15. BIN
      app/driver/Platform/platform_STM32F429.o
  16. BIN
      app/driver/Platform/platform_main.o
  17. BIN
      app/driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.o
  18. BIN
      app/driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.o
  19. BIN
      app/driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.o
  20. BIN
      app/driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.o
  21. BIN
      app/driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.o
  22. BIN
      app/driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.o
  23. BIN
      app/driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.o
  24. BIN
      app/driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fmc.o
  25. BIN
      app/driver/STM32F4xx_HAL_Driver/system_stm32f4xx.o
  26. BIN
      app/driver/test/test_main.o
  27. BIN
      app/driver/test/test_module.mod.o
  28. BIN
      app/driver/test/test_module.o
  29. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/goahead
  30. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/goahead-test
  31. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/goahead-test.gdb
  32. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/goahead.gdb
  33. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/gopass
  34. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/gopass.gdb
  35. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/libgo.a
  36. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/libgoahead-mbedtls.a
  37. BIN
      app/goahead-5.1.0/build/linux-arm-static/bin/libmbedtls.a
  38. 151 0
      app/goahead-5.1.0/build/linux-arm-static/inc/cJSON.h
  39. 359 0
      app/goahead-5.1.0/build/linux-arm-static/inc/com_IPMIDefs.h
  40. 95 0
      app/goahead-5.1.0/build/linux-arm-static/inc/com_IPMI_App.h
  41. 619 0
      app/goahead-5.1.0/build/linux-arm-static/inc/com_IPMI_AppDevice.h
  42. 307 0
      app/goahead-5.1.0/build/linux-arm-static/inc/com_IPMI_IPM.h
  43. 43 0
      app/goahead-5.1.0/build/linux-arm-static/inc/com_UDSIfc.h
  44. 674 0
      app/goahead-5.1.0/build/linux-arm-static/inc/libipmi.h
  45. 52 0
      app/goahead-5.1.0/build/linux-arm-static/inc/libipmi_IPM.h
  46. 134 0
      app/goahead-5.1.0/build/linux-arm-static/inc/libipmi_errorcodes.h
  47. 141 0
      app/goahead-5.1.0/build/linux-arm-static/inc/libipmi_session.h
  48. 171 0
      app/goahead-5.1.0/build/linux-arm-static/inc/libipmi_struct.h
  49. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/action.o
  50. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/alloc.o
  51. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/auth.o
  52. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/cgi.o
  53. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/crypt.o
  54. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/file.o
  55. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/fs.o
  56. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/goahead-mbedtls.o
  57. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/goahead.o
  58. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/gopass.o
  59. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/http.o
  60. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/js.o
  61. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/jst.o
  62. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/mbedtls.o
  63. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/options.o
  64. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/osdep.o
  65. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/rom.o
  66. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/route.o
  67. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/runtime.o
  68. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/socket.o
  69. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/test.o
  70. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/time.o
  71. BIN
      app/goahead-5.1.0/build/linux-arm-static/obj/upload.o
  72. 105 1
      app/goahead-5.1.0/projects/goahead-linux-static.mk
  73. 756 0
      app/goahead-5.1.0/src/cJSON/cJSON.c
  74. 151 0
      app/goahead-5.1.0/src/cJSON/cJSON.h
  75. 674 0
      app/goahead-5.1.0/src/libipmi/inc/libipmi.h
  76. 116 0
      app/goahead-5.1.0/src/libipmi/inc/libipmi_AppDevice.h
  77. 161 0
      app/goahead-5.1.0/src/libipmi/inc/libipmi_ChassisDevice.h
  78. 52 0
      app/goahead-5.1.0/src/libipmi/inc/libipmi_IPM.h
  79. 132 0
      app/goahead-5.1.0/src/libipmi/inc/libipmi_PEF.h
  80. 173 0
      app/goahead-5.1.0/src/libipmi/inc/libipmi_StorDevice.h
  81. 474 0
      app/goahead-5.1.0/src/libipmi/inc/libipmi_XportDevice.h
  82. 134 0
      app/goahead-5.1.0/src/libipmi/inc/libipmi_errorcodes.h
  83. 95 0
      app/goahead-5.1.0/src/libipmi/inc/libipmi_fru.h
  84. 131 0
      app/goahead-5.1.0/src/libipmi/inc/libipmi_rmcp.h
  85. 150 0
      app/goahead-5.1.0/src/libipmi/inc/libipmi_sdr.h
  86. 190 0
      app/goahead-5.1.0/src/libipmi/inc/libipmi_sensor.h
  87. 141 0
      app/goahead-5.1.0/src/libipmi/inc/libipmi_session.h
  88. 124 0
      app/goahead-5.1.0/src/libipmi/inc/libipmi_storlead_OEM.h
  89. 171 0
      app/goahead-5.1.0/src/libipmi/inc/libipmi_struct.h
  90. 31 0
      app/goahead-5.1.0/src/libipmi/inc/libipmi_usermgmt.h
  91. 20 0
      app/goahead-5.1.0/src/libipmi/inc/libipmi_version.h
  92. 57 0
      app/goahead-5.1.0/src/libipmi/inc/libsensor.h
  93. 150 0
      app/goahead-5.1.0/src/libipmi/inc/std_macros.h
  94. 398 0
      app/goahead-5.1.0/src/libipmi/src/libipmi_Chassis.c
  95. 560 0
      app/goahead-5.1.0/src/libipmi/src/libipmi_PEF.c
  96. 936 0
      app/goahead-5.1.0/src/libipmi/src/libipmi_StorDevice.c
  97. 2583 0
      app/goahead-5.1.0/src/libipmi/src/libipmi_XportDevice.c
  98. 81 0
      app/goahead-5.1.0/src/libipmi/src/libipmi_device_api.c
  99. 1258 0
      app/goahead-5.1.0/src/libipmi/src/libipmi_fru.c
  100. 592 0
      app/goahead-5.1.0/src/libipmi/src/libipmi_sdr.c

+ 8 - 1
.gitignore

@@ -1 +1,8 @@
-gd32450i-eval.uImage
+*.uImage
+*.o
+*.kernel.STMDISCO
+#ignore switch file
+*~
+*.swp
+#ignore goahead build
+./app/goahead-5.1.0/build/

+ 2 - 2
app/Makefile

@@ -1,8 +1,8 @@
 all	: 
-	make -C ./web
+	make -C ./goahead-5.1.0
 #	apps modules test_apps
 clean	: clean_apps clean_modules clean_test_apps
-
+	
 apps	: 
 	#make -C ./web
 	#make -C ./bmc_server

BIN
app/bmc_server/ipmi_dev/.IPMI_AppDevice.h.swp


+ 359 - 0
app/common_include/com_IPMIDefs.h

@@ -0,0 +1,359 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************
+ ****************************************************************
+ ******************************************************************
+ *
+ * ipmi_defs.h
+ * IPMI Definitions
+ *
+ *  Author: Govind Kothandapani <govindk@ami.com>
+ *
+ ******************************************************************/
+#ifndef  IPMI_DEFS_H
+#define IPMI_DEFS_H
+
+#include <stdint.h>
+
+#ifndef TRUE
+    #define TRUE 1
+#endif
+
+#ifndef FALSE
+    #define FALSE 0
+#endif    
+
+
+/*----------------------------------------------
+ * Bit fields
+ *----------------------------------------------*/
+#define BIT0    0x0001
+#define BIT1    0x0002
+#define BIT2    0x0004
+#define BIT3    0x0008
+#define BIT4    0x0010
+#define BIT5    0x0020
+#define BIT6    0x0040
+#define BIT7    0x0080
+#define BIT8    0x0100
+#define BIT9    0x0200
+#define BIT10   0x0400
+#define BIT11   0x0800
+#define BIT12   0x1000
+#define BIT13   0x2000
+#define BIT14   0x4000
+#define BIT15   0x8000
+
+/*------- Net Functions  -------------------*/
+#define NETFN_CHASSIS                     0x00
+#define NETFN_BRIDGE                      0x02
+#define NETFN_SENSOR                      0x04
+#define NETFN_APP                         0x06
+#define NETFN_FIRMWARE                    0x08
+#define NETFN_STORAGE                     0x0A
+#define NETFN_TRANSPORT                   0x0C
+#define NETFN_PICMG                       0x2C
+#define NETFN_AMI                         0x32
+#define NETFN_OEM                         0x2E
+#define NETFN_OPMA1                       0x30
+#define NETFN_OPMA2                       0x3E
+#ifdef  CFG_PROJ_SHMC_TEST_SUPPORT_YES
+#define NETFN_TEST_OEM                    0x34
+#endif
+
+#define NETFN_UNKNOWN                     0xFF
+#define IPMI_CMD_UNKNOWN                  0xFF
+
+#define NETFN_GROUP_EXTN                  0x2C
+#define IPMI_GROUP_EXTN_CODE_DCMI         0xDC
+
+#define MAX_USER_NAME_LEN                 (16+1) //+1 for null terminator
+#define IP6_ADDR_LEN                      16
+
+/**** Command Completion Codes ****/
+#define CC_NORMAL                                       0x00
+#define CC_SUCCESS                                      0x00
+#define CC_NODE_BUSY                                    0xC0
+#define CC_INV_CMD                                      0xC1
+#define CC_INV_CMD_FOR_LUN                              0xC2
+#define CC_TIMEOUT                                      0xC3
+#define CC_OUT_OF_SPACE                                 0xC4
+#define CC_INV_RESERVATION_ID                           0xC5
+#define CC_REQ_TRUNCATED                                0xC6
+#define CC_REQ_INV_LEN                                  0xC7
+#define CC_REQ_FIELD_LEN_EXCEEDED                       0xC8
+#define CC_PARAM_OUT_OF_RANGE                           0xC9
+#define CC_CANNOT_RETURN_REQ_BYTES                      0xCA
+#define CC_SEL_REC_NOT_PRESENT                          0xCB
+#define CC_SDR_REC_NOT_PRESENT                          0xCB
+#define CC_FRU_REC_NOT_PRESENT                          0xCB
+#define CC_INV_DATA_FIELD                               0xCC
+#define CC_ILLEGAL_CMD_FOR_SENSOR_REC                   0xCD
+#define CC_COULD_NOT_PROVIDE_RESP                       0xCE
+#define CC_CANNOT_EXEC_DUPL_REQ                         0xCF
+#define CC_SDR_REP_IN_UPDATE_MODE                       0xD0
+#define CC_DEV_IN_FIRMWARE_UPDATE_MODE                  0xD1
+#define CC_INIT_AGENT_IN_PROGRESS                       0xD2
+#define CC_DEST_UNAVAILABLE                             0xD3
+#define CC_INSUFFIENT_PRIVILEGE                         0xD4
+#define CC_PARAM_NOT_SUP_IN_CUR_STATE                   0xD5
+#define CC_ERR_HANDLING_COMMAND_FAILURE                 0xD6
+#define CC_UNSPECIFIED_ERR                              0xFF
+#define CC_GET_MSG_QUEUE_EMPTY                          0x80
+#define CC_EVT_MSG_QUEUE_EMPTY                          0x80
+#define CC_GET_SESSION_INVALID_USER                     0x81
+#define CC_GET_SESSION_NULL_USER_DISABLED               0x82
+#define CC_ACTIVATE_SESS_NO_SESSION_SLOT_AVAILABLE      0x81
+#define CC_ACTIVATE_SESS_NO_SLOT_AVAILABLE_USER         0x82
+#define CC_ACTIVATE_SESS_REQ_LEVEL_EXCEEDS_LIMIT        0x83
+#define CC_ACTIVATE_SESS_SEQ_OUT_OF_RANGE               0x84
+#define CC_ACTIVATE_SESS_INVALID_SESSION_ID             0x85
+#define CC_ACTIVATE_SESS_MAX_PRIVILEGE_EXCEEDS_LIMIT    0x86
+#define CC_PASSWORD_TEST_FAILED                         0x80
+#define CC_PASSWORD_TEST_FAILED_WRONG_SIZE              0x81
+#define CC_SETPASSWORD_INVALID_USERID                   0x81
+#define CC_SETPASSWORD_CANNOT_DISABLE_USER              0x82
+#define CC_NO_ACK_FROM_SLAVE                            0x83
+#define CC_GET_CH_COMMAND_NOT_SUPPORTED                 0x82
+#define CC_SET_CH_COMMAND_NOT_SUPPORTED                 0x82
+#define CC_SET_CH_ACCES_MODE_NOT_SUPPORTED              0x83
+#define CC_SET_SESS_PREV_REQ_LEVEL_NOT_AVAILABLE        0x80
+#define CC_SET_SESS_PREV_REQ_PRIVILEGE_EXCEEDS_LIMIT    0x81
+#define CC_SET_SESS_PREV_INVALID_SESSION_ID             0x82
+#define CC_ACTIVATE_SESS_NO_SLOT_AVAILABLE_USER         0x82
+#define CC_CLOSE_INVALID_SESSION_ID                     0x87
+#define CC_CLOSE_INVALID_SESSION_ID_HANDLE              0x88
+#define CC_PEF_PARAM_NOT_SUPPORTED                      0x80
+#define CC_PEF_SET_IN_PROGRESS                          0x81
+#define CC_SESSION_IN_PROGRESS                          0x82
+#define CC_PEF_ATTEMPT_TO_SET_READ_ONLY_PARAM           0x82
+#define CC_SET_IN_PROGRESS                              0x81
+#define CC_ATTEMPT_TO_SET_RO_PARAM                      0x82
+#define CC_PARAM_NOT_SUPPORTED                          0x80
+#define CC_BIOS_NOT_READY                               0x82
+#define CC_IFC_NOT_SUPPORTED                            0x81
+#define CC_DISABLE_SM                                   0x81
+#define CC_BIOS_IS_BUSY                                 0x81
+#define CC_CMD_UNSUPPORTED_UNCONFIGURABLE               0x80
+#define CC_NTP_RESTART_ERROR                            0x80
+
+#define CC_CALLBACK_REJ_SESSION_ACTIVE                  0x82
+#define CC_WRITE_ONLY_PARAM                             0x83
+
+#define CC_INST_ALREADY_ACTIVE                          0x80
+#define CC_CANNOT_ACTIVATE_WITH_ENCR                    0x83
+#define CC_PAYLOAD_NOT_ENABLED                          0x81
+#define CC_INST_EXCEEDED                                0x82
+#define CC_INST_ALREADY_INACTIVE                        0x80
+#define CC_PAYLOAD_NOT_AVAILABLE                        0x80
+#define CC_ENCRYPT_NOT_AVAILABLE                        0x82
+#define CC_INST_NOT_ACTIVE                              0x83
+#define CC_KEYS_LOCKED                                  0x80
+#define CC_INSUF_KEY_BYTES                              0x81
+#define CC_TOO_MANY_KEY_BYTES                           0x82
+#define CC_KEY_MISMATCH                                 0x83
+
+#define CC_INVALID_KEY                                  0x80
+
+#define CC_OP_NOT_SUPPORTED                             0x80
+#define CC_OP_NOT_ALLOWED                               0x81
+#define CC_ENC_NOT_AVAILABLE                            0x82
+#define CC_CANNOT_ACTIVATE_WITH_ENCR                    0x83
+#define CC_CANNOT_ACTIVATE_WITHOUT_ENCR                 0x84
+
+#define CC_ATTEMPT_TO_RESET_UNIN_WATCHDOG               0x80
+
+#define CC_ILLEGAL_CONNECTOR_ID                         0x81
+#define CC_SEL_ERASE_IN_PROGRESS                        0x81
+
+#define CC_SAME_PAM_ORDER                               0x90
+#define CC_PAM_ORDER_SEC_DIFERS                         0x91
+#define CC_PAM_ORDER_FILE_DIFERS                        0x92
+
+#define CC_INSUFFICIENT_SLAVE_COUNT                     0x84
+#define CC_IFC_ALREADY_SLAVEDTO_BOND                    0x85
+#define CC_BOND_DISABLED_TOCONF_DNS                     0x86
+#define CC_DNS_CURRENTLY_NOT_SUPPORTED_FOR_IPV6         0x87
+#define CC_INV_DOMAIN_NAME                              0x88
+#define CC_TSIGPRIVATEKEY_VALIDATION_FAILED             0x89
+#define CC_DNS_CURRENTLY_NOT_ENABLED                    0x90
+
+#define CC_NULL_USERID_NOT_SUPPORTED                    0x80
+
+#define CC_DEVICE_NOT_SUPPORTED                         0X80
+#define CC_INCOMPLETE_WRITTEN_BYTES			0x80
+
+/* Completion code for Set system info parameter command */
+#define CC_SYS_INFO_PARAM_NOT_SUPPORTED                 0x80
+#define CC_SYS_INFO_SET_IN_PROGRESS                     0x81
+#define CC_SYS_INFO_READ_ONLY_PARAM                     0x82
+#define IPMI_EVM_REVISION                               0x04
+#define IPMI_SENSOR_TEMP_TYPE                           0x01
+#define IPMI_SENSOR_VOLT_TYPE                           0x02
+#define IPMI_SENSOR_FAN_TYPE                            0x04
+#define IPMI_SENSOR_PHYSICAL_SECURITY_TYPE              0x05
+#define IPMI_SENSOR_POWER_SUPPLY_TYPE                   0x08
+#define IPMI_SENSOR_MEMORY_TYPE                         0x0C
+#define IPMI_SENSOR_DRIVE_TYPE                          0x0D
+#define IPMI_SENSOR_BUTTON_TYPE                         0x14
+#define IPMI_SENSOR_ENTITY_PRESENCE_TYPE                0x25
+#define IPMI_SENSOR_OEM_TYPE                            0xC0
+
+/******************OEM Completion codes*********************/
+#define OEMCC_INVALID_USERNAME                          0x01
+#define OEMCC_PASSWD_MISMATCH                           0x02
+#define OEMCC_INVALID_PASSWD                            0x03
+#define OEMCC_DUPLICATE_USERNAME                        0x04
+#define OEMCC_USER_EXISTS_AT_SLOT                       0x05
+#define OEMCC_NOMEM                                     0x06
+#define OEMCC_FILE_ERR                                  0x07
+#define OEMCC_SSHKEY_UPDATE_FAILURE                     0x08
+#define OEMCC_SENSOR_DISABLED                           0x09
+#define OEMCC_INVALID_SDR_ENTRY                         0x0a
+#define OEMCC_CORRUPT_FLASH_DATA                        0x0b
+#define OEMCC_CORRUPT_DATA_CHKSUM                       0x0c
+#define OEMCC_FLASH_UPGRADE_FAILURE                     0x0d
+#define OEMCC_VERSION_MISMATCH                          0x0e
+#define OEMCC_USER_NOT_EXISTS                           0x0f
+
+#define OEMCC_SAL_INVALID_TARGET                        0x0f //CMM sal completion code
+
+#define OEMCC_EMAIL_NOT_CONFIGURED                      0x10
+#define OEMCC_SMTP_DISABLED                             0x11
+#define OEMCC_UNSUPPORTED_AUTH_TYPE                     0x12
+#define OEMCC_SEND_EMAIL_AUTH_FAILED                    0x13
+#define OEMCC_UNABLE_TO_CONNECT_SMTPSERVER              0x14
+#define OEMCC_SEND_EMAIL_FAILED                         0x15
+#define OEMCC_USER_DISABLED                             0x16
+#define OEMCC_RESERVED_USER_NAME                        0x17
+#define OEMCC_INSUFFIENT_LANIFC_COUNT                   0x80
+#define OEMCC_UNSUPPORTED_BOND_MODE                     0x81
+#define OEMCC_VLAN_ENABLED_ON_SLAVE                     0x82
+#define OEMCC_BOND_ALREADY_DISABLED     0x83
+#define OEMCC_INV_PARAM_ONLY_FOR_NON_BONDING            0x81
+#define OEMCC_INV_IP4_NOT_ENABLED                       0x82
+#define OEMCC_INV_MIN_IFC_COUNT_DISABLED                0x83
+#define OEMCC_BOND_NOT_ENABLED                          0x80
+#define OEMCC_ACTIVE_SLAVE_LINK_DOWN                    0x81
+#define OEMCC_ETH_IFACE_DISABLED                        0x85
+#define OEMCC_SEL_EMPTY_REPOSITORY                      0x86
+#define OEMCC_SEL_CLEARED                               0x85
+#define OEMCC_SENSOR_INFO_EMPTY                         0x87
+
+#define OEMCC_ATTEMPT_TO_GET_WO_PARAM                   0x82
+
+#define CC_POWER_LIMIT_OUT_OF_RANGE                     0x84
+#define CC_CORRECTION_TIME_OUT_OF_RANGE                 0x85
+#define CC_STAT_REPORTING_OUT_OF_RANGE                  0x89
+
+#define CC_THERMAL_LIMIT_OUT_OF_RANGE                   0x84
+#define CC_THERMAL_EXCEPTION_TIME_OUT_OF_RANGE          0x85
+
+#define OEMCC_INV_DATE_TIME                             0x93
+/* HPM related Completion codes */
+#define CC_UPG_NOT_SUPPORTED_OVER_IFC                   0x81
+#define CC_INV_COMPONENT_ID                             0x82
+#define CC_INV_COMPONENT_PROP_SELECTOR                  0x83
+#define CC_INV_COMPONENT                                0x81
+#define CC_IMAGE_LEN_MISMATCH                           0x81
+#define CC_INV_FW_CHECKSUM                              0x82
+#define CC_IMAGE_NOT_MATCH                              0x83
+#define CC_UPG_NOT_ABORTED_AT_THIS_MOMENT               0x80
+#define CC_UPG_ABORTED_FW_NOT_RESUMABLE                 0x81
+#define CC_CMD_INPROGRESS                               0x80
+/* Remote Images Service completion code*/
+#define CC_SERVICE_NOT_ENABLED              0x90
+#define CC_INVALID_MEDIA_TYPE               0x91
+#define CC_INVALID_SHARE_TYPE               0x92
+#define CC_INVALID_IP_ADDR                  0x93
+#define CC_INVALID_COMMAND                  0x94
+#define CC_INVALID_IMAGE_FILE_NAME          0x95
+#define CC_INVALID_DOMAIN                   0x96
+#define CC_INVALID_CONFIGURATION            0x97
+#define CC_INVALID_IMG_PATH                 0x98
+#define CC_INVALID_USR_NAME                 0x99
+#define CC_INVALID_PASSWD                   0x9A
+#define CC_INVALID_BLOCK_SELECTOR              0x9B
+#define CC_INV_PROGRESS_BIT              0x9C
+#define CC_PROGRESS_BIT_NOT_SET              0x9D
+#define CC_PUBLICKEY_VALIDATION_FAILED          0x80
+
+/*Host Lock Feature*/
+#define CC_FEATURE_NOT_ENABLED          0x80
+#define CC_INV_FEATURE_CMD          0x81
+#define CC_INV_LOCK_CMD          0x82
+/*--------------------------------------------
+ * Macro to extract the net function.
+ *--------------------------------------------*/
+#define NET_FN(NetFnLUN)	((uint8_t)((NetFnLUN & 0xFC) >> 2))
+
+#pragma pack( 1 )
+
+/*-------------------------
+ * Disable Message Filter Table
+ *-------------------------*/
+typedef struct
+{
+    uint8_t                   NetFn;
+    uint8_t                   Command;
+}  DisableMsgFilterTbl_T;
+
+typedef struct
+{
+    uint8_t                   NetFn;
+    uint8_t                   Cmd;
+}  FlashModeFilterTbl_T;
+
+
+/*----------------------------------
+ * IPMI Commands Filter List Structure  
+ *----------------------------------*/
+typedef struct
+{
+    uint8_t   NetFn;
+    uint8_t   Cmd;
+}  IPMICmdsFilterTbl_T;
+
+
+/* IPMI Message Header */
+typedef struct
+{
+    uint8_t	ResAddr;
+    uint8_t	NetFnLUN;
+    uint8_t	ChkSum;
+    uint8_t	ReqAddr;
+    uint8_t	RqSeqLUN;
+    uint8_t	Cmd;
+} IPMIMsgHdr_T;
+
+typedef struct
+{
+    uint32_t SessionID;
+    uint8_t Privilege;
+    uint16_t IPMIMsgLen;
+    uint8_t NetFnLUN;
+    uint8_t Cmd;
+    uint8_t ChannelNum;
+    uint8_t AuthFlag;
+    uint8_t UserName[MAX_USER_NAME_LEN];
+    uint8_t IPAddr[IP6_ADDR_LEN];
+    uint32_t ProcessID;
+    uint32_t ThreadID;
+}IPMIUDSMsg_T;
+
+#pragma pack( )
+
+
+
+
+#endif	/* IPMI_DEFS_H */

+ 95 - 0
app/common_include/com_IPMI_App.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.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************
+ *****************************************************************
+ *
+ * IPMI_App.h
+ * Application Command numbers
+ *
+ *****************************************************************/
+#ifndef IPMI_APP_H
+#define IPMI_APP_H
+
+/*** Application Commands ***/
+#define CMD_GET_DEV_ID              0x01
+#define CMD_BROADCAST_GET_DEV_ID    0x01
+#define CMD_COLD_RESET              0x02
+#define CMD_WARM_RESET              0x03
+#define CMD_GET_SELF_TEST_RESULTS   0x04
+#define CMD_MFG_TEST_ON             0x05
+#define CMD_SET_ACPI_PWR_STATE      0x06
+#define CMD_GET_ACPI_PWR_STATE      0x07
+#define CMD_GET_DEV_GUID            0x08
+#define CMD_GET_NETFN_SUP           0x09
+#define CMD_GET_CMD_SUP             0x0A
+#define CMD_GET_SUBFN_SUP           0x0B
+#define CMD_GET_CONFIG_CMDS         0x0C
+#define CMD_GET_CONFIG_SUB_FNS      0x0D
+
+
+#define CMD_SET_CMD_ENABLES         0x60
+#define CMD_GET_CMD_ENABLES         0x61
+#define CMD_SET_SUBFN_ENABLES       0x62
+#define CMD_GET_SUBFN_ENABLES       0x63
+#define CMD_GET_OEM_NETFN_IANA_SUPPORT   0x64
+
+
+#define CMD_RESET_WDT               0x22
+#define CMD_SET_WDT                 0x24
+#define CMD_GET_WDT                 0x25
+
+#define CMD_SET_BMC_GBL_ENABLES     0x2E
+#define CMD_GET_BMC_GBL_ENABLES     0x2F
+#define CMD_CLR_MSG_FLAGS           0x30
+#define CMD_GET_MSG_FLAGS           0x31
+#define CMD_ENBL_MSG_CH_RCV         0x32
+#define CMD_GET_MSG                 0x33
+#define CMD_SEND_MSG                0x34
+#define CMD_READ_EVT_MSG_BUFFER     0x35
+#define CMD_GET_BTIFC_CAP           0x36
+#define CMD_GET_SYSTEM_GUID         0x37
+#define CMD_GET_CH_AUTH_CAP         0x38
+#define CMD_GET_SESSION_CHALLENGE   0x39
+#define CMD_ACTIVATE_SESSION        0x3A
+#define CMD_SET_SESSION_PRIV_LEVEL  0x3B
+#define CMD_CLOSE_SESSION           0x3C
+#define CMD_GET_SESSION_INFO        0x3D
+#define CMD_GET_AUTH_CODE           0x3F
+#define CMD_SET_CH_ACCESS           0x40
+#define CMD_GET_CH_ACCESS           0x41
+#define CMD_GET_CH_INFO             0x42
+#define CMD_SET_USER_ACCESS         0x43
+#define CMD_GET_USER_ACCESS         0x44
+#define CMD_SET_USER_NAME           0x45
+#define CMD_GET_USER_NAME           0x46
+#define CMD_SET_USER_PASSWORD       0x47
+#define CMD_MASTER_WRITE_READ       0x52
+
+#define CMD_ACTIVATE_PAYLOAD        0x48
+#define CMD_DEACTIVATE_PAYLOAD      0x49
+#define CMD_GET_PAYLD_ACT_STATUS    0x4A
+#define CMD_GET_PAYLD_INST_INFO     0x4B
+#define CMD_SET_USR_PAYLOAD_ACCESS  0x4C
+#define CMD_GET_USR_PAYLOAD_ACCESS  0x4D
+#define CMD_GET_CH_PAYLOAD_SUPPORT  0x4E
+#define CMD_GET_CH_PAYLOAD_VER      0x4F
+#define CMD_GET_CH_OEM_PAYLOAD_INFO 0x50
+#define CMD_GET_CH_CIPHER_SUITES    0x54
+#define CMD_SUS_RES_PAYLOAD_ENCRYPT 0x55
+#define CMD_SET_CH_SECURITY_KEYS    0x56
+#define CMD_GET_SYS_IFC_CAPS        0x57
+
+#define CMD_SET_SYSTEM_INFO_PARAM   0x58
+#define CMD_GET_SYSTEM_INFO_PARAM   0x59
+#endif  /* IPMI_APP_H */
+

+ 619 - 0
app/common_include/com_IPMI_AppDevice.h

@@ -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.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************
+ *****************************************************************
+ *
+ * IPMI_App.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 IPMI_APPDEV_H
+#define IPMI_APPDEV_H
+
+#include <stdint.h>
+
+/*** Macro definition ***/
+#define CHALLENGE_STR_LEN       16
+#define AUTH_CODE_LEN           16
+#define MAX_APP_CONF_PARAM				4
+#define MIN_SYSINFO_OEM_CONF_PARAM		192
+#define MAX_SYSINFO_OEM_CONF_PARAM		255
+
+/* Added to Support IPMI v2.0/RMCP+ Integrity Algorithm Number */ 
+#define AUTH_CODE_HASH_LEN      20 
+#define HASH_DATA_LEN           16 
+#define MAX_USERNAME_LEN        16
+#define MAX_PASSWORD_LEN        20
+#define  MAX_I2C_BUFFER_SIZE    50
+#define IPMI15_MAX_PASSWORD_LEN 16
+#define SIXTEEN_COUNT_WINDOW_LEN 16
+#define SEQNUM_ROLLOVER 0xFFFFFFFF
+#define RMCPPLUS_SEQLOWLIMIT 16
+#define RMCPPLUS_SEQUPLIMIT 15
+#define EIGHT_COUNT_WINDOW_LEN 8
+#define	MAX_FW_VER_LENGTH  	254
+#define MAX_SYS_NAME_LENGTH	254
+#define MAX_PRIM_OS_NAME_LENGTH 254
+#define MAX_OS_NAME_LENGTH	254
+#define MAX_BLOCK_SIZE			16
+
+#define SYS_INFO_SET_COMPLETE    0x00
+#define SYS_INFO_SET_IN_PROGRESS 0x01
+#define SYS_INFO_COMMIT_WRITE	 0x02
+#define PARAM_PRESENT_REVISION   0x11
+#define PARAM_OLDER_REVISION 	 0x00
+
+#define SET_IN_PROGRESS_PARAM	0x00
+#define SYS_FW_VERSION_PARAM	0x01
+#define SYS_NAME_PARAM			0x02
+#define PRIM_OS_NAME_PARAM		0x03
+#define OS_NAME_PARAM			0x04
+#define MAX_PARAM_SELECTOR		OS_NAME_PARAM +1 /* Last Parameter + 1 */
+
+#define GET_PARAM_REV_ONLY		0x80
+
+
+
+
+#pragma pack( 1 )
+
+/* SetWDTReq_T */
+typedef struct
+{
+    uint8_t   TmrUse;
+    uint8_t   TmrActions;
+    uint8_t   PreTimeOutInterval;
+    uint8_t   ExpirationFlag;
+    uint16_t  InitCountDown;
+
+} SetWDTReq_T;
+
+/* GetWDTRes_T */
+typedef struct
+{
+    uint8_t       CompletionCode;
+    SetWDTReq_T CurrentSettings;
+    uint16_t      PresentCountDown;
+
+}   GetWDTRes_T;
+
+/* GetBMCGblEnblRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   BMCGblEnblByte;
+
+} GetBMCGblEnblRes_T;
+
+/* ClearMsgsFlagReq_T */
+typedef struct
+{
+    uint8_t   Flag;
+}   ClearMsgsFlagReq_T;
+
+/* GetMsgFlagsRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   MsgFlags;
+
+} GetMsgFlagsRes_T;
+
+/* EnblMsgChRcvReq_T */
+typedef struct
+{
+    uint8_t   ChannelNum;
+    uint8_t   ChannelState;
+
+}   EnblMsgChRcvReq_T;
+
+/* EnblMsgChRcvRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   ChannelNum;
+    uint8_t   ChannelState;
+
+}   EnblMsgChRcvRes_T;
+
+/* GetMsgRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   ChannelNum;
+
+}   GetMsgRes_T;
+
+/* SendMsgReq_T */
+typedef struct
+{
+    uint8_t   ChNoTrackReq;
+
+}   SendMsgReq_T;
+
+/* SendMsgRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   ResData;
+
+}   SendMsgRes_T;
+
+/* ReadEvtMsgBufRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   ResData[16];
+
+}   ReadEvtMsgBufRes_T;
+
+/* GetBTIfcCapRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   NumReqSupported;
+    uint8_t   InputBufSize;
+    uint8_t   OutputBufSize;
+    uint8_t   RespTime;
+    uint8_t   Retries;
+
+}   GetBTIfcCapRes_T;
+
+/* GetSysGUIDRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   Node[6];
+    uint16_t  ClockSeq;
+    uint16_t  TimeHigh;
+    uint16_t  TimeMid;
+    uint32_t  TimeLow;
+
+}   GetSysGUIDRes_T;
+
+/* GetChAuthCapReq_T */
+typedef struct
+{
+    uint8_t   ChannelNum;
+    uint8_t   PrivLevel;
+
+}   GetChAuthCapReq_T;
+
+/* GetChAuthCapRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   ChannelNum;
+    uint8_t   AuthType;
+    uint8_t   PerMsgUserAuthLoginStatus;
+    uint8_t   ExtCap;
+    uint8_t   OEMID[3];
+    uint8_t   OEMAuxData;
+
+}   GetChAuthCapRes_T;
+
+/* GetSesChallengeReq_T */
+typedef struct
+{
+    uint8_t   AuthType;
+    uint8_t   UserName[16];
+
+}   GetSesChallengeReq_T;
+
+/* GetSesChallengeRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint32_t  TempSessionID;
+    uint8_t   ChallengeString[16];
+
+}   GetSesChallengeRes_T;
+
+/* ActivateSesReq_T */
+typedef struct
+{
+    uint8_t   AuthType;
+    uint8_t   Privilege;
+    uint8_t   ChallengeString[CHALLENGE_STR_LEN];
+    uint32_t  OutboundSeq;
+
+}   ActivateSesReq_T;
+
+/* ActivateSesRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   AuthType;
+    uint32_t  SessionID;
+    uint32_t  InboundSeq;
+    uint8_t   Privilege;
+
+}   ActivateSesRes_T;
+
+/* SetSesPrivLevelReq_T */
+typedef struct
+{
+    uint8_t   Privilege;
+
+}   SetSesPrivLevelReq_T;
+
+/* SetSesPrivLevelRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   Privilege;
+
+}   SetSesPrivLevelRes_T;
+
+/* GetSesInfoReq_T */
+typedef struct
+{
+    uint8_t   SessionIndex;
+    uint8_t   SessionHandleOrID [4];
+
+}   GetSesInfoReq_T;
+
+/* LANSesInfoRes_T */
+typedef struct
+{
+    uint8_t    IPAddress[4];
+    uint8_t    MACAddress[6];
+    uint16_t   PortNumber;
+
+}   LANSesInfoRes_T;
+
+/* SerialSesInfoRes_T */
+typedef struct
+{
+    uint8_t    SessionActivityType;
+    uint8_t    DestinationSelector;
+    uint8_t    IPAddress[4];
+    uint16_t   PortNumber;
+
+}   SerialSesInfoRes_T;
+
+/* Union SessionInfoRes_T */
+typedef union
+{
+    LANSesInfoRes_T     LANSesInfo;
+    SerialSesInfoRes_T  SerialSesInfo;
+
+}   SessionInfoRes_T;
+
+/* ActiveSesInfo_T */
+typedef struct
+{
+    uint8_t       UserID;
+    uint8_t       Privilege;
+    uint8_t       ChannelNum;
+
+}   ActiveSesInfo_T;
+
+/* GetSesInfoRes_T */
+typedef struct
+{
+    uint8_t               CompletionCode;
+    uint8_t               SessionHandle;
+    uint8_t               NumPossibleActiveSession;
+    uint8_t               NumActiveSession;
+    ActiveSesInfo_T     ActiveSesinfo;
+    SessionInfoRes_T    SesInfo;
+
+}   GetSesInfoRes_T;
+
+/* LANIPv6SesInfoRes_T */
+typedef struct
+{
+    uint8_t    IPv6Address[16];
+    uint8_t    MACAddress[6];
+    uint16_t   PortNumber;
+
+}   LANIPv6SesInfoRes_T;
+
+/* CloseSesReq_T */
+typedef struct
+{
+    uint32_t  SessionID;
+    uint8_t   SessionHandle;
+
+}   CloseSesReq_T;
+
+/* GetAuthCodeReq_T */
+typedef struct
+{
+    uint8_t   AuthType;
+    uint8_t   ChannelNum;
+    uint8_t   UserID;
+    uint8_t   HashData[HASH_DATA_LEN];
+
+}   GetAuthCodeReq_T;
+
+
+/* GetAuthCodeRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   AuthCode[AUTH_CODE_HASH_LEN];
+
+}   GetAuthCodeRes_T;
+
+/* SetChAccessReq_T */
+typedef struct
+{
+    uint8_t   ChannelNum;
+    uint8_t   ChannelAccess;
+    uint8_t   Privilege;
+
+}   SetChAccessReq_T;
+
+typedef struct
+{
+	uint8_t		CompletionCode;
+}   SetChAccessRes_T;
+
+/* GetChAccessReq_T */
+typedef struct
+{
+    uint8_t   ChannelNum;
+    uint8_t   AccessFlag;
+
+}   GetChAccessReq_T;
+
+/* GetChAccessRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   ChannelAccess;
+    uint8_t   Privilege;
+
+}   GetChAccessRes_T;
+
+typedef struct
+{
+	uint8_t ChannelNum;
+}   GetChInfoReq_T;
+
+/* GetChInfoRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   ChannelNum;
+    uint8_t   ChannelMedium;
+    uint8_t   ChannelProtocol;
+    uint8_t   SessionActiveSupport;
+    uint8_t   VendorID[3];
+    uint8_t   AuxiliaryInfo[2];
+
+}   GetChInfoRes_T;
+
+/* SetUserAccessReq_T */
+typedef struct
+{
+    uint8_t   ChannelNoUserAccess;
+    uint8_t   UserID;
+    uint8_t   AccessLimit;
+    uint8_t   SessionLimit;
+
+}   SetUserAccessReq_T;
+
+typedef struct
+{
+    uint8_t CompletionCode;
+}   SetUserAccessRes_T;
+
+
+/* GetUserAccessReq_T */
+typedef struct
+{
+    uint8_t   ChannelNum;
+    uint8_t   UserID;
+
+}   GetUserAccessReq_T;
+
+/* GetUserAccessRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   MaxNoUserID;
+    uint8_t   CurrentUserID;
+    uint8_t   FixedUserID;
+    uint8_t   ChannelAccess;
+
+}   GetUserAccessRes_T;
+
+/* SetUserNameReq_T */
+typedef struct
+{
+    uint8_t   UserID;
+    uint8_t   UserName[MAX_USERNAME_LEN];
+
+}   SetUserNameReq_T;
+
+typedef struct
+{
+    uint8_t   CompletionCode;
+}   SetUserNameRes_T;
+
+
+/*GetUserNameReq_T*/
+typedef struct
+{
+    uint8_t   UserID;
+}   GetUserNameReq_T;
+
+
+/* GetUserNameRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   UserName[MAX_USERNAME_LEN];
+
+}   GetUserNameRes_T;
+
+
+
+/* SetUserPswdReq_T */
+typedef struct
+{
+    uint8_t   UserID;
+    uint8_t   Operation;
+    uint8_t   Password[MAX_PASSWORD_LEN];
+
+}   SetUserPswdReq_T;
+
+/* SetUserPswdReq_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+}   SetUserPswdRes_T;
+
+/* MasterWriteReadReq_T */
+typedef struct
+{
+    uint8_t   BusTypeChNo;
+    uint8_t   SlaveAddress;
+    uint8_t   ReadCount;
+    uint8_t   Data[MAX_I2C_BUFFER_SIZE];
+
+}   MasterWriteReadReq_T;
+
+/* MasterWriteReadRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   Data[MAX_I2C_BUFFER_SIZE];
+
+}   MasterWriteReadRes_T;
+
+typedef struct 
+{
+    uint8_t       TypeOfEncoding ;
+    uint8_t       StringLength;
+    uint8_t       SysFWVersionName[MAX_FW_VER_LENGTH];
+}  SysFWVersion_T;
+typedef struct
+{
+    uint8_t    TypeOfEncoding_Sys_Name;
+    uint8_t    StringLength_Sys_Name;
+    uint8_t    SystemName[MAX_SYS_NAME_LENGTH];
+}   SysName_T;
+typedef struct 
+{
+    uint8_t    TypeOfEncoding_PrimaryOSName;
+    uint8_t    StringLength_PrimaryOSName;
+    uint8_t    PrimaryOperatingSystemName[MAX_PRIM_OS_NAME_LENGTH];
+}   PrimaryOSName_T;
+typedef struct 
+{
+    uint8_t    TypeOfEncoding_OSName;
+    uint8_t    StringLength_OSName;
+    uint8_t   OSName[MAX_OS_NAME_LENGTH];
+}  OSName_T;
+
+typedef struct 
+{
+    uint8_t   SetSelector;
+    uint8_t   SysFWVersion[MAX_BLOCK_SIZE];
+}   SysVerInfo_T;
+
+typedef struct 
+{
+
+    uint8_t   SetSelector;
+    uint8_t    SysName[MAX_BLOCK_SIZE];
+
+}   SysNameInfo_T;
+
+typedef struct {
+
+    uint8_t    SetSelector;
+    uint8_t    PrimaryOSName[MAX_BLOCK_SIZE];
+
+}   PrimOSInfo_T;
+
+
+typedef struct {
+
+    uint8_t   SetSelector;
+    uint8_t   OperatingSystemName[MAX_BLOCK_SIZE];
+
+}   OSInfo_T;
+
+typedef union {
+
+    uint8_t   SetInProgress;
+    SysVerInfo_T    SysVerInfo;
+    SysNameInfo_T   SysNameInfo;
+    PrimOSInfo_T    PrimOSInfo;
+    OSInfo_T    OSInfo;
+}    SysInfoUN_T	;
+
+
+/* GetSystemInfoParamReq_T */
+typedef struct
+{
+    uint8_t   ParamRev;
+    uint8_t   ParamSelector;
+    uint8_t   SetSelector;
+    uint8_t   BlockSelector;
+
+}   GetSystemInfoParamReq_T;
+
+
+/* GetSystemInfoParamRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   ParamRevision;
+    SysInfoUN_T     SysInfo;
+
+}   GetSystemInfoParamRes_T;
+
+/* GetSystemInfoParamOEMRes_T */
+typedef struct
+{
+    uint8_t           CompletionCode;
+    uint8_t           ParamRevision;
+    /* OEM Info */
+}   GetSystemInfoParamOEMRes_T;
+
+
+/* SetSystemInfoParamReq_T */
+typedef struct
+{
+    uint8_t   		ParamSelector;
+    SysInfoUN_T		SysInfo;
+}   SetSystemInfoParamReq_T;
+
+
+/* SetSystemInfoParamRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+}   SetSystemInfoParamRes_T;
+
+/* SetSystemInfoParamOEMReq_T */
+typedef struct
+{
+    uint8_t   ParamSelector;
+    /* OEM parameter */
+}   SetSystemInfoParamOEMReq_T;
+
+#pragma pack( )
+
+#endif /* IPMI_APPDEV_H */

+ 307 - 0
app/common_include/com_IPMI_IPM.h

@@ -0,0 +1,307 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************
+ ****************************************************************
+ *
+ * IPMI_IPM.h
+ * 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>
+ *
+ *****************************************************************/
+#ifndef IPMI_IPMDEV_H
+#define IPMI_IPMDEV_H
+#include <stdint.h>
+
+
+#pragma pack( 1 )
+
+/*** Macro Definitions ***/
+/**
+ * @def DEVICE_ID
+ * @brief Device ID
+ **/
+#define DEVICE_ID                       0x20
+/**
+ * @def SDR_SUPPORT
+ * @brief SDR support bit flag 
+ **/
+#define SDR_SUPPORT                     0x80    
+/**
+ * @def DEV_REVISION                    
+ * @brief Device Revision 
+ **/
+#define DEV_REVISION                    0x01    
+#define IPMI_DEV_REVISION               DEV_REVISION
+/**
+ * @def DEV_AVAILABLE                   
+ * @brief Device availability bit flag
+ **/
+#define DEV_AVAILABLE                   0x80
+/**
+ * @def IPMI_VERSION
+ * @brief IPMI version
+ **/
+#define IPMI_VERSION                    0x02
+/**
+ * @def CHASSIS_DEVICE_SUPPORT          
+ * @brief Chassis Device support bit flag
+ **/
+#define CHASSIS_DEVICE_SUPPORT          ( CHASSIS_DEVICE << 7 )
+/**
+ * @def BRIDGE_COMMAND_SUPPORT          
+ * @brief Bridge Device support bit flag
+ **/
+#define BRIDGE_COMMAND_SUPPORT          ( BRIDGE_DEVICE << 6 )
+/**
+ * @def IPMB_EVENT_GENERATOR_SUPPORT    
+ * @brief IPMB Event generator support bit flag 
+ **/
+#define IPMB_EVENT_GENERATOR_SUPPORT    ( EVENT_GENERATOR << 5 )
+/**
+ * @def IPMB_EVENT_RECEIVER_SUPPORT     
+ * @brief IPMB Event receiver support bit flag 
+ **/
+#define IPMB_EVENT_RECEIVER_SUPPORT     ( EVENT_RECEIVER << 4 )
+/**
+ * @def FRU_INVENTORY_DEVICE_SUPPORT    
+ * @brief FRU Device support bit flag 
+ **/
+#define FRU_INVENTORY_DEVICE_SUPPORT    ( FRU_DEVICE << 3 )
+/**
+ * @def SEL_DEVICE_SUPPORT              
+ * @brief SEL Device support bit flag 
+ **/
+#define SEL_DEVICE_SUPPORT              ( SEL_DEVICE << 2 )
+/**
+ * @def SDR_REPOSITORY_DEVICE_SUPPORT   
+ * @brief SDR Device support bit flag
+ **/
+#define SDR_REPOSITORY_DEVICE_SUPPORT   ( SDR_DEVICE << 1 )
+/**
+ * @def SENSOR_DEVICE_SUPPORT           
+ * @brief Sensor Device support bit flag 
+ **/
+#define SENSOR_DEVICE_SUPPORT           ( SENSOR_DEVICE )
+
+#define DEV_SUPPORT                     CHASSIS_DEVICE_SUPPORT          | BRIDGE_COMMAND_SUPPORT        | \
+                                        IPMB_EVENT_GENERATOR_SUPPORT    | IPMB_EVENT_RECEIVER_SUPPORT   | \
+                                        FRU_INVENTORY_DEVICE_SUPPORT    | SEL_DEVICE_SUPPORT            | \
+                                        SDR_REPOSITORY_DEVICE_SUPPORT   | SENSOR_DEVICE_SUPPORT 
+/**
+ * @def MFG_ID_AMI                      
+ * @brief IANA number for AMI 
+ **/
+#define MFG_ID_AMI                      {0x00,0x00,0x00}    
+/**
+ * @def PROD_ID_AMI_PM                  
+ * @brief AMI Product ID {'E','M'} 
+ **/
+#define PROD_ID_AMI_PM                  0x0000
+
+/**
+ * @def DEV_GUID_NODE                   
+ * @brief node - Mac Address 
+ **/
+#define DEV_GUID_NODE                   {0x45,0xDF,0x44,0xAC,0x25,0xD4} 
+/**
+ * @def DEV_GUID_CLOCK_SEQ              
+ * @brief GUID Clolck Sequenbce
+ **/
+#define DEV_GUID_CLOCK_SEQ              0xB24A  
+/**
+ * @def DEV_GUID_TIME_HIGH
+ * @brief GUID Time High 
+ **/
+#define DEV_GUID_TIME_HIGH              0x48F3  
+/**
+ * @def DEV_GUID_TIME_MID               
+ * @brief GUID Time Mid 
+ **/
+#define DEV_GUID_TIME_MID               0x4F46  
+/**
+ * @def DEV_GUID_TIME_LOW               
+ * @brief GUID Time Low 
+ **/
+#define DEV_GUID_TIME_LOW               0xBD2C300A 
+
+/**
+ * @def GST_NO_ERROR
+ * @brief Error Code for Get Self Test Results
+ **/
+#define GST_NO_ERROR                    0x55 
+/**
+ * @def GST_CORRUPTED_DEVICES           
+ * @brief Error code for Get Self Test Results 
+ **/
+#define GST_CORRUPTED_DEVICES           0x57 
+/**
+ * @def GST_CANNOT_ACCESS_SEL           
+ * @brief Error code for Get Self Test Results 
+ **/
+#define GST_CANNOT_ACCESS_SEL           0x80 
+/**
+ * @def GST_CANNOT_ACCESS_SDR           
+ * @brief Error code for Get Self Test Results
+ **/
+#define GST_CANNOT_ACCESS_SDR           0x40
+/**
+ * @def GST_CANNOT_ACCESS_FRU           
+ * @brief Error code for Get Self Test Results 
+ **/
+#define GST_CANNOT_ACCESS_FRU           0x20 
+/**
+ * @def GST_IPMB_DO_NOT_RESPOND         
+ * @brief Error code for Get Self Test Results 
+ **/
+#define GST_IPMB_DO_NOT_RESPOND         0x10 
+/**
+ * @def GST_SDR_EMPTY
+ * @brief Error code for Get Self Test Results
+ **/
+#define GST_SDR_EMPTY                   0x08 
+/**
+ * @def GST_FRU_CORRUPTED               
+ * @brief Error code for Get Self Test Results 
+ **/
+#define GST_FRU_CORRUPTED               0x04 
+/**
+ * @def GST_BBLK_CORRUPTED              
+ * @brief Error code for Get Self Test Results 
+ **/
+#define GST_BBLK_CORRUPTED              0x02 
+/**
+ * @def GST_FIRMWARE_CORRUPTED          
+ * @brief Error code for Get Self Test Results 
+ **/
+#define GST_FIRMWARE_CORRUPTED          0x01 
+
+/**
+ * @def IPMI_ACPI_S0                    
+ * @brief ACPI State
+ **/
+#define IPMI_ACPI_S0                    0x00    
+/**
+ * @def IPMI_ACPI_S1                    
+ * @brief ACPI State 
+ **/
+#define IPMI_ACPI_S1                    0x01    
+/**
+ * @def IPMI_ACPI_S2
+ * @brief ACPI State 
+ **/
+#define IPMI_ACPI_S2                    0x02    
+/**
+ * @def IPMI_ACPI_S3                    
+ * @brief ACPI State
+ **/
+#define IPMI_ACPI_S3                    0x03    
+/**
+ * @def IPMI_ACPI_S4                    
+ * @brief ACPI State 
+ **/
+#define IPMI_ACPI_S4                    0x04
+/**
+ * @def IPMI_ACPI_S5                    
+ * @brief ACPI State 
+ **/
+#define IPMI_ACPI_S5                    0x05    
+/**
+ * @def IPMI_ACPI_S4_S5                 
+ * @brief ACPI State 
+ **/
+#define IPMI_ACPI_S4_S5                 0x06    
+/**
+ * @def IPMI_ACPI_G3                    
+ * @brief ACPI State 
+ **/
+#define IPMI_ACPI_G3                    0x07
+/**
+ * @def IPMI_ACPI_LEGACY_ON
+ * @brief ACPI State
+ **/
+#define IPMI_ACPI_LEGACY_ON             0x20
+
+/**
+ * @def IPMI_ACPI_LEGACY_OFF
+ * @brief ACPI State
+ **/
+#define IPMI_ACPI_LEGACY_OFF            0x21
+
+/**
+ * @def IPMI_ACPI_SLEEPING_S1_S3                    
+ * @brief ACPI State 
+ **/
+#define IPMI_ACPI_SLEEPING_S1_S3        0x08
+/**
+ * @def IPMI_ACPI_G1_SLEPPING_S1_S4                    
+ * @brief ACPI State 
+ **/
+#define IPMI_ACPI_G1_SLEPPING_S1_S4     0x09
+
+/**
+ * @def IPMI_S5_OVERRIDE
+ * @brief ACPI State 
+ **/
+#define IPMI_S5_OVERRIDE                0x0A
+
+/* GetDevIDRes_T */
+typedef struct {
+    uint8_t   CompletionCode;
+    uint8_t   DeviceID;
+    uint8_t   DevRevision;
+    uint8_t   FirmwareRevision1;
+    uint8_t   FirmwareRevision2;
+    uint8_t   IPMIVersion;
+    uint8_t   DevSupport;
+    uint8_t   MfgID[3];
+    uint16_t  ProdID;
+    uint32_t  AuxFirmwareRevision;
+}  GetDevIDRes_T;
+
+/* GetSelfTestRes_T */
+typedef struct {
+    uint8_t   CompletionCode;
+    uint8_t   TestResultByte1;
+    uint8_t   TestResultByte2;
+}  GetSelfTestRes_T;
+
+/* SetACPIPwrStateReq_T */
+typedef struct {
+    uint8_t   ACPISysPwrState;
+    uint8_t   ACPIDevPwrState;
+}  SetACPIPwrStateReq_T;
+
+/* getACPIPwrStateRes_T */
+typedef struct {
+    uint8_t   CompletionCode;
+    uint8_t   ACPISysPwrState;
+    uint8_t   ACPIDevPwrState;
+}  GetACPIPwrStateRes_T;
+
+/* GetDevGUIDRes_T */
+typedef struct {
+    uint8_t   CompletionCode;
+    uint8_t   Node[6];
+    uint16_t  ClockSeq;
+    uint16_t  TimeHigh;
+    uint16_t  TimeMid;
+    uint32_t  TimeLow;
+}  GetDevGUIDRes_T;
+
+#pragma pack( )
+
+#endif /* IPMI_IPMDEV_H */

+ 43 - 0
app/common_include/com_UDSIfc.h

@@ -0,0 +1,43 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************/
+/*****************************************************************
+ *
+ * UDSIfc.h
+ *
+ * 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
+
+/* 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
+
+#define UDS_SUCCESS 0
+#define UDS_CMD_FAILURE 1
+#define UDS_FAILURE -1
+#define UDS_PARAM_FAILURE -2
+
+#define UDS_SOCKET_PATH "/var/UDSocket"
+
+
+#endif /* UDSIFC_H */

BIN
app/driver/FMC/fmc.mod.o


BIN
app/driver/FMC/fmc.o


BIN
app/driver/FMC/fmc_main.o


BIN
app/driver/I2C/.i2c_main.c.swp


BIN
app/driver/I2C/.stm32f429_hw.h.swp


BIN
app/driver/Platform/platform_STM32F429.mod.o


BIN
app/driver/Platform/platform_STM32F429.o


BIN
app/driver/Platform/platform_main.o


BIN
app/driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.o


BIN
app/driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.o


BIN
app/driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.o


BIN
app/driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.o


BIN
app/driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.o


BIN
app/driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.o


BIN
app/driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.o


BIN
app/driver/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fmc.o


BIN
app/driver/STM32F4xx_HAL_Driver/system_stm32f4xx.o


BIN
app/driver/test/test_main.o


BIN
app/driver/test/test_module.mod.o


BIN
app/driver/test/test_module.o


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/goahead


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/goahead-test


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/goahead-test.gdb


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/goahead.gdb


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/gopass


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/gopass.gdb


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/libgo.a


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/libgoahead-mbedtls.a


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/libmbedtls.a


+ 151 - 0
app/goahead-5.1.0/build/linux-arm-static/inc/cJSON.h

@@ -0,0 +1,151 @@
+/*
+  Copyright (c) 2009 Dave Gamble
+ 
+  Permission is hereby granted, free of charge, to any person obtaining a copy
+  of this software and associated documentation files (the "Software"), to deal
+  in the Software without restriction, including without limitation the rights
+  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+  copies of the Software, and to permit persons to whom the Software is
+  furnished to do so, subject to the following conditions:
+ 
+  The above copyright notice and this permission notice shall be included in
+  all copies or substantial portions of the Software.
+ 
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+  THE SOFTWARE.
+*/
+
+#ifndef cJSON__h
+#define cJSON__h
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* cJSON Types: */
+#define cJSON_False 0
+#define cJSON_True 1
+#define cJSON_NULL 2
+#define cJSON_Number 3
+#define cJSON_String 4
+#define cJSON_Array 5
+#define cJSON_Object 6
+	
+#define cJSON_IsReference 256
+#define cJSON_StringIsConst 512
+
+/* The cJSON structure: */
+typedef struct cJSON {
+	struct cJSON *next,*prev;	/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
+	struct cJSON *child;		/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
+
+	int type;					/* The type of the item, as above. */
+
+	char *valuestring;			/* The item's string, if type==cJSON_String */
+	int valueint;				/* The item's number, if type==cJSON_Number */
+	double valuedouble;			/* The item's number, if type==cJSON_Number */
+
+	char *string;				/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
+} cJSON;
+
+typedef struct cJSON_Hooks {
+      void *(*malloc_fn)(size_t sz);
+      void (*free_fn)(void *ptr);
+} cJSON_Hooks;
+
+extern void jimboTestcJson(void);
+
+/* Supply malloc, realloc and free functions to cJSON */
+extern void cJSON_InitHooks(cJSON_Hooks* hooks);
+
+
+/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
+extern cJSON *cJSON_Parse(const char *value);
+/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
+extern char  *cJSON_Print(cJSON *item);
+/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
+extern char  *cJSON_PrintUnformatted(cJSON *item);
+/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
+extern char *cJSON_PrintBuffered(cJSON *item,int prebuffer,int fmt);
+/* Delete a cJSON entity and all subentities. */
+extern void   cJSON_Delete(cJSON *c);
+
+/* Returns the number of items in an array (or object). */
+extern int	  cJSON_GetArraySize(cJSON *array);
+/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
+extern cJSON *cJSON_GetArrayItem(cJSON *array,int item);
+/* Get item "string" from object. Case insensitive. */
+extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
+
+/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
+extern const char *cJSON_GetErrorPtr(void);
+	
+/* These calls create a cJSON item of the appropriate type. */
+extern cJSON *cJSON_CreateNull(void);
+extern cJSON *cJSON_CreateTrue(void);
+extern cJSON *cJSON_CreateFalse(void);
+extern cJSON *cJSON_CreateBool(int b);
+extern cJSON *cJSON_CreateNumber(double num);
+extern cJSON *cJSON_CreateString(const char *string);
+extern cJSON *cJSON_CreateArray(void);
+extern cJSON *cJSON_CreateObject(void);
+
+/* These utilities create an Array of count items. */
+extern cJSON *cJSON_CreateIntArray(const int *numbers,int count);
+extern cJSON *cJSON_CreateFloatArray(const float *numbers,int count);
+extern cJSON *cJSON_CreateDoubleArray(const double *numbers,int count);
+extern cJSON *cJSON_CreateStringArray(const char **strings,int count);
+
+/* Append item to the specified array/object. */
+extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
+extern void	cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item);
+extern void	cJSON_AddItemToObjectCS(cJSON *object,const char *string,cJSON *item);	/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object */
+/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
+extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
+extern void	cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item);
+
+/* Remove/Detatch items from Arrays/Objects. */
+extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which);
+extern void   cJSON_DeleteItemFromArray(cJSON *array,int which);
+extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string);
+extern void   cJSON_DeleteItemFromObject(cJSON *object,const char *string);
+	
+/* Update array items. */
+extern void cJSON_InsertItemInArray(cJSON *array,int which,cJSON *newitem);	/* Shifts pre-existing items to the right. */
+extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
+extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
+
+/* Duplicate a cJSON item */
+extern cJSON *cJSON_Duplicate(cJSON *item,int recurse);
+/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
+need to be released. With recurse!=0, it will duplicate any children connected to the item.
+The item->next and ->prev pointers are always zero on return from Duplicate. */
+
+/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
+extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated);
+
+extern void cJSON_Minify(char *json);
+
+/* Macros for creating things quickly. */
+#define cJSON_AddNullToObject(object,name)		cJSON_AddItemToObject(object, name, cJSON_CreateNull())
+#define cJSON_AddTrueToObject(object,name)		cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
+#define cJSON_AddFalseToObject(object,name)		cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
+#define cJSON_AddBoolToObject(object,name,b)	cJSON_AddItemToObject(object, name, cJSON_CreateBool(b))
+#define cJSON_AddNumberToObject(object,name,n)	cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
+#define cJSON_AddStringToObject(object,name,s)	cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
+
+/* When assigning an integer value, it needs to be propagated to valuedouble too. */
+#define cJSON_SetIntValue(object,val)			((object)?(object)->valueint=(object)->valuedouble=(val):(val))
+#define cJSON_SetNumberValue(object,val)		((object)?(object)->valueint=(object)->valuedouble=(val):(val))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

+ 359 - 0
app/goahead-5.1.0/build/linux-arm-static/inc/com_IPMIDefs.h

@@ -0,0 +1,359 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************
+ ****************************************************************
+ ******************************************************************
+ *
+ * ipmi_defs.h
+ * IPMI Definitions
+ *
+ *  Author: Govind Kothandapani <govindk@ami.com>
+ *
+ ******************************************************************/
+#ifndef  IPMI_DEFS_H
+#define IPMI_DEFS_H
+
+#include <stdint.h>
+
+#ifndef TRUE
+    #define TRUE 1
+#endif
+
+#ifndef FALSE
+    #define FALSE 0
+#endif    
+
+
+/*----------------------------------------------
+ * Bit fields
+ *----------------------------------------------*/
+#define BIT0    0x0001
+#define BIT1    0x0002
+#define BIT2    0x0004
+#define BIT3    0x0008
+#define BIT4    0x0010
+#define BIT5    0x0020
+#define BIT6    0x0040
+#define BIT7    0x0080
+#define BIT8    0x0100
+#define BIT9    0x0200
+#define BIT10   0x0400
+#define BIT11   0x0800
+#define BIT12   0x1000
+#define BIT13   0x2000
+#define BIT14   0x4000
+#define BIT15   0x8000
+
+/*------- Net Functions  -------------------*/
+#define NETFN_CHASSIS                     0x00
+#define NETFN_BRIDGE                      0x02
+#define NETFN_SENSOR                      0x04
+#define NETFN_APP                         0x06
+#define NETFN_FIRMWARE                    0x08
+#define NETFN_STORAGE                     0x0A
+#define NETFN_TRANSPORT                   0x0C
+#define NETFN_PICMG                       0x2C
+#define NETFN_AMI                         0x32
+#define NETFN_OEM                         0x2E
+#define NETFN_OPMA1                       0x30
+#define NETFN_OPMA2                       0x3E
+#ifdef  CFG_PROJ_SHMC_TEST_SUPPORT_YES
+#define NETFN_TEST_OEM                    0x34
+#endif
+
+#define NETFN_UNKNOWN                     0xFF
+#define IPMI_CMD_UNKNOWN                  0xFF
+
+#define NETFN_GROUP_EXTN                  0x2C
+#define IPMI_GROUP_EXTN_CODE_DCMI         0xDC
+
+#define MAX_USER_NAME_LEN                 (16+1) //+1 for null terminator
+#define IP6_ADDR_LEN                      16
+
+/**** Command Completion Codes ****/
+#define CC_NORMAL                                       0x00
+#define CC_SUCCESS                                      0x00
+#define CC_NODE_BUSY                                    0xC0
+#define CC_INV_CMD                                      0xC1
+#define CC_INV_CMD_FOR_LUN                              0xC2
+#define CC_TIMEOUT                                      0xC3
+#define CC_OUT_OF_SPACE                                 0xC4
+#define CC_INV_RESERVATION_ID                           0xC5
+#define CC_REQ_TRUNCATED                                0xC6
+#define CC_REQ_INV_LEN                                  0xC7
+#define CC_REQ_FIELD_LEN_EXCEEDED                       0xC8
+#define CC_PARAM_OUT_OF_RANGE                           0xC9
+#define CC_CANNOT_RETURN_REQ_BYTES                      0xCA
+#define CC_SEL_REC_NOT_PRESENT                          0xCB
+#define CC_SDR_REC_NOT_PRESENT                          0xCB
+#define CC_FRU_REC_NOT_PRESENT                          0xCB
+#define CC_INV_DATA_FIELD                               0xCC
+#define CC_ILLEGAL_CMD_FOR_SENSOR_REC                   0xCD
+#define CC_COULD_NOT_PROVIDE_RESP                       0xCE
+#define CC_CANNOT_EXEC_DUPL_REQ                         0xCF
+#define CC_SDR_REP_IN_UPDATE_MODE                       0xD0
+#define CC_DEV_IN_FIRMWARE_UPDATE_MODE                  0xD1
+#define CC_INIT_AGENT_IN_PROGRESS                       0xD2
+#define CC_DEST_UNAVAILABLE                             0xD3
+#define CC_INSUFFIENT_PRIVILEGE                         0xD4
+#define CC_PARAM_NOT_SUP_IN_CUR_STATE                   0xD5
+#define CC_ERR_HANDLING_COMMAND_FAILURE                 0xD6
+#define CC_UNSPECIFIED_ERR                              0xFF
+#define CC_GET_MSG_QUEUE_EMPTY                          0x80
+#define CC_EVT_MSG_QUEUE_EMPTY                          0x80
+#define CC_GET_SESSION_INVALID_USER                     0x81
+#define CC_GET_SESSION_NULL_USER_DISABLED               0x82
+#define CC_ACTIVATE_SESS_NO_SESSION_SLOT_AVAILABLE      0x81
+#define CC_ACTIVATE_SESS_NO_SLOT_AVAILABLE_USER         0x82
+#define CC_ACTIVATE_SESS_REQ_LEVEL_EXCEEDS_LIMIT        0x83
+#define CC_ACTIVATE_SESS_SEQ_OUT_OF_RANGE               0x84
+#define CC_ACTIVATE_SESS_INVALID_SESSION_ID             0x85
+#define CC_ACTIVATE_SESS_MAX_PRIVILEGE_EXCEEDS_LIMIT    0x86
+#define CC_PASSWORD_TEST_FAILED                         0x80
+#define CC_PASSWORD_TEST_FAILED_WRONG_SIZE              0x81
+#define CC_SETPASSWORD_INVALID_USERID                   0x81
+#define CC_SETPASSWORD_CANNOT_DISABLE_USER              0x82
+#define CC_NO_ACK_FROM_SLAVE                            0x83
+#define CC_GET_CH_COMMAND_NOT_SUPPORTED                 0x82
+#define CC_SET_CH_COMMAND_NOT_SUPPORTED                 0x82
+#define CC_SET_CH_ACCES_MODE_NOT_SUPPORTED              0x83
+#define CC_SET_SESS_PREV_REQ_LEVEL_NOT_AVAILABLE        0x80
+#define CC_SET_SESS_PREV_REQ_PRIVILEGE_EXCEEDS_LIMIT    0x81
+#define CC_SET_SESS_PREV_INVALID_SESSION_ID             0x82
+#define CC_ACTIVATE_SESS_NO_SLOT_AVAILABLE_USER         0x82
+#define CC_CLOSE_INVALID_SESSION_ID                     0x87
+#define CC_CLOSE_INVALID_SESSION_ID_HANDLE              0x88
+#define CC_PEF_PARAM_NOT_SUPPORTED                      0x80
+#define CC_PEF_SET_IN_PROGRESS                          0x81
+#define CC_SESSION_IN_PROGRESS                          0x82
+#define CC_PEF_ATTEMPT_TO_SET_READ_ONLY_PARAM           0x82
+#define CC_SET_IN_PROGRESS                              0x81
+#define CC_ATTEMPT_TO_SET_RO_PARAM                      0x82
+#define CC_PARAM_NOT_SUPPORTED                          0x80
+#define CC_BIOS_NOT_READY                               0x82
+#define CC_IFC_NOT_SUPPORTED                            0x81
+#define CC_DISABLE_SM                                   0x81
+#define CC_BIOS_IS_BUSY                                 0x81
+#define CC_CMD_UNSUPPORTED_UNCONFIGURABLE               0x80
+#define CC_NTP_RESTART_ERROR                            0x80
+
+#define CC_CALLBACK_REJ_SESSION_ACTIVE                  0x82
+#define CC_WRITE_ONLY_PARAM                             0x83
+
+#define CC_INST_ALREADY_ACTIVE                          0x80
+#define CC_CANNOT_ACTIVATE_WITH_ENCR                    0x83
+#define CC_PAYLOAD_NOT_ENABLED                          0x81
+#define CC_INST_EXCEEDED                                0x82
+#define CC_INST_ALREADY_INACTIVE                        0x80
+#define CC_PAYLOAD_NOT_AVAILABLE                        0x80
+#define CC_ENCRYPT_NOT_AVAILABLE                        0x82
+#define CC_INST_NOT_ACTIVE                              0x83
+#define CC_KEYS_LOCKED                                  0x80
+#define CC_INSUF_KEY_BYTES                              0x81
+#define CC_TOO_MANY_KEY_BYTES                           0x82
+#define CC_KEY_MISMATCH                                 0x83
+
+#define CC_INVALID_KEY                                  0x80
+
+#define CC_OP_NOT_SUPPORTED                             0x80
+#define CC_OP_NOT_ALLOWED                               0x81
+#define CC_ENC_NOT_AVAILABLE                            0x82
+#define CC_CANNOT_ACTIVATE_WITH_ENCR                    0x83
+#define CC_CANNOT_ACTIVATE_WITHOUT_ENCR                 0x84
+
+#define CC_ATTEMPT_TO_RESET_UNIN_WATCHDOG               0x80
+
+#define CC_ILLEGAL_CONNECTOR_ID                         0x81
+#define CC_SEL_ERASE_IN_PROGRESS                        0x81
+
+#define CC_SAME_PAM_ORDER                               0x90
+#define CC_PAM_ORDER_SEC_DIFERS                         0x91
+#define CC_PAM_ORDER_FILE_DIFERS                        0x92
+
+#define CC_INSUFFICIENT_SLAVE_COUNT                     0x84
+#define CC_IFC_ALREADY_SLAVEDTO_BOND                    0x85
+#define CC_BOND_DISABLED_TOCONF_DNS                     0x86
+#define CC_DNS_CURRENTLY_NOT_SUPPORTED_FOR_IPV6         0x87
+#define CC_INV_DOMAIN_NAME                              0x88
+#define CC_TSIGPRIVATEKEY_VALIDATION_FAILED             0x89
+#define CC_DNS_CURRENTLY_NOT_ENABLED                    0x90
+
+#define CC_NULL_USERID_NOT_SUPPORTED                    0x80
+
+#define CC_DEVICE_NOT_SUPPORTED                         0X80
+#define CC_INCOMPLETE_WRITTEN_BYTES			0x80
+
+/* Completion code for Set system info parameter command */
+#define CC_SYS_INFO_PARAM_NOT_SUPPORTED                 0x80
+#define CC_SYS_INFO_SET_IN_PROGRESS                     0x81
+#define CC_SYS_INFO_READ_ONLY_PARAM                     0x82
+#define IPMI_EVM_REVISION                               0x04
+#define IPMI_SENSOR_TEMP_TYPE                           0x01
+#define IPMI_SENSOR_VOLT_TYPE                           0x02
+#define IPMI_SENSOR_FAN_TYPE                            0x04
+#define IPMI_SENSOR_PHYSICAL_SECURITY_TYPE              0x05
+#define IPMI_SENSOR_POWER_SUPPLY_TYPE                   0x08
+#define IPMI_SENSOR_MEMORY_TYPE                         0x0C
+#define IPMI_SENSOR_DRIVE_TYPE                          0x0D
+#define IPMI_SENSOR_BUTTON_TYPE                         0x14
+#define IPMI_SENSOR_ENTITY_PRESENCE_TYPE                0x25
+#define IPMI_SENSOR_OEM_TYPE                            0xC0
+
+/******************OEM Completion codes*********************/
+#define OEMCC_INVALID_USERNAME                          0x01
+#define OEMCC_PASSWD_MISMATCH                           0x02
+#define OEMCC_INVALID_PASSWD                            0x03
+#define OEMCC_DUPLICATE_USERNAME                        0x04
+#define OEMCC_USER_EXISTS_AT_SLOT                       0x05
+#define OEMCC_NOMEM                                     0x06
+#define OEMCC_FILE_ERR                                  0x07
+#define OEMCC_SSHKEY_UPDATE_FAILURE                     0x08
+#define OEMCC_SENSOR_DISABLED                           0x09
+#define OEMCC_INVALID_SDR_ENTRY                         0x0a
+#define OEMCC_CORRUPT_FLASH_DATA                        0x0b
+#define OEMCC_CORRUPT_DATA_CHKSUM                       0x0c
+#define OEMCC_FLASH_UPGRADE_FAILURE                     0x0d
+#define OEMCC_VERSION_MISMATCH                          0x0e
+#define OEMCC_USER_NOT_EXISTS                           0x0f
+
+#define OEMCC_SAL_INVALID_TARGET                        0x0f //CMM sal completion code
+
+#define OEMCC_EMAIL_NOT_CONFIGURED                      0x10
+#define OEMCC_SMTP_DISABLED                             0x11
+#define OEMCC_UNSUPPORTED_AUTH_TYPE                     0x12
+#define OEMCC_SEND_EMAIL_AUTH_FAILED                    0x13
+#define OEMCC_UNABLE_TO_CONNECT_SMTPSERVER              0x14
+#define OEMCC_SEND_EMAIL_FAILED                         0x15
+#define OEMCC_USER_DISABLED                             0x16
+#define OEMCC_RESERVED_USER_NAME                        0x17
+#define OEMCC_INSUFFIENT_LANIFC_COUNT                   0x80
+#define OEMCC_UNSUPPORTED_BOND_MODE                     0x81
+#define OEMCC_VLAN_ENABLED_ON_SLAVE                     0x82
+#define OEMCC_BOND_ALREADY_DISABLED     0x83
+#define OEMCC_INV_PARAM_ONLY_FOR_NON_BONDING            0x81
+#define OEMCC_INV_IP4_NOT_ENABLED                       0x82
+#define OEMCC_INV_MIN_IFC_COUNT_DISABLED                0x83
+#define OEMCC_BOND_NOT_ENABLED                          0x80
+#define OEMCC_ACTIVE_SLAVE_LINK_DOWN                    0x81
+#define OEMCC_ETH_IFACE_DISABLED                        0x85
+#define OEMCC_SEL_EMPTY_REPOSITORY                      0x86
+#define OEMCC_SEL_CLEARED                               0x85
+#define OEMCC_SENSOR_INFO_EMPTY                         0x87
+
+#define OEMCC_ATTEMPT_TO_GET_WO_PARAM                   0x82
+
+#define CC_POWER_LIMIT_OUT_OF_RANGE                     0x84
+#define CC_CORRECTION_TIME_OUT_OF_RANGE                 0x85
+#define CC_STAT_REPORTING_OUT_OF_RANGE                  0x89
+
+#define CC_THERMAL_LIMIT_OUT_OF_RANGE                   0x84
+#define CC_THERMAL_EXCEPTION_TIME_OUT_OF_RANGE          0x85
+
+#define OEMCC_INV_DATE_TIME                             0x93
+/* HPM related Completion codes */
+#define CC_UPG_NOT_SUPPORTED_OVER_IFC                   0x81
+#define CC_INV_COMPONENT_ID                             0x82
+#define CC_INV_COMPONENT_PROP_SELECTOR                  0x83
+#define CC_INV_COMPONENT                                0x81
+#define CC_IMAGE_LEN_MISMATCH                           0x81
+#define CC_INV_FW_CHECKSUM                              0x82
+#define CC_IMAGE_NOT_MATCH                              0x83
+#define CC_UPG_NOT_ABORTED_AT_THIS_MOMENT               0x80
+#define CC_UPG_ABORTED_FW_NOT_RESUMABLE                 0x81
+#define CC_CMD_INPROGRESS                               0x80
+/* Remote Images Service completion code*/
+#define CC_SERVICE_NOT_ENABLED              0x90
+#define CC_INVALID_MEDIA_TYPE               0x91
+#define CC_INVALID_SHARE_TYPE               0x92
+#define CC_INVALID_IP_ADDR                  0x93
+#define CC_INVALID_COMMAND                  0x94
+#define CC_INVALID_IMAGE_FILE_NAME          0x95
+#define CC_INVALID_DOMAIN                   0x96
+#define CC_INVALID_CONFIGURATION            0x97
+#define CC_INVALID_IMG_PATH                 0x98
+#define CC_INVALID_USR_NAME                 0x99
+#define CC_INVALID_PASSWD                   0x9A
+#define CC_INVALID_BLOCK_SELECTOR              0x9B
+#define CC_INV_PROGRESS_BIT              0x9C
+#define CC_PROGRESS_BIT_NOT_SET              0x9D
+#define CC_PUBLICKEY_VALIDATION_FAILED          0x80
+
+/*Host Lock Feature*/
+#define CC_FEATURE_NOT_ENABLED          0x80
+#define CC_INV_FEATURE_CMD          0x81
+#define CC_INV_LOCK_CMD          0x82
+/*--------------------------------------------
+ * Macro to extract the net function.
+ *--------------------------------------------*/
+#define NET_FN(NetFnLUN)	((uint8_t)((NetFnLUN & 0xFC) >> 2))
+
+#pragma pack( 1 )
+
+/*-------------------------
+ * Disable Message Filter Table
+ *-------------------------*/
+typedef struct
+{
+    uint8_t                   NetFn;
+    uint8_t                   Command;
+}  DisableMsgFilterTbl_T;
+
+typedef struct
+{
+    uint8_t                   NetFn;
+    uint8_t                   Cmd;
+}  FlashModeFilterTbl_T;
+
+
+/*----------------------------------
+ * IPMI Commands Filter List Structure  
+ *----------------------------------*/
+typedef struct
+{
+    uint8_t   NetFn;
+    uint8_t   Cmd;
+}  IPMICmdsFilterTbl_T;
+
+
+/* IPMI Message Header */
+typedef struct
+{
+    uint8_t	ResAddr;
+    uint8_t	NetFnLUN;
+    uint8_t	ChkSum;
+    uint8_t	ReqAddr;
+    uint8_t	RqSeqLUN;
+    uint8_t	Cmd;
+} IPMIMsgHdr_T;
+
+typedef struct
+{
+    uint32_t SessionID;
+    uint8_t Privilege;
+    uint16_t IPMIMsgLen;
+    uint8_t NetFnLUN;
+    uint8_t Cmd;
+    uint8_t ChannelNum;
+    uint8_t AuthFlag;
+    uint8_t UserName[MAX_USER_NAME_LEN];
+    uint8_t IPAddr[IP6_ADDR_LEN];
+    uint32_t ProcessID;
+    uint32_t ThreadID;
+}IPMIUDSMsg_T;
+
+#pragma pack( )
+
+
+
+
+#endif	/* IPMI_DEFS_H */

+ 95 - 0
app/goahead-5.1.0/build/linux-arm-static/inc/com_IPMI_App.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.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************
+ *****************************************************************
+ *
+ * IPMI_App.h
+ * Application Command numbers
+ *
+ *****************************************************************/
+#ifndef IPMI_APP_H
+#define IPMI_APP_H
+
+/*** Application Commands ***/
+#define CMD_GET_DEV_ID              0x01
+#define CMD_BROADCAST_GET_DEV_ID    0x01
+#define CMD_COLD_RESET              0x02
+#define CMD_WARM_RESET              0x03
+#define CMD_GET_SELF_TEST_RESULTS   0x04
+#define CMD_MFG_TEST_ON             0x05
+#define CMD_SET_ACPI_PWR_STATE      0x06
+#define CMD_GET_ACPI_PWR_STATE      0x07
+#define CMD_GET_DEV_GUID            0x08
+#define CMD_GET_NETFN_SUP           0x09
+#define CMD_GET_CMD_SUP             0x0A
+#define CMD_GET_SUBFN_SUP           0x0B
+#define CMD_GET_CONFIG_CMDS         0x0C
+#define CMD_GET_CONFIG_SUB_FNS      0x0D
+
+
+#define CMD_SET_CMD_ENABLES         0x60
+#define CMD_GET_CMD_ENABLES         0x61
+#define CMD_SET_SUBFN_ENABLES       0x62
+#define CMD_GET_SUBFN_ENABLES       0x63
+#define CMD_GET_OEM_NETFN_IANA_SUPPORT   0x64
+
+
+#define CMD_RESET_WDT               0x22
+#define CMD_SET_WDT                 0x24
+#define CMD_GET_WDT                 0x25
+
+#define CMD_SET_BMC_GBL_ENABLES     0x2E
+#define CMD_GET_BMC_GBL_ENABLES     0x2F
+#define CMD_CLR_MSG_FLAGS           0x30
+#define CMD_GET_MSG_FLAGS           0x31
+#define CMD_ENBL_MSG_CH_RCV         0x32
+#define CMD_GET_MSG                 0x33
+#define CMD_SEND_MSG                0x34
+#define CMD_READ_EVT_MSG_BUFFER     0x35
+#define CMD_GET_BTIFC_CAP           0x36
+#define CMD_GET_SYSTEM_GUID         0x37
+#define CMD_GET_CH_AUTH_CAP         0x38
+#define CMD_GET_SESSION_CHALLENGE   0x39
+#define CMD_ACTIVATE_SESSION        0x3A
+#define CMD_SET_SESSION_PRIV_LEVEL  0x3B
+#define CMD_CLOSE_SESSION           0x3C
+#define CMD_GET_SESSION_INFO        0x3D
+#define CMD_GET_AUTH_CODE           0x3F
+#define CMD_SET_CH_ACCESS           0x40
+#define CMD_GET_CH_ACCESS           0x41
+#define CMD_GET_CH_INFO             0x42
+#define CMD_SET_USER_ACCESS         0x43
+#define CMD_GET_USER_ACCESS         0x44
+#define CMD_SET_USER_NAME           0x45
+#define CMD_GET_USER_NAME           0x46
+#define CMD_SET_USER_PASSWORD       0x47
+#define CMD_MASTER_WRITE_READ       0x52
+
+#define CMD_ACTIVATE_PAYLOAD        0x48
+#define CMD_DEACTIVATE_PAYLOAD      0x49
+#define CMD_GET_PAYLD_ACT_STATUS    0x4A
+#define CMD_GET_PAYLD_INST_INFO     0x4B
+#define CMD_SET_USR_PAYLOAD_ACCESS  0x4C
+#define CMD_GET_USR_PAYLOAD_ACCESS  0x4D
+#define CMD_GET_CH_PAYLOAD_SUPPORT  0x4E
+#define CMD_GET_CH_PAYLOAD_VER      0x4F
+#define CMD_GET_CH_OEM_PAYLOAD_INFO 0x50
+#define CMD_GET_CH_CIPHER_SUITES    0x54
+#define CMD_SUS_RES_PAYLOAD_ENCRYPT 0x55
+#define CMD_SET_CH_SECURITY_KEYS    0x56
+#define CMD_GET_SYS_IFC_CAPS        0x57
+
+#define CMD_SET_SYSTEM_INFO_PARAM   0x58
+#define CMD_GET_SYSTEM_INFO_PARAM   0x59
+#endif  /* IPMI_APP_H */
+

+ 619 - 0
app/goahead-5.1.0/build/linux-arm-static/inc/com_IPMI_AppDevice.h

@@ -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.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************
+ *****************************************************************
+ *
+ * IPMI_App.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 IPMI_APPDEV_H
+#define IPMI_APPDEV_H
+
+#include <stdint.h>
+
+/*** Macro definition ***/
+#define CHALLENGE_STR_LEN       16
+#define AUTH_CODE_LEN           16
+#define MAX_APP_CONF_PARAM				4
+#define MIN_SYSINFO_OEM_CONF_PARAM		192
+#define MAX_SYSINFO_OEM_CONF_PARAM		255
+
+/* Added to Support IPMI v2.0/RMCP+ Integrity Algorithm Number */ 
+#define AUTH_CODE_HASH_LEN      20 
+#define HASH_DATA_LEN           16 
+#define MAX_USERNAME_LEN        16
+#define MAX_PASSWORD_LEN        20
+#define  MAX_I2C_BUFFER_SIZE    50
+#define IPMI15_MAX_PASSWORD_LEN 16
+#define SIXTEEN_COUNT_WINDOW_LEN 16
+#define SEQNUM_ROLLOVER 0xFFFFFFFF
+#define RMCPPLUS_SEQLOWLIMIT 16
+#define RMCPPLUS_SEQUPLIMIT 15
+#define EIGHT_COUNT_WINDOW_LEN 8
+#define	MAX_FW_VER_LENGTH  	254
+#define MAX_SYS_NAME_LENGTH	254
+#define MAX_PRIM_OS_NAME_LENGTH 254
+#define MAX_OS_NAME_LENGTH	254
+#define MAX_BLOCK_SIZE			16
+
+#define SYS_INFO_SET_COMPLETE    0x00
+#define SYS_INFO_SET_IN_PROGRESS 0x01
+#define SYS_INFO_COMMIT_WRITE	 0x02
+#define PARAM_PRESENT_REVISION   0x11
+#define PARAM_OLDER_REVISION 	 0x00
+
+#define SET_IN_PROGRESS_PARAM	0x00
+#define SYS_FW_VERSION_PARAM	0x01
+#define SYS_NAME_PARAM			0x02
+#define PRIM_OS_NAME_PARAM		0x03
+#define OS_NAME_PARAM			0x04
+#define MAX_PARAM_SELECTOR		OS_NAME_PARAM +1 /* Last Parameter + 1 */
+
+#define GET_PARAM_REV_ONLY		0x80
+
+
+
+
+#pragma pack( 1 )
+
+/* SetWDTReq_T */
+typedef struct
+{
+    uint8_t   TmrUse;
+    uint8_t   TmrActions;
+    uint8_t   PreTimeOutInterval;
+    uint8_t   ExpirationFlag;
+    uint16_t  InitCountDown;
+
+} SetWDTReq_T;
+
+/* GetWDTRes_T */
+typedef struct
+{
+    uint8_t       CompletionCode;
+    SetWDTReq_T CurrentSettings;
+    uint16_t      PresentCountDown;
+
+}   GetWDTRes_T;
+
+/* GetBMCGblEnblRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   BMCGblEnblByte;
+
+} GetBMCGblEnblRes_T;
+
+/* ClearMsgsFlagReq_T */
+typedef struct
+{
+    uint8_t   Flag;
+}   ClearMsgsFlagReq_T;
+
+/* GetMsgFlagsRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   MsgFlags;
+
+} GetMsgFlagsRes_T;
+
+/* EnblMsgChRcvReq_T */
+typedef struct
+{
+    uint8_t   ChannelNum;
+    uint8_t   ChannelState;
+
+}   EnblMsgChRcvReq_T;
+
+/* EnblMsgChRcvRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   ChannelNum;
+    uint8_t   ChannelState;
+
+}   EnblMsgChRcvRes_T;
+
+/* GetMsgRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   ChannelNum;
+
+}   GetMsgRes_T;
+
+/* SendMsgReq_T */
+typedef struct
+{
+    uint8_t   ChNoTrackReq;
+
+}   SendMsgReq_T;
+
+/* SendMsgRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   ResData;
+
+}   SendMsgRes_T;
+
+/* ReadEvtMsgBufRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   ResData[16];
+
+}   ReadEvtMsgBufRes_T;
+
+/* GetBTIfcCapRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   NumReqSupported;
+    uint8_t   InputBufSize;
+    uint8_t   OutputBufSize;
+    uint8_t   RespTime;
+    uint8_t   Retries;
+
+}   GetBTIfcCapRes_T;
+
+/* GetSysGUIDRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   Node[6];
+    uint16_t  ClockSeq;
+    uint16_t  TimeHigh;
+    uint16_t  TimeMid;
+    uint32_t  TimeLow;
+
+}   GetSysGUIDRes_T;
+
+/* GetChAuthCapReq_T */
+typedef struct
+{
+    uint8_t   ChannelNum;
+    uint8_t   PrivLevel;
+
+}   GetChAuthCapReq_T;
+
+/* GetChAuthCapRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   ChannelNum;
+    uint8_t   AuthType;
+    uint8_t   PerMsgUserAuthLoginStatus;
+    uint8_t   ExtCap;
+    uint8_t   OEMID[3];
+    uint8_t   OEMAuxData;
+
+}   GetChAuthCapRes_T;
+
+/* GetSesChallengeReq_T */
+typedef struct
+{
+    uint8_t   AuthType;
+    uint8_t   UserName[16];
+
+}   GetSesChallengeReq_T;
+
+/* GetSesChallengeRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint32_t  TempSessionID;
+    uint8_t   ChallengeString[16];
+
+}   GetSesChallengeRes_T;
+
+/* ActivateSesReq_T */
+typedef struct
+{
+    uint8_t   AuthType;
+    uint8_t   Privilege;
+    uint8_t   ChallengeString[CHALLENGE_STR_LEN];
+    uint32_t  OutboundSeq;
+
+}   ActivateSesReq_T;
+
+/* ActivateSesRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   AuthType;
+    uint32_t  SessionID;
+    uint32_t  InboundSeq;
+    uint8_t   Privilege;
+
+}   ActivateSesRes_T;
+
+/* SetSesPrivLevelReq_T */
+typedef struct
+{
+    uint8_t   Privilege;
+
+}   SetSesPrivLevelReq_T;
+
+/* SetSesPrivLevelRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   Privilege;
+
+}   SetSesPrivLevelRes_T;
+
+/* GetSesInfoReq_T */
+typedef struct
+{
+    uint8_t   SessionIndex;
+    uint8_t   SessionHandleOrID [4];
+
+}   GetSesInfoReq_T;
+
+/* LANSesInfoRes_T */
+typedef struct
+{
+    uint8_t    IPAddress[4];
+    uint8_t    MACAddress[6];
+    uint16_t   PortNumber;
+
+}   LANSesInfoRes_T;
+
+/* SerialSesInfoRes_T */
+typedef struct
+{
+    uint8_t    SessionActivityType;
+    uint8_t    DestinationSelector;
+    uint8_t    IPAddress[4];
+    uint16_t   PortNumber;
+
+}   SerialSesInfoRes_T;
+
+/* Union SessionInfoRes_T */
+typedef union
+{
+    LANSesInfoRes_T     LANSesInfo;
+    SerialSesInfoRes_T  SerialSesInfo;
+
+}   SessionInfoRes_T;
+
+/* ActiveSesInfo_T */
+typedef struct
+{
+    uint8_t       UserID;
+    uint8_t       Privilege;
+    uint8_t       ChannelNum;
+
+}   ActiveSesInfo_T;
+
+/* GetSesInfoRes_T */
+typedef struct
+{
+    uint8_t               CompletionCode;
+    uint8_t               SessionHandle;
+    uint8_t               NumPossibleActiveSession;
+    uint8_t               NumActiveSession;
+    ActiveSesInfo_T     ActiveSesinfo;
+    SessionInfoRes_T    SesInfo;
+
+}   GetSesInfoRes_T;
+
+/* LANIPv6SesInfoRes_T */
+typedef struct
+{
+    uint8_t    IPv6Address[16];
+    uint8_t    MACAddress[6];
+    uint16_t   PortNumber;
+
+}   LANIPv6SesInfoRes_T;
+
+/* CloseSesReq_T */
+typedef struct
+{
+    uint32_t  SessionID;
+    uint8_t   SessionHandle;
+
+}   CloseSesReq_T;
+
+/* GetAuthCodeReq_T */
+typedef struct
+{
+    uint8_t   AuthType;
+    uint8_t   ChannelNum;
+    uint8_t   UserID;
+    uint8_t   HashData[HASH_DATA_LEN];
+
+}   GetAuthCodeReq_T;
+
+
+/* GetAuthCodeRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   AuthCode[AUTH_CODE_HASH_LEN];
+
+}   GetAuthCodeRes_T;
+
+/* SetChAccessReq_T */
+typedef struct
+{
+    uint8_t   ChannelNum;
+    uint8_t   ChannelAccess;
+    uint8_t   Privilege;
+
+}   SetChAccessReq_T;
+
+typedef struct
+{
+	uint8_t		CompletionCode;
+}   SetChAccessRes_T;
+
+/* GetChAccessReq_T */
+typedef struct
+{
+    uint8_t   ChannelNum;
+    uint8_t   AccessFlag;
+
+}   GetChAccessReq_T;
+
+/* GetChAccessRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   ChannelAccess;
+    uint8_t   Privilege;
+
+}   GetChAccessRes_T;
+
+typedef struct
+{
+	uint8_t ChannelNum;
+}   GetChInfoReq_T;
+
+/* GetChInfoRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   ChannelNum;
+    uint8_t   ChannelMedium;
+    uint8_t   ChannelProtocol;
+    uint8_t   SessionActiveSupport;
+    uint8_t   VendorID[3];
+    uint8_t   AuxiliaryInfo[2];
+
+}   GetChInfoRes_T;
+
+/* SetUserAccessReq_T */
+typedef struct
+{
+    uint8_t   ChannelNoUserAccess;
+    uint8_t   UserID;
+    uint8_t   AccessLimit;
+    uint8_t   SessionLimit;
+
+}   SetUserAccessReq_T;
+
+typedef struct
+{
+    uint8_t CompletionCode;
+}   SetUserAccessRes_T;
+
+
+/* GetUserAccessReq_T */
+typedef struct
+{
+    uint8_t   ChannelNum;
+    uint8_t   UserID;
+
+}   GetUserAccessReq_T;
+
+/* GetUserAccessRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   MaxNoUserID;
+    uint8_t   CurrentUserID;
+    uint8_t   FixedUserID;
+    uint8_t   ChannelAccess;
+
+}   GetUserAccessRes_T;
+
+/* SetUserNameReq_T */
+typedef struct
+{
+    uint8_t   UserID;
+    uint8_t   UserName[MAX_USERNAME_LEN];
+
+}   SetUserNameReq_T;
+
+typedef struct
+{
+    uint8_t   CompletionCode;
+}   SetUserNameRes_T;
+
+
+/*GetUserNameReq_T*/
+typedef struct
+{
+    uint8_t   UserID;
+}   GetUserNameReq_T;
+
+
+/* GetUserNameRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   UserName[MAX_USERNAME_LEN];
+
+}   GetUserNameRes_T;
+
+
+
+/* SetUserPswdReq_T */
+typedef struct
+{
+    uint8_t   UserID;
+    uint8_t   Operation;
+    uint8_t   Password[MAX_PASSWORD_LEN];
+
+}   SetUserPswdReq_T;
+
+/* SetUserPswdReq_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+}   SetUserPswdRes_T;
+
+/* MasterWriteReadReq_T */
+typedef struct
+{
+    uint8_t   BusTypeChNo;
+    uint8_t   SlaveAddress;
+    uint8_t   ReadCount;
+    uint8_t   Data[MAX_I2C_BUFFER_SIZE];
+
+}   MasterWriteReadReq_T;
+
+/* MasterWriteReadRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   Data[MAX_I2C_BUFFER_SIZE];
+
+}   MasterWriteReadRes_T;
+
+typedef struct 
+{
+    uint8_t       TypeOfEncoding ;
+    uint8_t       StringLength;
+    uint8_t       SysFWVersionName[MAX_FW_VER_LENGTH];
+}  SysFWVersion_T;
+typedef struct
+{
+    uint8_t    TypeOfEncoding_Sys_Name;
+    uint8_t    StringLength_Sys_Name;
+    uint8_t    SystemName[MAX_SYS_NAME_LENGTH];
+}   SysName_T;
+typedef struct 
+{
+    uint8_t    TypeOfEncoding_PrimaryOSName;
+    uint8_t    StringLength_PrimaryOSName;
+    uint8_t    PrimaryOperatingSystemName[MAX_PRIM_OS_NAME_LENGTH];
+}   PrimaryOSName_T;
+typedef struct 
+{
+    uint8_t    TypeOfEncoding_OSName;
+    uint8_t    StringLength_OSName;
+    uint8_t   OSName[MAX_OS_NAME_LENGTH];
+}  OSName_T;
+
+typedef struct 
+{
+    uint8_t   SetSelector;
+    uint8_t   SysFWVersion[MAX_BLOCK_SIZE];
+}   SysVerInfo_T;
+
+typedef struct 
+{
+
+    uint8_t   SetSelector;
+    uint8_t    SysName[MAX_BLOCK_SIZE];
+
+}   SysNameInfo_T;
+
+typedef struct {
+
+    uint8_t    SetSelector;
+    uint8_t    PrimaryOSName[MAX_BLOCK_SIZE];
+
+}   PrimOSInfo_T;
+
+
+typedef struct {
+
+    uint8_t   SetSelector;
+    uint8_t   OperatingSystemName[MAX_BLOCK_SIZE];
+
+}   OSInfo_T;
+
+typedef union {
+
+    uint8_t   SetInProgress;
+    SysVerInfo_T    SysVerInfo;
+    SysNameInfo_T   SysNameInfo;
+    PrimOSInfo_T    PrimOSInfo;
+    OSInfo_T    OSInfo;
+}    SysInfoUN_T	;
+
+
+/* GetSystemInfoParamReq_T */
+typedef struct
+{
+    uint8_t   ParamRev;
+    uint8_t   ParamSelector;
+    uint8_t   SetSelector;
+    uint8_t   BlockSelector;
+
+}   GetSystemInfoParamReq_T;
+
+
+/* GetSystemInfoParamRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+    uint8_t   ParamRevision;
+    SysInfoUN_T     SysInfo;
+
+}   GetSystemInfoParamRes_T;
+
+/* GetSystemInfoParamOEMRes_T */
+typedef struct
+{
+    uint8_t           CompletionCode;
+    uint8_t           ParamRevision;
+    /* OEM Info */
+}   GetSystemInfoParamOEMRes_T;
+
+
+/* SetSystemInfoParamReq_T */
+typedef struct
+{
+    uint8_t   		ParamSelector;
+    SysInfoUN_T		SysInfo;
+}   SetSystemInfoParamReq_T;
+
+
+/* SetSystemInfoParamRes_T */
+typedef struct
+{
+    uint8_t   CompletionCode;
+}   SetSystemInfoParamRes_T;
+
+/* SetSystemInfoParamOEMReq_T */
+typedef struct
+{
+    uint8_t   ParamSelector;
+    /* OEM parameter */
+}   SetSystemInfoParamOEMReq_T;
+
+#pragma pack( )
+
+#endif /* IPMI_APPDEV_H */

+ 307 - 0
app/goahead-5.1.0/build/linux-arm-static/inc/com_IPMI_IPM.h

@@ -0,0 +1,307 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************
+ ****************************************************************
+ *
+ * IPMI_IPM.h
+ * 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>
+ *
+ *****************************************************************/
+#ifndef IPMI_IPMDEV_H
+#define IPMI_IPMDEV_H
+#include <stdint.h>
+
+
+#pragma pack( 1 )
+
+/*** Macro Definitions ***/
+/**
+ * @def DEVICE_ID
+ * @brief Device ID
+ **/
+#define DEVICE_ID                       0x20
+/**
+ * @def SDR_SUPPORT
+ * @brief SDR support bit flag 
+ **/
+#define SDR_SUPPORT                     0x80    
+/**
+ * @def DEV_REVISION                    
+ * @brief Device Revision 
+ **/
+#define DEV_REVISION                    0x01    
+#define IPMI_DEV_REVISION               DEV_REVISION
+/**
+ * @def DEV_AVAILABLE                   
+ * @brief Device availability bit flag
+ **/
+#define DEV_AVAILABLE                   0x80
+/**
+ * @def IPMI_VERSION
+ * @brief IPMI version
+ **/
+#define IPMI_VERSION                    0x02
+/**
+ * @def CHASSIS_DEVICE_SUPPORT          
+ * @brief Chassis Device support bit flag
+ **/
+#define CHASSIS_DEVICE_SUPPORT          ( CHASSIS_DEVICE << 7 )
+/**
+ * @def BRIDGE_COMMAND_SUPPORT          
+ * @brief Bridge Device support bit flag
+ **/
+#define BRIDGE_COMMAND_SUPPORT          ( BRIDGE_DEVICE << 6 )
+/**
+ * @def IPMB_EVENT_GENERATOR_SUPPORT    
+ * @brief IPMB Event generator support bit flag 
+ **/
+#define IPMB_EVENT_GENERATOR_SUPPORT    ( EVENT_GENERATOR << 5 )
+/**
+ * @def IPMB_EVENT_RECEIVER_SUPPORT     
+ * @brief IPMB Event receiver support bit flag 
+ **/
+#define IPMB_EVENT_RECEIVER_SUPPORT     ( EVENT_RECEIVER << 4 )
+/**
+ * @def FRU_INVENTORY_DEVICE_SUPPORT    
+ * @brief FRU Device support bit flag 
+ **/
+#define FRU_INVENTORY_DEVICE_SUPPORT    ( FRU_DEVICE << 3 )
+/**
+ * @def SEL_DEVICE_SUPPORT              
+ * @brief SEL Device support bit flag 
+ **/
+#define SEL_DEVICE_SUPPORT              ( SEL_DEVICE << 2 )
+/**
+ * @def SDR_REPOSITORY_DEVICE_SUPPORT   
+ * @brief SDR Device support bit flag
+ **/
+#define SDR_REPOSITORY_DEVICE_SUPPORT   ( SDR_DEVICE << 1 )
+/**
+ * @def SENSOR_DEVICE_SUPPORT           
+ * @brief Sensor Device support bit flag 
+ **/
+#define SENSOR_DEVICE_SUPPORT           ( SENSOR_DEVICE )
+
+#define DEV_SUPPORT                     CHASSIS_DEVICE_SUPPORT          | BRIDGE_COMMAND_SUPPORT        | \
+                                        IPMB_EVENT_GENERATOR_SUPPORT    | IPMB_EVENT_RECEIVER_SUPPORT   | \
+                                        FRU_INVENTORY_DEVICE_SUPPORT    | SEL_DEVICE_SUPPORT            | \
+                                        SDR_REPOSITORY_DEVICE_SUPPORT   | SENSOR_DEVICE_SUPPORT 
+/**
+ * @def MFG_ID_AMI                      
+ * @brief IANA number for AMI 
+ **/
+#define MFG_ID_AMI                      {0x00,0x00,0x00}    
+/**
+ * @def PROD_ID_AMI_PM                  
+ * @brief AMI Product ID {'E','M'} 
+ **/
+#define PROD_ID_AMI_PM                  0x0000
+
+/**
+ * @def DEV_GUID_NODE                   
+ * @brief node - Mac Address 
+ **/
+#define DEV_GUID_NODE                   {0x45,0xDF,0x44,0xAC,0x25,0xD4} 
+/**
+ * @def DEV_GUID_CLOCK_SEQ              
+ * @brief GUID Clolck Sequenbce
+ **/
+#define DEV_GUID_CLOCK_SEQ              0xB24A  
+/**
+ * @def DEV_GUID_TIME_HIGH
+ * @brief GUID Time High 
+ **/
+#define DEV_GUID_TIME_HIGH              0x48F3  
+/**
+ * @def DEV_GUID_TIME_MID               
+ * @brief GUID Time Mid 
+ **/
+#define DEV_GUID_TIME_MID               0x4F46  
+/**
+ * @def DEV_GUID_TIME_LOW               
+ * @brief GUID Time Low 
+ **/
+#define DEV_GUID_TIME_LOW               0xBD2C300A 
+
+/**
+ * @def GST_NO_ERROR
+ * @brief Error Code for Get Self Test Results
+ **/
+#define GST_NO_ERROR                    0x55 
+/**
+ * @def GST_CORRUPTED_DEVICES           
+ * @brief Error code for Get Self Test Results 
+ **/
+#define GST_CORRUPTED_DEVICES           0x57 
+/**
+ * @def GST_CANNOT_ACCESS_SEL           
+ * @brief Error code for Get Self Test Results 
+ **/
+#define GST_CANNOT_ACCESS_SEL           0x80 
+/**
+ * @def GST_CANNOT_ACCESS_SDR           
+ * @brief Error code for Get Self Test Results
+ **/
+#define GST_CANNOT_ACCESS_SDR           0x40
+/**
+ * @def GST_CANNOT_ACCESS_FRU           
+ * @brief Error code for Get Self Test Results 
+ **/
+#define GST_CANNOT_ACCESS_FRU           0x20 
+/**
+ * @def GST_IPMB_DO_NOT_RESPOND         
+ * @brief Error code for Get Self Test Results 
+ **/
+#define GST_IPMB_DO_NOT_RESPOND         0x10 
+/**
+ * @def GST_SDR_EMPTY
+ * @brief Error code for Get Self Test Results
+ **/
+#define GST_SDR_EMPTY                   0x08 
+/**
+ * @def GST_FRU_CORRUPTED               
+ * @brief Error code for Get Self Test Results 
+ **/
+#define GST_FRU_CORRUPTED               0x04 
+/**
+ * @def GST_BBLK_CORRUPTED              
+ * @brief Error code for Get Self Test Results 
+ **/
+#define GST_BBLK_CORRUPTED              0x02 
+/**
+ * @def GST_FIRMWARE_CORRUPTED          
+ * @brief Error code for Get Self Test Results 
+ **/
+#define GST_FIRMWARE_CORRUPTED          0x01 
+
+/**
+ * @def IPMI_ACPI_S0                    
+ * @brief ACPI State
+ **/
+#define IPMI_ACPI_S0                    0x00    
+/**
+ * @def IPMI_ACPI_S1                    
+ * @brief ACPI State 
+ **/
+#define IPMI_ACPI_S1                    0x01    
+/**
+ * @def IPMI_ACPI_S2
+ * @brief ACPI State 
+ **/
+#define IPMI_ACPI_S2                    0x02    
+/**
+ * @def IPMI_ACPI_S3                    
+ * @brief ACPI State
+ **/
+#define IPMI_ACPI_S3                    0x03    
+/**
+ * @def IPMI_ACPI_S4                    
+ * @brief ACPI State 
+ **/
+#define IPMI_ACPI_S4                    0x04
+/**
+ * @def IPMI_ACPI_S5                    
+ * @brief ACPI State 
+ **/
+#define IPMI_ACPI_S5                    0x05    
+/**
+ * @def IPMI_ACPI_S4_S5                 
+ * @brief ACPI State 
+ **/
+#define IPMI_ACPI_S4_S5                 0x06    
+/**
+ * @def IPMI_ACPI_G3                    
+ * @brief ACPI State 
+ **/
+#define IPMI_ACPI_G3                    0x07
+/**
+ * @def IPMI_ACPI_LEGACY_ON
+ * @brief ACPI State
+ **/
+#define IPMI_ACPI_LEGACY_ON             0x20
+
+/**
+ * @def IPMI_ACPI_LEGACY_OFF
+ * @brief ACPI State
+ **/
+#define IPMI_ACPI_LEGACY_OFF            0x21
+
+/**
+ * @def IPMI_ACPI_SLEEPING_S1_S3                    
+ * @brief ACPI State 
+ **/
+#define IPMI_ACPI_SLEEPING_S1_S3        0x08
+/**
+ * @def IPMI_ACPI_G1_SLEPPING_S1_S4                    
+ * @brief ACPI State 
+ **/
+#define IPMI_ACPI_G1_SLEPPING_S1_S4     0x09
+
+/**
+ * @def IPMI_S5_OVERRIDE
+ * @brief ACPI State 
+ **/
+#define IPMI_S5_OVERRIDE                0x0A
+
+/* GetDevIDRes_T */
+typedef struct {
+    uint8_t   CompletionCode;
+    uint8_t   DeviceID;
+    uint8_t   DevRevision;
+    uint8_t   FirmwareRevision1;
+    uint8_t   FirmwareRevision2;
+    uint8_t   IPMIVersion;
+    uint8_t   DevSupport;
+    uint8_t   MfgID[3];
+    uint16_t  ProdID;
+    uint32_t  AuxFirmwareRevision;
+}  GetDevIDRes_T;
+
+/* GetSelfTestRes_T */
+typedef struct {
+    uint8_t   CompletionCode;
+    uint8_t   TestResultByte1;
+    uint8_t   TestResultByte2;
+}  GetSelfTestRes_T;
+
+/* SetACPIPwrStateReq_T */
+typedef struct {
+    uint8_t   ACPISysPwrState;
+    uint8_t   ACPIDevPwrState;
+}  SetACPIPwrStateReq_T;
+
+/* getACPIPwrStateRes_T */
+typedef struct {
+    uint8_t   CompletionCode;
+    uint8_t   ACPISysPwrState;
+    uint8_t   ACPIDevPwrState;
+}  GetACPIPwrStateRes_T;
+
+/* GetDevGUIDRes_T */
+typedef struct {
+    uint8_t   CompletionCode;
+    uint8_t   Node[6];
+    uint16_t  ClockSeq;
+    uint16_t  TimeHigh;
+    uint16_t  TimeMid;
+    uint32_t  TimeLow;
+}  GetDevGUIDRes_T;
+
+#pragma pack( )
+
+#endif /* IPMI_IPMDEV_H */

+ 43 - 0
app/goahead-5.1.0/build/linux-arm-static/inc/com_UDSIfc.h

@@ -0,0 +1,43 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************/
+/*****************************************************************
+ *
+ * UDSIfc.h
+ *
+ * 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
+
+/* 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
+
+#define UDS_SUCCESS 0
+#define UDS_CMD_FAILURE 1
+#define UDS_FAILURE -1
+#define UDS_PARAM_FAILURE -2
+
+#define UDS_SOCKET_PATH "/var/UDSocket"
+
+
+#endif /* UDSIFC_H */

+ 674 - 0
app/goahead-5.1.0/build/linux-arm-static/inc/libipmi.h

@@ -0,0 +1,674 @@
+
+
+#ifndef LIBIPMI_H
+#define LIBIPMI_H
+
+#define u8 	unsigned char
+#define u16	unsigned short int
+#define s32 long int
+
+/*! Return value that indicates a specified sensor is disabled, and cannot be read */
+#define IPMI_SENSOR_DISABLED        ( -3 )
+
+/* IPMI threshold state definitions for monitoring */
+#define THRESH_UNINITIALIZED        ( (u16)0x00 ) /*!< Threshold state on first run */
+#define THRESH_NORMAL               ( (u16)0x01 ) /*!< Sensor is normal (unused in IPMI ) */
+#define THRESH_UP_NONCRIT           ( (u16)0x02 ) /*!< IPMI Upper Non-Critical Threshold */
+#define THRESH_UP_CRITICAL          ( (u16)0x04 ) /*!< IPMI Upper Critical Threshold */
+#define THRESH_LOW_NONCRIT          ( (u16)0x08 ) /*!< IPMI Lower Non-Critical Threshold */
+#define THRESH_LOW_CRITICAL         ( (u16)0x10 ) /*!< IPMI Lower Critical Threshold */
+#define THRESH_ACCESS_FAILED        ( (u16)0x20 ) /*!< Access failed sensor state */
+#define THRESH_UP_NON_RECOV         ( (u16)0x40 ) /*!< IPMI Upper Non-Recoverable Threshold */
+#define THRESH_LOW_NON_RECOV        ( (u16)0x80 ) /*!< IPMI Lower Non-Recoverable Threshold */
+
+/* Macros for converting netfn/lun combos */
+#define NETFN( netfnlun )       ( ( netfnlun & (u8)0xFC ) >> 2 )
+#define NETLUN( netfnlun )      ( ( netfnlun & (u8)0x03 ) )
+#define NETFNLUN( netfn,lun )   ( ( netfn << 2 ) | ( lun ) )
+
+/* Macros for converting seq/lun combos */
+#define SEQ( seqlun )           ( ( seqlun & (u8)0xFC ) >> 2 )
+#define SLUN( seqlun )          ( ( seqlun & (u8)0x03 ) )
+#define SEQLUN( seq, lun )      ( ( seq << 2 ) | ( lun ) )
+
+
+/*****                 IPMI Constant Definitions                         *****/
+
+/* Completion Codes */
+#define IPMI_SUCCESS            ( (u8)0x00 )
+
+/* Sensor Data Record types */
+#define SDR_FULL                ( (u8)0x01 ) /**< SDR RecordType for Full Sensor Record */
+#define SDR_COMPACT             ( (u8)0x02 ) /**< SDR RecordType for Compact Sensor Record */
+
+/* Raw sensor reading numeric format codes */
+#define SDR_READING_UNSIGNED    ( (u8)0 )
+#define SDR_READING_1SCOMP      ( (u8)1 )
+#define SDR_READING_2SCOMP      ( (u8)2 )
+#define SDR_READING_NONANALOG   ( (u8)3 )
+
+/* Max size of an SDR of type SDR_FULL.  SDR_COMPACT records are smaller. */
+#define SDR_MAX_SIZE            ( 64 )
+
+/* Chassis control codes */
+#define CHASSIS_POWER_DOWN      ( (u8)0x00 )
+#define CHASSIS_POWER_UP        ( (u8)0x01 )
+#define CHASSIS_POWER_CYCLE     ( (u8)0x02 )
+#define CHASSIS_HARD_RESET      ( (u8)0x03 )
+#define CHASSIS_PULSE_DUMP      ( (u8)0x04 )
+#define CHASSIS_ACPI_POWER_DOWN ( (u8)0x05 )
+
+/* Sensor Type Codes */
+#define IPMI_SENSOR_TEMPERATURE     ( (u8)0x01 )
+#define IPMI_SENSOR_VOLTAGE         ( (u8)0x02 )
+#define IPMI_SENSOR_CURRENT         ( (u8)0x03 )
+#define IPMI_SENSOR_FAN             ( (u8)0x04 )
+#define IPMI_SENSOR_POWER_SUPPLY    ( (u8)0x08 )
+#define IPMI_SENSOR_POWER_UNIT      ( (u8)0x09 )
+#define IPMI_SENSOR_COOLING_DEVICE  ( (u8)0x0A )
+#define IPMI_SENSOR_MEMORY          ( (u8)0x0C )
+
+/* Sensor Unit Type Codes from the IPMI spec */
+#define IPMI_UNIT_UNSPECIFIED   0
+#define IPMI_UNIT_DEGREES_C     1
+#define IPMI_UNIT_DEGREES_F     2
+#define IPMI_UNIT_DEGREES_K     3
+#define IPMI_UNIT_VOLTS         4
+#define IPMI_UNIT_AMPS          5
+#define IPMI_UNIT_WATTS         6
+#define IPMI_UNIT_JOULES        7
+#define IPMI_UNIT_COULOMBS      8
+#define IPMI_UNIT_VA            9
+#define IPMI_UNIT_NITS          10
+#define IPMI_UNIT_LUMEN         11
+#define IPMI_UNIT_LUX           12
+#define IPMI_UNIT_CANDELA       13
+#define IPMI_UNIT_KPA           14
+#define IPMI_UNIT_PSI           15
+#define IPMI_UNIT_NEWTON        16
+#define IPMI_UNIT_CFM           17
+#define IPMI_UNIT_RPM           18
+#define IPMI_UNIT_HZ            19
+#define IPMI_UNIT_MICROSECOND   20
+#define IPMI_UNIT_MILLISECOND   21
+#define IPMI_UNIT_SECOND        22
+#define IPMI_UNIT_MINUTE        23
+#define IPMI_UNIT_HOUR          24
+#define IPMI_UNIT_DAY           25
+#define IPMI_UNIT_WEEK          26
+#define IPMI_UNIT_MIL           27
+#define IPMI_UNIT_INCHES        28
+#define IPMI_UNIT_FEET          29
+#define IPMI_UNIT_CUIN          30
+#define IPMI_UNIT_CUFEET        31
+#define IPMI_UNIT_MM            32
+#define IPMI_UNIT_CM            33
+#define IPMI_UNIT_M             34
+#define IPMI_UNIT_CUCM          35
+#define IPMI_UNIT_CUM           36
+#define IPMI_UNIT_LITERS        37
+#define IPMI_UNIT_FLUIDOUNCE    38
+#define IPMI_UNIT_RADIANS       39
+#define IPMI_UNIT_STERADIANS    40
+#define IPMI_UNIT_REVOLUTIONS   41
+#define IPMI_UNIT_CYCLES        42
+#define IPMI_UNIT_GRAVITIES     43
+#define IPMI_UNIT_OUNCE         44
+#define IPMI_UNIT_POUND         45
+#define IPMI_UNIT_FTLB          46
+#define IPMI_UNIT_OZIN          47
+#define IPMI_UNIT_GAUSS         48
+#define IPMI_UNIT_GILBERTS      49
+#define IPMI_UNIT_HENRY         50
+#define IPMI_UNIT_MILLIHENRY    51
+#define IPMI_UNIT_FARAD         52
+#define IPMI_UNIT_MICROFARAD    53
+#define IPMI_UNIT_OHMS          54
+#define IPMI_UNIT_SIEMENS       55
+#define IPMI_UNIT_MOLE          56
+#define IPMI_UNIT_BECQUEREL     57
+#define IPMI_UNIT_PPM           58
+#define IPMI_UNIT_RESERVED      59
+#define IPMI_UNIT_DECIBELS      60
+#define IPMI_UNIT_DBA           61
+#define IPMI_UNIT_DBC           62
+#define IPMI_UNIT_GRAY          63
+#define IPMI_UNIT_SIEVERT       64
+#define IPMI_UNIT_COLORTEMPDK   65
+#define IPMI_UNIT_BIT           66
+#define IPMI_UNIT_KILOBIT       67
+#define IPMI_UNIT_MEGABIT       68
+#define IPMI_UNIT_GIGABIT       69
+#define IPMI_UNIT_BYTE          70
+#define IPMI_UNIT_KILOBYTE      71
+#define IPMI_UNIT_MEGABYTE      72
+#define IPMI_UNIT_GIGABYTE      73
+#define IPMI_UNIT_WORD          74
+#define IPMI_UNIT_DWORD         75
+#define IPMI_UNIT_QWORD         76
+#define IPMI_UNIT_LINE          77
+#define IPMI_UNIT_HIT           78
+#define IPMI_UNIT_MISS          79
+#define IPMI_UNIT_RETRY         80
+#define IPMI_UNIT_RESET         81
+#define IPMI_UNIT_OVERRUNFLOW   82
+#define IPMI_UNIT_UNDERRUN      83
+#define IPMI_UNIT_COLLISION     84
+#define IPMI_UNIT_PACKETS       85
+#define IPMI_UNIT_MESSAGES      86
+#define IPMI_UNIT_CHARACTERS    87
+#define IPMI_UNIT_ERROR         88
+#define IPMI_UNIT_CORRERROR     89
+#define IPMI_UNIT_UNCORRERROR   90
+
+
+
+/** \name IPMI Functions */
+/** \{ */
+
+/** \brief Send the IPMI Get Sensor Reading command and get the response
+ *
+ *  Send the GetSensorReading command to the specified slave with \a sensor as
+ *  the sensor number, and get the response.
+ *
+ *  \param slave The slave address of the IPMI device (8-bit format)
+ *  \param sensor The sensor number on the IPMI device
+ *  \param reading The address of a u8 that will be filled with the sensor
+ *  reading.  Note that this is a raw sensor value which must be converted
+ *  by use of the \ref ipmi_convert_reading function.
+ *  \param response The address of a \ref GetSensorReadingResponseStruct
+ *  if you want the entire sensor response, not just the sensor reading.
+ *  Pass \c NULL if you just want the sensor reading.
+ *
+ *  \retval "IPMI response code" Success
+ *  \retval HHM_FAILURE The sensor reading could not be retrieved.
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+
+/*@external@*/extern int
+ipmi_get_sensor_reading( u8 slave, u8 sensor, /*@out@*/u8 *reading,
+                         /*@null@*//*@out@*/GetSensorReadingResponseStruct *response )
+/*@globals fileSystem@*/
+/*@modifies *reading,fileSystem,response@*/;
+
+/** \brief Get a reservation to access the SDR repository
+ *
+ *  This is required for certain IPMI commands, such as GetSDR when doing
+ *  partial reads and from non-zero offsets, as well as other commands.
+ *  See the IPMI spec for details.
+ *
+ *  \param slave The slave address of the IPMI device (8-bit format)
+ *  \param response A pointer to an \ref IPMBReserveSDRRepositoryStruct that
+ *  this function fills in
+ *
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+
+/*@external@*/extern int
+ipmi_reserve_sdr_repository( u8 slave, /*@out@*/IPMBReserveSDRRepositoryStruct *response )
+/*@globals fileSystem@*/
+/*@modifies *response,fileSystem@*/;
+
+
+/** \brief Get a reservation to access the SEL
+ *
+ *  Get a reservation to access the SEL.  This is required for
+ *  certain IPMI commands  See the IPMI spec for details.
+ *
+ *  \param slave The slave address of the IPMI device (8-bit format)
+ *  \param response An \ref ReserveSELResponseStruct that this
+ *  function fills in.
+ *  
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+
+/*@external@*/extern int
+ipmi_reserve_sel_repository( u8 slave, /*@out@*/ReserveSELResponseStruct *response )	//jimbo notice!
+/*@globals fileSystem@*/
+/*@modifies *response,fileSystem@*/;
+
+
+/** \brief Read an SDR entry or part of an SDR entry from an IPMI device
+ *
+ *  Read an SDR entry from the SDR repository.  Usually only BMCs have SDR
+ *  repositories.  SDR entries have useful info such as sensor numbers,
+ *  sensor types, and data conversion equations, and can be used to determine
+ *  the type of sensors available, and how to monitor them.
+ *  This is probably not the function you are looking for.  This function is
+ *  a raw interface to the GetSDR function, suitable for performing partial
+ *  reads and testing.  If you just want to read the entire SDR entry, use
+ *  \ref ipmi_get_sdr_full which is much easier to use.
+ *
+ *  \param slave The slave address of the IPMI device (8-bit format)
+ *  \param reservation_id An SDR reservation ID obtained from the 
+ *  \ref ipmi_reserve_sdr_repository command, or zero if not doing a partial
+ *  read and \a offset_into_record is zero.
+ *  \param record_id The SDR record ID to read
+ *  \param bytes_to_read The number of bytes to read from the record. Pass
+ *  0xFF to read the entire record.   Be aware, however, that most BMCs do not
+ *  support sending a response large enough to contain the entire record.
+ *  \param offset_into_record The starting point for the SDR read operation in
+ *  the record.  If this is not 0, you need to call
+ *  \ref ipmi_reserve_sdr_repository before this function.
+ *  \param record_data A buffer that will be filled in with the entire GetSDR
+ *  response (cast this buffer to an \ref IPMBGetSDRResponseStruct after
+ *  calling).  The length of the SDR entry is variable, so the data buffer
+ *  should be ~255 bytes long to be safe.
+ *
+ *  \retval "Length of the SDR read" Success.  The IPMI completion code is 
+ *  contained within the \ref IPMBGetSDRResponseStruct returned in
+ *  \a record_data
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+/*@external@*/extern int
+ipmi_get_sdr( u8 slave, u16 reservation_id, u16 record_id,
+              u8 offset_into_record, u8 bytes_to_read, /*@out@*/u8 *record_data )
+/*@globals fileSystem@*/
+/*@modifies *record_data,fileSystem@*/;
+
+
+/** \brief Read an entire SDR entry from an IPMI device
+ *
+ *  Like \ref ipmi_get_sdr, but this command always reads the entire SDR entry,
+ *  even if it needs to break the operation down into a series of partial
+ *  reads.  Like \ref ipmi_get_sdr, \a record_data should be able to accomodate
+ *  255 bytes.
+ *
+ *  \param slave The slave address of the IPMI device (8-bit format)
+ *  \param record_id The SDR record to read
+ *  \param record_data A buffer the function fills in that will contain the
+ *  \ref IPMBGetSDRResponseStruct and the entire SDR entry specified in 
+ *  \a record_id
+ *
+ *  \retval "Length of the SDR read" Success.  The completion code is contained
+ *  within the \ref IPMBGetSDRResponseStruct returned in \a record_data
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+/*@external@*/extern int
+ipmi_get_sdr_full( u8 slave, u16 record_id, /*@out@*/u8 *record_data )
+/*@globals fileSystem@*/
+/*@modifies *record_data,fileSystem@*/;
+
+
+/** \brief Get an SEL entry from an IPMI device
+ *
+ *  Read an SEL entry from the SEL.  Usually only BMCs have an SEL.  This is
+ *  probably not the function you are looking for.  This function is a raw
+ *  interface to the GetSEL function, suitable for performing partial reads
+ *  and testing.  If you just want to read the entire SEL entry, use
+ *  \ref ipmi_get_sel_full, which is much easier to use.
+ *
+ *  \param slave The slave address of the IPMI device (8-bit format)
+ *  \param reservation_id An SEL reservation ID obtained from the
+ *  \ref ipmi_reserve_sel_repository command, or zero if not doing a partial
+ *  read and \a offset_into_record is zero.
+ *  \param record_id The SEL record ID to read.
+ *  \param offset_into_record The offset into the specified record to read
+ *  from.  Zero for the beginning of the record.
+ *  \param bytes_to_read The number of bytes to read from the record. Pass
+ *  0xFF to read the entire record.   Be aware, however, that most BMCs do
+ *  not support sending a response large enough to contain the entire record
+ *  \param response A \ref GetSELEntryResponseStruct that will be filled in
+ *  with the entire GetSEL response.
+ *
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+///*@external@*/extern int
+//ipmi_get_sel_entry( u8 slave, u16 reservation_id, u16 record_id,
+//                    u8 offset_into_record, u8 bytes_to_read,
+//                    /*@out@*/GetSELEntryResponseStruct *response )
+/*@globals fileSystem@*/
+/*@modifies *response,fileSystem@*/;
+
+
+/** \brief Get an entire SEL entry from an IPMI device
+ *
+ *  Like \ref ipmi_get_sel_entry, but this command always reads the entire SEL
+ *  entry, even if it needs to break the operation down into a series of
+ *  partial reads
+ *
+ *  \param slave The slave address of the IPMI device (8-bit format)
+ *  \param record_id The SEL entry to read
+ *  \param response A \ref GetSELEntryResponseStruct pointer which will
+ *  be filled in by this function.
+ *
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ */
+///*@external@*/extern int
+//ipmi_get_sel_full( u8 slave, u16 record_id, /*@out@*/GetSELEntryResponseStruct *response )
+///*@globals fileSystem@*/
+///*@modifies *response,fileSystem@*/;
+
+
+/** \brief Send the IPMI Get Device ID command and get the response
+ *
+ *  Send the get device ID IPMI command to a slave address on the I2C bus, and
+ *  receive the response.
+ *
+ *  \param slave Slave address of the IPMI device (8-bit format)
+ *  \param response The above slave's complete response to the get device
+ *  ID command.
+ *
+ *  \retval "IPMI Completion Code" Succes
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+///*@external@*/extern int
+//ipmi_get_device_id( u8 slave, /*@out@*/IPMBGetDeviceIDResponseStruct *response )
+///*@globals fileSystem@*/
+///*@modifies *response,fileSystem@*/;
+
+
+/** \brief Send the IPMI Chassis Power Down command
+ *
+ *  \param slave Slave address of the IPMI device (8-bit format)
+ *
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+/*@external@*/extern int
+ipmi_chassis_power_down( u8 slave )
+/*@globals fileSystem@*//*@modifies fileSystem@*/;
+
+
+/** \brief Send the IPMI Chassis Power Up command
+ *
+ *  \param slave Slave address of the IPMI device (8-bit format)
+ *
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+/*@external@*/extern int
+ipmi_chassis_power_up( u8 slave )
+/*@globals fileSystem@*//*@modifies fileSystem@*/;
+
+
+/** \brief Send the IPMI Chassis Power Cycle command
+ *
+ *  \param slave Slave address of the IPMI device (8-bit format)
+ *
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+/*@external@*/extern int
+ipmi_chassis_power_cycle( u8 slave )
+/*@globals fileSystem@*//*@modifies fileSystem@*/;
+
+
+/** \brief Send the IPMI Chassis Hard Reset command
+ *
+ *  \param slave Slave address of the IPMI device (8-bit format)
+ *
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+/*@external@*/extern int
+ipmi_chassis_hard_reset( u8 slave )
+/*@globals fileSystem@*//*@modifies fileSystem@*/;
+
+
+/** \brief Send the IPMI Chassis ACPI Power Down command
+ *
+ *  \param slave Slave address of the IPMI device (8-bit format)
+ *
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+/*@external@*/extern int
+ipmi_chassis_acpi_power_down( u8 slave )
+/*@globals fileSystem@*//*@modifies fileSystem@*/;
+
+
+/** \brief Send an arbitrary IPMI command, and get the response
+ *
+ *  Send any IPMI command your heart desires to any I2C/LUN combo and receive
+ *  the response.  See the IPMI spec for further info.
+ *
+ *  \param slave Slave address of the IPMI device (8-bit format)
+ *  \param netFn The net function of the command to send
+ *  \param targetLUN The LUN of the IPMI device
+ *  \param command A buffer containing the command number, and any extra data
+ *  which is needed for the command.
+ *  \param cmd_len The length of the command buffer
+ *  \param response_buffer The buffer which will be filled with the response
+ *  to your ipmi command.
+ *  \param response_len The size of the buffer to which
+ *  \a response_buffer points
+ *
+ *  \retval "Length of the IPMI response" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ */
+/*@external@*/extern int
+ipmi_generic_command( u8 slave, u8 netFn, u8 targetLUN, u8 *command,
+                      size_t cmd_len, /*@out@*/u8 *response_buffer,
+                      size_t response_len )
+/*@globals fileSystem@*/
+/*@modifies *response_buffer,fileSystem@*/;
+
+
+/** \brief Convert a raw sensor reading to its final reading using an SDR
+ *
+ *  Use the standard IPMI method and SDR data to convert a raw sensor reading
+ *  into its converted value.  See the IPMI spec for further info on this
+ *  conversion.
+ *
+ *  \param sdr_buffer A pointer to a complete SDR entry which contains reading
+ *  conversion data.  IE, it is a Full SDR entry.
+ *  \param raw_reading The raw sensor reading you want to convert
+ *  \param converted_reading Pointer to an s32 that will be assigned the
+ *  converted reading on success.
+ *
+ *  \retval 0 Success, or sensor out of IPMI sensor min/max reading range, with
+ *  0 in \a converted_reading
+ *  \retval HHM_FAILURE Not enough information to perform the conversion
+ */
+/*@external@*/extern int
+ipmi_convert_reading( u8 *sdr_buffer, u8 raw_reading, /*@out@*/float *converted_reading )
+/*@modifies *converted_reading@*/;
+
+
+/** \brief Use an SDR entry to read the corresponding sensor
+ *
+ *  Use a (usually saved) SDR entry to read the current value of
+ *  a sensor.  The reading is performed as specified by the SDR
+ *  entry passed in \a sdr_buffer.  The reading obtained is the
+ *  final, converted sensor reading
+ *
+ *  \param sdr_buffer Pointer to a complete SDR buffer that contains
+ *  information on accessing a sensor.
+ *  \param raw_reading The raw sensor reading fresh from the BMC.
+ *  \param reading The converted sensor reading read and converted
+ *  as specified by the SDR entry.
+ *  \param discrete Pointer to a u8 used as a boolean, indicates if
+ *  the sensor read is a discrete sensor instead of an analog sensor
+ *
+ *  \retval HHM_FAILURE Failure
+ *  \retval IPMI_SENSOR_DISABLED Reading is invalid, this sensor is disabled
+ *  \retval 0 Success
+ */
+/*@external@*/extern int
+hhm_access_sdr_sensors( u8 *sdr_buffer, /*@out@*/u8 *raw_reading,
+                        /*@out@*/float *reading, /*@out@*/u8 *discrete )
+/*@globals fileSystem@*/
+/*@modifies *raw_reading,*reading,fileSystem,discrete@*/;
+
+/** \} */
+
+/** \brief Extract a descriptive string from an SDR entry
+ *
+ *  Read the text description field from the provided SDR, convert it
+ *  to a nice standard ascii string, and copy it into \a description.
+ *
+ *  \param sdr_buffer Pointer to a buffer containing an SDR
+ *  \param description Pointer to a buffer that will be filled with the
+ *  description of this SDR.  \a Description should have 17 bytes of storage,
+ *  to account for the 16 possible bytes of description defined by IPMI, and
+ *  the \c NULL terminator.
+ *
+ *  \retval 0 Success
+ *  \retval HHM_FAILURE Failure, errno set
+ */
+/*@external@*/extern int
+extract_sdr_id( u8 *sdr_buffer, /*@out@*/char *description )
+/*@modifies *description@*/;
+
+
+/** \brief Convert an IPMI (or AMI OEM) unit type code to a descriptive string
+ *
+ *  Convert an IPMI or AMI OEM unit type code into a string suitable for
+ *  display.  This function could (for example), convert the unit type 0x01 to
+ *  the string "degrees C".
+ *
+ *  \param unit_type_code An IPMI (or AMI OEM) unit type code
+ *  \param unit_type_string A char buffer that will contain the unit string
+ *  on completion.
+ *  \param unit_string_len The length of the unit string.  Expect around 20
+ *  chars at most, but there is no internal limit to any particular size.
+ *
+ *  \retval 0 Success
+ *  \retval HHM_FAILURE Failure, errno set, "Unrecognized" is set in
+ *  \a unit_type_string.
+ */
+/*@external@*/extern int
+sdk_unit_to_string( u8 unit_type_code, /*@out@*/char *unit_type_string,
+                    size_t unit_string_len )
+/*@modifies unit_type_string@*/;
+
+
+/** \brief Generate a string corresponding to a discrete reading code
+ *
+ *  Convert a discrete state (supplied in \a reading) into a string using the
+ *  \a reading_type_code and the IPMI table of discrete states.
+ *
+ *  \param reading The sensor reading (discrete state)
+ *  \param reading_type_code The reading type code from the SDR
+ *  \param sensor_type The sensor type code from the SDR
+ *  \param discrete_string Pointer to a buffer we will fill with text
+ *  describing the discrete state
+ *  \param string_size The amount of storage at \a discrete_string
+ *
+ *  \retval 0 Success
+ *  \retval HHM_FAILURE Failure, errno set
+ */
+/*@external@*/extern int
+ipmi_discrete_reading_string( s32 reading, u8 reading_type_code,
+                              u8 sensor_type,
+                              /*@out@*/char *discrete_string,
+                              size_t string_size )
+/*@modifies discrete_string@*/;
+
+
+/** \brief Get the threshold state of a sensor based on its SDR
+ *
+ *  Determine the state of a given sensor based on threshold information
+ *  from its SDR.  This state is a bitfield with individual bits indicating
+ *  which thresholds have been passed.  A bit is set to 1 when the threshold
+ *  it represents has been passed.  This function also handles threshold
+ *  hysteresis values correctly.
+ *
+ *  \param sensor_reading A raw, unconverted sensor reading
+ *  \param sdr_buffer A pointer to a buffer containing an SDR
+ *  \param last_state The previous state of the sensor, obtained from a prior
+ *  call to this function.  Pass \ref THRESH_UNINITIALIZED if there is no
+ *  \a last_state because this is the first call to \ref get_sdr_sensor_state
+ *  for this sensor.
+ *  \param current_state Variable that will be filled with the current state
+ *  of the sensor, based on information passed in \a sensor_reading and 
+ *  \a sdr_buffer.  See \ref THRESH_UP_NONCRIT for an example of a state
+ *  bitfield.
+ *
+ *  \retval 0 Success
+ *  \retval HHM_FAILURE Failure, errno set
+ */
+/*@external@*/extern int
+get_sdr_sensor_state( u8 sensor_reading, u8 *sdr_buffer, u16 last_state,
+                      /*@out@*/u16 *current_state )
+/*@modifies *current_state@*/;
+
+#endif

+ 52 - 0
app/goahead-5.1.0/build/linux-arm-static/inc/libipmi_IPM.h

@@ -0,0 +1,52 @@
+/**
+ * @file   libipmi_IPM.h
+ * @author Rajasekhar (rajasekharj@amiindia.co.in)
+ * @date   02-Sep-2004
+ *
+ * @brief  Contains exported IPM API by LIBIPMI for
+ *			communicating with the BMC.Corresponds
+ 			directly to IPM device commands
+ *
+ */
+
+#ifndef __LIBIPMI_IPM_H__
+#define __LIBIPMI_IPM_H__
+
+/* LIIPMI core header files */
+#include "libipmi_session.h"
+#include "libipmi_errorcodes.h"
+
+/* command specific header files */
+#include "com_IPMI_IPM.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+/*---------- IPMI Command direct routines ----------*/
+/* Device ID */
+extern uint16_t	IPMICMD_GetDeviceID( IPMI20_SESSION_T *pSession/*in*/,
+										GetDevIDRes_T *pGetDeviceID/*out*/,
+										int timeout/*in*/);
+/* Device GUID */
+extern uint16_t	IPMICMD_GetDeviceGUID( IPMI20_SESSION_T *pSession/*in*/, 
+                                        GetDevGUIDRes_T *pGetDeviceGUID/*out*/,
+                                        int timeout/*in*/ );
+
+/*---------- LIBIPMI Higher level routines -----------*/
+/* Device ID */
+extern uint16_t LIBIPMI_HL_GetDeviceID( IPMI20_SESSION_T *pSession/*in*/,
+											char *pszDeviceID/*out*/, int timeout/*in*/ );
+
+/* Device GUID */
+extern uint16_t LIBIPMI_HL_GetDeviceGUID( IPMI20_SESSION_T *pSession /*in*/, 
+                                            char *pszDeviceGUID /*out*/, int timeout /*in*/);
+
+#ifdef  __cplusplus
+}
+#endif
+
+
+#endif
+
+

+ 134 - 0
app/goahead-5.1.0/build/linux-arm-static/inc/libipmi_errorcodes.h

@@ -0,0 +1,134 @@
+/**
+ * @file   libipmi_errorcodes.h
+ * @author Rajasekhar (rajasekharj@amiindia.co.in)
+ * @date   02-Sep-2004
+ *
+ * @brief  Contains the error codes returned by LIBIPMI API
+ *		
+ *			
+ */
+
+#ifndef __LIBIPMI_ERROR_CODES_H__
+#define __LIBIPMI_ERROR_CODES_H__
+
+/* Error code retrieval macros */
+#define MEDIUM_ERROR_FLAG					0
+#define	IPMI_ERROR_FLAG						1
+#define	RMCP_RAKP_ERROR_FLAG				2
+
+/**
+	@def STATUS_CODE(x,y)
+	@brief forms a 2 byte error code. Here x specifies error type and y specifies
+		actual error code.
+*/
+#define STATUS_CODE(x,y)				((uint16_t)( (((uint16_t)(x))<<8) | ((uint16_t)(y)) ))
+
+/**
+	@def IS_MEDIUM_ERROR(x)
+	@brief checks if error type is MEDIUM_ERROR_FLAG
+*/
+#define IS_MEDIUM_ERROR(x)				( ((x)>>8) ==  MEDIUM_ERROR_FLAG )
+
+/**
+	@def IS_IPMI_ERROR(x)
+	@brief checks if error type is IPMI_ERROR_FLAG
+*/
+#define IS_IPMI_ERROR(x)				( ((x)>>8) ==  IPMI_ERROR_FLAG )
+
+/**
+	@def IS_RMCP_RAKP_ERROR(x)
+	@brief checks if error type is IPMI_ERROR_FLAG
+*/
+#define IS_RMCP_RAKP_ERROR(x)				( ((x)>>8) ==  RMCP_RAKP_ERROR_FLAG )
+
+/**
+	@def GET_ERROR_CODE(x)
+	@brief returns the actual 1 byte error code.
+*/
+#define	GET_ERROR_CODE(x)					( ((uint8_t)x & 0xff) )
+/**************************/
+
+/* Error Codes */
+#define LIBIPMI_E_SUCCESS										0x0000
+
+#define LIBIPMI_STATUS_SUCCESS									0x00
+
+/* Medium related errors */
+#define LIBIPMI_MEDIUM_E_CONNECT_FAILURE						0x01
+#define LIBIPMI_MEDIUM_E_SEND_DATA_FAILURE						0x02
+#define LIBIPMI_MEDIUM_E_RECV_DATA_FAILURE						0x03
+#define LIBIPMI_MEDIUM_E_WSA_INIT_FAILURE						0x04
+#define LIBIPMI_MEDIUM_E_INVALID_SOCKET							0x05
+#define LIBIPMI_MEDIUM_E_TIMED_OUT								0x06
+#define LIBIPMI_MEDIUM_E_UNSUPPORTED							0x07
+#define LIBIPMI_MEDIUM_E_OS_UNSUPPORTED							0x08
+#define LIBIPMI_MEDIUM_E_INVALID_PARAMS							0x09
+#define LIBIPMI_MEDIUM_E_INVALID_DATA							0x0A
+#define LIBIPMI_MEDIUM_E_TIMED_OUT_ON_SEND						0x0B
+#define LIBIPMI_MEDIUM_E_RESOLVED_ADDR_FAILURE                  0x0C
+
+/* Session related errors */
+#define LIBIPMI_SESSION_E_EXPIRED								0x10
+#define LIBIPMI_SESSION_E_RECONNECT_FAILURE						0x11
+#define LIBIPMI_SESSION_E_HANDSHAKE_NOT_RECVD					0x12
+
+/* RMCP reated errors*/
+#define LIBIPMI_RMCP_E_INVALID_PACKET							0x20
+#define LIBIPMI_RMCP_E_INVALID_PONG								0x21
+
+#define LIBIPMI_BMC_E_IPMI2_NOT_SUPPORTED						0x30
+
+/* AES Encryption Errors */
+#define LIBIPMI_AES_CBC_E_NO_ENOUGH_MEMORY						0x40
+#define LIBIPMI_ENCRYPTION_UNSUPPORTED							0x41
+
+/* Validation Errors */
+#define	LIBIPMI_E_INVALID_AUTHTYPE								0x50
+#define	LIBIPMI_E_INVALID_SESSIONID								0x51
+#define LIBIPMI_E_PADBYTES_MISMATCH								0x52
+#define LIBIPMI_E_AUTHCODE_MISMATCH								0x53
+#define LIBIPMI_E_CHKSUM_MISMATCH								0x54
+#define	LIBIPMI_E_AUTHTYPE_NOT_SUPPORTED						0x55
+
+/* Session Establishment Errors */
+#define	LIBIPMI_E_INVALID_OPEN_SESSION_RESPONSE					0x60
+#define	LIBIPMI_E_INVALID_RAKP_MESSAGE_2						0x61
+#define LIBIPMI_E_AUTH_ALG_UNSUPPORTED							0x62
+#define LIBIPMI_E_INTEGRITY_ALG_UNSUPPORTED						0x63
+#define LIBIPMI_E_CONFIDENTIALITY_ALG_UNSUPPORTED				0x64
+#define LIBIPMI_E_AUTH_CODE_INVALID								0x65
+#define LIBIPMI_E_INVALID_RAKP_MESSAGE_4						0x66
+#define LIBIPMI_E_INVALID_HMAC_SIK      						0x67
+
+/* Highlevel function errors */
+#define LIBIPMI_E_INVALID_USER_ID								0x70
+#define LIBIPMI_E_INVALID_USER_NAME								0x71
+#define LIBIPMI_E_INVALID_PASSWORD								0x80
+
+#define LIBIPMI_E_INVALID_INDEX 					0x72
+
+/* IPMB errors */
+#define LIBIPMI_E_NO_ENOUGH_MEMORY						0x80
+#define LIBIPMI_E_INVALID_HOST_ADDR						0x81
+#define LIBIPMI_E_I2C_WRITE_FAILURE						0x82
+#define LIBIPMI_E_I2C_READ_FAILURE						0x83
+#define LIBIPMI_E_I2C_BUS_SUSPEND						0x84
+#define LIBIPMI_E_SEQ_NUM_MISMATCH						0x85
+#define LIBIPMI_E_INSUFFICIENT_BUFFER_SIZE					0x86
+#define LIBIPMI_E_IPMB_LOCK_ACCESS_FAILED					0x87
+#define LIBIPMI_E_IPMB_COMM_FAILURE						0x88
+#define LIBIPMI_E_IPMB_UNKNOWN_ERROR						0x89
+#define LIBIPMI_E_IPMB_REQ_BUFF_TOO_BIG						0x8A
+#define LIBIPMI_E_IPMB_RES_BUFF_TOO_BIG						0x8B
+#define LIBIPMI_E_SEL_CLEARED                                              0x85
+#define LIBIPMI_E_SEL_EMPTY                                                  0x86
+#define LIBIPMI_E_SENSOR_INFO_EMPTY                                 0x87
+
+
+/* Last RMCP+/RAKP satus code */
+#define LAST_RMCP_RAKP_STATUS_CODE	(SC_NO_CIPHER_SUITE_MATCH)
+/* Error Codes for FRU*/
+#define FRU_INVALID_HEADER_VERSION						0x8C
+#define FRU_INVALID_AREA								0x8D
+#endif
+

+ 141 - 0
app/goahead-5.1.0/build/linux-arm-static/inc/libipmi_session.h

@@ -0,0 +1,141 @@
+/**
+ * @file   libipmi_session.h
+ * @author Rajasekhar (rajasekharj@amiindia.co.in)
+ * @date   02-Sep-2004
+ *
+ * @brief  Contains function definitions & data structures
+ *			required for establishing a session
+ *			
+ */
+
+#ifndef __LIBIPMI_SESSION_H__
+#define __LIBIPMI_SESSION_H__
+
+#include <stdio.h>
+#include "libipmi_struct.h"
+#include "libipmi_errorcodes.h"
+//#include "libipmiifc.h"
+//#include "libipmi_version.h"
+
+
+#define PACK __attribute__ ((packed))
+
+//#include "IPMI_RMCP.h"
+#include "com_IPMIDefs.h"
+//#include "IPMI_App.h"
+//#include "IPMI_AppDevice.h"
+//#include "IPMI_RMCP+.h"
+//#include "IPMI_AMI.h"
+//#include "AES.h"
+//#include "hmac.h"
+//#include "sha1.h"
+//#include <time.h>
+//
+//typedef struct
+//{
+//    uint32_t      Param;                    /* Parameter */
+//    uint8_t       Channel;                  /* Originator's channel number */
+//    uint8_t       SrcQ [64];     /* Originator Queue */
+//    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 */
+//    time_t      ReqTime;                  /* Request Timestamp */
+//    uint16_t       ResTimeOut;              /* response timeout in secs */
+//    uint16_t      SessionType;               /* Session Type */
+//    uint8_t       IPAddr [16];    /* IPv6 Address */
+//    uint16_t      UDPPort;                  /* UDP Port Number  */
+//    uint16_t      Socket;                   /* socket handle    */
+//    uint32_t      Size;                     /* Size of the data */
+//    uint8_t       Data [1024 * 60];  /* Data */
+//} PACKED MsgPkt_T;
+//
+//typedef union
+//{
+//    IPMIMsgHdr_T        IPMIMsgHdr;
+//    IPMIUDSMsg_T        UDSMsgHdr;
+//}PACKED ResMsgHdr_T;
+//#include "BridgeMsgAPI.h"
+
+/* Undefine PACK so that it can be redefined in other header files */
+#if defined (PACK)
+#undef PACK
+#endif
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+extern uint16_t Create_IPMI20_UDS_Session(IPMI20_SESSION_T *pSession, char *pszSocketPath,
+							char *pszUserName, char *pszPassword, uint8_t *byPrivLevel,
+							char *pUserName, uint8_t *ipaddr, int timeout, int AuthFlag, uint8_t ChannelNum);
+
+/**
+This function is used to get the UserID for given Username and Password.
+It compares all IPMI username with the IN argument Username.
+If it matches, then it checks for the password.
+If password also matches, it will return SUCCESS and corresponding User ID.
+Since duplicate username is supported in IPMI specification,
+It will executes unless it gets SUCCESS or reaches MAX_USERS_COUNT.
+Username and Password are IN arguments, UserID is OUT argument.
+**/
+extern int LIBIPMI_GetUserIDForUserName(IPMI20_SESSION_T *pSession, 
+							char *UserName, char *Password, 
+							uint8_t *UserID, uint8_t AuthEnable,int timeout);
+
+
+/**
+\breif	Sends RAW IPMI Command to the BMC
+ @param	pSession			[in]Session Info handle
+ @param	byPayLoadType		[in]Pay Load Type in NETWORK_MEDIUM.
+								shd be 0 in case of serial and kcs mediums.
+ @param	byNetFnLUN			[in] Net Function and LUN for the given byCommand
+ @param byCommand			[in] Command number.
+ @param pszReqData			[in] Command Request Data
+ @param dwReqDataLen		[in] size of Command Request data.
+ @param pszResData			[in] Command Response Data
+ @param	pdwResDataLen		[in] size of Command Response data.
+ @param	timeout				[in]timeout value in seconds.
+
+ @retval Returns LIBIPMI_E_SUCCESS on success and error codes on failure
+*/
+extern uint16_t LIBIPMI_Send_RAW_IPMI2_0_Command(IPMI20_SESSION_T *pSession,
+									uint8_t byNetFnLUN, uint8_t byCommand,
+									uint8_t *pszReqData, uint32_t dwReqDataLen,
+									uint8_t *pszResData, uint32_t *pdwResDataLen,
+									int	timeout);
+
+
+/**
+\breif	Closes the IPMI 2.0 Session
+ @param	pSession			[in]Session Info handle
+
+ @retval Returns LIBIPMI_E_SUCCESS on success and error codes on failure
+*/
+extern uint16_t LIBIPMI_CloseSession( IPMI20_SESSION_T *pSession );
+
+/**
+\breif	returns status whether the session is started or not
+ @param	pSession			[in]Session Info handle
+ 
+ @retval 1 if session is started and 0 if not
+*/
+extern uint8_t	IsSessionStarted(IPMI20_SESSION_T *pSession);
+
+/**
+\brief  Sets the Cmd Retry Count and Interval
+ @param pSession                        [in]Session Info handle
+ @retval Returns LIBIPMI_E_SUCCESS on success and error codes on failure
+ @note This function is not implemented 
+*/
+
+extern uint16_t LIBIPMI_SetRetryCfg( IPMI20_SESSION_T *pSession, 
+										int nCmdRetryCount, 
+										int nCmdRetryInterval);
+
+#ifdef  __cplusplus
+}
+#endif
+
+
+#endif /* __LIBIPMI_SESSION_H__ */

+ 171 - 0
app/goahead-5.1.0/build/linux-arm-static/inc/libipmi_struct.h

@@ -0,0 +1,171 @@
+/**
+ * @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 <stdint.h>
+
+#define PACK __attribute__ ((packed))
+
+#define	MAX_REQUEST_SIZE		1024 * 60
+#define	MAX_RESPONSE_SIZE		1024 * 60
+
+
+#define HANDLE			int
+#define SOCKET			int
+#define SOCKET_ERROR	-1
+
+#define IP4_VERSION     4
+#define IP6_VERSION     6
+#define IP4_ADDR_LEN    4
+#define IP6_ADDR_LEN   16
+
+/**
+ @def UDS_CHANNEL_T
+ @brief holds data required for network medium
+*/
+typedef struct UDS_CHANNEL_T_tag {
+	uint16_t			hSocketPath;
+	SOCKET			hSocket;
+	uint8_t			byIsConnected;
+} PACK UDS_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_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;
+}PACK IPMI20_UDS_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;
+
+} PACK IPMI20_SESSION_T;
+typedef enum
+{
+    AUTH_FLAG = 1,
+    AUTH_BYPASS_FLAG,
+}USER_Auth;
+
+
+
+/* Undefine PACK so that it can be redefined in other header files */
+#if defined (PACK)
+#undef PACK
+#endif
+
+#endif /* __LIBIPMI_STRUCT_H__ */

BIN
app/goahead-5.1.0/build/linux-arm-static/obj/action.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/alloc.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/auth.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/cgi.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/crypt.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/file.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/fs.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/goahead-mbedtls.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/goahead.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/gopass.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/http.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/js.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/jst.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/mbedtls.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/options.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/osdep.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/rom.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/route.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/runtime.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/socket.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/test.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/time.o


BIN
app/goahead-5.1.0/build/linux-arm-static/obj/upload.o


+ 105 - 1
app/goahead-5.1.0/projects/goahead-linux-static.mk

@@ -497,6 +497,106 @@ $(BUILD)/bin/libgoahead-openssl.a: $(DEPS_35)
 	@echo '      [Link] $(BUILD)/bin/libgoahead-openssl.a'
 	$(AR) -cr $(BUILD)/bin/libgoahead-openssl.a "$(BUILD)/obj/goahead-openssl.o"
 endif
+#################### jimbo modify ###########################
+#
+#   cJSON
+#
+DEPS_USER_H1 += src/cJSON/cJSON.h
+DEPS_USER_H1 += $(BUILD)/inc/goahead.h
+
+$(BUILD)/inc/cJSON.h: $(DEPS_USER_H1)
+	@echo '      [Copy] $(BUILD)/inc/cJSON.h'
+	mkdir -p "$(BUILD)/inc"
+	cp src/cJSON/cJSON.h $(BUILD)/inc/cJSON.h
+
+DEPS_USER_C1 += $(BUILD)/inc/goahead.h
+DEPS_USER_C1 += $(BUILD)/inc/cJSON.h
+
+$(BUILD)/obj/cJSON.o: \
+    src/cJSON/cJSON.c $(DEPS_USER_C1)
+	@echo '   [Compile] $(BUILD)/obj/cJSON.o'
+	$(CC) -c -o $(BUILD)/obj/cJSON.o $(LDFLAGS) $(CFLAGS) $(DFLAGS) -D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS=64 -DMBEDTLS_USER_CONFIG_FILE=\"embedtls.h\" -DME_COM_OPENSSL_PATH=$(ME_COM_OPENSSL_PATH) $(IFLAGS) "-I$(ME_COM_OPENSSL_PATH)/include" src/cJSON/cJSON.c
+
+#
+#	libipmi
+#
+DEPS_USER_H2 += src/libipmi/inc/libipmi_session.h
+DEPS_USER_H2 += src/libipmi/inc/libipmi.h
+DEPS_USER_H2 += src/libipmi/inc/libipmi_errorcodes.h
+DEPS_USER_H2 += src/libipmi/inc/libipmi_struct.h
+DEPS_USER_H2 += src/libipmi/inc/libipmi_IPM.h
+DEPS_USER_H2 += ../common_include/com_IPMI_AppDevice.h
+DEPS_USER_H2 += ../common_include/com_IPMIDefs.h
+DEPS_USER_H2 += ../common_include/com_IPMI_IPM.h
+DEPS_USER_H2 += ../common_include/com_UDSIfc.h
+DEPS_USER_H2 += ../common_include/com_IPMI_App.h
+
+
+$(BUILD)/inc/libipmi_session.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/libipmi_session.h'
+	mkdir -p "$(BUILD)/inc"
+	cp src/libipmi/inc/libipmi_session.h $(BUILD)/inc/libipmi_session.h
+$(BUILD)/inc/libipmi.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/libipmi.h'
+	mkdir -p "$(BUILD)/inc"
+	cp src/libipmi/inc/libipmi.h $(BUILD)/inc/libipmi.h
+$(BUILD)/inc/libipmi_errorcodes.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/libipmi_errorcodes.h'
+	mkdir -p "$(BUILD)/inc"
+	cp src/libipmi/inc/libipmi_errorcodes.h $(BUILD)/inc/libipmi_errorcodes.h
+$(BUILD)/inc/libipmi_struct.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/libipmi_struct.h'
+	mkdir -p "$(BUILD)/inc"
+	cp src/libipmi/inc/libipmi_struct.h $(BUILD)/inc/libipmi_struct.h
+$(BUILD)/inc/libipmi_IPM.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/libipmi_IPM.h'
+	mkdir -p "$(BUILD)/inc"
+	cp src/libipmi/inc/libipmi_IPM.h $(BUILD)/inc/libipmi_IPM.h
+
+$(BUILD)/inc/com_IPMI_AppDevice.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/com_IPMI_AppDevice.h'
+	mkdir -p "$(BUILD)/inc"
+	cp ../common_include/com_IPMI_AppDevice.h $(BUILD)/inc/com_IPMI_AppDevice.h
+$(BUILD)/inc/com_IPMIDefs.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/com_IPMIDefs.h'
+	mkdir -p "$(BUILD)/inc"
+	cp ../common_include/com_IPMIDefs.h $(BUILD)/inc/com_IPMIDefs.h
+$(BUILD)/inc/com_IPMI_IPM.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/com_IPMI_IPM.h'
+	mkdir -p "$(BUILD)/inc"
+	cp ../common_include/com_IPMI_IPM.h $(BUILD)/inc/com_IPMI_IPM.h
+$(BUILD)/inc/com_UDSIfc.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/com_UDSIfc.h'
+	mkdir -p "$(BUILD)/inc"
+	cp ../common_include/com_UDSIfc.h $(BUILD)/inc/com_UDSIfc.h
+$(BUILD)/inc/com_IPMI_App.h: $(DEPS_USER_H2)
+	@echo '      [Copy] $(BUILD)/inc/com_IPMI_App.h'
+	mkdir -p "$(BUILD)/inc"
+	cp ../common_include/com_IPMI_App.h $(BUILD)/inc/com_IPMI_App.h
+
+DEPS_USER_C2 += $(BUILD)/inc/libipmi_session.h
+DEPS_USER_C2 += $(BUILD)/inc/libipmi.h
+DEPS_USER_C2 += $(BUILD)/inc/libipmi_errorcodes.h
+DEPS_USER_C2 += $(BUILD)/inc/libipmi_struct.h
+DEPS_USER_C2 += $(BUILD)/inc/libipmi_IPM.h
+DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_AppDevice.h
+DEPS_USER_C2 += $(BUILD)/inc/com_IPMIDefs.h
+DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_IPM.h
+DEPS_USER_C2 += $(BUILD)/inc/com_UDSIfc.h
+DEPS_USER_C2 += $(BUILD)/inc/com_IPMI_App.h
+
+$(BUILD)/obj/libipmi_session.o: \
+    src/libipmi/src/libipmi_session.c $(DEPS_USER_C2)
+	@echo '   [Compile] $(BUILD)/obj/libipmi_session.o'
+	$(CC) -c -o $(BUILD)/obj/libipmi_session.o $(LDFLAGS) $(CFLAGS) $(DFLAGS) -D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS=64 -DMBEDTLS_USER_CONFIG_FILE=\"embedtls.h\" -DME_COM_OPENSSL_PATH=$(ME_COM_OPENSSL_PATH) $(IFLAGS) "-I$(ME_COM_OPENSSL_PATH)/include" src/libipmi/src/libipmi_session.c
+$(BUILD)/obj/libipmi_uds_session.o: \
+    src/libipmi/src/libipmi_uds_session.c $(DEPS_USER_C2)
+	@echo '   [Compile] $(BUILD)/obj/libipmi_uds_session.o'
+	$(CC) -c -o $(BUILD)/obj/libipmi_uds_session.o $(LDFLAGS) $(CFLAGS) $(DFLAGS) -D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS=64 -DMBEDTLS_USER_CONFIG_FILE=\"embedtls.h\" -DME_COM_OPENSSL_PATH=$(ME_COM_OPENSSL_PATH) $(IFLAGS) "-I$(ME_COM_OPENSSL_PATH)/include" src/libipmi/src/libipmi_uds_session.c
+
+
+
+
 
 #
 #   libgo
@@ -528,10 +628,14 @@ DEPS_36 += $(BUILD)/obj/runtime.o
 DEPS_36 += $(BUILD)/obj/socket.o
 DEPS_36 += $(BUILD)/obj/time.o
 DEPS_36 += $(BUILD)/obj/upload.o
+DEPS_36 += $(BUILD)/obj/cJSON.o
+DEPS_36 += $(BUILD)/obj/libipmi_session.o
+DEPS_36 += $(BUILD)/obj/libipmi_uds_session.o
+
 
 $(BUILD)/bin/libgo.a: $(DEPS_36)
 	@echo '      [Link] $(BUILD)/bin/libgo.a'
-	$(AR) -cr $(BUILD)/bin/libgo.a "$(BUILD)/obj/action.o" "$(BUILD)/obj/alloc.o" "$(BUILD)/obj/auth.o" "$(BUILD)/obj/cgi.o" "$(BUILD)/obj/crypt.o" "$(BUILD)/obj/file.o" "$(BUILD)/obj/fs.o" "$(BUILD)/obj/http.o" "$(BUILD)/obj/js.o" "$(BUILD)/obj/jst.o" "$(BUILD)/obj/options.o" "$(BUILD)/obj/osdep.o" "$(BUILD)/obj/rom.o" "$(BUILD)/obj/route.o" "$(BUILD)/obj/runtime.o" "$(BUILD)/obj/socket.o" "$(BUILD)/obj/time.o" "$(BUILD)/obj/upload.o"
+	$(AR) -cr $(BUILD)/bin/libgo.a "$(BUILD)/obj/action.o" "$(BUILD)/obj/alloc.o" "$(BUILD)/obj/auth.o" "$(BUILD)/obj/cgi.o" "$(BUILD)/obj/crypt.o" "$(BUILD)/obj/file.o" "$(BUILD)/obj/fs.o" "$(BUILD)/obj/http.o" "$(BUILD)/obj/js.o" "$(BUILD)/obj/jst.o" "$(BUILD)/obj/options.o" "$(BUILD)/obj/osdep.o" "$(BUILD)/obj/rom.o" "$(BUILD)/obj/route.o" "$(BUILD)/obj/runtime.o" "$(BUILD)/obj/socket.o" "$(BUILD)/obj/time.o" "$(BUILD)/obj/upload.o" "$(BUILD)/obj/cJSON.o" "$(BUILD)/obj/libipmi_session.o" "$(BUILD)/obj/libipmi_uds_session.o"
 
 #
 #   install-certs

+ 756 - 0
app/goahead-5.1.0/src/cJSON/cJSON.c

@@ -0,0 +1,756 @@
+/*
+  Copyright (c) 2009 Dave Gamble
+
+  Permission is hereby granted, free of charge, to any person obtaining a copy
+  of this software and associated documentation files (the "Software"), to deal
+  in the Software without restriction, including without limitation the rights
+  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+  copies of the Software, and to permit persons to whom the Software is
+  furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included in
+  all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+  THE SOFTWARE.
+*/
+
+/* cJSON */
+/* JSON parser in C. */
+
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+#include <stdlib.h>
+#include <float.h>
+#include <limits.h>
+#include <ctype.h>
+#include "cJSON.h"
+#include "goahead.h"
+
+static const char *ep;
+
+void jimboTestcJson(void)
+{
+	error("---> This is jimbo test cJSON.c\n");
+}
+
+const char *cJSON_GetErrorPtr(void) {return ep;}
+
+static int cJSON_strcasecmp(const char *s1,const char *s2)
+{
+	if (!s1) return (s1==s2)?0:1;if (!s2) return 1;
+	for(; tolower(*s1) == tolower(*s2); ++s1, ++s2)	if(*s1 == 0)	return 0;
+	return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
+}
+
+static void *(*cJSON_malloc)(size_t sz) = malloc;
+static void (*cJSON_free)(void *ptr) = free;
+
+static char* cJSON_strdup(const char* str)
+{
+      size_t len;
+      char* copy;
+
+      len = strlen(str) + 1;
+      if (!(copy = (char*)cJSON_malloc(len))) return 0;
+      memcpy(copy,str,len);
+      return copy;
+}
+
+void cJSON_InitHooks(cJSON_Hooks* hooks)
+{
+    if (!hooks) { /* Reset hooks */
+        cJSON_malloc = malloc;
+        cJSON_free = free;
+        return;
+    }
+
+	cJSON_malloc = (hooks->malloc_fn)?hooks->malloc_fn:malloc;
+	cJSON_free	 = (hooks->free_fn)?hooks->free_fn:free;
+}
+
+/* Internal constructor. */
+static cJSON *cJSON_New_Item(void)
+{
+	cJSON* node = (cJSON*)cJSON_malloc(sizeof(cJSON));
+	if (node) memset(node,0,sizeof(cJSON));
+	return node;
+}
+
+/* Delete a cJSON structure. */
+void cJSON_Delete(cJSON *c)
+{
+	cJSON *next;
+	while (c)
+	{
+		next=c->next;
+		if (!(c->type&cJSON_IsReference) && c->child) cJSON_Delete(c->child);
+		if (!(c->type&cJSON_IsReference) && c->valuestring) cJSON_free(c->valuestring);
+		if (!(c->type&cJSON_StringIsConst) && c->string) cJSON_free(c->string);
+		cJSON_free(c);
+		c=next;
+	}
+}
+
+/* Parse the input text to generate a number, and populate the result into item. */
+static const char *parse_number(cJSON *item,const char *num)
+{
+	double n=0,sign=1,scale=0;int subscale=0,signsubscale=1;
+
+	if (*num=='-') sign=-1,num++;	/* Has sign? */
+	if (*num=='0') num++;			/* is zero */
+	if (*num>='1' && *num<='9')	do	n=(n*10.0)+(*num++ -'0');	while (*num>='0' && *num<='9');	/* Number? */
+	if (*num=='.' && num[1]>='0' && num[1]<='9') {num++;		do	n=(n*10.0)+(*num++ -'0'),scale--; while (*num>='0' && *num<='9');}	/* Fractional part? */
+	if (*num=='e' || *num=='E')		/* Exponent? */
+	{	num++;if (*num=='+') num++;	else if (*num=='-') signsubscale=-1,num++;		/* With sign? */
+		while (*num>='0' && *num<='9') subscale=(subscale*10)+(*num++ - '0');	/* Number? */
+	}
+
+	n=sign*n*pow(10.0,(scale+subscale*signsubscale));	/* number = +/- number.fraction * 10^+/- exponent */
+	
+	item->valuedouble=n;
+	item->valueint=(int)n;
+	item->type=cJSON_Number;
+	return num;
+}
+
+static int pow2gt (int x)	{	--x;	x|=x>>1;	x|=x>>2;	x|=x>>4;	x|=x>>8;	x|=x>>16;	return x+1;	}
+
+typedef struct {char *buffer; int length; int offset; } printbuffer;
+
+static char* ensure(printbuffer *p,int needed)
+{
+	char *newbuffer;int newsize;
+	if (!p || !p->buffer) return 0;
+	needed+=p->offset;
+	if (needed<=p->length) return p->buffer+p->offset;
+
+	newsize=pow2gt(needed);
+	newbuffer=(char*)cJSON_malloc(newsize);
+	if (!newbuffer) {cJSON_free(p->buffer);p->length=0,p->buffer=0;return 0;}
+	if (newbuffer) memcpy(newbuffer,p->buffer,p->length);
+	cJSON_free(p->buffer);
+	p->length=newsize;
+	p->buffer=newbuffer;
+	return newbuffer+p->offset;
+}
+
+static int update(printbuffer *p)
+{
+	char *str;
+	if (!p || !p->buffer) return 0;
+	str=p->buffer+p->offset;
+	return p->offset+strlen(str);
+}
+
+/* Render the number nicely from the given item into a string. */
+static char *print_number(cJSON *item,printbuffer *p)
+{
+	char *str=0;
+	double d=item->valuedouble;
+	if (d==0)
+	{
+		if (p)	str=ensure(p,2);
+		else	str=(char*)cJSON_malloc(2);	/* special case for 0. */
+		if (str) strcpy(str,"0");
+	}
+	else if (fabs(((double)item->valueint)-d)<=DBL_EPSILON && d<=INT_MAX && d>=INT_MIN)
+	{
+		if (p)	str=ensure(p,21);
+		else	str=(char*)cJSON_malloc(21);	/* 2^64+1 can be represented in 21 chars. */
+		if (str)	sprintf(str,"%d",item->valueint);
+	}
+	else
+	{
+		if (p)	str=ensure(p,64);
+		else	str=(char*)cJSON_malloc(64);	/* This is a nice tradeoff. */
+		if (str)
+		{
+			if (fabs(floor(d)-d)<=DBL_EPSILON && fabs(d)<1.0e60)sprintf(str,"%.0f",d);
+			else if (fabs(d)<1.0e-6 || fabs(d)>1.0e9)			sprintf(str,"%e",d);
+			else												sprintf(str,"%f",d);
+		}
+	}
+	return str;
+}
+
+static unsigned parse_hex4(const char *str)
+{
+	unsigned h=0;
+	if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
+	h=h<<4;str++;
+	if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
+	h=h<<4;str++;
+	if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
+	h=h<<4;str++;
+	if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
+	return h;
+}
+
+/* Parse the input text into an unescaped cstring, and populate item. */
+static const unsigned char firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
+static const char *parse_string(cJSON *item,const char *str)
+{
+	const char *ptr=str+1;char *ptr2;char *out;int len=0;unsigned uc,uc2;
+	if (*str!='\"') {ep=str;return 0;}	/* not a string! */
+	
+	while (*ptr!='\"' && *ptr && ++len) if (*ptr++ == '\\') ptr++;	/* Skip escaped quotes. */
+	
+	out=(char*)cJSON_malloc(len+1);	/* This is how long we need for the string, roughly. */
+	if (!out) return 0;
+	
+	ptr=str+1;ptr2=out;
+	while (*ptr!='\"' && *ptr)
+	{
+		if (*ptr!='\\') *ptr2++=*ptr++;
+		else
+		{
+			ptr++;
+			switch (*ptr)
+			{
+				case 'b': *ptr2++='\b';	break;
+				case 'f': *ptr2++='\f';	break;
+				case 'n': *ptr2++='\n';	break;
+				case 'r': *ptr2++='\r';	break;
+				case 't': *ptr2++='\t';	break;
+				case 'u':	 /* transcode utf16 to utf8. */
+					uc=parse_hex4(ptr+1);ptr+=4;	/* get the unicode char. */
+
+					if ((uc>=0xDC00 && uc<=0xDFFF) || uc==0)	break;	/* check for invalid.	*/
+
+					if (uc>=0xD800 && uc<=0xDBFF)	/* UTF16 surrogate pairs.	*/
+					{
+						if (ptr[1]!='\\' || ptr[2]!='u')	break;	/* missing second-half of surrogate.	*/
+						uc2=parse_hex4(ptr+3);ptr+=6;
+						if (uc2<0xDC00 || uc2>0xDFFF)		break;	/* invalid second-half of surrogate.	*/
+						uc=0x10000 + (((uc&0x3FF)<<10) | (uc2&0x3FF));
+					}
+
+					len=4;if (uc<0x80) len=1;else if (uc<0x800) len=2;else if (uc<0x10000) len=3; ptr2+=len;
+					
+					switch (len) {
+						case 4: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
+						case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
+						case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
+						case 1: *--ptr2 =(uc | firstByteMark[len]);
+					}
+					ptr2+=len;
+					break;
+				default:  *ptr2++=*ptr; break;
+			}
+			ptr++;
+		}
+	}
+	*ptr2=0;
+	if (*ptr=='\"') ptr++;
+	item->valuestring=out;
+	item->type=cJSON_String;
+	return ptr;
+}
+
+/* Render the cstring provided to an escaped version that can be printed. */
+static char *print_string_ptr(const char *str,printbuffer *p)
+{
+	const char *ptr;char *ptr2,*out;int len=0,flag=0;unsigned char token;
+	
+	for (ptr=str;*ptr;ptr++) flag|=((*ptr>0 && *ptr<32)||(*ptr=='\"')||(*ptr=='\\'))?1:0;
+	if (!flag)
+	{
+		len=ptr-str;
+		if (p) out=ensure(p,len+3);
+		else		out=(char*)cJSON_malloc(len+3);
+		if (!out) return 0;
+		ptr2=out;*ptr2++='\"';
+		strcpy(ptr2,str);
+		ptr2[len]='\"';
+		ptr2[len+1]=0;
+		return out;
+	}
+	
+	if (!str)
+	{
+		if (p)	out=ensure(p,3);
+		else	out=(char*)cJSON_malloc(3);
+		if (!out) return 0;
+		strcpy(out,"\"\"");
+		return out;
+	}
+	ptr=str;while ((token=*ptr) && ++len) {if (strchr("\"\\\b\f\n\r\t",token)) len++; else if (token<32) len+=5;ptr++;}
+	
+	if (p)	out=ensure(p,len+3);
+	else	out=(char*)cJSON_malloc(len+3);
+	if (!out) return 0;
+
+	ptr2=out;ptr=str;
+	*ptr2++='\"';
+	while (*ptr)
+	{
+		if ((unsigned char)*ptr>31 && *ptr!='\"' && *ptr!='\\') *ptr2++=*ptr++;
+		else
+		{
+			*ptr2++='\\';
+			switch (token=*ptr++)
+			{
+				case '\\':	*ptr2++='\\';	break;
+				case '\"':	*ptr2++='\"';	break;
+				case '\b':	*ptr2++='b';	break;
+				case '\f':	*ptr2++='f';	break;
+				case '\n':	*ptr2++='n';	break;
+				case '\r':	*ptr2++='r';	break;
+				case '\t':	*ptr2++='t';	break;
+				default: sprintf(ptr2,"u%04x",token);ptr2+=5;	break;	/* escape and print */
+			}
+		}
+	}
+	*ptr2++='\"';*ptr2++=0;
+	return out;
+}
+/* Invote print_string_ptr (which is useful) on an item. */
+static char *print_string(cJSON *item,printbuffer *p)	{return print_string_ptr(item->valuestring,p);}
+
+/* Predeclare these prototypes. */
+static const char *parse_value(cJSON *item,const char *value);
+static char *print_value(cJSON *item,int depth,int fmt,printbuffer *p);
+static const char *parse_array(cJSON *item,const char *value);
+static char *print_array(cJSON *item,int depth,int fmt,printbuffer *p);
+static const char *parse_object(cJSON *item,const char *value);
+static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p);
+
+/* Utility to jump whitespace and cr/lf */
+static const char *skip(const char *in) {while (in && *in && (unsigned char)*in<=32) in++; return in;}
+
+/* Parse an object - create a new root, and populate. */
+cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated)
+{
+	const char *end=0;
+	cJSON *c=cJSON_New_Item();
+	ep=0;
+	if (!c) return 0;       /* memory fail */
+
+	end=parse_value(c,skip(value));
+	if (!end)	{cJSON_Delete(c);return 0;}	/* parse failure. ep is set. */
+
+	/* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */
+	if (require_null_terminated) {end=skip(end);if (*end) {cJSON_Delete(c);ep=end;return 0;}}
+	if (return_parse_end) *return_parse_end=end;
+	return c;
+}
+/* Default options for cJSON_Parse */
+cJSON *cJSON_Parse(const char *value) {return cJSON_ParseWithOpts(value,0,0);}
+
+/* Render a cJSON item/entity/structure to text. */
+char *cJSON_Print(cJSON *item)				{return print_value(item,0,1,0);}
+char *cJSON_PrintUnformatted(cJSON *item)	{return print_value(item,0,0,0);}
+
+char *cJSON_PrintBuffered(cJSON *item,int prebuffer,int fmt)
+{
+	printbuffer p;
+	p.buffer=(char*)cJSON_malloc(prebuffer);
+	p.length=prebuffer;
+	p.offset=0;
+	return print_value(item,0,fmt,&p);
+	return p.buffer;
+}
+
+
+/* Parser core - when encountering text, process appropriately. */
+static const char *parse_value(cJSON *item,const char *value)
+{
+	if (!value)						return 0;	/* Fail on null. */
+	if (!strncmp(value,"null",4))	{ item->type=cJSON_NULL;  return value+4; }
+	if (!strncmp(value,"false",5))	{ item->type=cJSON_False; return value+5; }
+	if (!strncmp(value,"true",4))	{ item->type=cJSON_True; item->valueint=1;	return value+4; }
+	if (*value=='\"')				{ return parse_string(item,value); }
+	if (*value=='-' || (*value>='0' && *value<='9'))	{ return parse_number(item,value); }
+	if (*value=='[')				{ return parse_array(item,value); }
+	if (*value=='{')				{ return parse_object(item,value); }
+
+	ep=value;return 0;	/* failure. */
+}
+
+/* Render a value to text. */
+static char *print_value(cJSON *item,int depth,int fmt,printbuffer *p)
+{
+	char *out=0;
+	if (!item) return 0;
+	if (p)
+	{
+		switch ((item->type)&255)
+		{
+			case cJSON_NULL:	{out=ensure(p,5);	if (out) strcpy(out,"null");	break;}
+			case cJSON_False:	{out=ensure(p,6);	if (out) strcpy(out,"false");	break;}
+			case cJSON_True:	{out=ensure(p,5);	if (out) strcpy(out,"true");	break;}
+			case cJSON_Number:	out=print_number(item,p);break;
+			case cJSON_String:	out=print_string(item,p);break;
+			case cJSON_Array:	out=print_array(item,depth,fmt,p);break;
+			case cJSON_Object:	out=print_object(item,depth,fmt,p);break;
+		}
+	}
+	else
+	{
+		switch ((item->type)&255)
+		{
+			case cJSON_NULL:	out=cJSON_strdup("null");	break;
+			case cJSON_False:	out=cJSON_strdup("false");break;
+			case cJSON_True:	out=cJSON_strdup("true"); break;
+			case cJSON_Number:	out=print_number(item,0);break;
+			case cJSON_String:	out=print_string(item,0);break;
+			case cJSON_Array:	out=print_array(item,depth,fmt,0);break;
+			case cJSON_Object:	out=print_object(item,depth,fmt,0);break;
+		}
+	}
+	return out;
+}
+
+/* Build an array from input text. */
+static const char *parse_array(cJSON *item,const char *value)
+{
+	cJSON *child;
+	if (*value!='[')	{ep=value;return 0;}	/* not an array! */
+
+	item->type=cJSON_Array;
+	value=skip(value+1);
+	if (*value==']') return value+1;	/* empty array. */
+
+	item->child=child=cJSON_New_Item();
+	if (!item->child) return 0;		 /* memory fail */
+	value=skip(parse_value(child,skip(value)));	/* skip any spacing, get the value. */
+	if (!value) return 0;
+
+	while (*value==',')
+	{
+		cJSON *new_item;
+		if (!(new_item=cJSON_New_Item())) return 0; 	/* memory fail */
+		child->next=new_item;new_item->prev=child;child=new_item;
+		value=skip(parse_value(child,skip(value+1)));
+		if (!value) return 0;	/* memory fail */
+	}
+
+	if (*value==']') return value+1;	/* end of array */
+	ep=value;return 0;	/* malformed. */
+}
+
+/* Render an array to text */
+static char *print_array(cJSON *item,int depth,int fmt,printbuffer *p)
+{
+	char **entries;
+	char *out=0,*ptr,*ret;int len=5;
+	cJSON *child=item->child;
+	int numentries=0,i=0,fail=0;
+	size_t tmplen=0;
+	
+	/* How many entries in the array? */
+	while (child) numentries++,child=child->next;
+	/* Explicitly handle numentries==0 */
+	if (!numentries)
+	{
+		if (p)	out=ensure(p,3);
+		else	out=(char*)cJSON_malloc(3);
+		if (out) strcpy(out,"[]");
+		return out;
+	}
+
+	if (p)
+	{
+		/* Compose the output array. */
+		i=p->offset;
+		ptr=ensure(p,1);if (!ptr) return 0;	*ptr='[';	p->offset++;
+		child=item->child;
+		while (child && !fail)
+		{
+			print_value(child,depth+1,fmt,p);
+			p->offset=update(p);
+			if (child->next) {len=fmt?2:1;ptr=ensure(p,len+1);if (!ptr) return 0;*ptr++=',';if(fmt)*ptr++=' ';*ptr=0;p->offset+=len;}
+			child=child->next;
+		}
+		ptr=ensure(p,2);if (!ptr) return 0;	*ptr++=']';*ptr=0;
+		out=(p->buffer)+i;
+	}
+	else
+	{
+		/* Allocate an array to hold the values for each */
+		entries=(char**)cJSON_malloc(numentries*sizeof(char*));
+		if (!entries) return 0;
+		memset(entries,0,numentries*sizeof(char*));
+		/* Retrieve all the results: */
+		child=item->child;
+		while (child && !fail)
+		{
+			ret=print_value(child,depth+1,fmt,0);
+			entries[i++]=ret;
+			if (ret) len+=strlen(ret)+2+(fmt?1:0); else fail=1;
+			child=child->next;
+		}
+		
+		/* If we didn't fail, try to malloc the output string */
+		if (!fail)	out=(char*)cJSON_malloc(len);
+		/* If that fails, we fail. */
+		if (!out) fail=1;
+
+		/* Handle failure. */
+		if (fail)
+		{
+			for (i=0;i<numentries;i++) if (entries[i]) cJSON_free(entries[i]);
+			cJSON_free(entries);
+			return 0;
+		}
+		
+		/* Compose the output array. */
+		*out='[';
+		ptr=out+1;*ptr=0;
+		for (i=0;i<numentries;i++)
+		{
+			tmplen=strlen(entries[i]);memcpy(ptr,entries[i],tmplen);ptr+=tmplen;
+			if (i!=numentries-1) {*ptr++=',';if(fmt)*ptr++=' ';*ptr=0;}
+			cJSON_free(entries[i]);
+		}
+		cJSON_free(entries);
+		*ptr++=']';*ptr++=0;
+	}
+	return out;	
+}
+
+/* Build an object from the text. */
+static const char *parse_object(cJSON *item,const char *value)
+{
+	cJSON *child;
+	if (*value!='{')	{ep=value;return 0;}	/* not an object! */
+	
+	item->type=cJSON_Object;
+	value=skip(value+1);
+	if (*value=='}') return value+1;	/* empty array. */
+	
+	item->child=child=cJSON_New_Item();
+	if (!item->child) return 0;
+	value=skip(parse_string(child,skip(value)));
+	if (!value) return 0;
+	child->string=child->valuestring;child->valuestring=0;
+	if (*value!=':') {ep=value;return 0;}	/* fail! */
+	value=skip(parse_value(child,skip(value+1)));	/* skip any spacing, get the value. */
+	if (!value) return 0;
+	
+	while (*value==',')
+	{
+		cJSON *new_item;
+		if (!(new_item=cJSON_New_Item()))	return 0; /* memory fail */
+		child->next=new_item;new_item->prev=child;child=new_item;
+		value=skip(parse_string(child,skip(value+1)));
+		if (!value) return 0;
+		child->string=child->valuestring;child->valuestring=0;
+		if (*value!=':') {ep=value;return 0;}	/* fail! */
+		value=skip(parse_value(child,skip(value+1)));	/* skip any spacing, get the value. */
+		if (!value) return 0;
+	}
+	
+	if (*value=='}') return value+1;	/* end of array */
+	ep=value;return 0;	/* malformed. */
+}
+
+/* Render an object to text. */
+static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p)
+{
+	char **entries=0,**names=0;
+	char *out=0,*ptr,*ret,*str;int len=7,i=0,j;
+	cJSON *child=item->child;
+	int numentries=0,fail=0;
+	size_t tmplen=0;
+	/* Count the number of entries. */
+	while (child) numentries++,child=child->next;
+	/* Explicitly handle empty object case */
+	if (!numentries)
+	{
+		if (p) out=ensure(p,fmt?depth+4:3);
+		else	out=(char*)cJSON_malloc(fmt?depth+4:3);
+		if (!out)	return 0;
+		ptr=out;*ptr++='{';
+		if (fmt) {*ptr++='\n';for (i=0;i<depth-1;i++) *ptr++='\t';}
+		*ptr++='}';*ptr++=0;
+		return out;
+	}
+	if (p)
+	{
+		/* Compose the output: */
+		i=p->offset;
+		len=fmt?2:1;	ptr=ensure(p,len+1);	if (!ptr) return 0;
+		*ptr++='{';	if (fmt) *ptr++='\n';	*ptr=0;	p->offset+=len;
+		child=item->child;depth++;
+		while (child)
+		{
+			if (fmt)
+			{
+				ptr=ensure(p,depth);	if (!ptr) return 0;
+				for (j=0;j<depth;j++) *ptr++='\t';
+				p->offset+=depth;
+			}
+			print_string_ptr(child->string,p);
+			p->offset=update(p);
+			
+			len=fmt?2:1;
+			ptr=ensure(p,len);	if (!ptr) return 0;
+			*ptr++=':';if (fmt) *ptr++='\t';
+			p->offset+=len;
+			
+			print_value(child,depth,fmt,p);
+			p->offset=update(p);
+
+			len=(fmt?1:0)+(child->next?1:0);
+			ptr=ensure(p,len+1); if (!ptr) return 0;
+			if (child->next) *ptr++=',';
+			if (fmt) *ptr++='\n';*ptr=0;
+			p->offset+=len;
+			child=child->next;
+		}
+		ptr=ensure(p,fmt?(depth+1):2);	 if (!ptr) return 0;
+		if (fmt)	for (i=0;i<depth-1;i++) *ptr++='\t';
+		*ptr++='}';*ptr=0;
+		out=(p->buffer)+i;
+	}
+	else
+	{
+		/* Allocate space for the names and the objects */
+		entries=(char**)cJSON_malloc(numentries*sizeof(char*));
+		if (!entries) return 0;
+		names=(char**)cJSON_malloc(numentries*sizeof(char*));
+		if (!names) {cJSON_free(entries);return 0;}
+		memset(entries,0,sizeof(char*)*numentries);
+		memset(names,0,sizeof(char*)*numentries);
+
+		/* Collect all the results into our arrays: */
+		child=item->child;depth++;if (fmt) len+=depth;
+		while (child)
+		{
+			names[i]=str=print_string_ptr(child->string,0);
+			entries[i++]=ret=print_value(child,depth,fmt,0);
+			if (str && ret) len+=strlen(ret)+strlen(str)+2+(fmt?2+depth:0); else fail=1;
+			child=child->next;
+		}
+		
+		/* Try to allocate the output string */
+		if (!fail)	out=(char*)cJSON_malloc(len);
+		if (!out) fail=1;
+
+		/* Handle failure */
+		if (fail)
+		{
+			for (i=0;i<numentries;i++) {if (names[i]) cJSON_free(names[i]);if (entries[i]) cJSON_free(entries[i]);}
+			cJSON_free(names);cJSON_free(entries);
+			return 0;
+		}
+		
+		/* Compose the output: */
+		*out='{';ptr=out+1;if (fmt)*ptr++='\n';*ptr=0;
+		for (i=0;i<numentries;i++)
+		{
+			if (fmt) for (j=0;j<depth;j++) *ptr++='\t';
+			tmplen=strlen(names[i]);memcpy(ptr,names[i],tmplen);ptr+=tmplen;
+			*ptr++=':';if (fmt) *ptr++='\t';
+			strcpy(ptr,entries[i]);ptr+=strlen(entries[i]);
+			if (i!=numentries-1) *ptr++=',';
+			if (fmt) *ptr++='\n';*ptr=0;
+			cJSON_free(names[i]);cJSON_free(entries[i]);
+		}
+		
+		cJSON_free(names);cJSON_free(entries);
+		if (fmt) for (i=0;i<depth-1;i++) *ptr++='\t';
+		*ptr++='}';*ptr++=0;
+	}
+	return out;	
+}
+
+/* Get Array size/item / object item. */
+int    cJSON_GetArraySize(cJSON *array)							{cJSON *c=array->child;int i=0;while(c)i++,c=c->next;return i;}
+cJSON *cJSON_GetArrayItem(cJSON *array,int item)				{cJSON *c=array->child;  while (c && item>0) item--,c=c->next; return c;}
+cJSON *cJSON_GetObjectItem(cJSON *object,const char *string)	{cJSON *c=object->child; while (c && cJSON_strcasecmp(c->string,string)) c=c->next; return c;}
+
+/* Utility for array list handling. */
+static void suffix_object(cJSON *prev,cJSON *item) {prev->next=item;item->prev=prev;}
+/* Utility for handling references. */
+static cJSON *create_reference(cJSON *item) {cJSON *ref=cJSON_New_Item();if (!ref) return 0;memcpy(ref,item,sizeof(cJSON));ref->string=0;ref->type|=cJSON_IsReference;ref->next=ref->prev=0;return ref;}
+
+/* Add item to array/object. */
+void   cJSON_AddItemToArray(cJSON *array, cJSON *item)						{cJSON *c=array->child;if (!item) return; if (!c) {array->child=item;} else {while (c && c->next) c=c->next; suffix_object(c,item);}}
+void   cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item)	{if (!item) return; if (item->string) cJSON_free(item->string);item->string=cJSON_strdup(string);cJSON_AddItemToArray(object,item);}
+void   cJSON_AddItemToObjectCS(cJSON *object,const char *string,cJSON *item)	{if (!item) return; if (!(item->type&cJSON_StringIsConst) && item->string) cJSON_free(item->string);item->string=(char*)string;item->type|=cJSON_StringIsConst;cJSON_AddItemToArray(object,item);}
+void	cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item)						{cJSON_AddItemToArray(array,create_reference(item));}
+void	cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item)	{cJSON_AddItemToObject(object,string,create_reference(item));}
+
+cJSON *cJSON_DetachItemFromArray(cJSON *array,int which)			{cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return 0;
+	if (c->prev) c->prev->next=c->next;if (c->next) c->next->prev=c->prev;if (c==array->child) array->child=c->next;c->prev=c->next=0;return c;}
+void   cJSON_DeleteItemFromArray(cJSON *array,int which)			{cJSON_Delete(cJSON_DetachItemFromArray(array,which));}
+cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string) {int i=0;cJSON *c=object->child;while (c && cJSON_strcasecmp(c->string,string)) i++,c=c->next;if (c) return cJSON_DetachItemFromArray(object,i);return 0;}
+void   cJSON_DeleteItemFromObject(cJSON *object,const char *string) {cJSON_Delete(cJSON_DetachItemFromObject(object,string));}
+
+/* Replace array/object items with new ones. */
+void   cJSON_InsertItemInArray(cJSON *array,int which,cJSON *newitem)		{cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) {cJSON_AddItemToArray(array,newitem);return;}
+	newitem->next=c;newitem->prev=c->prev;c->prev=newitem;if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;}
+void   cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem)		{cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return;
+	newitem->next=c->next;newitem->prev=c->prev;if (newitem->next) newitem->next->prev=newitem;
+	if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;c->next=c->prev=0;cJSON_Delete(c);}
+void   cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem){int i=0;cJSON *c=object->child;while(c && cJSON_strcasecmp(c->string,string))i++,c=c->next;if(c){newitem->string=cJSON_strdup(string);cJSON_ReplaceItemInArray(object,i,newitem);}}
+
+/* Create basic types: */
+cJSON *cJSON_CreateNull(void)					{cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;}
+cJSON *cJSON_CreateTrue(void)					{cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_True;return item;}
+cJSON *cJSON_CreateFalse(void)					{cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_False;return item;}
+cJSON *cJSON_CreateBool(int b)					{cJSON *item=cJSON_New_Item();if(item)item->type=b?cJSON_True:cJSON_False;return item;}
+cJSON *cJSON_CreateNumber(double num)			{cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_Number;item->valuedouble=num;item->valueint=(int)num;}return item;}
+cJSON *cJSON_CreateString(const char *string)	{cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_String;item->valuestring=cJSON_strdup(string);}return item;}
+cJSON *cJSON_CreateArray(void)					{cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Array;return item;}
+cJSON *cJSON_CreateObject(void)					{cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Object;return item;}
+
+/* Create Arrays: */
+cJSON *cJSON_CreateIntArray(const int *numbers,int count)		{int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
+cJSON *cJSON_CreateFloatArray(const float *numbers,int count)	{int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
+cJSON *cJSON_CreateDoubleArray(const double *numbers,int count)	{int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
+cJSON *cJSON_CreateStringArray(const char **strings,int count)	{int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateString(strings[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
+
+/* Duplication */
+cJSON *cJSON_Duplicate(cJSON *item,int recurse)
+{
+	cJSON *newitem,*cptr,*nptr=0,*newchild;
+	/* Bail on bad ptr */
+	if (!item) return 0;
+	/* Create new item */
+	newitem=cJSON_New_Item();
+	if (!newitem) return 0;
+	/* Copy over all vars */
+	newitem->type=item->type&(~cJSON_IsReference),newitem->valueint=item->valueint,newitem->valuedouble=item->valuedouble;
+	if (item->valuestring)	{newitem->valuestring=cJSON_strdup(item->valuestring);	if (!newitem->valuestring)	{cJSON_Delete(newitem);return 0;}}
+	if (item->string)		{newitem->string=cJSON_strdup(item->string);			if (!newitem->string)		{cJSON_Delete(newitem);return 0;}}
+	/* If non-recursive, then we're done! */
+	if (!recurse) return newitem;
+	/* Walk the ->next chain for the child. */
+	cptr=item->child;
+	while (cptr)
+	{
+		newchild=cJSON_Duplicate(cptr,1);		/* Duplicate (with recurse) each item in the ->next chain */
+		if (!newchild) {cJSON_Delete(newitem);return 0;}
+		if (nptr)	{nptr->next=newchild,newchild->prev=nptr;nptr=newchild;}	/* If newitem->child already set, then crosswire ->prev and ->next and move on */
+		else		{newitem->child=newchild;nptr=newchild;}					/* Set newitem->child and move to it */
+		cptr=cptr->next;
+	}
+	return newitem;
+}
+
+void cJSON_Minify(char *json)
+{
+	char *into=json;
+	while (*json)
+	{
+		if (*json==' ') json++;
+		else if (*json=='\t') json++;	/* Whitespace characters. */
+		else if (*json=='\r') json++;
+		else if (*json=='\n') json++;
+		else if (*json=='/' && json[1]=='/')  while (*json && *json!='\n') json++;	/* double-slash comments, to end of line. */
+		else if (*json=='/' && json[1]=='*') {while (*json && !(*json=='*' && json[1]=='/')) json++;json+=2;}	/* multiline comments. */
+		else if (*json=='\"'){*into++=*json++;while (*json && *json!='\"'){if (*json=='\\') *into++=*json++;*into++=*json++;}*into++=*json++;} /* string literals, which are \" sensitive. */
+		else *into++=*json++;			/* All other characters. */
+	}
+	*into=0;	/* and null-terminate. */
+}

+ 151 - 0
app/goahead-5.1.0/src/cJSON/cJSON.h

@@ -0,0 +1,151 @@
+/*
+  Copyright (c) 2009 Dave Gamble
+ 
+  Permission is hereby granted, free of charge, to any person obtaining a copy
+  of this software and associated documentation files (the "Software"), to deal
+  in the Software without restriction, including without limitation the rights
+  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+  copies of the Software, and to permit persons to whom the Software is
+  furnished to do so, subject to the following conditions:
+ 
+  The above copyright notice and this permission notice shall be included in
+  all copies or substantial portions of the Software.
+ 
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+  THE SOFTWARE.
+*/
+
+#ifndef cJSON__h
+#define cJSON__h
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* cJSON Types: */
+#define cJSON_False 0
+#define cJSON_True 1
+#define cJSON_NULL 2
+#define cJSON_Number 3
+#define cJSON_String 4
+#define cJSON_Array 5
+#define cJSON_Object 6
+	
+#define cJSON_IsReference 256
+#define cJSON_StringIsConst 512
+
+/* The cJSON structure: */
+typedef struct cJSON {
+	struct cJSON *next,*prev;	/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
+	struct cJSON *child;		/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
+
+	int type;					/* The type of the item, as above. */
+
+	char *valuestring;			/* The item's string, if type==cJSON_String */
+	int valueint;				/* The item's number, if type==cJSON_Number */
+	double valuedouble;			/* The item's number, if type==cJSON_Number */
+
+	char *string;				/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
+} cJSON;
+
+typedef struct cJSON_Hooks {
+      void *(*malloc_fn)(size_t sz);
+      void (*free_fn)(void *ptr);
+} cJSON_Hooks;
+
+extern void jimboTestcJson(void);
+
+/* Supply malloc, realloc and free functions to cJSON */
+extern void cJSON_InitHooks(cJSON_Hooks* hooks);
+
+
+/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
+extern cJSON *cJSON_Parse(const char *value);
+/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
+extern char  *cJSON_Print(cJSON *item);
+/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
+extern char  *cJSON_PrintUnformatted(cJSON *item);
+/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
+extern char *cJSON_PrintBuffered(cJSON *item,int prebuffer,int fmt);
+/* Delete a cJSON entity and all subentities. */
+extern void   cJSON_Delete(cJSON *c);
+
+/* Returns the number of items in an array (or object). */
+extern int	  cJSON_GetArraySize(cJSON *array);
+/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
+extern cJSON *cJSON_GetArrayItem(cJSON *array,int item);
+/* Get item "string" from object. Case insensitive. */
+extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
+
+/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
+extern const char *cJSON_GetErrorPtr(void);
+	
+/* These calls create a cJSON item of the appropriate type. */
+extern cJSON *cJSON_CreateNull(void);
+extern cJSON *cJSON_CreateTrue(void);
+extern cJSON *cJSON_CreateFalse(void);
+extern cJSON *cJSON_CreateBool(int b);
+extern cJSON *cJSON_CreateNumber(double num);
+extern cJSON *cJSON_CreateString(const char *string);
+extern cJSON *cJSON_CreateArray(void);
+extern cJSON *cJSON_CreateObject(void);
+
+/* These utilities create an Array of count items. */
+extern cJSON *cJSON_CreateIntArray(const int *numbers,int count);
+extern cJSON *cJSON_CreateFloatArray(const float *numbers,int count);
+extern cJSON *cJSON_CreateDoubleArray(const double *numbers,int count);
+extern cJSON *cJSON_CreateStringArray(const char **strings,int count);
+
+/* Append item to the specified array/object. */
+extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
+extern void	cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item);
+extern void	cJSON_AddItemToObjectCS(cJSON *object,const char *string,cJSON *item);	/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object */
+/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
+extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
+extern void	cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item);
+
+/* Remove/Detatch items from Arrays/Objects. */
+extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which);
+extern void   cJSON_DeleteItemFromArray(cJSON *array,int which);
+extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string);
+extern void   cJSON_DeleteItemFromObject(cJSON *object,const char *string);
+	
+/* Update array items. */
+extern void cJSON_InsertItemInArray(cJSON *array,int which,cJSON *newitem);	/* Shifts pre-existing items to the right. */
+extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
+extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
+
+/* Duplicate a cJSON item */
+extern cJSON *cJSON_Duplicate(cJSON *item,int recurse);
+/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
+need to be released. With recurse!=0, it will duplicate any children connected to the item.
+The item->next and ->prev pointers are always zero on return from Duplicate. */
+
+/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
+extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated);
+
+extern void cJSON_Minify(char *json);
+
+/* Macros for creating things quickly. */
+#define cJSON_AddNullToObject(object,name)		cJSON_AddItemToObject(object, name, cJSON_CreateNull())
+#define cJSON_AddTrueToObject(object,name)		cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
+#define cJSON_AddFalseToObject(object,name)		cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
+#define cJSON_AddBoolToObject(object,name,b)	cJSON_AddItemToObject(object, name, cJSON_CreateBool(b))
+#define cJSON_AddNumberToObject(object,name,n)	cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
+#define cJSON_AddStringToObject(object,name,s)	cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
+
+/* When assigning an integer value, it needs to be propagated to valuedouble too. */
+#define cJSON_SetIntValue(object,val)			((object)?(object)->valueint=(object)->valuedouble=(val):(val))
+#define cJSON_SetNumberValue(object,val)		((object)?(object)->valueint=(object)->valuedouble=(val):(val))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

+ 674 - 0
app/goahead-5.1.0/src/libipmi/inc/libipmi.h

@@ -0,0 +1,674 @@
+
+
+#ifndef LIBIPMI_H
+#define LIBIPMI_H
+
+#define u8 	unsigned char
+#define u16	unsigned short int
+#define s32 long int
+
+/*! Return value that indicates a specified sensor is disabled, and cannot be read */
+#define IPMI_SENSOR_DISABLED        ( -3 )
+
+/* IPMI threshold state definitions for monitoring */
+#define THRESH_UNINITIALIZED        ( (u16)0x00 ) /*!< Threshold state on first run */
+#define THRESH_NORMAL               ( (u16)0x01 ) /*!< Sensor is normal (unused in IPMI ) */
+#define THRESH_UP_NONCRIT           ( (u16)0x02 ) /*!< IPMI Upper Non-Critical Threshold */
+#define THRESH_UP_CRITICAL          ( (u16)0x04 ) /*!< IPMI Upper Critical Threshold */
+#define THRESH_LOW_NONCRIT          ( (u16)0x08 ) /*!< IPMI Lower Non-Critical Threshold */
+#define THRESH_LOW_CRITICAL         ( (u16)0x10 ) /*!< IPMI Lower Critical Threshold */
+#define THRESH_ACCESS_FAILED        ( (u16)0x20 ) /*!< Access failed sensor state */
+#define THRESH_UP_NON_RECOV         ( (u16)0x40 ) /*!< IPMI Upper Non-Recoverable Threshold */
+#define THRESH_LOW_NON_RECOV        ( (u16)0x80 ) /*!< IPMI Lower Non-Recoverable Threshold */
+
+/* Macros for converting netfn/lun combos */
+#define NETFN( netfnlun )       ( ( netfnlun & (u8)0xFC ) >> 2 )
+#define NETLUN( netfnlun )      ( ( netfnlun & (u8)0x03 ) )
+#define NETFNLUN( netfn,lun )   ( ( netfn << 2 ) | ( lun ) )
+
+/* Macros for converting seq/lun combos */
+#define SEQ( seqlun )           ( ( seqlun & (u8)0xFC ) >> 2 )
+#define SLUN( seqlun )          ( ( seqlun & (u8)0x03 ) )
+#define SEQLUN( seq, lun )      ( ( seq << 2 ) | ( lun ) )
+
+
+/*****                 IPMI Constant Definitions                         *****/
+
+/* Completion Codes */
+#define IPMI_SUCCESS            ( (u8)0x00 )
+
+/* Sensor Data Record types */
+#define SDR_FULL                ( (u8)0x01 ) /**< SDR RecordType for Full Sensor Record */
+#define SDR_COMPACT             ( (u8)0x02 ) /**< SDR RecordType for Compact Sensor Record */
+
+/* Raw sensor reading numeric format codes */
+#define SDR_READING_UNSIGNED    ( (u8)0 )
+#define SDR_READING_1SCOMP      ( (u8)1 )
+#define SDR_READING_2SCOMP      ( (u8)2 )
+#define SDR_READING_NONANALOG   ( (u8)3 )
+
+/* Max size of an SDR of type SDR_FULL.  SDR_COMPACT records are smaller. */
+#define SDR_MAX_SIZE            ( 64 )
+
+/* Chassis control codes */
+#define CHASSIS_POWER_DOWN      ( (u8)0x00 )
+#define CHASSIS_POWER_UP        ( (u8)0x01 )
+#define CHASSIS_POWER_CYCLE     ( (u8)0x02 )
+#define CHASSIS_HARD_RESET      ( (u8)0x03 )
+#define CHASSIS_PULSE_DUMP      ( (u8)0x04 )
+#define CHASSIS_ACPI_POWER_DOWN ( (u8)0x05 )
+
+/* Sensor Type Codes */
+#define IPMI_SENSOR_TEMPERATURE     ( (u8)0x01 )
+#define IPMI_SENSOR_VOLTAGE         ( (u8)0x02 )
+#define IPMI_SENSOR_CURRENT         ( (u8)0x03 )
+#define IPMI_SENSOR_FAN             ( (u8)0x04 )
+#define IPMI_SENSOR_POWER_SUPPLY    ( (u8)0x08 )
+#define IPMI_SENSOR_POWER_UNIT      ( (u8)0x09 )
+#define IPMI_SENSOR_COOLING_DEVICE  ( (u8)0x0A )
+#define IPMI_SENSOR_MEMORY          ( (u8)0x0C )
+
+/* Sensor Unit Type Codes from the IPMI spec */
+#define IPMI_UNIT_UNSPECIFIED   0
+#define IPMI_UNIT_DEGREES_C     1
+#define IPMI_UNIT_DEGREES_F     2
+#define IPMI_UNIT_DEGREES_K     3
+#define IPMI_UNIT_VOLTS         4
+#define IPMI_UNIT_AMPS          5
+#define IPMI_UNIT_WATTS         6
+#define IPMI_UNIT_JOULES        7
+#define IPMI_UNIT_COULOMBS      8
+#define IPMI_UNIT_VA            9
+#define IPMI_UNIT_NITS          10
+#define IPMI_UNIT_LUMEN         11
+#define IPMI_UNIT_LUX           12
+#define IPMI_UNIT_CANDELA       13
+#define IPMI_UNIT_KPA           14
+#define IPMI_UNIT_PSI           15
+#define IPMI_UNIT_NEWTON        16
+#define IPMI_UNIT_CFM           17
+#define IPMI_UNIT_RPM           18
+#define IPMI_UNIT_HZ            19
+#define IPMI_UNIT_MICROSECOND   20
+#define IPMI_UNIT_MILLISECOND   21
+#define IPMI_UNIT_SECOND        22
+#define IPMI_UNIT_MINUTE        23
+#define IPMI_UNIT_HOUR          24
+#define IPMI_UNIT_DAY           25
+#define IPMI_UNIT_WEEK          26
+#define IPMI_UNIT_MIL           27
+#define IPMI_UNIT_INCHES        28
+#define IPMI_UNIT_FEET          29
+#define IPMI_UNIT_CUIN          30
+#define IPMI_UNIT_CUFEET        31
+#define IPMI_UNIT_MM            32
+#define IPMI_UNIT_CM            33
+#define IPMI_UNIT_M             34
+#define IPMI_UNIT_CUCM          35
+#define IPMI_UNIT_CUM           36
+#define IPMI_UNIT_LITERS        37
+#define IPMI_UNIT_FLUIDOUNCE    38
+#define IPMI_UNIT_RADIANS       39
+#define IPMI_UNIT_STERADIANS    40
+#define IPMI_UNIT_REVOLUTIONS   41
+#define IPMI_UNIT_CYCLES        42
+#define IPMI_UNIT_GRAVITIES     43
+#define IPMI_UNIT_OUNCE         44
+#define IPMI_UNIT_POUND         45
+#define IPMI_UNIT_FTLB          46
+#define IPMI_UNIT_OZIN          47
+#define IPMI_UNIT_GAUSS         48
+#define IPMI_UNIT_GILBERTS      49
+#define IPMI_UNIT_HENRY         50
+#define IPMI_UNIT_MILLIHENRY    51
+#define IPMI_UNIT_FARAD         52
+#define IPMI_UNIT_MICROFARAD    53
+#define IPMI_UNIT_OHMS          54
+#define IPMI_UNIT_SIEMENS       55
+#define IPMI_UNIT_MOLE          56
+#define IPMI_UNIT_BECQUEREL     57
+#define IPMI_UNIT_PPM           58
+#define IPMI_UNIT_RESERVED      59
+#define IPMI_UNIT_DECIBELS      60
+#define IPMI_UNIT_DBA           61
+#define IPMI_UNIT_DBC           62
+#define IPMI_UNIT_GRAY          63
+#define IPMI_UNIT_SIEVERT       64
+#define IPMI_UNIT_COLORTEMPDK   65
+#define IPMI_UNIT_BIT           66
+#define IPMI_UNIT_KILOBIT       67
+#define IPMI_UNIT_MEGABIT       68
+#define IPMI_UNIT_GIGABIT       69
+#define IPMI_UNIT_BYTE          70
+#define IPMI_UNIT_KILOBYTE      71
+#define IPMI_UNIT_MEGABYTE      72
+#define IPMI_UNIT_GIGABYTE      73
+#define IPMI_UNIT_WORD          74
+#define IPMI_UNIT_DWORD         75
+#define IPMI_UNIT_QWORD         76
+#define IPMI_UNIT_LINE          77
+#define IPMI_UNIT_HIT           78
+#define IPMI_UNIT_MISS          79
+#define IPMI_UNIT_RETRY         80
+#define IPMI_UNIT_RESET         81
+#define IPMI_UNIT_OVERRUNFLOW   82
+#define IPMI_UNIT_UNDERRUN      83
+#define IPMI_UNIT_COLLISION     84
+#define IPMI_UNIT_PACKETS       85
+#define IPMI_UNIT_MESSAGES      86
+#define IPMI_UNIT_CHARACTERS    87
+#define IPMI_UNIT_ERROR         88
+#define IPMI_UNIT_CORRERROR     89
+#define IPMI_UNIT_UNCORRERROR   90
+
+
+
+/** \name IPMI Functions */
+/** \{ */
+
+/** \brief Send the IPMI Get Sensor Reading command and get the response
+ *
+ *  Send the GetSensorReading command to the specified slave with \a sensor as
+ *  the sensor number, and get the response.
+ *
+ *  \param slave The slave address of the IPMI device (8-bit format)
+ *  \param sensor The sensor number on the IPMI device
+ *  \param reading The address of a u8 that will be filled with the sensor
+ *  reading.  Note that this is a raw sensor value which must be converted
+ *  by use of the \ref ipmi_convert_reading function.
+ *  \param response The address of a \ref GetSensorReadingResponseStruct
+ *  if you want the entire sensor response, not just the sensor reading.
+ *  Pass \c NULL if you just want the sensor reading.
+ *
+ *  \retval "IPMI response code" Success
+ *  \retval HHM_FAILURE The sensor reading could not be retrieved.
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+
+/*@external@*/extern int
+ipmi_get_sensor_reading( u8 slave, u8 sensor, /*@out@*/u8 *reading,
+                         /*@null@*//*@out@*/GetSensorReadingResponseStruct *response )
+/*@globals fileSystem@*/
+/*@modifies *reading,fileSystem,response@*/;
+
+/** \brief Get a reservation to access the SDR repository
+ *
+ *  This is required for certain IPMI commands, such as GetSDR when doing
+ *  partial reads and from non-zero offsets, as well as other commands.
+ *  See the IPMI spec for details.
+ *
+ *  \param slave The slave address of the IPMI device (8-bit format)
+ *  \param response A pointer to an \ref IPMBReserveSDRRepositoryStruct that
+ *  this function fills in
+ *
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+
+/*@external@*/extern int
+ipmi_reserve_sdr_repository( u8 slave, /*@out@*/IPMBReserveSDRRepositoryStruct *response )
+/*@globals fileSystem@*/
+/*@modifies *response,fileSystem@*/;
+
+
+/** \brief Get a reservation to access the SEL
+ *
+ *  Get a reservation to access the SEL.  This is required for
+ *  certain IPMI commands  See the IPMI spec for details.
+ *
+ *  \param slave The slave address of the IPMI device (8-bit format)
+ *  \param response An \ref ReserveSELResponseStruct that this
+ *  function fills in.
+ *  
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+
+/*@external@*/extern int
+ipmi_reserve_sel_repository( u8 slave, /*@out@*/ReserveSELResponseStruct *response )	//jimbo notice!
+/*@globals fileSystem@*/
+/*@modifies *response,fileSystem@*/;
+
+
+/** \brief Read an SDR entry or part of an SDR entry from an IPMI device
+ *
+ *  Read an SDR entry from the SDR repository.  Usually only BMCs have SDR
+ *  repositories.  SDR entries have useful info such as sensor numbers,
+ *  sensor types, and data conversion equations, and can be used to determine
+ *  the type of sensors available, and how to monitor them.
+ *  This is probably not the function you are looking for.  This function is
+ *  a raw interface to the GetSDR function, suitable for performing partial
+ *  reads and testing.  If you just want to read the entire SDR entry, use
+ *  \ref ipmi_get_sdr_full which is much easier to use.
+ *
+ *  \param slave The slave address of the IPMI device (8-bit format)
+ *  \param reservation_id An SDR reservation ID obtained from the 
+ *  \ref ipmi_reserve_sdr_repository command, or zero if not doing a partial
+ *  read and \a offset_into_record is zero.
+ *  \param record_id The SDR record ID to read
+ *  \param bytes_to_read The number of bytes to read from the record. Pass
+ *  0xFF to read the entire record.   Be aware, however, that most BMCs do not
+ *  support sending a response large enough to contain the entire record.
+ *  \param offset_into_record The starting point for the SDR read operation in
+ *  the record.  If this is not 0, you need to call
+ *  \ref ipmi_reserve_sdr_repository before this function.
+ *  \param record_data A buffer that will be filled in with the entire GetSDR
+ *  response (cast this buffer to an \ref IPMBGetSDRResponseStruct after
+ *  calling).  The length of the SDR entry is variable, so the data buffer
+ *  should be ~255 bytes long to be safe.
+ *
+ *  \retval "Length of the SDR read" Success.  The IPMI completion code is 
+ *  contained within the \ref IPMBGetSDRResponseStruct returned in
+ *  \a record_data
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+/*@external@*/extern int
+ipmi_get_sdr( u8 slave, u16 reservation_id, u16 record_id,
+              u8 offset_into_record, u8 bytes_to_read, /*@out@*/u8 *record_data )
+/*@globals fileSystem@*/
+/*@modifies *record_data,fileSystem@*/;
+
+
+/** \brief Read an entire SDR entry from an IPMI device
+ *
+ *  Like \ref ipmi_get_sdr, but this command always reads the entire SDR entry,
+ *  even if it needs to break the operation down into a series of partial
+ *  reads.  Like \ref ipmi_get_sdr, \a record_data should be able to accomodate
+ *  255 bytes.
+ *
+ *  \param slave The slave address of the IPMI device (8-bit format)
+ *  \param record_id The SDR record to read
+ *  \param record_data A buffer the function fills in that will contain the
+ *  \ref IPMBGetSDRResponseStruct and the entire SDR entry specified in 
+ *  \a record_id
+ *
+ *  \retval "Length of the SDR read" Success.  The completion code is contained
+ *  within the \ref IPMBGetSDRResponseStruct returned in \a record_data
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+/*@external@*/extern int
+ipmi_get_sdr_full( u8 slave, u16 record_id, /*@out@*/u8 *record_data )
+/*@globals fileSystem@*/
+/*@modifies *record_data,fileSystem@*/;
+
+
+/** \brief Get an SEL entry from an IPMI device
+ *
+ *  Read an SEL entry from the SEL.  Usually only BMCs have an SEL.  This is
+ *  probably not the function you are looking for.  This function is a raw
+ *  interface to the GetSEL function, suitable for performing partial reads
+ *  and testing.  If you just want to read the entire SEL entry, use
+ *  \ref ipmi_get_sel_full, which is much easier to use.
+ *
+ *  \param slave The slave address of the IPMI device (8-bit format)
+ *  \param reservation_id An SEL reservation ID obtained from the
+ *  \ref ipmi_reserve_sel_repository command, or zero if not doing a partial
+ *  read and \a offset_into_record is zero.
+ *  \param record_id The SEL record ID to read.
+ *  \param offset_into_record The offset into the specified record to read
+ *  from.  Zero for the beginning of the record.
+ *  \param bytes_to_read The number of bytes to read from the record. Pass
+ *  0xFF to read the entire record.   Be aware, however, that most BMCs do
+ *  not support sending a response large enough to contain the entire record
+ *  \param response A \ref GetSELEntryResponseStruct that will be filled in
+ *  with the entire GetSEL response.
+ *
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+///*@external@*/extern int
+//ipmi_get_sel_entry( u8 slave, u16 reservation_id, u16 record_id,
+//                    u8 offset_into_record, u8 bytes_to_read,
+//                    /*@out@*/GetSELEntryResponseStruct *response )
+/*@globals fileSystem@*/
+/*@modifies *response,fileSystem@*/;
+
+
+/** \brief Get an entire SEL entry from an IPMI device
+ *
+ *  Like \ref ipmi_get_sel_entry, but this command always reads the entire SEL
+ *  entry, even if it needs to break the operation down into a series of
+ *  partial reads
+ *
+ *  \param slave The slave address of the IPMI device (8-bit format)
+ *  \param record_id The SEL entry to read
+ *  \param response A \ref GetSELEntryResponseStruct pointer which will
+ *  be filled in by this function.
+ *
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ */
+///*@external@*/extern int
+//ipmi_get_sel_full( u8 slave, u16 record_id, /*@out@*/GetSELEntryResponseStruct *response )
+///*@globals fileSystem@*/
+///*@modifies *response,fileSystem@*/;
+
+
+/** \brief Send the IPMI Get Device ID command and get the response
+ *
+ *  Send the get device ID IPMI command to a slave address on the I2C bus, and
+ *  receive the response.
+ *
+ *  \param slave Slave address of the IPMI device (8-bit format)
+ *  \param response The above slave's complete response to the get device
+ *  ID command.
+ *
+ *  \retval "IPMI Completion Code" Succes
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+///*@external@*/extern int
+//ipmi_get_device_id( u8 slave, /*@out@*/IPMBGetDeviceIDResponseStruct *response )
+///*@globals fileSystem@*/
+///*@modifies *response,fileSystem@*/;
+
+
+/** \brief Send the IPMI Chassis Power Down command
+ *
+ *  \param slave Slave address of the IPMI device (8-bit format)
+ *
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+/*@external@*/extern int
+ipmi_chassis_power_down( u8 slave )
+/*@globals fileSystem@*//*@modifies fileSystem@*/;
+
+
+/** \brief Send the IPMI Chassis Power Up command
+ *
+ *  \param slave Slave address of the IPMI device (8-bit format)
+ *
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+/*@external@*/extern int
+ipmi_chassis_power_up( u8 slave )
+/*@globals fileSystem@*//*@modifies fileSystem@*/;
+
+
+/** \brief Send the IPMI Chassis Power Cycle command
+ *
+ *  \param slave Slave address of the IPMI device (8-bit format)
+ *
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+/*@external@*/extern int
+ipmi_chassis_power_cycle( u8 slave )
+/*@globals fileSystem@*//*@modifies fileSystem@*/;
+
+
+/** \brief Send the IPMI Chassis Hard Reset command
+ *
+ *  \param slave Slave address of the IPMI device (8-bit format)
+ *
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+/*@external@*/extern int
+ipmi_chassis_hard_reset( u8 slave )
+/*@globals fileSystem@*//*@modifies fileSystem@*/;
+
+
+/** \brief Send the IPMI Chassis ACPI Power Down command
+ *
+ *  \param slave Slave address of the IPMI device (8-bit format)
+ *
+ *  \retval "IPMI Completion Code" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ *
+ *  \note For almost all sensors, the IPMI response code should be 0x00.
+ *  Some devices might return other completion codes to convey OEM specific
+ *  information, or just to be contrary.  If the behaviour of a particular
+ *  device is not well known with respect to completion codes, assume that if
+ *  a completion code other than 0x00 is returned, the value in \a reading
+ *  is invalid.
+ */
+/*@external@*/extern int
+ipmi_chassis_acpi_power_down( u8 slave )
+/*@globals fileSystem@*//*@modifies fileSystem@*/;
+
+
+/** \brief Send an arbitrary IPMI command, and get the response
+ *
+ *  Send any IPMI command your heart desires to any I2C/LUN combo and receive
+ *  the response.  See the IPMI spec for further info.
+ *
+ *  \param slave Slave address of the IPMI device (8-bit format)
+ *  \param netFn The net function of the command to send
+ *  \param targetLUN The LUN of the IPMI device
+ *  \param command A buffer containing the command number, and any extra data
+ *  which is needed for the command.
+ *  \param cmd_len The length of the command buffer
+ *  \param response_buffer The buffer which will be filled with the response
+ *  to your ipmi command.
+ *  \param response_len The size of the buffer to which
+ *  \a response_buffer points
+ *
+ *  \retval "Length of the IPMI response" Success
+ *  \retval HHM_FAILURE Failure, errno set
+ */
+/*@external@*/extern int
+ipmi_generic_command( u8 slave, u8 netFn, u8 targetLUN, u8 *command,
+                      size_t cmd_len, /*@out@*/u8 *response_buffer,
+                      size_t response_len )
+/*@globals fileSystem@*/
+/*@modifies *response_buffer,fileSystem@*/;
+
+
+/** \brief Convert a raw sensor reading to its final reading using an SDR
+ *
+ *  Use the standard IPMI method and SDR data to convert a raw sensor reading
+ *  into its converted value.  See the IPMI spec for further info on this
+ *  conversion.
+ *
+ *  \param sdr_buffer A pointer to a complete SDR entry which contains reading
+ *  conversion data.  IE, it is a Full SDR entry.
+ *  \param raw_reading The raw sensor reading you want to convert
+ *  \param converted_reading Pointer to an s32 that will be assigned the
+ *  converted reading on success.
+ *
+ *  \retval 0 Success, or sensor out of IPMI sensor min/max reading range, with
+ *  0 in \a converted_reading
+ *  \retval HHM_FAILURE Not enough information to perform the conversion
+ */
+/*@external@*/extern int
+ipmi_convert_reading( u8 *sdr_buffer, u8 raw_reading, /*@out@*/float *converted_reading )
+/*@modifies *converted_reading@*/;
+
+
+/** \brief Use an SDR entry to read the corresponding sensor
+ *
+ *  Use a (usually saved) SDR entry to read the current value of
+ *  a sensor.  The reading is performed as specified by the SDR
+ *  entry passed in \a sdr_buffer.  The reading obtained is the
+ *  final, converted sensor reading
+ *
+ *  \param sdr_buffer Pointer to a complete SDR buffer that contains
+ *  information on accessing a sensor.
+ *  \param raw_reading The raw sensor reading fresh from the BMC.
+ *  \param reading The converted sensor reading read and converted
+ *  as specified by the SDR entry.
+ *  \param discrete Pointer to a u8 used as a boolean, indicates if
+ *  the sensor read is a discrete sensor instead of an analog sensor
+ *
+ *  \retval HHM_FAILURE Failure
+ *  \retval IPMI_SENSOR_DISABLED Reading is invalid, this sensor is disabled
+ *  \retval 0 Success
+ */
+/*@external@*/extern int
+hhm_access_sdr_sensors( u8 *sdr_buffer, /*@out@*/u8 *raw_reading,
+                        /*@out@*/float *reading, /*@out@*/u8 *discrete )
+/*@globals fileSystem@*/
+/*@modifies *raw_reading,*reading,fileSystem,discrete@*/;
+
+/** \} */
+
+/** \brief Extract a descriptive string from an SDR entry
+ *
+ *  Read the text description field from the provided SDR, convert it
+ *  to a nice standard ascii string, and copy it into \a description.
+ *
+ *  \param sdr_buffer Pointer to a buffer containing an SDR
+ *  \param description Pointer to a buffer that will be filled with the
+ *  description of this SDR.  \a Description should have 17 bytes of storage,
+ *  to account for the 16 possible bytes of description defined by IPMI, and
+ *  the \c NULL terminator.
+ *
+ *  \retval 0 Success
+ *  \retval HHM_FAILURE Failure, errno set
+ */
+/*@external@*/extern int
+extract_sdr_id( u8 *sdr_buffer, /*@out@*/char *description )
+/*@modifies *description@*/;
+
+
+/** \brief Convert an IPMI (or AMI OEM) unit type code to a descriptive string
+ *
+ *  Convert an IPMI or AMI OEM unit type code into a string suitable for
+ *  display.  This function could (for example), convert the unit type 0x01 to
+ *  the string "degrees C".
+ *
+ *  \param unit_type_code An IPMI (or AMI OEM) unit type code
+ *  \param unit_type_string A char buffer that will contain the unit string
+ *  on completion.
+ *  \param unit_string_len The length of the unit string.  Expect around 20
+ *  chars at most, but there is no internal limit to any particular size.
+ *
+ *  \retval 0 Success
+ *  \retval HHM_FAILURE Failure, errno set, "Unrecognized" is set in
+ *  \a unit_type_string.
+ */
+/*@external@*/extern int
+sdk_unit_to_string( u8 unit_type_code, /*@out@*/char *unit_type_string,
+                    size_t unit_string_len )
+/*@modifies unit_type_string@*/;
+
+
+/** \brief Generate a string corresponding to a discrete reading code
+ *
+ *  Convert a discrete state (supplied in \a reading) into a string using the
+ *  \a reading_type_code and the IPMI table of discrete states.
+ *
+ *  \param reading The sensor reading (discrete state)
+ *  \param reading_type_code The reading type code from the SDR
+ *  \param sensor_type The sensor type code from the SDR
+ *  \param discrete_string Pointer to a buffer we will fill with text
+ *  describing the discrete state
+ *  \param string_size The amount of storage at \a discrete_string
+ *
+ *  \retval 0 Success
+ *  \retval HHM_FAILURE Failure, errno set
+ */
+/*@external@*/extern int
+ipmi_discrete_reading_string( s32 reading, u8 reading_type_code,
+                              u8 sensor_type,
+                              /*@out@*/char *discrete_string,
+                              size_t string_size )
+/*@modifies discrete_string@*/;
+
+
+/** \brief Get the threshold state of a sensor based on its SDR
+ *
+ *  Determine the state of a given sensor based on threshold information
+ *  from its SDR.  This state is a bitfield with individual bits indicating
+ *  which thresholds have been passed.  A bit is set to 1 when the threshold
+ *  it represents has been passed.  This function also handles threshold
+ *  hysteresis values correctly.
+ *
+ *  \param sensor_reading A raw, unconverted sensor reading
+ *  \param sdr_buffer A pointer to a buffer containing an SDR
+ *  \param last_state The previous state of the sensor, obtained from a prior
+ *  call to this function.  Pass \ref THRESH_UNINITIALIZED if there is no
+ *  \a last_state because this is the first call to \ref get_sdr_sensor_state
+ *  for this sensor.
+ *  \param current_state Variable that will be filled with the current state
+ *  of the sensor, based on information passed in \a sensor_reading and 
+ *  \a sdr_buffer.  See \ref THRESH_UP_NONCRIT for an example of a state
+ *  bitfield.
+ *
+ *  \retval 0 Success
+ *  \retval HHM_FAILURE Failure, errno set
+ */
+/*@external@*/extern int
+get_sdr_sensor_state( u8 sensor_reading, u8 *sdr_buffer, u16 last_state,
+                      /*@out@*/u16 *current_state )
+/*@modifies *current_state@*/;
+
+#endif

+ 116 - 0
app/goahead-5.1.0/src/libipmi/inc/libipmi_AppDevice.h

@@ -0,0 +1,116 @@
+/**
+ * @file   libipmi_AppDevice.h
+ * @author Rajasekhar (rajasekharj@amiindia.co.in)
+ * @date   02-Sep-2004
+ *
+ * @brief  Contains exported AppDevice API by LIBIPMI for
+ *			communicating with the BMC.
+ *
+ */
+
+#ifndef __LIBIPMI_APPDEVICE_H__
+#define __LIBIPMI_APPDEVICE_H__
+
+/* LIIPMI core header files */
+#include "libipmi_session.h"
+#include "libipmi_errorcodes.h"
+#include "libipmiifc.h"
+
+/* command specific header files */
+#include "IPMI_AppDevice.h"
+#include "IPMI_AppDevice+.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#define TWENTY_BYTE_PWD 0x80
+#define MAX_CHANNEL_NUM 15
+#define LAN_CHANNEL_MEDIUM_TYPE      0x04
+#define SERIAL_CHANNEL_MEDIUM_TYPE   0x05
+/*---------- IPMI Command direct routines ----------*/
+/* User Management functions */
+uint16_t IPMICMD_GetUserAccess(IPMI20_SESSION_T* pSession,
+								 GetUserAccessReq_T* pReqGetUserAccess,
+								 GetUserAccessRes_T* pResGetUserAccess,
+								 int timeout);
+
+uint16_t	IPMICMD_GetUser(IPMI20_SESSION_T *pSession/*in*/, GetUserNameReq_T	*pReqGetUser/*in*/,
+							GetUserNameRes_T *pResGetUser/*out*/, int timeout/*in*/);
+uint16_t	IPMICMD_SetUser(IPMI20_SESSION_T *pSession/*in*/, SetUserNameReq_T	*pReqSetUser/*in*/,
+							SetUserNameRes_T	*pResSetUser/*out*/, int timeout/*in*/);
+uint16_t	IPMICMD_GetSessionInfo(IPMI20_SESSION_T *pSession/*in*/, GetSesInfoReq_T	*pReqSetUser/*in*/,
+							GetSesInfoRes_T	*pResSetUser/*out*/, int timeout/*in*/);
+uint16_t IPMICMD_GetUserAccessPayload(IPMI20_SESSION_T* pSession,
+							 GetUsrPayldAccReq_T* pReqGetUserAccessPayload,
+							 GetUsrPayldAccRes_T* pResGetUserAccessPayload,
+							 int timeout);
+uint16_t IPMICMD_GetWDT(IPMI20_SESSION_T* pSession,
+							 GetWDTRes_T* pResGetWDT,
+							 int timeout);
+
+uint16_t IPMICMD_GetChannelInfo(IPMI20_SESSION_T* pSession,
+							 GetChInfoReq_T* pReqGetChInfo,
+							 GetChInfoRes_T* pResGetChInfo,
+							 int timeout);
+
+LIBIPMI_API uint16_t	IPMICMD_GetSystemGUID( IPMI20_SESSION_T *pSession,
+                                            GetSysGUIDRes_T *pGetSystemGUID,
+                                            int timeout );
+LIBIPMI_API uint16_t IPMICMD_SendMessage(IPMI20_SESSION_T *pSession,uint8_t *pSendMsgReq,
+                                                          uint8_t *pSendMsgRes,uint32_t SendMsgReqLen,int timeout);
+
+/*---------- LIBIPMI Higher level routines -----------*/
+
+/* User Management functions */
+LIBIPMI_API uint16_t LIBIPMI_HL_SetUser( IPMI20_SESSION_T *pSession/*in*/, char *pszUsername/*in*/,
+										uint8_t byID/*in*/, int timeout/*in*/);
+LIBIPMI_API uint16_t LIBIPMI_HL_GetUser( IPMI20_SESSION_T *pSession/*in*/, char *pszUsername/*out*/,
+										uint8_t byID/*in*/, int timeout/*in*/);
+
+LIBIPMI_API uint16_t LIBIPMI_HL_AddUser(IPMI20_SESSION_T *pSession/*in*/,uint8_t UserID/*in*/,
+                                    char* UserName/*in*/,   char* ClearPswd/*in*/,
+                                    uint8_t NetworkPriv/*in*/,uint8_t SerialPriv/*in*/,
+                                    int timeout);
+uint16_t LIBIPMI_HL_ModUser(IPMI20_SESSION_T *pSession,
+					uint8_t UserID,uint8_t IsPwdChange,
+					char* UserName,char* ClearPswd,
+					uint8_t NetworkPriv,uint8_t SerialPriv,uint8_t EnableUser,
+					uint8_t ModifyUserName, uint8_t EnableSOL,
+					int timeout);
+LIBIPMI_API uint16_t LIBIPMI_HL_DelUser(IPMI20_SESSION_T *pSession/*in*/,uint8_t UserID/*in*/,
+                                    int timeout);
+LIBIPMI_API uint16_t LIBIPMI_HL_GetMaxNumUsers(IPMI20_SESSION_T* pSession/*in*/,
+                                    uint8_t *nNumUsers/*in*/, int timeout);
+uint16_t LIBIPMI_HL_GetAllUserInfo(IPMI20_SESSION_T *pSession,
+							uint8_t* nNumUsers,
+							GetUserNameRes_T* pResGetUserName,
+							GetUserAccessRes_T* pResGetUserAccess_Network,
+							GetUserAccessRes_T* pResGetUserAccess_Serial,
+                            GetUsrPayldAccRes_T* pResGetUserAccessPayload_SOL,
+							int timeout);
+uint16_t LIBIPMI_HL_GetOneUserInfo(IPMI20_SESSION_T *pSession,
+                            int UserID,
+                            GetUserNameRes_T* pResGetUserName,
+							GetUserAccessRes_T* pResGetUserAccess_Network,
+							GetUserAccessRes_T* pResGetUserAccess_Serial,
+                            GetUsrPayldAccRes_T* pResGetUserAccessPayload_SOL,
+							int timeout);
+
+uint16_t LIBIPMI_HL_GetSessionInfoCurrent( IPMI20_SESSION_T *pSession, GetSesInfoRes_T* SesInfoRes, int timeout );
+uint16_t LIBIPMI_HL_GetChannelAccess(IPMI20_SESSION_T* pSession,uint8_t ChannelMedium,GetChAccessRes_T* pChAccessRes, int timeout);
+uint16_t LIBIPMI_HL_SetChannelAccessPrivilege(IPMI20_SESSION_T* pSession,
+                                   uint8_t ChannelMedium,uint8_t Privilege,
+                                      SetChAccessRes_T* pChAccessRes, int timeout);
+
+LIBIPMI_API uint16_t LIBIPMI_HL_GetSystemGUID( IPMI20_SESSION_T *pSession, char *pszSystemGUID, int timeout );
+
+LIBIPMI_API uint16_t LIBIPMI_HL_GetUserPrivilege(IPMI20_SESSION_T *pSession, uint8_t UserID, uint32_t *Privilege, int timeout);
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif
+
+

+ 161 - 0
app/goahead-5.1.0/src/libipmi/inc/libipmi_ChassisDevice.h

@@ -0,0 +1,161 @@
+/* @(#)libipmi_ChassisDevice.h
+ */
+
+#ifndef _LIBIPMI_CHASSISDEVICE_H
+#define _LIBIPMI_CHASSISDEVICE_H 1
+
+
+/* LIIPMI core header files */
+#include "libipmi_session.h"
+#include "libipmi_errorcodes.h"
+#include "libipmiifc.h"
+
+/* command specific header files */
+#include "IPMI_ChassisDevice.h"
+#include "IPMI_Chassis.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+
+
+
+/*---------- LIBIPMI Higher level routines -----------*/
+
+
+#define CHASSIS_POWEROFF	 0x00
+#define CHASSIS_POWERUP		 0x01
+#define CHASSIS_POWERCYCLE	 0x02
+#define CHASSIS_HARDRESET	 0x03
+#define CHASSIS_DIAGINT          0x04
+#define CHASSIS_SOFTOFF	         0x05
+
+
+
+
+
+/**
+   \breif	Higher level function for PowerOff Host.
+   @param	pSession		[in]Session handle
+   @param	timeout			[in]timeout value in seconds.
+
+   @retval Returns LIBIPMI_STATUS_SUCCESS on success and error codes on failure
+*/
+LIBIPMI_API uint16_t LIBIPMI_HL_PowerOff( IPMI20_SESSION_T *pSession/*in*/, int timeout/*in*/);
+
+
+
+/**
+   \breif	Higher level function for PowerUP Host
+   @param	pSession		[in]Session handle
+   @param	timeout			[in]timeout value in seconds.
+
+   @retval Returns LIBIPMI_STATUS_SUCCESS on success and error codes on failure
+*/
+LIBIPMI_API uint16_t LIBIPMI_HL_PowerUp( IPMI20_SESSION_T *pSession/*in*/, int timeout/*in*/);
+
+
+
+/**
+   \breif	Higher level function for PowerCycle host.
+   @param	pSession		[in]Session handle
+   @param	timeout			[in]timeout value in seconds.
+
+   @retval Returns LIBIPMI_STATUS_SUCCESS on success and error codes on failure
+*/
+LIBIPMI_API uint16_t LIBIPMI_HL_PowerCycle( IPMI20_SESSION_T *pSession, int timeout );
+
+
+
+/**
+   \breif	Higher level function for HardReset
+   @param	pSession		[in]Session handle
+   @param	timeout			[in]timeout value in seconds.
+
+   @retval Returns LIBIPMI_STATUS_SUCCESS on success and error codes on failure
+*/
+LIBIPMI_API uint16_t LIBIPMI_HL_HardReset( IPMI20_SESSION_T *pSession, int timeout );
+    
+
+/**
+   \breif	Higher level function for DiagInt
+   @param	pSession		[in]Session handle
+   @param	timeout			[in]timeout value in seconds.
+
+   @retval Returns LIBIPMI_STATUS_SUCCESS on success and error codes on failure
+*/
+LIBIPMI_API uint16_t LIBIPMI_HL_DiagInt( IPMI20_SESSION_T *pSession, int timeout );
+    
+
+/**
+   \breif	Higher level function for SoftOff
+   @param	pSession		[in]Session handle
+   @param	timeout			[in]timeout value in seconds.
+
+   @retval Returns LIBIPMI_STATUS_SUCCESS on success and error codes on failure
+*/
+LIBIPMI_API uint16_t LIBIPMI_HL_SoftOff( IPMI20_SESSION_T *pSession, int timeout );
+    
+
+
+typedef enum tag_CHASSIS_ID_STATE
+{
+	CHASSIS_ID_OFF=0,
+	CHASSIS_ID_TIMED_ON=1,
+	CHASSIS_ID_INDEFINITE_ON=2
+} CHASSIS_ID_STATE;
+
+typedef struct tag_chassis_status_T
+{
+	unsigned char power_state;
+	unsigned char last_power_event;
+	unsigned char chassis_indetify_supported;
+	CHASSIS_ID_STATE chassis_identify_state;
+} chassis_status_T;
+
+/** 
+ * 
+ * 
+ *  @param	pSession		[in]Session handle
+ *  @param	timeout			[in]timeout value in seconds.
+ *  @param      status			[out]status of the host is returned.
+ * 
+ * @return  Returns LIBIPMI_STATUS_SUCCESS on success and error codes on failure
+ */
+LIBIPMI_API uint16_t	LIBIPMI_HL_GetChassisStatus( IPMI20_SESSION_T *pSession, int timeout,  chassis_status_T *status);
+
+/*---------------------Chassis Idnetify defines ---------------------*/
+#define CHASSIS_ID_INTERVAL_TURN_OFF		0
+#define CHASSIS_ID_INTERVAL_SPEC_DEFAULT   	15
+
+typedef enum tag_FORCE_CHASSIS_ID
+{
+	USE_INTERVAL=0,
+	FORCE=1
+} FORCE_CHASSIS_ID;
+
+/** 
+ * 
+ * 
+ *  @param	pSession		[in]Session handle
+ *  @param	timeout			[in]timeout value in seconds.
+ *  @param      BlinkTimeSecs		[in]BlinkTimeInSecs.0 for Turn off (use #defs above)
+ *  @param 	ForceOn			[in] Whether Interval is indefinite (Use enum above)
+ * 
+ * @return  Returns LIBIPMI_STATUS_SUCCESS on success and error codes on failure
+ */
+LIBIPMI_API uint16_t LIBIPMI_HL_ChassisIdentify(IPMI20_SESSION_T *pSession, int timeout,uint8_t BlinkTimeSecs,FORCE_CHASSIS_ID ForceOn);
+
+uint16_t	LIBIPMI_HL_GetSystemBootOptions_BootFlags( IPMI20_SESSION_T *pSession, BootFlags_T* pBootFlags,int timeout);
+uint16_t	LIBIPMI_HL_SetSystemBootOptions_BootFlags( IPMI20_SESSION_T *pSession, BootFlags_T* pBootFlags,int timeout);
+
+    
+
+#ifdef  __cplusplus
+}
+#endif
+
+
+#endif /* _LIBIPMI_CHASSISDEVICE_H */
+

+ 52 - 0
app/goahead-5.1.0/src/libipmi/inc/libipmi_IPM.h

@@ -0,0 +1,52 @@
+/**
+ * @file   libipmi_IPM.h
+ * @author Rajasekhar (rajasekharj@amiindia.co.in)
+ * @date   02-Sep-2004
+ *
+ * @brief  Contains exported IPM API by LIBIPMI for
+ *			communicating with the BMC.Corresponds
+ 			directly to IPM device commands
+ *
+ */
+
+#ifndef __LIBIPMI_IPM_H__
+#define __LIBIPMI_IPM_H__
+
+/* LIIPMI core header files */
+#include "libipmi_session.h"
+#include "libipmi_errorcodes.h"
+
+/* command specific header files */
+#include "com_IPMI_IPM.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+/*---------- IPMI Command direct routines ----------*/
+/* Device ID */
+extern uint16_t	IPMICMD_GetDeviceID( IPMI20_SESSION_T *pSession/*in*/,
+										GetDevIDRes_T *pGetDeviceID/*out*/,
+										int timeout/*in*/);
+/* Device GUID */
+extern uint16_t	IPMICMD_GetDeviceGUID( IPMI20_SESSION_T *pSession/*in*/, 
+                                        GetDevGUIDRes_T *pGetDeviceGUID/*out*/,
+                                        int timeout/*in*/ );
+
+/*---------- LIBIPMI Higher level routines -----------*/
+/* Device ID */
+extern uint16_t LIBIPMI_HL_GetDeviceID( IPMI20_SESSION_T *pSession/*in*/,
+											char *pszDeviceID/*out*/, int timeout/*in*/ );
+
+/* Device GUID */
+extern uint16_t LIBIPMI_HL_GetDeviceGUID( IPMI20_SESSION_T *pSession /*in*/, 
+                                            char *pszDeviceGUID /*out*/, int timeout /*in*/);
+
+#ifdef  __cplusplus
+}
+#endif
+
+
+#endif
+
+

+ 132 - 0
app/goahead-5.1.0/src/libipmi/inc/libipmi_PEF.h

@@ -0,0 +1,132 @@
+#ifndef __LIBIPMI_PEF_H__
+#define __LIBIPMI_PEF_H__
+
+/* LIIPMI core header files */
+#include "libipmi_session.h"
+#include "libipmi_errorcodes.h"
+#include "libipmiifc.h"
+
+/* command specific header files */
+#pragma pack(1)
+#include "IPMI_PEF.h"
+#pragma pack()
+
+#include "IPMI_SensorEvent.h"
+
+
+#define SET_IN_PROGRESS_PARAM 0x00
+#define SET_IN_PROGRESS_MASK   0x03
+#define SET_COMPLETE			0x00
+#define SET_IN_PROGRESS 		0x01
+#define COMMIT_WRITE 			0x02
+
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+/* Get PEF Capabilities Command */
+LIBIPMI_API uint16_t	IPMICMD_GetPEFCapabilities( IPMI20_SESSION_T *pSession,
+							GetPEFCapRes_T *pResGetPEFCap,
+							int timeout);
+
+/* Arm PEF Postpone Timer Command */
+LIBIPMI_API uint16_t	IPMICMD_ArmPEFTimer( IPMI20_SESSION_T *pSession/*in*/,
+							uint8_t*	pReqTmrTimeout/*in*/,
+							ArmPEFTmrRes_T *pResArmPEFTmr/*out*/,
+							int timeout/*in*/);
+
+/* Set PEF Configuration Parameters Command */
+LIBIPMI_API uint16_t	IPMICMD_SetPEFConf( IPMI20_SESSION_T *pSession/*in*/,
+							uint8_t *pReqSetPEFConf/*in*/,
+							uint32_t dwReqBufLen,
+							uint8_t *pResSetPEFConf/*out*/,
+							int timeout/*in*/);
+
+/* Get PEF Configuration Parameters Command */
+LIBIPMI_API uint16_t	IPMICMD_GetPEFConf( IPMI20_SESSION_T *pSession/*in*/,
+							GetPEFConfigReq_T *pReqGetPEFConf/*in*/,
+							uint8_t *pResGetPEFConf/*out*/,
+							int timeout/*in*/);
+
+/* Set Last Processed Event ID Command */
+LIBIPMI_API uint16_t	IPMICMD_SetLastEventID( IPMI20_SESSION_T *pSession/*in*/,
+							SetLastEvtIDReq_T *pReqSetLastEvt/*in*/,
+							uint8_t *pResSetLastEvt/*out*/,
+							int timeout/*in*/);
+
+/* Get Last Processed Event ID Command */
+LIBIPMI_API uint16_t	IPMICMD_GetLastEventID( IPMI20_SESSION_T *pSession/*in*/,
+							GetLastEvtIDRes_T *pResGetLastEvt/*out*/,
+							int timeout/*in*/);
+
+/* Alert Immediate Command */
+LIBIPMI_API uint16_t	IPMICMD_AlertImmediate( IPMI20_SESSION_T *pSession/*in*/,
+							AlertImmReq_T *pReqAlertImmediate/*in*/,
+							AlertImmRes_T *pResAlertImmediate/*out*/,
+							int timeout/*in*/);
+
+/* PET Acknowledge Command */
+LIBIPMI_API uint16_t	IPMICMD_PETAck( IPMI20_SESSION_T *pSession/*in*/,
+							PETAckReq_T *pReqPETAck /*out*/,
+							uint8_t *pResPETACK /*out*/,
+							int timeout/*in*/);
+
+/*---------- PEF Higher level routines -----------*/
+/*********** Alert Table **********/
+LIBIPMI_API uint16_t LIBIPMI_HL_GetNumOfAlertPolicyEntries(IPMI20_SESSION_T *pSession,
+					uint8_t* pNumOfAlertPolicyEntries,
+					int timeout);
+LIBIPMI_API uint16_t LIBIPMI_HL_GetAnAlertEntry(IPMI20_SESSION_T *pSession,
+					uint8_t AlertEntryNumber,
+					AlertPolicyTblEntry_T* pAlertEntry,
+					int timeout);
+LIBIPMI_API uint16_t LIBIPMI_HL_SetAnAlertEntry(IPMI20_SESSION_T *pSession,
+					uint8_t AlertEntryNumber,
+					AlertPolicyTblEntry_T* pAlertEntry,
+					int timeout);
+
+LIBIPMI_API uint16_t LIBIPMI_HL_GetAlertTable(IPMI20_SESSION_T *pSession,
+					AlertPolicyTblEntry_T* pAlertTable,
+					uint8_t* pNumOfAlertEntries,
+					int timeout);
+
+LIBIPMI_API uint16_t LIBIPMI_HL_SetGraspAlertLevel(IPMI20_SESSION_T *pSession,
+					uint8_t IndexNum,
+					uint8_t AlertLevel, 
+					uint8_t Channel, 
+					int timeout);
+
+
+LIBIPMI_API uint16_t LIBIPMI_HL_GetGraspAlertLevel(IPMI20_SESSION_T *pSession,
+					uint8_t IndexNum,
+					uint8_t* AlertLevel, 
+					uint8_t* DestIndex,
+					int timeout);
+/*********** PEF Table ********/
+LIBIPMI_API uint16_t LIBIPMI_HL_GetPEFTable(IPMI20_SESSION_T *pSession,
+					EvtFilterTblEntry_T* pPEFTable,
+					uint8_t* pNumOfPEFEntries,
+					int timeout);
+LIBIPMI_API uint16_t LIBIPMI_HL_GetPEFEntry(IPMI20_SESSION_T *pSession,
+					uint8_t PEFEntryNumber,
+					EvtFilterTblEntry_T* pPEFEntry,
+					int timeout);
+LIBIPMI_API uint16_t LIBIPMI_HL_SetPEFEntry(IPMI20_SESSION_T *pSession,
+					uint8_t PEFEntryNumber,
+					EvtFilterTblEntry_T* pPEFEntry,
+					int timeout);
+LIBIPMI_API uint16_t LIBIPMI_HL_GetNumOfPEFEntries(IPMI20_SESSION_T *pSession,
+					uint8_t* pNumOfPEFEntries,
+					int timeout);
+
+#ifdef  __cplusplus
+}
+#endif
+
+
+#endif
+
+
+
+

+ 173 - 0
app/goahead-5.1.0/src/libipmi/inc/libipmi_StorDevice.h

@@ -0,0 +1,173 @@
+/**
+ * @file   libipmi_StorDevice.h
+ * @author Anurag Bhatia
+ * @date   15-Sep-2004
+ *
+ * @brief  Contains exported APIs by LIBIPMI for
+ *  		communicating with the BMC for NetFn type Storage.
+ *
+ */
+
+#ifndef __LIBIPMI_STORDEVICE_H__
+#define __LIBIPMI_STORDEVICE_H__
+
+/* LIIPMI core header files */
+#include "libipmi_session.h"
+#include "libipmi_errorcodes.h"
+#include "libipmiifc.h"
+
+/* command specific header files */
+#include "IPMI_SEL.h"
+#include "IPMI_FRU.h"
+#include "IPMI_IPMB.h"
+#include "IPMI_Storage.h"
+//#include "IPMIConf.h"
+#include "SELRecord.h"
+
+#include "libipmi_sdr.h"
+#include "std_macros.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+/*****************************************************************************
+	System Event Log
+******************************************************************************/
+LIBIPMI_API uint16_t IPMICMD_GetSELInfo(IPMI20_SESSION_T *pSession,
+					SELInfo_T *pResGetSELInfo,
+					int timeout);
+LIBIPMI_API uint16_t IPMICMD_GetSELAllocationInfo(IPMI20_SESSION_T *pSession,
+					SELAllocInfo_T *pResGetSELAllocInfo,
+					int timeout);
+LIBIPMI_API uint16_t IPMICMD_ReserveSEL(IPMI20_SESSION_T *pSession,
+					ReserveSELRes_T* pReserveSelRes,
+					int timeout);
+LIBIPMI_API uint16_t IPMICMD_GetSELEntry(IPMI20_SESSION_T *pSession,
+					GetSELReq_T* pGetSELReqData,
+					uint8_t* pGetSELResData,
+					uint32_t ResDataLen,
+					int timeout);
+LIBIPMI_API uint16_t IPMICMD_AddSELEntry(IPMI20_SESSION_T *pSession,
+					SELEventRecord_T* pSELReqData,
+					AddSELRes_T* pSELResData,
+					int timeout);
+LIBIPMI_API uint16_t IPMICMD_DeleteSELEntry(IPMI20_SESSION_T *pSession,
+					uint16_t RecordID,
+					int timeout);
+
+/*---------- LIBIPMI Higher level routines -----------*/
+LIBIPMI_API uint16_t LIBIPMI_HL_GetNumOfSELEntries(IPMI20_SESSION_T *pSession,
+					uint16_t* nNumOfSELEntries,
+					int timeout);
+LIBIPMI_API uint16_t LIBIPMI_HL_GetMaxPossibleSELEntries(IPMI20_SESSION_T *pSession,
+					uint16_t* nMaxPossibleSELEntries,
+					int timeout);
+LIBIPMI_API uint16_t LIBIPMI_HL_GetAllSELEntries(IPMI20_SESSION_T *pSession,
+					SELEventRecord_T *pSELEntriesBuffer,
+					int timeout);
+
+LIBIPMI_API uint16_t LIBIPMI_HL_GetAllSensorInfo(IPMI20_SESSION_T *pSession,
+					uint8_t **SDRBuff,
+					int *SDRCount,
+					int *MaxSDRLen,
+					int timeout);
+LIBIPMI_API uint16_t LIBIPMI_HL_GetSensorName(IPMI20_SESSION_T *pSession,
+					uint8_t SlaveAdd,
+					uint8_t LUNid,
+					uint8_t SensorNum,
+					uint8_t *SensorName,
+					int timeout);
+uint16_t LIBIPMI_HL_GetAllFRUDevice(IPMI20_SESSION_T *pSession,
+					uint8_t *pFRUIDs,
+					uint8_t *nFRUs,
+					uint8_t nFRUsName[][16],
+					int timeout);
+
+/*****************************************************************************
+	Field Replacement Unit (FRU)
+******************************************************************************/
+
+#pragma pack(1)
+/*this is a structure used by an abstraction function
+for getallselentries
+we want all sel entires but we also want sensor names*/
+typedef struct _SELEventRecordWithSensorName
+{
+	SELRec_T EventRecord;
+	uint8_t SensorName[65]; //65 is the max possible because SensorName len in SDR is indicated by 6 bits
+} PACKED
+SELEventRecordWithSensorName_T;
+
+#ifndef MAX_FRU_DEVICES
+#define MAX_FRU_DEVICES	32
+#endif
+
+#pragma pack(1)
+typedef struct _SDRHeader
+{
+    /** The ID of this SDR, LSB first */
+    uint8_t RecordID[ 2 ];
+    /** Version of this SDR (Not always the same as the IPMI version!) */
+    uint8_t SDRVersion;
+    /** The type of this SDR, usually \ref SDR_FULL or \ref SDR_COMPACT */
+    uint8_t RecordType;
+    /** The length of the SDR that follows this header */
+    uint8_t RecordLength;
+}PACKED  SDRHeader;
+
+#pragma pack()
+
+uint8_t libipmi_GetBits(uint8_t orig, uint8_t startbit, uint8_t endbit);
+
+//Having this for backward compatibility. Projects still using GetBits
+//Will remove this macro when all projects stop using it
+#define GetBits libipmi_GetBits
+
+LIBIPMI_API uint16_t IPMICMD_GetFRUInventoryAreaInfo(IPMI20_SESSION_T *pSession,
+				FRUInventoryAreaInfoReq_T *pReqFRUInventoryAreaInfo,
+				FRUInventoryAreaInfoRes_T *pResFRUInventoryAreaInfo,
+				int timeout);
+
+LIBIPMI_API uint16_t IPMICMD_ReadFRUData(IPMI20_SESSION_T *pSession,
+				FRUReadReq_T* pFRUReadReqData,
+				FRUReadRes_T* pFRUReadResData,
+				int timeout);
+
+LIBIPMI_API uint16_t IPMICMD_WriteFRUData(IPMI20_SESSION_T *pSession,
+				FRUWriteReq_T* pFRUWriteReqData,
+				uint32_t ReqDataLen /* Bytes to be written + sizeof(FRUWriteReq_T) */,
+				FRUWriteRes_T* pFRUWriteResData,
+				int timeout);
+
+LIBIPMI_API uint16_t LIBIPMI_HL_GetAllFRUDevices(IPMI20_SESSION_T *pSession,
+				uint8_t *pFRUIDs,
+				uint8_t *pFRUNames,
+				uint8_t *nFRUs,
+				int timeout);
+
+LIBIPMI_API uint16_t LIBIPMI_HL_GetAllSelEntriesWithSensorNames(IPMI20_SESSION_T *pSession,
+	SELEventRecordWithSensorName_T *pSELEntriesBuffer,
+	int timeout);
+
+LIBIPMI_API uint16_t IPMICMD_ClearSEL(IPMI20_SESSION_T *pSession,
+				int timeout);
+
+LIBIPMI_API uint8_t IPMICMD_GetSELTime(IPMI20_SESSION_T *pSession,
+				GetSELTimeRes_T *pGetSELTimeRes, int timeout);
+
+LIBIPMI_API uint8_t IPMICMD_SetSELTime(IPMI20_SESSION_T *pSession,
+				SetSELTimeReq_T *pSetSELTimeReq, int timeout);
+
+LIBIPMI_API uint8_t IPMICMD_GetSELTimeUTCOffset(IPMI20_SESSION_T *pSession,
+				GetSELTimeUTCOffsetRes_T *pGetSELTimeUTCOffsetRes, int timeout);
+
+LIBIPMI_API uint8_t IPMICMD_SetSELTimeUTCOffset(IPMI20_SESSION_T *pSession,
+				SetSELTimeUTCOffsetReq_T *pSetSELTimeUTCOffsetReq, int timeout);
+
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif

+ 474 - 0
app/goahead-5.1.0/src/libipmi/inc/libipmi_XportDevice.h

@@ -0,0 +1,474 @@
+/**
+ * @file   libipmi_XportDevice.h
+ * @author Anurag Bhatia
+ * @date   21-Sep-2004
+ *
+ * @brief  Contains exported APIs by LIBIPMI for
+ *  		communicating with the BMC for NetFn type Transport.
+ *
+ */
+
+#ifndef __LIBIPMI_XPORTDEVICE_H__
+#define __LIBIPMI_XPORTDEVICE_H__
+
+/* LIIPMI core header files */
+#include "libipmi_session.h"
+#include "libipmi_errorcodes.h"
+#include "libipmiifc.h"
+
+/* command specific header files */
+#include "IPMIDefs.h"
+#include "IPMI_DeviceConfig.h"
+#include "IPMI_LANConfig.h" // For LAN configuration parameters union definition
+
+
+#include "IPMI_SOLConfig.h"
+#include "IPMI_SerialModem.h"
+
+
+/* Handling for packing structs */
+#ifdef __GNUC__
+#define PACKED __attribute__ ((packed))
+#else
+#define PACKED
+#pragma pack( 1 )
+#endif
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#define CHANNEL_MEDIUM_TYPE_LAN 0x04
+#define MAX_IPV6_ADDRS 16
+
+/* ----------------- Multiple IPv6 Response Structure ----------------- */
+
+typedef struct 
+{
+	unsigned char Address[MAX_IPV6_ADDRS][IP6_ADDR_LEN];
+	unsigned char Prefix[MAX_IPV6_ADDRS];
+	unsigned char Source;
+} GetAllIPv6Address_T;
+	
+/*---------- IPMI Command direct routines ----------*/
+/* LAN related functions */
+LIBIPMI_API uint16_t IPMICMD_GetLANConfig(IPMI20_SESSION_T *pSession,
+				GetLanConfigReq_T* pGetLANConfigReqData,
+				GetLanConfigRes_T* pGetLANConfigResData,
+				int timeout);
+LIBIPMI_API uint16_t IPMICMD_SetLANConfig(IPMI20_SESSION_T *pSession,
+				SetLanConfigReq_T* pSetLANConfigReqData,
+				unsigned int ReqDataLen,
+				SetLanConfigRes_T* pSetLANConfigResData,
+				int timeout);
+
+
+/*---------- LIBIPMI Higher level routines -----------*/
+#define LAN_DEST_TYPE_SNMP 0x0
+#define LAN_DEST_TYPE_OEM1 0x6
+#define LAN_DEST_ADDR_FORMAT_IPV4 0x0
+#define LAN_DEST_ADDR_FORMAT_IPV6 0x1
+#define VLAN_STATUS_BIT 0x8000
+
+uint16_t LIBIPMI_HL_GetNumOfLANInterfaces(IPMI20_SESSION_T *pSession, uint8_t* pLanInfo,
+					uint8_t* pNumOfLANDestEntries, int timeout);
+
+uint16_t LIBIPMI_HL_GetPHYConfig(IPMI20_SESSION_T *pSession, uint8_t Channel,
+               		       PHYConfig_T *PHYConfigRes, int timeout);
+
+uint16_t LIBIPMI_HL_GetPHYConfigTable(IPMI20_SESSION_T *pSession, PHYConfig_T* pPHYConfigTable,
+       				    uint8_t* pNumOfLANInterfaces, int timeout);
+
+uint16_t LIBIPMI_HL_SetPHYConfig(IPMI20_SESSION_T *pSession, uint8_t Channel, uint8_t AutoNegotiation,
+         		       uint16_t Speed, uint8_t Duplex, int timeout);
+
+uint16_t LIBIPMI_HL_GetNCSIMode(IPMI20_SESSION_T *pSession, uint8_t Channel,
+                                                                    uint8_t Index,uint8_t *AutoSelect, int timeout);
+
+uint16_t LIBIPMI_HL_SetNCSIMode(IPMI20_SESSION_T *pSession, uint8_t Channel, uint8_t Index,
+                                                                   uint8_t AutoSelect, int timeout);
+
+uint16_t LIBIPMI_HL_SetNCSISetting(IPMI20_SESSION_T *pSession, uint8_t Channel, uint8_t Index,
+                                                                   uint8_t ChannelID, uint8_t PackageID, int timeout);
+
+uint16_t LIBIPMI_HL_GetNCSISetting(IPMI20_SESSION_T *pSession, uint8_t Channel,
+                                                                    uint8_t Index,uint8_t *ChannelID,uint8_t *PackageID, int timeout);
+
+uint16_t LIBIPMI_HL_GetNCSIConfigNUM(IPMI20_SESSION_T *pSession, uint8_t Channel,
+                                                                            uint8_t *ConfigNum, int timeout);
+
+uint16_t LIBIPMI_HL_GetNumOfLANDestinationEntries(IPMI20_SESSION_T *pSession,
+					uint8_t* pNumOfLANDestEntries,
+					uint8_t Channel,
+					int timeout);
+
+uint16_t LIBIPMI_HL_GetLANDestinationType(IPMI20_SESSION_T *pSession,
+					uint8_t Channel,
+					uint8_t  index,
+					LANDestType_T *LANDestTypeRes,
+					int timeout);
+
+uint16_t LIBIPMI_HL_GetLANDestinationAddress(IPMI20_SESSION_T *pSession,
+					uint8_t Channel,
+					uint8_t  index,
+					LANDestAddr_T *LANDestAddrRes,
+					int timeout);
+
+uint16_t LIBIPMI_HL_GetLANDestinationV6Address(IPMI20_SESSION_T *pSession,
+					uint8_t Channel,
+					uint8_t  index,
+					LANDestv6Addr_T *LANDestv6AddrRes,
+					int timeout);
+
+uint16_t LIBIPMI_HL_GetLANDestinationType_AddrTable(IPMI20_SESSION_T *pSession,
+					LANDestType_T* pDestTypeTable,
+					LANDestAddr_T* pDestAddrTable,
+					uint8_t* pNumOfLANDestEntries,
+					uint8_t Channel,
+					int timeout);
+
+uint16_t LIBIPMI_HL_SetLANDestinationType(IPMI20_SESSION_T *pSession,
+					uint8_t Channel,
+					uint8_t  index,
+					uint8_t desttype,
+					int timeout);
+
+uint16_t LIBIPMI_HL_SetLANDestinationAddress(IPMI20_SESSION_T *pSession,
+					uint8_t Channel,
+					uint8_t  index,
+					uint8_t addrFormat,
+					uint8_t* destAddr,
+					int timeout);
+
+uint16_t LIBIPMI_HL_SetLANDestinationV6Address(IPMI20_SESSION_T *pSession,
+					uint8_t Channel,
+					uint8_t  index,
+					uint8_t addrFormat,
+					uint8_t* destAddr,
+					int timeout);
+
+uint16_t LIBIPMI_HL_SetLANAlertEntry(IPMI20_SESSION_T *pSession,
+					uint8_t DestSel,
+					uint8_t* pDestAddr,uint8_t channel,
+					int timeout);
+
+uint16_t LIBIPMI_HL_SetLANAlertEntry_IPv6(IPMI20_SESSION_T *pSession,
+					uint8_t DestSel,
+					uint8_t* pDestAddr,uint8_t channel,
+					int timeout);
+
+uint16_t LIBIPMI_HL_EnableVlan (IPMI20_SESSION_T *pSession, 
+		            uint8_t VlanStatus, uint16_t vlanID, uint8_t Priority, uint8_t Channel, int timeout);
+
+uint16_t LIBIPMI_HL_GetVlanStatus (IPMI20_SESSION_T *pSession, 
+		            uint8_t *VlanStatus, uint16_t *vlanID, uint8_t *Priority, uint8_t Channel, int timeout);
+
+LIBIPMI_API uint16_t IPMICMD_SetLANAlertEntryType(IPMI20_SESSION_T *pSession,
+					uint8_t DestSel,
+					uint8_t AlertType,uint8_t Channel,
+					int timeout);
+
+uint16_t LIBIPMI_HL_GetLANEnable(IPMI20_SESSION_T *pSession,
+									uint8_t EthIndex, uint8_t *LANEnable, int timeout);
+
+uint16_t LIBIPMI_HL_SetLANEnable(IPMI20_SESSION_T *pSession,
+									uint8_t EthIndex, uint8_t LANEnable, int timeout);
+
+uint16_t LIBIPMI_HL_GetBondEnable(IPMI20_SESSION_T *pSession,
+                                                           uint8_t Index,uint8_t * BondCfg,int timeout);
+
+uint16_t LIBIPMI_HL_SetBondEnable(IPMI20_SESSION_T * pSession, 
+                                                           uint8_t * BondCfg, int timeout);
+
+uint16_t LIBIPMI_HL_SetActiveSlave(IPMI20_SESSION_T * pSession,uint8_t Index,
+                                                               uint8_t ActiveSlave, int timeout);
+
+uint16_t LIBIPMI_HL_GetActiveSlave(IPMI20_SESSION_T * pSession, 
+                                                                    uint8_t Index, uint8_t * Activeslave, int timeout);
+
+uint16_t LIBIPMI_HL_IsBondEnabled(IPMI20_SESSION_T * pSession, 
+                                                                    uint8_t * BondEnabled, int timeout);
+
+uint16_t LIBIPMI_HL_BondVLANEnabled(IPMI20_SESSION_T * pSession, 
+                                                                    uint8_t * BondVLANEnabled, int timeout);
+
+uint16_t LIBIPMI_HL_GetLANCount(IPMI20_SESSION_T * pSession, 
+                                                         uint8_t* LANCount,uint8_t * LANIndex, int timeout);
+
+uint16_t LIBIPMI_HL_GetChannelNum(IPMI20_SESSION_T * pSession, 
+                                                                    uint8_t Index, uint8_t * Channel, int timeout);
+
+uint16_t LIBIPMI_HL_GetLANIndex(IPMI20_SESSION_T * pSession, 
+                                                                    uint8_t Index, uint8_t * IfcName, int timeout);
+
+uint16_t LIBIPMI_HL_GetSNMPCommunity(IPMI20_SESSION_T *pSession,
+                    uint8_t* pCommunityStr, uint8_t Channel,
+					int timeout);
+
+uint16_t LIBIPMI_HL_SetSNMPCommunity(IPMI20_SESSION_T *pSession,
+                    uint8_t* CommunityStr,uint8_t Channel,
+					int timeout);
+
+uint16_t LIBIPMI_HL_GetMACAddress(IPMI20_SESSION_T *pSession,
+		            uint8_t *MACAddr,uint8_t Channel,
+		            int timeout);
+
+uint16_t LIBIPMI_HL_GetAllIPv6Addresses(IPMI20_SESSION_T *pSession,
+				uint8_t Channel, uint8_t *Address, uint8_t *pIPCount,
+				int timeout);
+
+uint16_t LIBIPMI_HL_SetIPv4Source(IPMI20_SESSION_T *pSession, 
+		            uint8_t Source,uint8_t Channel, 
+		            int timeout);
+
+uint16_t LIBIPMI_HL_GetIPv4Source(IPMI20_SESSION_T *pSession,
+		            uint8_t *Source,uint8_t Channel,
+		            int timeout);
+
+uint16_t LIBIPMI_HL_SetIPv6Source(IPMI20_SESSION_T *pSession,
+		            uint8_t Source,uint8_t Channel, 
+		            int timeout);
+
+uint16_t LIBIPMI_HL_GetIPv6Source(IPMI20_SESSION_T *pSession, 
+		            uint8_t *Source,uint8_t Channel, 
+		            int timeout);
+
+uint16_t LIBIPMI_HL_SetIPv4Address(IPMI20_SESSION_T *pSession, 
+		            uint8_t *Address,uint8_t Channel, 
+		            int timeout);
+
+uint16_t LIBIPMI_HL_GetIPv4Address(IPMI20_SESSION_T *pSession,
+		            uint8_t *Address,uint8_t Channel, 
+		            int timeout);
+
+uint16_t LIBIPMI_HL_SetIPv6Address(IPMI20_SESSION_T *pSession,
+		            uint8_t *Address,uint8_t Channel,
+		            int timeout);
+
+uint16_t LIBIPMI_HL_GetIPv6Address(IPMI20_SESSION_T *pSession,
+		            uint8_t *Address,uint8_t Channel,
+		            int timeout);
+		            
+uint16_t LIBIPMI_HL_GetIPv6LinkAddress(IPMI20_SESSION_T *pSession, 
+		            uint8_t *Address,uint8_t Channel,
+		            int timeout);
+
+uint16_t LIBIPMI_HL_SetIPv4NetMask(IPMI20_SESSION_T *pSession,
+		            uint8_t *Mask,uint8_t Channel,
+		            int timeout);
+
+uint16_t LIBIPMI_HL_GetIPv4NetMask(IPMI20_SESSION_T *pSession, 
+		            uint8_t *Mask,uint8_t Channel,
+		            int timeout);
+
+uint16_t LIBIPMI_HL_SetIPv6Prefix(IPMI20_SESSION_T *pSession,
+		            uint8_t Prefix,uint8_t Channel, 
+		            int timeout);
+
+uint16_t LIBIPMI_HL_GetIPv6Prefix(IPMI20_SESSION_T *pSession,
+		            uint8_t *Prefix,uint8_t Channel,
+		            int timeout);
+
+uint16_t LIBIPMI_HL_GetIPv6LinkPrefix (IPMI20_SESSION_T *pSession, 
+		            uint8_t *Prefix,uint8_t Channel,
+		            int timeout);
+
+uint16_t LIBIPMI_HL_SetIPv4Gateway(IPMI20_SESSION_T *pSession,
+		            uint8_t *Gateway,uint8_t Channel,
+		            int timeout);
+
+uint16_t LIBIPMI_HL_GetIPv4Gateway(IPMI20_SESSION_T *pSession,
+		            uint8_t *Gateway,uint8_t Channel,
+		            int timeout);
+
+uint16_t LIBIPMI_HL_SetIPv6Gateway(IPMI20_SESSION_T *pSession, 
+		            uint8_t *Gateway,uint8_t Channel,
+		            int timeout);
+
+uint16_t LIBIPMI_HL_GetIPv6Gateway(IPMI20_SESSION_T *pSession, 
+		            uint8_t *Gateway,uint8_t Channel, 
+		            int timeout);
+
+uint16_t LIBIPMI_HL_SetIPv6Enable(IPMI20_SESSION_T *pSession, 
+		            uint8_t Enable,uint8_t Channel, 
+		            int timeout);
+
+uint16_t LIBIPMI_HL_GetIPv6Enable(IPMI20_SESSION_T *pSession,
+		            uint8_t *Enable,uint8_t Channel, 
+		            int timeout);
+
+uint16_t LIBIPMI_HL_GetIPv4NetworkCfg(IPMI20_SESSION_T *pSession, 
+					uint8_t *Source,
+					uint8_t *Address,
+					uint8_t *Mask,
+					uint8_t *Gateway,
+					uint8_t Channel,
+					int timeout);
+
+uint16_t LIBIPMI_HL_SetIPv4NetworkCfg(IPMI20_SESSION_T *pSession,
+                                        uint8_t *Address,
+                                        uint8_t *Mask,
+                                        uint8_t *Gateway,
+                                        uint8_t Channel,
+                                        int timeout);
+
+uint16_t LIBIPMI_HL_GetIPv6NetworkCfg(IPMI20_SESSION_T *pSession, 
+					uint8_t *Source,
+					uint8_t *Address,
+					uint8_t *Prefix,
+					uint8_t *Gateway,
+					uint8_t Channel,
+					int timeout);
+
+uint16_t LIBIPMI_HL_SetIPv6NetworkCfg(IPMI20_SESSION_T *pSession,
+                                        uint8_t *Address,
+                                        uint8_t Prefix,
+                                        uint8_t *Gateway,
+                                        uint8_t Channel,
+                                        int timeout);
+
+/********************SERIAL PORT RELATED************************************/
+
+
+#define SOL_SERIAL_PORT 0x01
+#define SERIAL_MODEM_PORT 0x02
+#define DEFAULT_TIMEOUT 2
+#pragma pack(1)
+typedef struct
+{
+    GetSOLConfigRes_T Res;
+    uint8_t   BaudRate;
+
+}  Wrapper_GetSOLConfigRes_T;
+
+
+
+typedef struct
+{
+    SetSOLConfigReq_T Req;
+    uint8_t   BaudRate;
+
+}  Wrapper_SetSOLConfigReq_T;
+
+typedef struct
+{
+
+    struct
+        {
+        uint8_t   Reserved    : 4;
+        uint8_t	DtrHangup   : 1;
+        uint8_t	FlowControl : 2;
+        
+	
+    } PACKED Control;
+
+    struct 
+    {
+        uint8_t BitRate	    : 4;
+        uint8_t Reserved	    : 4;
+	
+
+    }  PACKED BaudRate;
+
+} PACKED Serial_Port_Settings_T;
+
+
+
+
+typedef enum
+{
+    None_Parity,
+    Odd_Parity,
+    Even_Parity
+} PARITY_TYPE;
+
+typedef enum
+{
+    None_FlowControl,
+    XonXoff_FlowControl,
+    Hardware_FlowControl
+} FLOW_CONTROL_TYPE;
+
+
+typedef struct
+{
+    unsigned long BaudRate;
+    unsigned char  DataBits;
+    PARITY_TYPE Parity;
+    unsigned char StopBits;
+    FLOW_CONTROL_TYPE FlowControl;
+    unsigned char DtrHangup;
+    
+
+} PACKED SERIAL_STRUCT;
+
+typedef struct
+{
+    GetSerialModemConfigRes_T Res;
+    Serial_Port_Settings_T serial;
+
+}  PACKED Wrapper_GetSerialModemConfigRes_T;
+
+
+typedef struct
+{
+    SetSerialModemConfigReq_T Req;
+    Serial_Port_Settings_T serial;
+
+}  Wrapper_SetSerialModemConfigReq_T;
+
+#pragma pack()
+
+/*---------- LIBIPMI Higher level routines -----------*/
+
+uint16_t IPMICMD_GetSerialCfg_SOL_Advanced( IPMI20_SESSION_T *pSession, uint8_t* char_acc_interval,uint8_t* char_send_threshold,int timeout );
+uint16_t IPMICMD_SetSerialCfg_SOL_Advanced( IPMI20_SESSION_T *pSession, uint8_t char_acc_interval,uint8_t char_send_threshold,int timeout );
+
+uint16_t LIBIPMI_HL_GetSerialCfg_Messaging(IPMI20_SESSION_T *pSession, \
+					 SERIAL_STRUCT *serial, int timeout );
+
+uint16_t LIBIPMI_HL_SetSerialCfg_Messaging(IPMI20_SESSION_T *pSession,  \
+					 SERIAL_STRUCT *serial, int timeout);
+
+uint16_t LIBIPMI_HL_GetSerialCfg_SOL(IPMI20_SESSION_T *pSession, \
+					 SERIAL_STRUCT *serial, uint8_t* Enabled,int timeout );
+
+uint16_t LIBIPMI_HL_SetSerialCfg_SOL(IPMI20_SESSION_T *pSession, \
+                                   SERIAL_STRUCT *serial, uint8_t Enabled,int timeout);
+
+
+/** 
+ * \breif Sets the Serial Port configurations of the serial ports, SOL, Modem/Serial 
+ * 
+ * @param pSession 
+ * @param type SOL or Modem/Serial
+ * @param serial 
+ * @param timeout 
+ * 
+ * @return -1 on error 0 on success.
+ */
+uint16_t	LIBIPMI_HL_Generic_SetSerialConfig( IPMI20_SESSION_T *pSession, int type, \
+						    SERIAL_STRUCT *serial, int timeout );
+
+/** 
+ * \brief Gets the Serial Port Configuration from the BMC.
+ * 
+ * @param pSession 
+ * @param type SOL or Modem/Serial
+ * @param serial 
+ * @param timeout 
+ * 
+ * @return 
+ */
+uint16_t	LIBIPMI_HL_Generic_GetSerialConfig( IPMI20_SESSION_T *pSession, int type, \
+					    SERIAL_STRUCT *serial, int timeout );
+
+/********************SERIAL PORT RELATED************************************/
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif
+
+

+ 134 - 0
app/goahead-5.1.0/src/libipmi/inc/libipmi_errorcodes.h

@@ -0,0 +1,134 @@
+/**
+ * @file   libipmi_errorcodes.h
+ * @author Rajasekhar (rajasekharj@amiindia.co.in)
+ * @date   02-Sep-2004
+ *
+ * @brief  Contains the error codes returned by LIBIPMI API
+ *		
+ *			
+ */
+
+#ifndef __LIBIPMI_ERROR_CODES_H__
+#define __LIBIPMI_ERROR_CODES_H__
+
+/* Error code retrieval macros */
+#define MEDIUM_ERROR_FLAG					0
+#define	IPMI_ERROR_FLAG						1
+#define	RMCP_RAKP_ERROR_FLAG				2
+
+/**
+	@def STATUS_CODE(x,y)
+	@brief forms a 2 byte error code. Here x specifies error type and y specifies
+		actual error code.
+*/
+#define STATUS_CODE(x,y)				((uint16_t)( (((uint16_t)(x))<<8) | ((uint16_t)(y)) ))
+
+/**
+	@def IS_MEDIUM_ERROR(x)
+	@brief checks if error type is MEDIUM_ERROR_FLAG
+*/
+#define IS_MEDIUM_ERROR(x)				( ((x)>>8) ==  MEDIUM_ERROR_FLAG )
+
+/**
+	@def IS_IPMI_ERROR(x)
+	@brief checks if error type is IPMI_ERROR_FLAG
+*/
+#define IS_IPMI_ERROR(x)				( ((x)>>8) ==  IPMI_ERROR_FLAG )
+
+/**
+	@def IS_RMCP_RAKP_ERROR(x)
+	@brief checks if error type is IPMI_ERROR_FLAG
+*/
+#define IS_RMCP_RAKP_ERROR(x)				( ((x)>>8) ==  RMCP_RAKP_ERROR_FLAG )
+
+/**
+	@def GET_ERROR_CODE(x)
+	@brief returns the actual 1 byte error code.
+*/
+#define	GET_ERROR_CODE(x)					( ((uint8_t)x & 0xff) )
+/**************************/
+
+/* Error Codes */
+#define LIBIPMI_E_SUCCESS										0x0000
+
+#define LIBIPMI_STATUS_SUCCESS									0x00
+
+/* Medium related errors */
+#define LIBIPMI_MEDIUM_E_CONNECT_FAILURE						0x01
+#define LIBIPMI_MEDIUM_E_SEND_DATA_FAILURE						0x02
+#define LIBIPMI_MEDIUM_E_RECV_DATA_FAILURE						0x03
+#define LIBIPMI_MEDIUM_E_WSA_INIT_FAILURE						0x04
+#define LIBIPMI_MEDIUM_E_INVALID_SOCKET							0x05
+#define LIBIPMI_MEDIUM_E_TIMED_OUT								0x06
+#define LIBIPMI_MEDIUM_E_UNSUPPORTED							0x07
+#define LIBIPMI_MEDIUM_E_OS_UNSUPPORTED							0x08
+#define LIBIPMI_MEDIUM_E_INVALID_PARAMS							0x09
+#define LIBIPMI_MEDIUM_E_INVALID_DATA							0x0A
+#define LIBIPMI_MEDIUM_E_TIMED_OUT_ON_SEND						0x0B
+#define LIBIPMI_MEDIUM_E_RESOLVED_ADDR_FAILURE                  0x0C
+
+/* Session related errors */
+#define LIBIPMI_SESSION_E_EXPIRED								0x10
+#define LIBIPMI_SESSION_E_RECONNECT_FAILURE						0x11
+#define LIBIPMI_SESSION_E_HANDSHAKE_NOT_RECVD					0x12
+
+/* RMCP reated errors*/
+#define LIBIPMI_RMCP_E_INVALID_PACKET							0x20
+#define LIBIPMI_RMCP_E_INVALID_PONG								0x21
+
+#define LIBIPMI_BMC_E_IPMI2_NOT_SUPPORTED						0x30
+
+/* AES Encryption Errors */
+#define LIBIPMI_AES_CBC_E_NO_ENOUGH_MEMORY						0x40
+#define LIBIPMI_ENCRYPTION_UNSUPPORTED							0x41
+
+/* Validation Errors */
+#define	LIBIPMI_E_INVALID_AUTHTYPE								0x50
+#define	LIBIPMI_E_INVALID_SESSIONID								0x51
+#define LIBIPMI_E_PADBYTES_MISMATCH								0x52
+#define LIBIPMI_E_AUTHCODE_MISMATCH								0x53
+#define LIBIPMI_E_CHKSUM_MISMATCH								0x54
+#define	LIBIPMI_E_AUTHTYPE_NOT_SUPPORTED						0x55
+
+/* Session Establishment Errors */
+#define	LIBIPMI_E_INVALID_OPEN_SESSION_RESPONSE					0x60
+#define	LIBIPMI_E_INVALID_RAKP_MESSAGE_2						0x61
+#define LIBIPMI_E_AUTH_ALG_UNSUPPORTED							0x62
+#define LIBIPMI_E_INTEGRITY_ALG_UNSUPPORTED						0x63
+#define LIBIPMI_E_CONFIDENTIALITY_ALG_UNSUPPORTED				0x64
+#define LIBIPMI_E_AUTH_CODE_INVALID								0x65
+#define LIBIPMI_E_INVALID_RAKP_MESSAGE_4						0x66
+#define LIBIPMI_E_INVALID_HMAC_SIK      						0x67
+
+/* Highlevel function errors */
+#define LIBIPMI_E_INVALID_USER_ID								0x70
+#define LIBIPMI_E_INVALID_USER_NAME								0x71
+#define LIBIPMI_E_INVALID_PASSWORD								0x80
+
+#define LIBIPMI_E_INVALID_INDEX 					0x72
+
+/* IPMB errors */
+#define LIBIPMI_E_NO_ENOUGH_MEMORY						0x80
+#define LIBIPMI_E_INVALID_HOST_ADDR						0x81
+#define LIBIPMI_E_I2C_WRITE_FAILURE						0x82
+#define LIBIPMI_E_I2C_READ_FAILURE						0x83
+#define LIBIPMI_E_I2C_BUS_SUSPEND						0x84
+#define LIBIPMI_E_SEQ_NUM_MISMATCH						0x85
+#define LIBIPMI_E_INSUFFICIENT_BUFFER_SIZE					0x86
+#define LIBIPMI_E_IPMB_LOCK_ACCESS_FAILED					0x87
+#define LIBIPMI_E_IPMB_COMM_FAILURE						0x88
+#define LIBIPMI_E_IPMB_UNKNOWN_ERROR						0x89
+#define LIBIPMI_E_IPMB_REQ_BUFF_TOO_BIG						0x8A
+#define LIBIPMI_E_IPMB_RES_BUFF_TOO_BIG						0x8B
+#define LIBIPMI_E_SEL_CLEARED                                              0x85
+#define LIBIPMI_E_SEL_EMPTY                                                  0x86
+#define LIBIPMI_E_SENSOR_INFO_EMPTY                                 0x87
+
+
+/* Last RMCP+/RAKP satus code */
+#define LAST_RMCP_RAKP_STATUS_CODE	(SC_NO_CIPHER_SUITE_MATCH)
+/* Error Codes for FRU*/
+#define FRU_INVALID_HEADER_VERSION						0x8C
+#define FRU_INVALID_AREA								0x8D
+#endif
+

+ 95 - 0
app/goahead-5.1.0/src/libipmi/inc/libipmi_fru.h

@@ -0,0 +1,95 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2007, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************
+ ****************************************************************
+ ****************************************************************
+ *
+ * libipmi_fru.h
+ ******************************************************************/
+
+#ifndef _LIBIPMI_FRU_
+
+#define _LIBIPMI_FRU_
+
+
+#include "libipmi_session.h"
+#include "libipmi_errorcodes.h"
+#include "libipmi_AppDevice.h"
+#include "libipmi_StorDevice.h"
+#include "libipmi_sensor.h"
+#include "libipmi_XportDevice.h"
+#include "IPMI_SDRRecord.h"
+#include "IPMI_FRU.h"
+
+
+typedef struct
+{
+	int present; //! 1 means yes..
+	char MfrName[60];
+	char ProductName[60];
+	char ProductVersion[60];
+	char ProductPartNum[60];
+	char ProductSerialNum[60];
+	char AssetTag[60];
+	char FRUFileID[60];
+
+	//! Custom fileds.......
+
+}ProductInfo;
+
+typedef struct
+{
+	int present; //! 1 means yes..
+	char BoardMfr[60];
+	char Language[60];
+	char BoardProductName[60];
+	char BoardSerialNum[60];
+	char BoardPartNum[60];
+	char FRUFileID[60];
+
+	//! Custom fileds.......
+
+}BoardInfo;
+
+typedef struct
+{
+	int present; //! 1 means yes..
+	uint8_t ChassisType;
+	char ChassisPartNum[60];
+	char ChassisSerialNum[60];
+
+	//! Custom fileds.......
+	char GUID[60]; //! chassis info area offset 36
+}ChassisInfo;
+
+//! FRU Data
+typedef struct fru_t
+{
+	uint8_t fruDeviceID;
+	ProductInfo pInfo;
+	BoardInfo bInfo;
+	ChassisInfo cInfo;
+
+}FRU_T;
+
+
+LIBIPMI_API uint16_t LIBIPMI_HL_GetFRUData(IPMI20_SESSION_T *pSession,
+					u8 fru_device_id,
+				  	u32* p_fru_size,
+				  	FRUData_T* fru_data,
+					int timeout);
+
+void LIBIPMI_HL_FreeFRUData(FRUData_T* fru_data);
+
+
+#endif

+ 131 - 0
app/goahead-5.1.0/src/libipmi/inc/libipmi_rmcp.h

@@ -0,0 +1,131 @@
+/**
+ * @file   libipmi_rmcp.h
+ * @author Rajasekhar (rajasekharj@amiindia.co.in)
+ * @date   02-Sep-2004
+ *
+ * @brief  Contains definition of RMCP layer API
+ *			required by Session layer for communicating with BMC.
+ *			
+ */
+
+#ifndef __LIBIPMI_RMCP_H__
+#define __LIBIPMI_RMCP_H__
+
+//#include "RMCP.h"
+
+#if LIBIPMI_IS_OS_LINUX()
+#define PACK __attribute__ ((packed))
+#else
+#define PACK
+#pragma pack(1)
+#endif/* LIBIPMI_IS_OS_LINUX() */
+
+
+/**
+ * @def RMCPPing_T
+ * @brief RMCP Ping Message
+ */
+/* IPMI2.0 Specification Table 13-6 */
+typedef struct
+{
+	RMCPHdr_T	Hdr;				/*< RMCP Header 		*/
+	uint8		IANANum[4];		/*< 4542 (ASF IANA) 	*/
+	uint8		MsgType;			/*< 80h = Presence Ping */
+	uint8		MsgTag;				/*< 0-FEh, generated by remote console */
+	uint8		Reserved1;			/*< 00h 				*/
+	uint8		DataLen;			/*< 00h					*/
+
+} PACK RMCPPing_T;
+
+/**
+ * @def RMCPPong_T
+ * @brief RMCP Pong Response
+ */
+/* IPMI2.0 Specification Table 13-7 */
+typedef struct
+{
+	RMCPHdr_T	Hdr;				/*< RMCP Header 		*/
+	uint8		IANANum[4];			/*< 4542 (ASF IANA) 	*/
+	uint8		MsgType;			/*< 40h = Presence Ping */
+	uint8		MsgTag;				/*< From Pin Request    */
+	uint8		Reserved1;			/*< 00h 				*/
+	uint8		DataLen;			/*< 10h					*/
+	uint8		OEMIANANum [4];			/*< OEM's IANA Number	*/
+	uint8		OEM [4];			/*< OEM Defined field	*/
+	uint8		Support;			/*< 81h for IPMI		*/
+	uint8		InteractionSupport;	/*< Reserved			*/
+	uint8		Reserved [6];
+
+} PACK RMCPPong_T;
+
+#if defined (PACK)
+#undef PACK
+#endif
+
+#if !LIBIPMI_IS_OS_LINUX()
+#pragma pack()
+#endif/* LIBIPMI_IS_OS_LINUX() */
+
+/**
+\breif	Connects to BMC's RMCP layer.
+ @param	LanInfo			[in]Lan Info handle
+ @param szIPAddress		[in]IP Address of BMC
+ @param	wPort			[in]socke port to be connected.
+
+ @retval Returns LIBIPMI_STATUS_SUCCESS on success and error codes on failure
+*/
+uint8 RMCP_Connect(LAN_CHANNEL_T *LanInfo, char *szIPAddress, uint16 wPort);
+
+/**
+\breif	Closes connection with BMC at RCMP layer
+ @param	LanInfo			[in]Lan Info handle
+
+ @retval Returns LIBIPMI_STATUS_SUCCESS on success and error codes on failure
+*/
+void RMCP_Close(LAN_CHANNEL_T *LanInfo );
+
+/**
+\breif	Fills RMCP Header and sends the data to network layer.
+ @param	LanInfo			[in]Lan Info handle
+ @param	szBuffer		[in]Data to be sent
+ @param	dwSize			[in]Size of the data to be sent.
+ @param	timeout			[in]timeout value in seconds.
+
+ @retval Returns LIBIPMI_STATUS_SUCCESS on success and error codes on failure
+*/
+uint8 RMCP_SendData(LAN_CHANNEL_T *LanInfo, char *szBuffer, uint32 dwSize, int timeout);
+
+/**
+\breif	Receives data from network layer and validates RMCP Header.
+ @param	LanInfo			[in]Lan Info handle
+ @param	szBuffer		[out]Data that will be received
+ @param	dwSize			[out]Size of the data received.
+ @param	timeout			[in]timeout value in seconds.
+
+ @retval Returns LIBIPMI_STATUS_SUCCESS on success and error codes on failure
+*/
+uint8 RMCP_ReceiveData(LAN_CHANNEL_T *LanInfo, char *szBuffer, uint32* pdwSize, int timeout);
+
+/**
+\breif	Sends RMCP Ping message to BMC
+ @param	LanInfo			[in]Lan Info handle
+ @param	timeout			[in]timeout value in seconds.
+
+ @retval Returns LIBIPMI_STATUS_SUCCESS on success and error codes on failure
+*/
+uint8 RMCP_Ping(LAN_CHANNEL_T *LanInfo, int timeout);
+
+/**
+\breif	Receives RMCP Pong message from BMC
+ @param	LanInfo			[in]Lan Info handle
+ @param	timeout			[in]timeout value in seconds.
+
+ @retval Returns LIBIPMI_STATUS_SUCCESS on success and error codes on failure
+*/
+uint8 RMCP_Pong(LAN_CHANNEL_T *LanInfo, int timeout);
+
+#endif
+
+
+
+

+ 150 - 0
app/goahead-5.1.0/src/libipmi/inc/libipmi_sdr.h

@@ -0,0 +1,150 @@
+#ifndef __LIBIPMI_SDR_H__
+#define __LIBIPMI_SDR_H__
+
+/* LIIPMI core header files */
+#include "libipmi_session.h"
+#include "libipmi_errorcodes.h"
+#include "libipmiifc.h"
+
+/* command specific header files */
+#pragma pack(1)
+#include "IPMI_SDR.h"
+#pragma pack()
+
+#include "IPMI_SensorEvent.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+
+
+
+/* Get SDR Repository Info Command */
+LIBIPMI_API uint16_t	IPMICMD_GetSDRRepositoryInfo( IPMI20_SESSION_T *pSession,
+										SDRRepositoryInfo_T *pResGetSDRRepositoryInfo,
+										int timeout);
+
+/* Get SDR Repository Allocation Info Command */
+LIBIPMI_API uint16_t	IPMICMD_GetSDRRepositoryAllocInfo( IPMI20_SESSION_T *pSession,
+										SDRRepositoryAllocInfo_T *pResGetSDRRepositoryAllocInfo,
+										int timeout);
+
+/* Reserve SDR Repository Command */
+LIBIPMI_API uint16_t	IPMICMD_ReserveSDRRepository( IPMI20_SESSION_T *pSession,
+										ReserveSDRRepositoryRes_T *pResReserveSDRRepository,
+										int timeout);
+
+/* Get SDR Command */
+LIBIPMI_API uint16_t	IPMICMD_GetSDR( IPMI20_SESSION_T *pSession,
+									GetSDRReq_T *pReqGetSDR,
+									GetSDRRes_T *pResGetSDR,
+									uint32_t		*pdwOutBuffLen,
+									int timeout);
+
+/* Add SDR Command */
+LIBIPMI_API uint16_t	IPMICMD_AddSDR( IPMI20_SESSION_T *pSession,
+									uint8_t		*pReqAddSDR,
+									uint32_t		dwInBuffLen,
+									AddSDRRes_T *pResAddSDR,
+									int timeout);
+
+/* Partial Add SDR Command */
+LIBIPMI_API uint16_t	IPMICMD_PartialAddSDR( IPMI20_SESSION_T *pSession,
+									PartialAddSDRReq_T *pReqPartialAddSDR,
+									uint32_t		dwInBuffLen,
+									PartialAddSDRRes_T *pResPartialAddSDR,
+									int timeout);
+
+/* Delete SDR Command */
+LIBIPMI_API uint16_t	IPMICMD_DeleteSDR( IPMI20_SESSION_T *pSession,
+									DeleteSDRReq_T *pReqDeleteSDR,
+									DeleteSDRReq_T *pResDeleteSDR,
+									int timeout);
+
+/* Clear SDR Repository Command */
+LIBIPMI_API uint16_t	IPMICMD_ClearSDRRepository( IPMI20_SESSION_T *pSession,
+									ClearSDRReq_T *pReqClearSDR,
+									ClearSDRRes_T *pResClearSDR,
+									int timeout);
+
+/* Get SDR Repository Time Command */
+LIBIPMI_API uint16_t	IPMICMD_GetSDRRepositoryTime( IPMI20_SESSION_T *pSession,
+									GetSDRRepositoryTimeRes_T *pResGetSDRRepositoryTime,
+									int timeout);
+
+/* Set SDR Repository Time Command */
+LIBIPMI_API uint16_t	IPMICMD_SetSDRRepositoryTime( IPMI20_SESSION_T *pSession,
+									SetSDRRepositoryTimeReq_T *pReqSetSDRRepositoryTime,
+									uint8_t *pResSetSDRRepositoryTime,
+									int timeout);
+
+/* Enter SDR Repository Update Mode Command */
+LIBIPMI_API uint16_t	IPMICMD_EnterSDRUpdateMode( IPMI20_SESSION_T *pSession,
+									EnterSDRUpdateModeRes_T *pResEnterSDRUpdateMode,
+									int timeout);
+
+/* Exit SDR Repository Update Mode Command */
+LIBIPMI_API uint16_t	IPMICMD_ExitSDRUpdateMode( IPMI20_SESSION_T *pSession,
+									ExitSDRUpdateModeRes_T *pResExitSDRUpdateMode,
+									int timeout);
+
+/* Run Initialization Agent Command */
+LIBIPMI_API uint16_t	IPMICMD_RunInitAgent( IPMI20_SESSION_T *pSession,
+									RunInitAgentReq_T *pReqRunInitAgent,
+									RunInitAgentRes_T *pResRunInitAgent,
+									int timeout);
+
+/*---------- LIBIPMI Higher level routines -----------*/
+LIBIPMI_API uint16_t LIBIPMI_HL_GetCompleteSDR( IPMI20_SESSION_T *pSession,
+                                              uint16_t record_id,
+                                              uint16_t *next_record_id,
+                                              uint8_t *sdr_buffer,
+                                              size_t buffer_len,
+                                              int timeout );
+
+LIBIPMI_API uint16_t LIBIPMI_HL_GetAllSDRs( IPMI20_SESSION_T *pSession,
+                                          uint8_t *sdr_buffer, size_t buffer_len,
+                                          int timeout );
+
+
+LIBIPMI_API uint16_t LIBIPMI_HL_GetSDR( IPMI20_SESSION_T *pSession,
+                                            uint16_t reservation_id,
+                                            uint16_t record_id,
+                                            GetSDRRes_T *pGetSDRRes,
+                                            uint32_t *dwDataLen,
+                                            int timeout );
+#define SDR_CACHE_PATH "/var/sdrcache"
+
+#define ERR_SDRCACHE_SUCCESS 		0
+#define ERR_SDRCACHE_FILEOP  		1
+#define ERR_SDRCACHE_INVALID_ARGS	2
+#define ERR_SDRCACHE_BUFFSIZE		3
+
+
+LIBIPMI_API uint16_t LIBIPMI_HL_GetAllSDRs_Cached( IPMI20_SESSION_T *pSession,
+                                          uint8_t *sdr_buffer, 
+										  uint32_t* sdr_buff_size,
+										  uint32_t* max_sdr_len,
+										  uint32_t * sdr_count,
+                                          int timeout );
+
+LIBIPMI_API uint16_t LIBIPMI_HL_GetSpecificSDR( IPMI20_SESSION_T *pSession,
+										uint8_t *sdr_buffer, 
+										uint32_t* sdr_buff_size,
+										int SensorNumber,
+										int timeout );
+
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif
+
+
+
+
+
+
+

+ 190 - 0
app/goahead-5.1.0/src/libipmi/inc/libipmi_sensor.h

@@ -0,0 +1,190 @@
+#ifndef __LIBIPMI_SENSOR_DEVICE_H__
+#define __LIBIPMI_SENSOR_DEVICE_H__
+
+/* LIIPMI core header files */
+#include "libipmi_session.h"
+#include "libipmi_errorcodes.h"
+#include "libipmiifc.h"
+#include "libsensor.h"
+
+/* command specific header files */
+#pragma pack(1)
+#include "IPMI_Sensor.h"
+#pragma pack()
+#include "IPMI_SensorEvent.h"
+#include "IPMI_AMI.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+/* 35.2 Get Device SDR Info Command */
+LIBIPMI_API uint16_t IPMICMD_GetSDRInfo( IPMI20_SESSION_T *pSession,
+                                       uint8_t *pReqGetSDRInfo,
+                                       GetSDRInfoRes_T *pResGetSDRInfo,
+                                       int timeout);
+    
+/* 35.3 Get Device SDR Command */
+LIBIPMI_API uint16_t IPMICMD_GetDevSDR( IPMI20_SESSION_T *pSession,
+                                      GetDevSDRReq_T *pReqDevSDR,
+                                      GetDevSDRRes_T *pResDevSDR,
+                                      uint32_t *pOutBuffLen,
+                                      int timeout);
+
+/* 35.4 Reserve Device SDR Repository Command */
+LIBIPMI_API uint16_t IPMICMD_ReserveDevSDR( IPMI20_SESSION_T *pSession,
+                                          ReserveDevSDRRes_T *pResReserveDevSDR,
+                                          int timeout);
+
+/* 35.5 Get Sensor Reading Factors Command */
+LIBIPMI_API uint16_t IPMICMD_GetSensorReadingFactor( IPMI20_SESSION_T *pSession,
+                                                   GetSensorReadingFactorReq_T *pReqGetSensorReadingFactor,
+                                                   GetSensorReadingFactorRes_T *pResGetSensorReadingFactor,
+                                                   int timeout);
+
+/* 35.6 Set Sensor Hysteresis Command */
+LIBIPMI_API uint16_t IPMICMD_SetSensorHysterisis( IPMI20_SESSION_T *pSession,
+                                                SetSensorHysterisisReq_T *pReqSetSensorHysterisis,
+                                                SetSensorHysterisisRes_T *pResSetSensorHysterisis,
+                                                int timeout);
+/* 35.7 Get Sensor Hysteresis Command */
+LIBIPMI_API uint16_t IPMICMD_GetSensorHysterisis( IPMI20_SESSION_T *pSession,
+                                                GetSensorHysterisisReq_T *pReqGetSensorHysterisis,
+                                                GetSensorHysterisisRes_T *pResGetSensorHysterisis,
+                                                int timeout);
+
+/* 35.8 Set Sensor Thresholds Command */
+LIBIPMI_API uint16_t IPMICMD_SetSensorThreshold( IPMI20_SESSION_T *pSession,
+                                               SetSensorThresholdReq_T *pReqSetSensorThreshold,
+                                               SetSensorThresholdRes_T *pResSetSensorThreshold,
+                                               int timeout);
+
+/* 35.9 Get Sensor Thresholds Command */
+LIBIPMI_API uint16_t IPMICMD_GetSensorThreshold( IPMI20_SESSION_T *pSession,
+                                               GetSensorThresholdReq_T *pReqGetSensorThreshold,
+                                               GetSensorThresholdRes_T *pResGetSensorThreshold,
+                                               int timeout);
+
+/* 35.10 Set Sensor Event Enable Command */
+LIBIPMI_API uint16_t IPMICMD_SetSensorEventEnable( IPMI20_SESSION_T *pSession,
+                                                 SetSensorEventEnableReq_T *pReqSetSensorEventEnable,
+                                                 SetSensorEventEnableRes_T *pResSetSensorEventEnable,
+                                                 int timeout);
+
+/* 35.11 Get Sensor Event Enable Command */
+LIBIPMI_API uint16_t IPMICMD_GetSensorEventEnable( IPMI20_SESSION_T *pSession,
+                                                 GetSensorEventEnableReq_T *pReqGetSensorEventEnable,
+                                                 GetSensorEventEnableRes_T *pResGetSensorEventEnable,
+                                                 int timeout);
+
+/* 35.12 ReArm Sensor Events Command */
+LIBIPMI_API uint16_t	IPMICMD_ReArmSensorEvents( IPMI20_SESSION_T *pSession,
+                                                 ReArmSensorReq_T *pReArmSensorReq,
+                                                 ReArmSensorRes_T *pReArmSensorRes,
+                                                 int timeout);
+
+/* 35.13 Get Sensor Event Status Command */
+LIBIPMI_API uint16_t	IPMICMD_GetSensorEventStatus( IPMI20_SESSION_T *pSession,
+                                                 GetSensorEventStatusReq_T *pReqGetSensorEventStatus,
+                                                 GetSensorEventStatusRes_T *pResGetSensorEventStatus,
+                                                 int timeout);
+
+/* 35.14 Get Sensor Reading Command */
+LIBIPMI_API uint16_t IPMICMD_GetSensorReading( IPMI20_SESSION_T *pSession,
+                                             GetSensorReadingReq_T *pReqGetSensorReading,
+                                             GetSensorReadingRes_T *pResGetSensorReading,
+                                             int timeout);
+
+/* 35.15 Set Sensor Type Command */
+LIBIPMI_API uint16_t IPMICMD_SetSensorType( IPMI20_SESSION_T *pSession,
+                                          SetSensorTypeReq_T *pReqSetSensorType,
+                                          SetSensorTypeRes_T *pResSetSensorType,
+                                          int timeout);
+
+/* 35.16 Get Sensor Type Command */
+LIBIPMI_API uint16_t IPMICMD_GetSensorType( IPMI20_SESSION_T *pSession,
+                                          GetSensorTypeReq_T *pReqGetSensorType,
+                                          GetSensorTypeRes_T *pResGetSensorType,
+                                          int timeout);
+LIBIPMI_API uint16_t IPMICMD_SetSensorReading( IPMI20_SESSION_T *pSession,
+                                           SetSensorReadingReq_T *pReqSetSensorReading,
+                                           SetSensorReadingRes_T *pResSetSensorReading,
+                                           int timeout);
+
+
+
+/*------- Structure definitions and defines for HL sensor functions ---------*/
+#pragma pack( 1 )
+struct sensor_info
+{
+    /* SDR Entry */
+    u8 sdr_buffer[ 64 ];      
+
+    /*! Sensor description as a null terminated string */
+    char description[ 17 ]; 
+
+    /*! True if this sensor returns a discrete state */
+    bool discrete_sensor;
+
+    /*! True if this sensor uses analog thresholds */
+    bool thresholds;
+
+    float low_non_recov_thresh;    /*!< Low non-recoverable threshold */
+    float low_crit_thresh;         /*!< Low critical threshold */
+    float low_non_crit_thresh;     /*!< Low non-critical threshold */
+    float high_non_crit_thresh;    /*!< High non-critical threshold */
+    float high_crit_thresh;        /*!< High critical threshold */
+    float high_non_recov_thresh;   /*!< High non-recoverable threshold */
+};
+
+/* IPMI threshold state definitions for monitoring */
+#define THRESH_UNINITIALIZED        ( (u16)0x00 )
+#define THRESH_NORMAL               ( (u16)0x01 )
+#define THRESH_UP_NONCRIT           ( (u16)0x02 )
+#define THRESH_UP_CRITICAL          ( (u16)0x04 )
+#define THRESH_LOW_NONCRIT          ( (u16)0x08 )
+#define THRESH_LOW_CRITICAL         ( (u16)0x10 )
+#define THRESH_ACCESS_FAILED        ( (u16)0x20 )
+#define THRESH_UP_NON_RECOV         ( (u16)0x40 )
+#define THRESH_LOW_NON_RECOV        ( (u16)0x80 )
+
+#define SENSOR_NOT_AVAILABLE        0xD5
+#define UNABLE_TO_READ_SENSOR       0x20
+#define SENSOR_SCANNING_BIT             0x40
+
+#pragma pack()
+
+
+/*------------------------- HL sensor functions -----------------------------*/
+LIBIPMI_API uint16_t
+LIBIPMI_HL_ReadSensorFromSDR( IPMI20_SESSION_T *pSession, uint8_t *sdr_buffer,
+                              uint8_t *raw_reading, float *reading,
+                              uint8_t *discrete, int timeout );
+
+LIBIPMI_API uint16_t
+LIBIPMI_HL_LoadSensorSDRs( IPMI20_SESSION_T *pSession, uint8_t **sdr_buffer, int *count, int timeout );
+
+LIBIPMI_API uint16_t
+LIBIPMI_HL_GetSensorCount( IPMI20_SESSION_T *pSession, int *sdr_count, int timeout );
+
+LIBIPMI_API uint16_t
+LIBIPMI_HL_GetAllSensorReadings( IPMI20_SESSION_T *pSession,
+                                 struct sensor_data *sensor_list, uint32_t* nNumSensor,int timeout );
+
+
+LIBIPMI_API uint16_t 
+LIBIPMI_HL_GetSensorHistoryReadingData( IPMI20_SESSION_T *pSession,            
+                                                 SensorhistoryData_T *pHistoryData, uint8_t nNumSensor, int timeout);
+
+
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif
+
+
+
+
+

+ 141 - 0
app/goahead-5.1.0/src/libipmi/inc/libipmi_session.h

@@ -0,0 +1,141 @@
+/**
+ * @file   libipmi_session.h
+ * @author Rajasekhar (rajasekharj@amiindia.co.in)
+ * @date   02-Sep-2004
+ *
+ * @brief  Contains function definitions & data structures
+ *			required for establishing a session
+ *			
+ */
+
+#ifndef __LIBIPMI_SESSION_H__
+#define __LIBIPMI_SESSION_H__
+
+#include <stdio.h>
+#include "libipmi_struct.h"
+#include "libipmi_errorcodes.h"
+//#include "libipmiifc.h"
+//#include "libipmi_version.h"
+
+
+#define PACK __attribute__ ((packed))
+
+//#include "IPMI_RMCP.h"
+#include "com_IPMIDefs.h"
+//#include "IPMI_App.h"
+//#include "IPMI_AppDevice.h"
+//#include "IPMI_RMCP+.h"
+//#include "IPMI_AMI.h"
+//#include "AES.h"
+//#include "hmac.h"
+//#include "sha1.h"
+//#include <time.h>
+//
+//typedef struct
+//{
+//    uint32_t      Param;                    /* Parameter */
+//    uint8_t       Channel;                  /* Originator's channel number */
+//    uint8_t       SrcQ [64];     /* Originator Queue */
+//    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 */
+//    time_t      ReqTime;                  /* Request Timestamp */
+//    uint16_t       ResTimeOut;              /* response timeout in secs */
+//    uint16_t      SessionType;               /* Session Type */
+//    uint8_t       IPAddr [16];    /* IPv6 Address */
+//    uint16_t      UDPPort;                  /* UDP Port Number  */
+//    uint16_t      Socket;                   /* socket handle    */
+//    uint32_t      Size;                     /* Size of the data */
+//    uint8_t       Data [1024 * 60];  /* Data */
+//} PACKED MsgPkt_T;
+//
+//typedef union
+//{
+//    IPMIMsgHdr_T        IPMIMsgHdr;
+//    IPMIUDSMsg_T        UDSMsgHdr;
+//}PACKED ResMsgHdr_T;
+//#include "BridgeMsgAPI.h"
+
+/* Undefine PACK so that it can be redefined in other header files */
+#if defined (PACK)
+#undef PACK
+#endif
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+extern uint16_t Create_IPMI20_UDS_Session(IPMI20_SESSION_T *pSession, char *pszSocketPath,
+							char *pszUserName, char *pszPassword, uint8_t *byPrivLevel,
+							char *pUserName, uint8_t *ipaddr, int timeout, int AuthFlag, uint8_t ChannelNum);
+
+/**
+This function is used to get the UserID for given Username and Password.
+It compares all IPMI username with the IN argument Username.
+If it matches, then it checks for the password.
+If password also matches, it will return SUCCESS and corresponding User ID.
+Since duplicate username is supported in IPMI specification,
+It will executes unless it gets SUCCESS or reaches MAX_USERS_COUNT.
+Username and Password are IN arguments, UserID is OUT argument.
+**/
+extern int LIBIPMI_GetUserIDForUserName(IPMI20_SESSION_T *pSession, 
+							char *UserName, char *Password, 
+							uint8_t *UserID, uint8_t AuthEnable,int timeout);
+
+
+/**
+\breif	Sends RAW IPMI Command to the BMC
+ @param	pSession			[in]Session Info handle
+ @param	byPayLoadType		[in]Pay Load Type in NETWORK_MEDIUM.
+								shd be 0 in case of serial and kcs mediums.
+ @param	byNetFnLUN			[in] Net Function and LUN for the given byCommand
+ @param byCommand			[in] Command number.
+ @param pszReqData			[in] Command Request Data
+ @param dwReqDataLen		[in] size of Command Request data.
+ @param pszResData			[in] Command Response Data
+ @param	pdwResDataLen		[in] size of Command Response data.
+ @param	timeout				[in]timeout value in seconds.
+
+ @retval Returns LIBIPMI_E_SUCCESS on success and error codes on failure
+*/
+extern uint16_t LIBIPMI_Send_RAW_IPMI2_0_Command(IPMI20_SESSION_T *pSession,
+									uint8_t byNetFnLUN, uint8_t byCommand,
+									uint8_t *pszReqData, uint32_t dwReqDataLen,
+									uint8_t *pszResData, uint32_t *pdwResDataLen,
+									int	timeout);
+
+
+/**
+\breif	Closes the IPMI 2.0 Session
+ @param	pSession			[in]Session Info handle
+
+ @retval Returns LIBIPMI_E_SUCCESS on success and error codes on failure
+*/
+extern uint16_t LIBIPMI_CloseSession( IPMI20_SESSION_T *pSession );
+
+/**
+\breif	returns status whether the session is started or not
+ @param	pSession			[in]Session Info handle
+ 
+ @retval 1 if session is started and 0 if not
+*/
+extern uint8_t	IsSessionStarted(IPMI20_SESSION_T *pSession);
+
+/**
+\brief  Sets the Cmd Retry Count and Interval
+ @param pSession                        [in]Session Info handle
+ @retval Returns LIBIPMI_E_SUCCESS on success and error codes on failure
+ @note This function is not implemented 
+*/
+
+extern uint16_t LIBIPMI_SetRetryCfg( IPMI20_SESSION_T *pSession, 
+										int nCmdRetryCount, 
+										int nCmdRetryInterval);
+
+#ifdef  __cplusplus
+}
+#endif
+
+
+#endif /* __LIBIPMI_SESSION_H__ */

+ 124 - 0
app/goahead-5.1.0/src/libipmi/inc/libipmi_storlead_OEM.h

@@ -0,0 +1,124 @@
+/*
+ * Brief:	Declare some functions.
+ * Author:	Jimbo_zhang@outlook.com
+ * Data:		2019-4-27
+ */
+#ifndef __LIBIPMI_STORLEAD_OEM_H__
+#define __LIBIPMI_STORLEAD_OEM_H__
+
+#include "libipmi_AMIOEM.h"
+
+#define MAX_TITLE_LEN	20
+#define MAX_TEXT_LEN		256
+#define MAX_HISTORY_LEN	480
+#define MAX_BLADE_NUM           32
+#define MAX_FAN_NUM	8
+
+#pragma pack(1)
+
+typedef struct{
+	uint8_t fanNum; 
+} OemFanInfo_T;
+
+typedef struct{
+	uint8_t index;
+	uint8_t name[16];
+	uint8_t mode;
+	uint8_t level;	//duty 0% - 100%
+	uint32_t speed;	//RPM 
+} OemFanStatus_T;
+
+
+typedef struct{
+	char *title;
+	char *text;
+}ExtraInfo_T;
+
+
+typedef struct{
+	uint8_t bladeNum;	//index
+	uint8_t isChmc;	//is main blade
+	uint8_t IPMBAddr;	//physical ID
+	uint8_t status;	//0: not install, 1: normal, 2: error
+	uint8_t reserve;
+} bladeStatus_T;
+
+typedef struct{
+	uint8_t complecode;	
+	bladeStatus_T bdStatus[10];
+} CardStatus_T;
+
+typedef struct{
+	uint8_t slotNum; //total slot numbers of chassis.
+	uint8_t supportChassisManageFn;
+	uint8_t chassisManageFnEnable;
+	uint8_t chMCIndex;
+} OemChassisInfo_T;
+
+typedef struct{
+	uint8_t status;
+	uint8_t bladeName[12];
+	uint8_t slotID;
+	uint8_t bladePowerStatus;
+} OemBladeStatus_T;
+
+typedef struct{
+	uint8_t supportEventLogs;
+	uint8_t supportBMCDevInfo;
+	uint8_t supportBMCNetworkInfo;
+	uint8_t supportCPUInfo;
+	uint8_t supportFanCtrl;
+	uint8_t supportFRU;
+	uint8_t supportRemoteCtrl;	//power on/off
+} OemIPMCCapability_T;
+
+typedef struct{
+	uint8_t IPMBAddr;
+	OemBladeStatus_T bladeStatus;
+} OemBladeInfo_T;
+
+typedef struct{
+	uint8_t bladeNum;
+	uint8_t fanNum;
+	uint8_t supportHistory;
+	
+} OemWebFlags_T;
+#pragma pack()
+
+typedef struct 
+{
+	/*
+		sensor_name array length increased from 17 to 20.
+		In some cases sensor_name length is more than 17 characters. webgo was giving some special character to web page in those cases and webpage was giving some weird behaviour when it found that special character.
+	*/
+    uint8_t sensor_num;
+    char sensor_name[ 20 ];
+    float sensor_history[ 480 ];
+    
+}sensor_history_st;
+
+typedef struct{
+	uint8_t isSupportSensorHistory;
+	uint8_t SensorHistoryEnable;
+} SensorHistoryCapability_T;
+
+extern OemWebFlags_T g_OemWebFlags;
+uint16_t LIBIPMI_HL_GetIPMCSensorInfo(IPMI20_SESSION_T *pSession,SenInfo_T *pSensorInfo,uint32_t *nNumSensor,int timeout);
+
+uint16_t LIBIPMI_HL_FanCtrol( IPMI20_SESSION_T *pSession, uint8_t fanIndex, uint8_t fanMode, uint8_t fanLevel, int timeout);
+int LIBIPMI_HL_GetFanStatus( IPMI20_SESSION_T *pSession, uint8_t fanIndex, OemFanStatus_T *pFanStatus, int timeout);
+uint16_t LIBIPMI_HL_GetExtraInfo( IPMI20_SESSION_T *pSession, ExtraInfo_T *extraInfo, int timeout);
+uint16_t LIBIPMI_HL_GetSensorHistory( IPMI20_SESSION_T *pSession, sensor_history_st *pSensorHistory_st, int card_index, int sensor_number, int IPMB_ADDR);
+uint16_t LIBIPMI_HL_GetAllCards(IPMI20_SESSION_T *pSession, CardStatus_T*	pResBladeSts, int timeout);
+int	 LIBIPMI_HL_GetChassisInfo(IPMI20_SESSION_T *pSession, OemChassisInfo_T* pBladeInfo, int timeout);
+int 	 LIBIPMI_HL_GetBladeStatus(IPMI20_SESSION_T *pSession, OemBladeStatus_T* pBladeStatus, int timeout);
+int LIBIPMI_HL_GetIPMCCapability(IPMI20_SESSION_T *pSession, uint8_t bladeIndex, OemIPMCCapability_T* pIPMCCapability, int timeout);
+int LIBIPMI_HL_SetBladeManageFn(IPMI20_SESSION_T *pSession, uint8_t enable, int timeout);
+int LIBIPMI_HL_GetManageWebName(IPMI20_SESSION_T *pSession, char* webName, int timeout);
+int LIBIPMI_HL_GetFanInfo(IPMI20_SESSION_T *pSession, OemFanInfo_T* pFanInfo, int timeout);
+int LIBIPMI_HL_GetSensorHistoryCapability(IPMI20_SESSION_T *pSession, uint8_t sensorNum, SensorHistoryCapability_T* pSensorHistoryCapability, int timeout);
+//int LIBIPMI_HL_GetSensorHistoryEn(IPMI20_SESSION_T *pSession, uint8_t* SensorHistoryEnable, int timeout);
+int LIBIPMI_HL_SetSensorHistoryEn(IPMI20_SESSION_T *pSession, uint8_t sensorNum, uint8_t SensorHistoryEnable, int timeout);
+
+#endif /* __LIBIPMI_STORLEAD_OEM_H__ */
+

+ 171 - 0
app/goahead-5.1.0/src/libipmi/inc/libipmi_struct.h

@@ -0,0 +1,171 @@
+/**
+ * @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 <stdint.h>
+
+#define PACK __attribute__ ((packed))
+
+#define	MAX_REQUEST_SIZE		1024 * 60
+#define	MAX_RESPONSE_SIZE		1024 * 60
+
+
+#define HANDLE			int
+#define SOCKET			int
+#define SOCKET_ERROR	-1
+
+#define IP4_VERSION     4
+#define IP6_VERSION     6
+#define IP4_ADDR_LEN    4
+#define IP6_ADDR_LEN   16
+
+/**
+ @def UDS_CHANNEL_T
+ @brief holds data required for network medium
+*/
+typedef struct UDS_CHANNEL_T_tag {
+	uint16_t			hSocketPath;
+	SOCKET			hSocket;
+	uint8_t			byIsConnected;
+} PACK UDS_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_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;
+}PACK IPMI20_UDS_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;
+
+} PACK IPMI20_SESSION_T;
+typedef enum
+{
+    AUTH_FLAG = 1,
+    AUTH_BYPASS_FLAG,
+}USER_Auth;
+
+
+
+/* Undefine PACK so that it can be redefined in other header files */
+#if defined (PACK)
+#undef PACK
+#endif
+
+#endif /* __LIBIPMI_STRUCT_H__ */

+ 31 - 0
app/goahead-5.1.0/src/libipmi/inc/libipmi_usermgmt.h

@@ -0,0 +1,31 @@
+#ifndef __LIBIPMI_USER_MANAGEMENT_H__
+#define __LIBIPMI_USER_MANAGEMENT_H__
+
+#ifdef __GNUC__
+#define PACK __attribute__ ((packed))
+#else
+#define PACK
+#pragma pack( 1 )
+#endif
+
+#define			MAX_USERS				64
+#define			MAX_USER_NAME_LEN		16
+
+typedef struct {
+	uint8_t		byUserID;
+	char		szUserName[16];
+} SetUser_T;
+
+typedef struct {
+	uint8_t		byCompletionCode;
+	char		szUserName[16];
+} GetUser_T;
+
+#undef PACK
+#ifndef __GNUC__
+#pragma pack()
+#endif
+
+
+#endif
+

+ 20 - 0
app/goahead-5.1.0/src/libipmi/inc/libipmi_version.h

@@ -0,0 +1,20 @@
+#ifndef __LIBIPMI_VERSION_H__
+#define __LIBIPMI_VERSION_H__
+
+/*
+Version - 1.1
+Date - 14-Dec-2005
+Changes:
+-Added IPMB Interface.
+-Added LIBIPMI_HL_GetSDR in libipmi_sdr.c, a high level function to retreive SDRs based on medium type. In IPMB medium, SDRs must be retreived in chunks whereas in other mediums they can be retreived in a single stretch.
+-Changed LIBIPMI_GetCompleteSDR to use LIBIPMI_HL_GetSDR instead of IPMICMD_GetSDR.
+-Version information added.
+-Fix: In LIBIPMI_SetUser, expected response length field was unassigned. It is corrected.
+*/
+
+#define LIBIPMI_VERSION		"1.1"
+
+#endif
+
+
+

+ 57 - 0
app/goahead-5.1.0/src/libipmi/inc/libsensor.h

@@ -0,0 +1,57 @@
+/* ***************************-*- andrew-c -*-****************************** */
+/* Filename:    libsensor.h                                                  */
+/* Author:      Andrew McCallum (andrewm@ami.com)                            */
+/* Format:      Indent: 4 spaces, no tabs                                    */
+/* Created:     09/21/2004                                                   */
+/* Modified:    09/21/2004                                                   */
+/* Description: Prototypes and defines for sensor helper functions           */
+/* ************************************************************************* */
+
+#ifndef LIBSENSOR_H_
+#define LIBSENSOR_H_
+
+#include "libipmi_session.h"
+
+/* IPMI threshold state definitions for monitoring */
+#define THRESH_UNINITIALIZED        ( (u16)0x00 )
+#define THRESH_NORMAL               ( (u16)0x01 )
+#define THRESH_UP_NONCRIT           ( (u16)0x02 )
+#define THRESH_UP_CRITICAL          ( (u16)0x04 )
+#define THRESH_LOW_NONCRIT          ( (u16)0x08 )
+#define THRESH_LOW_CRITICAL         ( (u16)0x10 )
+#define THRESH_ACCESS_FAILED        ( (u16)0x20 )
+#define THRESH_UP_NON_RECOV         ( (u16)0x40 )
+#define THRESH_LOW_NON_RECOV        ( (u16)0x80 )
+
+//#pragma pack(1)
+struct sensor_data
+{
+	/*
+		sensor_name array length increased from 17 to 20.
+		In some cases sensor_name length is more than 17 characters. webgo was giving some special character to web page in those cases and webpage was giving some weird behaviour when it found that special character.
+	*/
+    uint8_t sensor_num;
+    char sensor_name[ 20 ];
+    uint8_t owner_id;
+    uint8_t owner_lun;
+    uint8_t sensor_type;
+    uint8_t sensor_units[ 3 ];
+    float sensor_reading;
+    uint8_t raw_reading;
+    uint16_t sensor_state;
+    uint8_t discrete_state;
+    float low_non_recov_thresh;
+    float low_crit_thresh;
+    float low_non_crit_thresh;
+    float high_non_crit_thresh;
+    float high_crit_thresh;
+    float high_non_recov_thresh;
+    int SensorAccessibleFlags;
+    uint16_t Settable_Readable_ThreshMask;    
+};
+
+int getsensorcount( IPMI20_SESSION_T *pSession );
+int getallsensorreadings( struct sensor_data *sensors, IPMI20_SESSION_T *pSession );
+
+
+#endif

+ 150 - 0
app/goahead-5.1.0/src/libipmi/inc/std_macros.h

@@ -0,0 +1,150 @@
+/****************************************************************
+ ****************************************************************
+ **                                                            **
+ **    (C)Copyright 2005-2006, American Megatrends Inc.        **
+ **                                                            **
+ **            All Rights Reserved.                            **
+ **                                                            **
+ **        6145-F, Northbelt Parkway, Norcross,                **
+ **                                                            **
+ **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
+ **                                                            **
+ ****************************************************************
+ ****************************************************************
+ ****************************************************************
+ ****************************************************************
+ *
+ * std_macros.h
+ *
+ *  Author: Anurag Bhatia
+ *  Description: Taken from Platform.h inside IPMI stack.
+ ******************************************************************/
+#ifndef STD_MACROS_H
+#define STD_MACROS_H
+
+#include "Types.h"
+#include "platform.h"
+
+
+/**
+ * @def htoipmi_u32
+ * @brief Converts unsigned 32 bit data from Host format to IPMI format.
+ * @param Val 32bit value to be converted.
+ **/
+
+#if LIBIPMI_IS_PLATFORM_X86() || LIBIPMI_IS_PLATFORM_ARM() || LIBIPMI_IS_PLATFORM_SH()
+#define htoipmi_u32(Val)    (Val)
+#elif LIBIPMI_IS_PLATFORM_PPC() || LIBIPMI_IS_PLATFORM_MIPS()
+#define htoipmi_u32(Val)    ipmitoh_u32(Val)
+#endif
+                            
+/**
+ * @def ipmitoh_u32
+ * @brief Converts unsigned 32 bit data from IPMI format to Host format.
+ * @param Val 32bit value to be converted.
+ **/
+#if LIBIPMI_IS_PLATFORM_X86() || LIBIPMI_IS_PLATFORM_ARM() || LIBIPMI_IS_PLATFORM_SH()
+#define ipmitoh_u32(Val)    (Val)
+#elif LIBIPMI_IS_PLATFORM_PPC() || LIBIPMI_IS_PLATFORM_MIPS()
+#define ipmitoh_u32(Val)    (((Val & 0xFF000000) >> 24)| \
+                             ((Val & 0x00FF0000) >> 8) | \
+                             ((Val & 0x0000FF00) << 8) | \
+                             ((Val & 0x000000FF) << 24 ))
+#endif
+
+/**
+ * @def htoipmi_u16
+ * @brief Converts unsigned 16 bit data from Host format to IPMI format.
+ * @param Val 16bit value to be converted.
+ **/
+#if LIBIPMI_IS_PLATFORM_X86() || LIBIPMI_IS_PLATFORM_ARM() || LIBIPMI_IS_PLATFORM_SH()
+#define htoipmi_u16(Val)    (Val)
+#elif LIBIPMI_IS_PLATFORM_PPC() || LIBIPMI_IS_PLATFORM_MIPS()
+#define htoipmi_u16(Val)   ipmitoh_u16(Val)
+#endif
+
+/**
+ * @def htoipmi_u16
+ * @brief Converts unsigned 16 bit data from IPMI format to Host format.
+ * @param Val 16bit value to be converted.
+ **/
+#if LIBIPMI_IS_PLATFORM_X86() || LIBIPMI_IS_PLATFORM_ARM() || LIBIPMI_IS_PLATFORM_SH()
+#define ipmitoh_u16(Val)    (Val)
+#elif LIBIPMI_IS_PLATFORM_PPC() || LIBIPMI_IS_PLATFORM_MIPS()
+#define ipmitoh_u16(Val)   (uint16_t)(((uint16_t)(Val) & 0xFF00) >> 8 | ((uint16_t)(Val) & 0x00FF) << 8)
+#endif
+
+
+#if 0
+//Anurag Written
+/**
+ * @def htoipmi_u32
+ * @brief Converts unsigned 32 bit data from Host format to IPMI format.
+ * @param Val 32bit value to be converted.
+ **/
+#define htoipmi_u32(Val)   (Val)
+/* ((uint32_t)(((Val & 0xff) << 24) +    \
+                            ((Val & 0xff00) << 8) +             \
+                            ((Val & 0xff0000) >> 8) +           \
+                            ((Val & 0xff000000) >> 24)))*/
+
+
+/**
+ * @def ipmitoh_u32
+ * @brief Converts unsigned 32 bit data from IPMI format to Host format.
+ * @param Val 32bit value to be converted.
+ **/
+#define ipmitoh_u32(Val)    (Val)
+/*((uint32_t)(((Val & 0xff) << 24) +    \
+                            ((Val & 0xff00) << 8) +             \
+                            ((Val & 0xff0000) >> 8) +           \
+                            ((Val & 0xff000000) >> 24)))
+*/
+/**
+ * @def htoipmi_u16
+ * @brief Converts unsigned 16 bit data from Host format to IPMI format.
+ * @param Val 16bit value to be converted.
+ **/
+#define htoipmi_u16(Val)    (Val)
+/*((uint16_t)(((Val & 0xff) << 8) + (Val >> 8)))*/
+
+/**
+ * @def htoipmi_u16
+ * @brief Converts unsigned 16 bit data from IPMI format to Host format.
+ * @param Val 16bit value to be converted.
+ **/
+#define ipmitoh_u16(Val)    (Val)
+/*((uint16_t)(((Val & 0xff) << 8) + (Val >> 8)))*/
+
+#endif
+
+#if 0
+/**
+ * @def htons
+ * @brief Converts unsigned 16 bit data from Host format to Network format.
+ * @param Val 16bit value to be converted.
+ **/
+#define htons(Val)          Val
+
+/**
+ * @def htonl
+ * @brief Converts unsigned 32 bit data from Host format to Network format.
+ * @param Val 132bit value to be converted.
+ **/
+#define htonl(Val)          Val
+
+/**
+ * @def htons
+ * @brief Converts unsigned 16 bit data from Network format to Host format.
+ * @param Val 16bit value to be converted.
+ **/
+#define ntohs(Val)          Val
+
+/**
+ * @def ntohl
+ * @brief Converts unsigned 32 bit data from Network format to Host format.
+ * @param Val 32bit value to be converted.
+ **/
+#define ntohl(Val)          Val
+#endif
+#endif  /* STD_MACROS_H */

+ 398 - 0
app/goahead-5.1.0/src/libipmi/src/libipmi_Chassis.c

@@ -0,0 +1,398 @@
+/*****************************************************************
+******************************************************************
+***                                                            ***
+***        (C)Copyright 2008, American Megatrends Inc.         ***
+***                                                            ***
+***                    All Rights Reserved                     ***
+***                                                            ***
+***       5555 Oakbrook Parkway, Norcross, GA 30093, USA       ***
+***                                                            ***
+***                     Phone 770.246.8600                     ***
+***                                                            ***
+******************************************************************
+******************************************************************
+******************************************************************
+* 
+* Filename: libipmi_Chassis.c
+*
+* Descriptions: Chassis Control Subfunctions Implementation.
+*   For documentation see file libipmi_ChassisDevice.h
+*
+* Author: Chennakesava Rao Arnoori
+*
+******************************************************************/
+#include "libipmi_session.h"
+#include "libipmi_errorcodes.h"
+#include "libipmi_ChassisDevice.h"
+
+#include "string.h"
+#include <dbgout.h>
+
+
+/**
+   \breif	Internel function to execute the raw IPMI Command
+   @param	pSession		[in]Session handle
+   @param	timeout			[in]timeout value in seconds.
+
+   @retval Returns LIBIPMI_STATUS_SUCCESS on success and error codes on failure
+*/
+uint16_t	IPMICMD_ChassisControl( IPMI20_SESSION_T *pSession, int timeout, char cmd)
+{
+
+    uint32_t		dwResLen;
+    uint16_t		wRet;
+    ChassisControlReq_T ChassisReq;
+    ChassisControlRes_T ChassisRes;
+    
+    ChassisReq.ChassisControl = cmd; 
+    dwResLen = sizeof ( ChassisControlRes_T);
+
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+					    NETFNLUN_IPMI_CHASSIS, CMD_CHASSIS_CONTROL,
+					    (uint8_t *)&ChassisReq,sizeof(ChassisControlReq_T),
+					    (uint8_t*)&ChassisRes, &dwResLen,
+					    timeout);
+    return wRet;
+}
+
+
+uint16_t IPMICMD_GetSystemBootOptions(IPMI20_SESSION_T *pSession, GetBootOptionsReq_T* pReqGetBootOptions,
+							 GetBootOptionsRes_T* pResGetBootOptions,int reslen,int timeout)
+{
+	uint16_t wRet;
+	uint32_t dwResLen;
+
+	dwResLen = reslen;
+	
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+											NETFNLUN_IPMI_CHASSIS, CMD_GET_SYSTEM_BOOT_OPTIONS,
+											(uint8_t*)pReqGetBootOptions, sizeof(GetBootOptionsReq_T),
+											(uint8_t *)pResGetBootOptions, &dwResLen,
+											timeout);
+	return wRet;
+	
+}
+
+
+uint16_t IPMICMD_SetSystemBootOptions(IPMI20_SESSION_T *pSession, SetBootOptionsReq_T* pReqSetBootOptions,
+							 SetBootOptionsRes_T* pResSetBootOptions,int reqlen,int timeout)
+{
+	uint16_t wRet;
+	uint32_t dwResLen;
+	SetBootOptionsReq_T local_ReqSetBootOptions;
+	SetBootOptionsRes_T local_ResSetBootOptions;
+
+
+
+	
+	local_ReqSetBootOptions.ParamValidCumParam = 1; //for set in progress
+	local_ReqSetBootOptions.BootParam.SetInProgress = 1;
+	dwResLen = sizeof(SetBootOptionsRes_T);
+	//first do a set in progress
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+											NETFNLUN_IPMI_CHASSIS, CMD_SET_SYSTEM_BOOT_OPTIONS,
+											(uint8_t*)&local_ReqSetBootOptions, 2,
+											(uint8_t *)&local_ResSetBootOptions, &dwResLen,
+											timeout);
+
+	if(wRet != 0)
+	{
+		printf("Error while doing set in progress first before doing SetSystemBootOptions\n");
+		return wRet;
+	}
+
+
+	dwResLen = sizeof(SetBootOptionsRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+											NETFNLUN_IPMI_CHASSIS, CMD_SET_SYSTEM_BOOT_OPTIONS,
+											(uint8_t*)pReqSetBootOptions, reqlen,
+											(uint8_t *)pResSetBootOptions, &dwResLen,
+											timeout);
+	if(wRet != 0)
+	{
+		printf("error doing actual set system boot options\n");
+		return wRet;
+	}
+
+	//clear the set in progress
+	local_ReqSetBootOptions.ParamValidCumParam = 1; //for set in progress
+	local_ReqSetBootOptions.BootParam.SetInProgress = 0;
+	dwResLen = sizeof(SetBootOptionsRes_T);
+	//first do a set in progress
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+										NETFNLUN_IPMI_CHASSIS, CMD_SET_SYSTEM_BOOT_OPTIONS,
+										(uint8_t*)&local_ReqSetBootOptions, 2,
+										(uint8_t *)&local_ResSetBootOptions, &dwResLen,
+										timeout);
+
+	if(wRet != 0)
+	{
+		printf("Error while doing set in progress first before doing SetSystemBootOptions\n");
+		return wRet;
+	}
+
+	return wRet;
+	
+}
+
+
+
+uint16_t IPMICMD_ChassisIdentify(IPMI20_SESSION_T *pSession,int timeout,ChassisIdentifyReq_T* ChassisIdReq)
+{
+	 uint32_t		dwResLen;
+    	 uint16_t		wRet;
+	 ChassisIdentifyRes_T ChassisIdRes = {0};
+	 
+	 dwResLen = sizeof (ChassisIdentifyRes_T);
+	 
+	 wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+					    NETFNLUN_IPMI_CHASSIS, CMD_CHASSIS_IDENTIFY,
+					    (uint8_t *)ChassisIdReq,sizeof(ChassisIdentifyReq_T),
+					    (uint8_t*)&ChassisIdRes, &dwResLen,
+					    timeout);
+					    
+	return wRet;
+}
+
+
+uint16_t LIBIPMI_HL_PowerOff( IPMI20_SESSION_T *pSession, int timeout )
+{
+    uint16_t	wRet;
+
+    wRet = IPMICMD_ChassisControl( pSession, timeout, CHASSIS_POWEROFF);
+
+    if (wRet == LIBIPMI_E_SUCCESS){
+	TDBG("Succefully executed powerOFF  command.\n");
+    }else
+	TDBG("Error: PowerOFF Command Failed.\n");
+	
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_PowerUp( IPMI20_SESSION_T *pSession, int timeout )
+{
+    uint16_t	wRet;
+
+    wRet = IPMICMD_ChassisControl( pSession, timeout, CHASSIS_POWERUP);
+
+    if (wRet == LIBIPMI_E_SUCCESS){
+	TDBG("Succefully executed powerUP the command.\n");
+    }else
+	TDBG("Error: PowerUp Command Failed.\n");
+	
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_PowerCycle( IPMI20_SESSION_T *pSession, int timeout )
+{
+    uint16_t	wRet;
+
+    wRet = IPMICMD_ChassisControl( pSession, timeout, CHASSIS_POWERCYCLE);
+
+    if (wRet == LIBIPMI_E_SUCCESS){
+	TDBG("Succefully executed powerCycle the command.\n");
+    }else
+	TDBG("Error: PowerCycle Command Failed.\n");
+	
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_HardReset( IPMI20_SESSION_T *pSession, int timeout )
+{	//TODO: jimbo control rst1~10 pin
+    uint16_t	wRet;
+
+    wRet = IPMICMD_ChassisControl( pSession, timeout, CHASSIS_HARDRESET);
+
+    if (wRet == LIBIPMI_E_SUCCESS){
+	TDBG("Succefully executed HardReset the command.\n");
+    }else
+	TDBG("Error: HardReset Command Failed.\n");
+	
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_DiagInt( IPMI20_SESSION_T *pSession, int timeout )
+{
+    uint16_t	wRet;
+
+    wRet = IPMICMD_ChassisControl( pSession, timeout, CHASSIS_DIAGINT);
+
+    if (wRet == LIBIPMI_E_SUCCESS){
+	TDBG("Succefully executed DiagInt command.\n");
+    }else
+	TDBG("Error: DiagInt Command Failed.\n");
+	
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_SoftOff( IPMI20_SESSION_T *pSession, int timeout )
+{
+    uint16_t	wRet;
+
+    wRet = IPMICMD_ChassisControl( pSession, timeout, CHASSIS_SOFTOFF);
+
+    if (wRet == LIBIPMI_E_SUCCESS){
+	TDBG("Succefully executed SoftOff command.\n");
+    }else
+	TDBG("Error: SoftOff Command Failed.\n");
+	
+    return wRet;
+}
+
+uint16_t	LIBIPMI_HL_GetChassisStatus( IPMI20_SESSION_T *pSession, int timeout, chassis_status_T *status)
+{
+
+    uint32_t		dwResLen;
+    uint16_t		wRet;
+    uint8_t		ChassisStatusReq;
+    GetChassisStatusRes_T ChassisStatusRes;
+    uint8_t		powerState = -1;
+
+    dwResLen = sizeof(GetChassisStatusRes_T);
+    
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+					    NETFNLUN_IPMI_CHASSIS, CMD_GET_CHASSIS_STATUS,
+					    (uint8_t *)&ChassisStatusReq, 0 ,
+					    (uint8_t*)&ChassisStatusRes, &dwResLen,
+					    timeout);
+    
+    powerState = ChassisStatusRes.ChassisPowerState.PowerState ;
+    
+//    TINFO("PowerState is %d \n", powerState);
+    
+    status->power_state = powerState & 0x01;
+
+    status->last_power_event = ChassisStatusRes.ChassisPowerState.LastPowerEvent;
+
+
+    if(ChassisStatusRes.ChassisPowerState.MiscChassisState & CHASSIS_IDENTITY_STATE_INFO_SUPPORTED)
+    {
+	status->chassis_indetify_supported = 1;
+    }
+    else
+    {
+	status->chassis_indetify_supported = 0;
+    }
+
+
+    if(ChassisStatusRes.ChassisPowerState.MiscChassisState & CHASSIS_IDENTITY_INDEFINITE_ON)
+    {
+	status->chassis_identify_state = CHASSIS_ID_INDEFINITE_ON;
+    }
+    else if(ChassisStatusRes.ChassisPowerState.MiscChassisState & CHASSIS_IDENTITY_TIMED_ON)
+    {
+        status->chassis_identify_state = CHASSIS_ID_TIMED_ON;
+    }
+    else
+    {
+	status->chassis_identify_state = CHASSIS_ID_OFF;
+    }
+    
+    return wRet;
+}
+
+
+//will turn chassis identify on or off
+//BlinkTime - Set to TURN_OFF for turning off indefinitely
+//	      Set to Interval in secs for chassis identify to be on for that much time.
+// 	      for indefinite interval set ForceOn to 1.
+// ForceOn - overrides BlinkTime settings if set to 1.Set to 0 if controlling by interval
+uint16_t LIBIPMI_HL_ChassisIdentify(IPMI20_SESSION_T *pSession, int timeout,uint8_t BlinkTimeSecs,FORCE_CHASSIS_ID ForceOn)
+{
+	uint16_t wRet;
+	
+	ChassisIdentifyReq_T ChassisIdReq = {0};
+	
+	//set interval to blinktimesecs. If caller set it to 0 so be it.
+	//The caller should always give a time to this function . He can Use SPEC_DEFAULT to get default timeout behavior.
+	ChassisIdReq.IdentifyInterval = BlinkTimeSecs;
+	ChassisIdReq.ForceIdentify = ForceOn;
+	
+	TDBG("id interval and  force in libipmi are %d %d \n",ChassisIdReq.IdentifyInterval,ChassisIdReq.ForceIdentify);
+	
+	wRet = IPMICMD_ChassisIdentify(pSession,timeout,&ChassisIdReq);
+	
+	if(wRet == LIBIPMI_E_SUCCESS)
+	{
+		TDBG("Chassis identify command success\n");
+	}
+	else
+	{	
+		printf("Chassis Identify failed for the following params : %d %d",BlinkTimeSecs,ForceOn);
+	}
+	
+	return wRet;
+}
+
+
+uint16_t	LIBIPMI_HL_GetSystemBootOptions_BootFlags( IPMI20_SESSION_T *pSession, BootFlags_T* pBootFlags,int timeout)
+{
+	uint16_t wRet;
+	GetBootOptionsReq_T ReqGetBootOptions;
+	GetBootOptionsRes_T ResGetBootOptions;
+	int reslen;
+
+	//form the request
+	ReqGetBootOptions.ParamSel = 5;
+	ReqGetBootOptions.BlockSel = 0;
+	ReqGetBootOptions.SetSel = 0;
+
+	//calculate the response length
+	//we want the common response header + the sizeof bootflags
+	reslen = 3 + sizeof(BootFlags_T);
+
+
+	wRet = IPMICMD_GetSystemBootOptions(pSession,&ReqGetBootOptions,&ResGetBootOptions,reslen,timeout);
+
+	if(wRet != 0)
+	{
+		printf("Error getting system boot options when trying to get boot flags error code  is %x\n",wRet);
+		return wRet;
+	}
+
+	//check the response
+	if(ResGetBootOptions.ParameterValid & 0x80) 
+	{
+		printf("Got a parameter invlaid/locked error when trying to get Boot flags\n");
+    }
+
+	//we have the boot flags
+	memcpy(pBootFlags,&ResGetBootOptions.BootParams.BootFlags,sizeof(BootFlags_T));
+
+	return 0;
+}
+
+
+uint16_t	LIBIPMI_HL_SetSystemBootOptions_BootFlags( IPMI20_SESSION_T *pSession, BootFlags_T* pBootFlags,int timeout)
+{
+	uint16_t wRet;
+	SetBootOptionsReq_T ReqSetBootOptions;
+	SetBootOptionsRes_T ResSetBootOptions;
+	int reqlen;
+
+
+    
+	//form the request
+	ReqSetBootOptions.ParamValidCumParam = 5; //for bootflags
+	memcpy((uint8_t*)&(ReqSetBootOptions.BootParam.BootFlags),pBootFlags,sizeof(BootFlags_T));
+	
+	
+	
+	//we want the common response header + the sizeof bootflags
+	reqlen = 1 + sizeof(BootFlags_T);
+
+
+
+
+	wRet = IPMICMD_SetSystemBootOptions(pSession,&ReqSetBootOptions,&ResSetBootOptions,reqlen,timeout);
+
+	if(wRet != 0)
+	{
+		printf("Error setting system boot options when trying to set boot flags error code  is %x\n",wRet);
+		return wRet;
+	}
+
+
+	return 0;
+}

+ 560 - 0
app/goahead-5.1.0/src/libipmi/src/libipmi_PEF.c

@@ -0,0 +1,560 @@
+/*****************************************************************
+******************************************************************
+***                                                            ***
+***        (C)Copyright 2008, American Megatrends Inc.         ***
+***                                                            ***
+***                    All Rights Reserved                     ***
+***                                                            ***
+***       5555 Oakbrook Parkway, Norcross, GA 30093, USA       ***
+***                                                            ***
+***                     Phone 770.246.8600                     ***
+***                                                            ***
+******************************************************************
+******************************************************************
+******************************************************************
+*
+* Filename: libipmi_PEF.c
+*
+******************************************************************/
+#include "libipmi_session.h"
+#include "libipmi_PEF.h"
+#include "libipmi_StorDevice.h"			//For libipmi_GetBits
+
+#include <stdlib.h>
+#include <string.h>
+#include "dbgout.h"
+#include "std_macros.h"
+
+#ifndef ALERT_POLICY_PER_CHANNEL
+#define ALERT_POLICY_PER_CHANNEL   15
+#endif
+
+/* Get PEF Capabilities Command */
+uint16_t	IPMICMD_GetPEFCapabilities( IPMI20_SESSION_T *pSession,
+					GetPEFCapRes_T *pResGetPEFCap,
+					int timeout)
+{
+	uint8_t	Req[20];
+	uint16_t	wRet;
+	uint32_t	dwResLen;
+
+
+	dwResLen = sizeof(GetPEFCapRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NETFNLUN_IPMI_SENSOR, CMD_GET_PEF_CAPABILITIES,
+						(uint8_t*)Req, 0,
+						(uint8_t *)pResGetPEFCap, &dwResLen,
+						timeout);
+
+	return wRet;
+}
+
+/* Arm PEF Postpone Timer Command */
+uint16_t	IPMICMD_ArmPEFTimer( IPMI20_SESSION_T *pSession/*in*/,
+					uint8_t*	pReqTmrTimeout/*in*/,
+					ArmPEFTmrRes_T *pResArmPEFTmr/*out*/,
+					int timeout/*in*/)
+{
+	uint16_t	wRet;
+	uint32_t	dwResLen;
+
+
+	dwResLen = sizeof(ArmPEFTmrRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NETFNLUN_IPMI_SENSOR, CMD_ARM_PEF_POSTPONE_TIMER,
+						pReqTmrTimeout, sizeof(uint8_t),
+						(uint8_t *)pResArmPEFTmr, &dwResLen,
+						timeout);
+
+	return wRet;
+}
+
+/* Set PEF Configuration Parameters Command */
+uint16_t	IPMICMD_SetPEFConf( IPMI20_SESSION_T *pSession/*in*/,
+					uint8_t *pReqSetPEFConf/*in*/,
+					uint32_t dwReqBufLen,
+					uint8_t *pResSetPEFConf/*out*/,
+					int timeout/*in*/)
+{
+	uint16_t	wRet;
+	uint32_t	dwResLen;
+
+
+	dwResLen = sizeof(uint8_t);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NETFNLUN_IPMI_SENSOR, CMD_SET_PEF_CONFIG_PARAMS,
+						pReqSetPEFConf, dwReqBufLen,
+						(uint8_t *)pResSetPEFConf, &dwResLen,
+						timeout);
+
+	return wRet;
+}
+
+/* Get PEF Configuration Parameters Command */
+uint16_t	IPMICMD_GetPEFConf( IPMI20_SESSION_T *pSession/*in*/,
+					GetPEFConfigReq_T *pReqGetPEFConf/*in*/,
+					uint8_t *pResGetPEFConf/*out*/,
+					int timeout/*in*/)
+{
+	uint16_t	wRet;
+	uint32_t	dwResLen;
+
+
+	dwResLen = MAX_RESPONSE_SIZE;
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NETFNLUN_IPMI_SENSOR, CMD_GET_PEF_CONFIG_PARAMS,
+						(uint8_t*)pReqGetPEFConf, sizeof(GetPEFConfigReq_T),
+						pResGetPEFConf, &dwResLen,
+						timeout);
+
+	return wRet;
+}
+
+/* Set Last Processed Event ID Command */
+uint16_t	IPMICMD_SetLastEventID( IPMI20_SESSION_T *pSession/*in*/,
+					SetLastEvtIDReq_T *pReqSetLastEvt/*in*/,
+					uint8_t *pResSetLastEvt/*out*/,
+					int timeout/*in*/)
+{
+	uint16_t	wRet;
+	uint32_t	dwResLen;
+
+
+	dwResLen = sizeof(uint8_t);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NETFNLUN_IPMI_SENSOR, CMD_SET_LAST_PROCESSED_EVENT_ID,
+						(uint8_t*)pReqSetLastEvt, sizeof(SetLastEvtIDReq_T),
+						pResSetLastEvt, &dwResLen,
+						timeout);
+
+	return wRet;
+}
+
+/* Get Last Processed Event ID Command */
+uint16_t	IPMICMD_GetLastEventID( IPMI20_SESSION_T *pSession/*in*/,
+						GetLastEvtIDRes_T *pResGetLastEvt/*out*/,
+						int timeout/*in*/)
+{
+	uint8_t	Req[20];
+	uint16_t	wRet;
+	uint32_t	dwResLen;
+
+
+	dwResLen = sizeof(GetLastEvtIDRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NETFNLUN_IPMI_SENSOR, CMD_GET_LAST_PROCESSED_EVENT_ID,
+						(uint8_t*)Req, 0,
+						(uint8_t*)pResGetLastEvt, &dwResLen,
+						timeout);
+
+	return wRet;
+}
+
+/* Alert Immediate Command */
+uint16_t	IPMICMD_AlertImmediate( IPMI20_SESSION_T *pSession/*in*/,
+						AlertImmReq_T *pReqAlertImmediate/*in*/,
+						AlertImmRes_T *pResAlertImmediate/*out*/,
+						int timeout/*in*/)
+{
+	uint16_t	wRet;
+	uint32_t	dwResLen;
+
+
+	dwResLen = sizeof(AlertImmRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NETFNLUN_IPMI_SENSOR, CMD_ALERT_IMMEDIATE,
+						(uint8_t*)pReqAlertImmediate, sizeof(AlertImmReq_T),
+						(uint8_t*)pResAlertImmediate, &dwResLen,
+						timeout);
+
+	return wRet;
+}
+
+/* PET Acknowledge Command */
+uint16_t	IPMICMD_PETAck( IPMI20_SESSION_T *pSession/*in*/,
+						PETAckReq_T *pReqPETAck /*out*/,
+						uint8_t *pResPETACK /*out*/,
+						int timeout/*in*/)
+{
+	uint16_t	wRet;
+	uint32_t	dwResLen;
+
+	dwResLen = sizeof(uint8_t);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NETFNLUN_IPMI_SENSOR, CMD_PET_ACKNOWLEDGE,
+						(uint8_t*)pReqPETAck, sizeof(PETAckReq_T),
+						(uint8_t*)pResPETACK, &dwResLen,
+						timeout);
+
+	return wRet;
+}
+
+/******************************************************************************
+*****************************Higher level commands*****************************
+******************************************************************************/
+
+
+/*********** Alert Table **********/
+uint16_t LIBIPMI_HL_GetNumOfAlertPolicyEntries(IPMI20_SESSION_T *pSession,
+					uint8_t* pNumOfAlertPolicyEntries,
+					int timeout)
+{
+	uint16_t wRet = 0;
+	uint8_t  PEFConf[MAX_RESPONSE_SIZE];
+	GetPEFConfigReq_T GetPEFConfigReq;
+	uint8_t num = 0;
+
+	memset(&GetPEFConfigReq,0x00,sizeof(GetPEFConfigReq_T));
+	GetPEFConfigReq.ParamSel = 0x08;
+
+	wRet = IPMICMD_GetPEFConf(pSession,&GetPEFConfigReq,PEFConf,timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_GetNumOfAlertPolicyEntries: Error getting PEF Conf\n");
+		return wRet;
+	}
+	num = *(PEFConf + sizeof(GetPEFConfigRes_T));
+	*pNumOfAlertPolicyEntries = GetBits(num,6,0);
+
+	//printf("Number of Alert Policy entries : %d\n",*pNumOfAlertPolicyEntries);
+
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetAnAlertEntry(IPMI20_SESSION_T *pSession,
+					uint8_t AlertEntryNumber,
+					AlertPolicyTblEntry_T* pAlertEntry,
+					int timeout)
+{
+	uint16_t wRet = 0;
+	uint8_t  PEFConf[MAX_RESPONSE_SIZE];
+	GetPEFConfigReq_T GetPEFConfigReq;
+
+	memset(&GetPEFConfigReq,0x00,sizeof(GetPEFConfigReq_T));
+	GetPEFConfigReq.ParamSel = 0x09;
+	GetPEFConfigReq.SetSel = AlertEntryNumber;
+
+	wRet = IPMICMD_GetPEFConf(pSession,&GetPEFConfigReq,PEFConf,timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_GetAnAlertEntry: Error getting PEF Conf\n");
+		return wRet;
+	}
+	memcpy(pAlertEntry,(PEFConf + sizeof(GetPEFConfigRes_T) + 1),sizeof(AlertPolicyTblEntry_T));
+
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_EnDisPolicyTableEntry(IPMI20_SESSION_T *pSession,uint8_t IndexNum, int AlertNumEnable, uint8_t DestIndex,
+			uint8_t Channel, int timeout)
+{
+	uint16_t wRet = 0;
+	AlertPolicyTblEntry_T AlertEntry;
+
+	wRet = LIBIPMI_HL_GetAnAlertEntry(pSession,IndexNum,&AlertEntry,timeout);
+	if(wRet != 0)
+	{
+		printf("Critical error trying to Enable Disable alert policy - getting for index %d\n",IndexNum);
+		return wRet;
+	}
+	AlertEntry.AlertNum=AlertNumEnable;
+	//AlertEntry.ChannelDestSel |= DestIndex;
+	//AlertEntry.ChannelDestSel = (Channel << 4) | DestIndex;
+	AlertEntry.ChannelDestSel = (Channel << 4) | ((DestIndex-1)%(ALERT_POLICY_PER_CHANNEL)+1);
+
+	wRet = LIBIPMI_HL_SetAnAlertEntry(pSession,IndexNum,&AlertEntry,timeout);
+	if(wRet != 0)
+	{
+		printf("Critical error trying to Enable Disable alert policy - setting\n");
+		return wRet;
+	}
+
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_SetAnAlertEntry(IPMI20_SESSION_T *pSession,
+					uint8_t AlertEntryNumber,
+					AlertPolicyTblEntry_T* pAlertEntry,
+					int timeout)
+{
+	uint16_t wRet = 0;
+	uint8_t SetPEFConfigReq[MAX_RESPONSE_SIZE];
+	uint32_t reqLen = 0;
+	uint8_t response = 0;
+
+	memset(SetPEFConfigReq,0x00,MAX_RESPONSE_SIZE);
+	SetPEFConfigReq[0] = 0x09;
+	SetPEFConfigReq[1] = AlertEntryNumber;
+
+	memcpy(&SetPEFConfigReq[2],pAlertEntry,sizeof(AlertPolicyTblEntry_T));
+	reqLen = 2 + sizeof(AlertPolicyTblEntry_T);
+
+	wRet = IPMICMD_SetPEFConf(pSession,SetPEFConfigReq,reqLen,&response,timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_SetAnAlertEntry: Error setting PEF Conf\n");
+	}
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetAlertTable(IPMI20_SESSION_T *pSession,
+					AlertPolicyTblEntry_T* pAlertTable,
+					uint8_t* pNumOfAlertEntries,
+					int timeout)
+{
+	uint16_t wRet = 0;
+	uint8_t i,nAlertEntries = 0;
+	AlertPolicyTblEntry_T AlertEntry;
+
+	wRet = LIBIPMI_HL_GetNumOfAlertPolicyEntries(pSession,&nAlertEntries,timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_GetAlertTable: Error getting number of Alert policy entries\n");
+		return wRet;
+	}
+
+	*pNumOfAlertEntries = nAlertEntries;
+
+	for(i = 1; i <= nAlertEntries; i++)
+	{
+		wRet = LIBIPMI_HL_GetAnAlertEntry(pSession,(uint8_t)i,&AlertEntry,timeout);
+		if(wRet != 0)
+		{
+			printf("LIBIPMI_HL_GetAlertTable: Error getting an Alert Entry\n");
+			return wRet;
+		}
+		/* Copy this entry to pAlertTable */
+		memcpy(pAlertTable,&AlertEntry,sizeof(AlertPolicyTblEntry_T));
+		pAlertTable++;
+	}
+	return wRet;
+}
+
+
+/**************
+IPMI makes it fiendishly difficult to organize alerts.
+This is our mechanism
+You can choose to get Information and Above, Warning and above, Critical and Above or Non Recoverable and above alerts
+
+There are predefined Event Filter Table entries with All these categories
+Information,Warning, Critical, Nonrecoverable with Slert actions. (Other actions need to bbe configurd by the OEM)
+
+So when we choose a IP and select one of the levels above,
+We go to the PolicyTable (this is another table)
+There we have 4 entries per index of the destination.
+
+So Let us say you define an IP a.b.c.d for 1 and choose critical and above
+We go to the policytable and locate the 4 entries for index 1 (0 -3 )
+0 will have a predetremined policy number corresponding to Information, 1 will have a policy number corresponding to Warning etc
+So we enable index 2 and 3 since we want critical and above.
+
+When an event occurs the PEF code, looks up warning alert action sees policy number x and since we have set the destination in the
+policy table alerts will go out.
+
+*******************/
+#define NUM_ALERT_CATEGORIES 4 //we have 4 possible categories
+#define ALERT_LEVEL_DISBALE		0
+#define ALERT_LEVEL_INFO_AND_ABOVE     	1
+#define ALERT_LEVEL_WARN_AND_ABOVE     	1
+#define ALERT_LEVEL_CRIT_AND_ABOVE     	1
+#define ALERT_LEVEL__AND_ABOVE     	1
+
+uint16_t LIBIPMI_HL_SetGraspAlertLevel(IPMI20_SESSION_T *pSession,
+					uint8_t IndexNum,
+					uint8_t AlertLevel, //NOTE: we use our alert levels and the input AlertNum is the structure arg is not used
+					uint8_t Channel,
+					int timeout)
+{
+	//alert level can be info and above, warning and above,Critical and above,nonrecoverable and above
+	//we use 0-disable,1-info and above,2-warning and above,3-crit and above,4-nonrec and above
+
+	uint16_t wRet = 0;
+	int loopindex = 0,i=0;
+	int AlertNumEnable = 0;
+	int AlertEntryIndex = IndexNum * NUM_ALERT_CATEGORIES;
+
+
+	for(i=AlertEntryIndex-NUM_ALERT_CATEGORIES +1,loopindex = 1;i <= (AlertEntryIndex );i++,loopindex++)
+	{
+		//we assume ordering of policy entries
+		//Information, Warning, Critical and Non Recoverable - 0 is info etc..
+		//so if our alert level is say 1, which means information and above, we have to set all policies
+		//for our destination to enable
+		//example - let us say we get warning and above which is 3
+		//looping through we see that for the information case we want to disable.Since 3 is less than 1...
+		//if alert level is 0 which is disable we never enable it.
+		//printf("LIBIPMI_HL_SetGraspAlertLevel:  AlertLevel selected is : %d\n", AlertLevel);
+		//if((loopindex <=  AlertLevel ) && (AlertLevel != 0))
+		if((loopindex >=  AlertLevel ) && (AlertLevel != 0))
+			AlertNumEnable = ((loopindex<< 0x4) | 0x08);
+		else
+			AlertNumEnable = ((loopindex << 0x4) & 0xF7);
+
+
+			wRet = LIBIPMI_HL_EnDisPolicyTableEntry(pSession,(uint8_t)i,AlertNumEnable,IndexNum,Channel,timeout);
+			if(wRet != 0)
+			{
+				printf("Error while enabling, disabling Policy Table entry\n");
+				return wRet;
+			}
+	}
+
+	return 0;
+}
+
+
+//this will just return the alert level that has been set for a prticular destination
+uint16_t LIBIPMI_HL_GetGraspAlertLevel(IPMI20_SESSION_T *pSession,
+					uint8_t IndexNum,
+					uint8_t* AlertLevel, //NOTE: we use our alert levels and the input AlertNum is the structure arg is not used
+					uint8_t* DestIndex,
+					int timeout)
+{
+	//alert level can be info and above, warning and above,Critical and above,nonrecoverable and above
+	//we use 0-disable,1-info and above,2-warning and above,3-crit and above,4-nonrec and above
+
+	uint16_t wRet = 0;
+	AlertPolicyTblEntry_T AlertEntry;
+	int AlertEntryIndex = (IndexNum) * NUM_ALERT_CATEGORIES;
+	int i = 0,loopindex=0;
+
+	int tmpAlertLevel = 0;
+
+	for(i=(AlertEntryIndex - NUM_ALERT_CATEGORIES +1),loopindex = 1;i <= (AlertEntryIndex);i++,loopindex++)
+	{
+
+		wRet = LIBIPMI_HL_GetAnAlertEntry(pSession,(uint8_t)i,&AlertEntry,timeout);
+		if(wRet != 0)
+		{
+			printf("Critical error trying to get alert policy for index num %d\n",i);
+			return wRet;
+		}
+
+		//now we check the alert entry and arrive at the alert level number;
+		//if this entry is disabled
+		 //if( AlertEntry.AlertNum & 0x08 )
+		 if( (AlertEntry.AlertNum & 0x08) != 0)
+		 {
+		 	tmpAlertLevel = loopindex;
+			break;
+		 }
+	}
+
+	*AlertLevel = tmpAlertLevel;
+	*DestIndex = AlertEntry.ChannelDestSel;
+	return wRet;
+}
+
+
+
+/************* PEF Table **************/
+uint16_t LIBIPMI_HL_GetNumOfPEFEntries(IPMI20_SESSION_T *pSession,
+					uint8_t* pNumOfPEFEntries,
+					int timeout)
+{
+	uint16_t wRet = 0;
+	uint8_t  PEFConf[MAX_RESPONSE_SIZE];
+	GetPEFConfigReq_T GetPEFConfigReq;
+	uint8_t num = 0;
+
+	memset(&GetPEFConfigReq,0x00,sizeof(GetPEFConfigReq_T));
+	GetPEFConfigReq.ParamSel = 0x05;
+
+	wRet = IPMICMD_GetPEFConf(pSession,&GetPEFConfigReq,PEFConf,timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_GetNumOfPEFEntries: Error getting PEF Conf\n");
+		return wRet;
+	}
+	num = *(PEFConf + sizeof(GetPEFConfigRes_T));
+	*pNumOfPEFEntries = GetBits(num,6,0);
+
+	//printf("Number of PEF entries : %d\n",*pNumOfPEFEntries);
+
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_SetPEFEntry(IPMI20_SESSION_T *pSession,
+					uint8_t PEFEntryNumber,
+					EvtFilterTblEntry_T* pPEFEntry,
+					int timeout)
+{
+	uint16_t wRet = 0;
+	uint8_t SetPEFConfigReq[MAX_RESPONSE_SIZE];
+	uint32_t reqLen = 0;
+	uint8_t response = 0;
+
+	memset(SetPEFConfigReq,0x00,MAX_RESPONSE_SIZE);
+	SetPEFConfigReq[0] = 0x06;
+	SetPEFConfigReq[1] = PEFEntryNumber;
+
+	memcpy(&SetPEFConfigReq[2],pPEFEntry,sizeof(EvtFilterTblEntry_T));
+	reqLen = 2 + sizeof(EvtFilterTblEntry_T);
+
+	wRet = IPMICMD_SetPEFConf(pSession,SetPEFConfigReq,reqLen,&response,timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_SetPEFEntry: Error setting PEF Conf\n");
+	}
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetPEFEntry(IPMI20_SESSION_T *pSession,
+					uint8_t PEFEntryNumber,
+					EvtFilterTblEntry_T* pPEFEntry,
+					int timeout)
+{
+	uint16_t temp, wRet = 0;
+	uint8_t  PEFConf[MAX_RESPONSE_SIZE];
+	GetPEFConfigReq_T GetPEFConfigReq;
+
+	memset(&GetPEFConfigReq,0x00,sizeof(GetPEFConfigReq_T));
+	GetPEFConfigReq.ParamSel = 0x06;
+	GetPEFConfigReq.SetSel = PEFEntryNumber;
+
+	wRet = IPMICMD_GetPEFConf(pSession,&GetPEFConfigReq,PEFConf,timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_GetPEFEntry: Error getting PEF Conf\n");
+		return wRet;
+	}
+	memcpy(pPEFEntry,(PEFConf + sizeof(GetPEFConfigRes_T) + 1),sizeof(EvtFilterTblEntry_T));
+
+	temp = ipmitoh_u16(pPEFEntry->EventData1OffsetMask);
+	pPEFEntry->EventData1OffsetMask = temp;
+
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetPEFTable(IPMI20_SESSION_T *pSession,
+					EvtFilterTblEntry_T* pPEFTable,
+					uint8_t* pNumOfPEFEntries,
+					int timeout)
+{
+	uint16_t wRet = 0;
+	uint8_t i,nPEFEntries = 0;
+	EvtFilterTblEntry_T PEFEntry;
+
+	wRet = LIBIPMI_HL_GetNumOfPEFEntries(pSession,&nPEFEntries,timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_GetPEFTable: Error getting number of PEF entries\n");
+		return wRet;
+	}
+
+	*pNumOfPEFEntries = nPEFEntries;
+
+	for(i = 1; i <= nPEFEntries; i++)
+	{
+		wRet = LIBIPMI_HL_GetPEFEntry(pSession,i,&PEFEntry,timeout);
+		if(wRet != 0)
+		{
+			printf("LIBIPMI_HL_GetPEFTable: Error getting a PEF Entry\n");
+			return wRet;
+		}
+		/* Copy this entry to pPEFTable */
+		memcpy(pPEFTable,&PEFEntry,sizeof(EvtFilterTblEntry_T));
+		pPEFTable++;
+	}
+	return wRet;
+}

+ 936 - 0
app/goahead-5.1.0/src/libipmi/src/libipmi_StorDevice.c

@@ -0,0 +1,936 @@
+/*****************************************************************
+******************************************************************
+***                                                            ***
+***        (C)Copyright 2008, American Megatrends Inc.         ***
+***                                                            ***
+***                    All Rights Reserved                     ***
+***                                                            ***
+***       5555 Oakbrook Parkway, Norcross, GA 30093, USA       ***
+***                                                            ***
+***                     Phone 770.246.8600                     ***
+***                                                            ***
+******************************************************************
+******************************************************************
+******************************************************************
+*
+* Filename: libipmi_StorDevice.c
+*
+* Description: Contains implementation of NetFn Storage
+*   specific IPMI command functions
+*
+* Author: Anurag Bhatia
+*
+******************************************************************/
+#include "libipmi_session.h"
+#include "libipmi_errorcodes.h"
+#include "libipmi_StorDevice.h"
+#include "std_macros.h"
+#include "IPMI_AMIDevice.h"
+#include "libipmi_AMIOEM.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include "dbgout.h"
+
+/* Helper function */
+uint8_t libipmi_GetBits(uint8_t orig, uint8_t startbit, uint8_t endbit)
+{
+	uint8_t  temp = orig;
+	uint8_t  mask = 0x00;
+	int i;
+	for(i=startbit;i>=endbit;i--)
+	{
+		mask = mask | (1 << i);
+	}
+
+	return (temp & mask);
+}
+
+/*****************************************************************************
+	System Event Log
+******************************************************************************/
+uint16_t IPMICMD_GetSELInfo(IPMI20_SESSION_T *pSession,
+				SELInfo_T *pResGetSELInfo,
+				int timeout)
+{
+	uint16_t	wRet;
+	uint32_t	dwResLen;
+	uint8_t	DummyReqData[8];
+	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
+
+	dwResLen = sizeof(SELInfo_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NetFnLunStorage, CMD_GET_SEL_INFO,
+						(uint8_t*)DummyReqData, 0,
+						(uint8_t *)pResGetSELInfo, &dwResLen,
+						timeout);
+	return wRet;
+}
+
+
+
+uint16_t IPMICMD_GetSELAllocationInfo(IPMI20_SESSION_T *pSession,
+					SELAllocInfo_T *pResGetSELAllocInfo,
+					int timeout)
+{
+	uint16_t	wRet;
+	uint32_t	dwResLen;
+	uint8_t	DummyReqData[8];
+	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
+
+	dwResLen = sizeof(SELAllocInfo_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NetFnLunStorage, CMD_GET_SEL_ALLOCATION_INFO,
+						(uint8_t*)DummyReqData, 0,
+						(uint8_t *)pResGetSELAllocInfo, &dwResLen,
+						timeout);
+	return wRet;
+}
+
+/* This function reserves SEL and returns SEL reservation ID */
+uint16_t IPMICMD_ReserveSEL(IPMI20_SESSION_T *pSession,
+					ReserveSELRes_T* pReserveSelRes,
+					int timeout)
+{
+	uint16_t	wRet = 0;
+	uint32_t	dwResLen = 0;
+
+	memset(pReserveSelRes, 0, sizeof(ReserveSELRes_T));
+
+	dwResLen = sizeof(ReserveSELRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						(NETFN_STORAGE << 2), CMD_RESERVE_SEL,
+						NULL, 0,
+						(uint8_t *)pReserveSelRes, &dwResLen,
+						timeout);
+
+	if ( (wRet != 0) && (pReserveSelRes->CompletionCode != CC_INV_CMD) )
+	{
+		printf("Could not get SEL reservation!!\n");
+		return wRet;
+	}
+
+	/* If ReserveSEL command is not implemented, return 0x0000 as reservation ID */
+	if ( pReserveSelRes->CompletionCode == CC_INV_CMD )
+	{
+		pReserveSelRes->ReservationID = 0x0000;
+		wRet = 0;
+	}
+
+	return wRet;
+}
+
+/* This function gets an entry from SEL. */
+uint16_t IPMICMD_GetSELEntry(IPMI20_SESSION_T *pSession,
+				GetSELReq_T* pGetSELReqData,
+				uint8_t* pGetSELResData,
+				uint32_t ResDataLen,
+				int timeout)
+{
+	uint16_t wRet = 0;
+	uint8_t NetFnLunStorage = (NETFN_STORAGE << 2);
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NetFnLunStorage, CMD_GET_SEL_ENTRY,
+						(uint8_t*)pGetSELReqData, sizeof(GetSELReq_T),
+						(uint8_t *)pGetSELResData, &ResDataLen,
+						timeout);
+	return wRet;
+}
+
+/* This function adds an entry into SEL. */
+uint16_t IPMICMD_AddSELEntry(IPMI20_SESSION_T *pSession,
+				SELEventRecord_T* pSELReqData,
+				AddSELRes_T* pSELResData,
+				int timeout)
+{
+	uint16_t wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t NetFnLunStorage = (NETFN_STORAGE << 2);
+
+	dwResLen = sizeof(AddSELRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NetFnLunStorage, CMD_ADD_SEL_ENTRY,
+						(uint8_t*)pSELReqData, sizeof(SELEventRecord_T),
+						(uint8_t *)pSELResData, &dwResLen,
+						timeout);
+	return wRet;
+}
+
+/* This function deletes an entry from SEL. */
+uint16_t IPMICMD_DeleteSELEntry(IPMI20_SESSION_T *pSession,
+				uint16_t RecordID,
+				int timeout)
+{
+	uint16_t			wRet = 0;
+	uint32_t			dwResLen = 0;
+	ReserveSELRes_T	ReserveSelRes;
+	DeleteSELReq_T	DeleteSELReqData;
+	DeleteSELRes_T	DeleteSELResData;
+
+	memset(&ReserveSelRes, 0, sizeof(ReserveSelRes));
+	memset(&DeleteSELReqData, 0, sizeof(DeleteSELReqData));
+	memset(&DeleteSELResData, 0, sizeof(DeleteSELResData));
+
+	//first do a SEL reservation
+	dwResLen = sizeof(ReserveSELRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						(NETFN_STORAGE << 2), CMD_RESERVE_SEL,
+						NULL, 0,
+						(uint8_t *)&ReserveSelRes, &dwResLen,
+						timeout);
+	if ( (wRet != 0) && (ReserveSelRes.CompletionCode != CC_INV_CMD) )
+	{
+		printf("Could not get SEL reservation while trying to delete event log!!\n");
+		return wRet;
+	}
+
+	if (ReserveSelRes.CompletionCode == CC_INV_CMD)
+	{
+		// Reservation ID should be set as 0x0000 for implementations that don't
+		// implement ReserveSEL command
+		DeleteSELReqData.ReservationID = 0x0000;
+	}
+	else
+	{
+		DeleteSELReqData.ReservationID = ReserveSelRes.ReservationID;
+	}
+
+	DeleteSELReqData.RecID = RecordID;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						(NETFN_STORAGE << 2), CMD_DELETE_SEL_ENTRY,
+						(uint8_t*)&DeleteSELReqData, sizeof(DeleteSELReqData),
+						(uint8_t *)&DeleteSELResData, &dwResLen,
+						timeout);
+	return wRet;
+}
+
+uint16_t IPMICMD_ClearSEL(IPMI20_SESSION_T *pSession,
+				int timeout)
+{
+	uint16_t	wRet;
+	uint32_t	dwResLen;
+	ClearSELReq_T ClearSelReq;
+	ClearSELRes_T ClearSelRes;
+	ReserveSELRes_T ReserveSelRes;
+
+	uint8_t DummyReqData[8];
+
+	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
+
+	//first do a SEL reservation
+ 	dwResLen = sizeof(ReserveSELRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NetFnLunStorage, CMD_RESERVE_SEL,
+						(uint8_t*)DummyReqData, 0,
+						(uint8_t *)&ReserveSelRes, &dwResLen,
+						timeout);
+
+	if ( (wRet != 0) && (ReserveSelRes.CompletionCode != CC_INV_CMD) )
+	{
+		printf("Could not get SEL reservation while trying to clear event log!!\n");
+		return wRet;
+	}
+
+	if (ReserveSelRes.CompletionCode == CC_INV_CMD)
+	{
+		// Reservation ID should be set as 0x0000 for implementations that don't
+		// implement ReserveSEL command
+		ClearSelReq.ReservationID = 0x0000;
+	}
+	else
+	{
+		ClearSelReq.ReservationID = ReserveSelRes.ReservationID;
+	}
+
+	ClearSelReq.CLR[0] = 'C';
+	ClearSelReq.CLR[1] = 'L';
+	ClearSelReq.CLR[2] = 'R';
+	ClearSelReq.InitOrStatus = 0xAA;
+
+	dwResLen = sizeof(ClearSELRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NetFnLunStorage, CMD_CLEAR_SEL,
+						(uint8_t*)&ClearSelReq, sizeof(ClearSELReq_T),
+						(uint8_t *)&ClearSelRes, &dwResLen,
+						timeout);
+	return wRet;
+}
+/**************************************************************************************
+*****************************Higher level commands*****************************
+**************************************************************************************/
+/* This function returns total number of SEL entries present in the system at that time */
+uint16_t LIBIPMI_HL_GetNumOfSELEntries(IPMI20_SESSION_T *pSession,
+					uint16_t* nNumOfSELEntries,
+					int timeout)
+{
+	uint16_t wRet = 0;
+	SELInfo_T SELInfo;
+
+	wRet =  IPMICMD_GetSELInfo(pSession,&SELInfo,timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_GetNumOfSELEntries: Error getting SEL info\n");
+		return wRet;
+	}
+	*nNumOfSELEntries = ipmitoh_u16(SELInfo.RecCt);
+	return wRet;
+}
+
+/* This function returns max possible number of SEL entries in the system at any time */
+uint16_t LIBIPMI_HL_GetMaxPossibleSELEntries(IPMI20_SESSION_T *pSession,
+						uint16_t* nMaxPossibleSELEntries,
+						int timeout)
+{
+	uint16_t wRet = 0;
+	SELAllocInfo_T SELAllocInfo;
+
+	wRet =  IPMICMD_GetSELAllocationInfo(pSession,&SELAllocInfo,timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_GetMaxPossibleSELEntries: Error getting SEL Alloc info\n");
+		return wRet;
+	}
+	*nMaxPossibleSELEntries = ipmitoh_u16(SELAllocInfo.NumAllocUnits);
+	return wRet;
+}
+
+/* This function returns total number of SEL entries present in the system at that time.
+   IMPORTANT:
+   Before you call this function, call LIBIPMI_HL_GetNumOfSELEntries() to get the number of
+   SEL entries present in the system, then allocate a buffer size of ((Num of Entries) * SELEventRecord_T)
+   to hold the total number of SEL entries. Pass the pointer to this buffer as pSELEntriesBuffer when
+   calling this function.
+   Alternatively, you can call LIBIPMI_HL_GetMaxPossibleSELEntries() to get the maximum possible
+   number of SEL entries present in the system at any given time, and allocate the buffer to hold those
+   many entries. It's just that this approach would allocate a bigger buffer size. */
+uint16_t LIBIPMI_HL_GetAllSELEntries(IPMI20_SESSION_T *pSession,
+					SELEventRecord_T *pSELEntriesBuffer,
+					int timeout)
+{
+	GetSELReq_T GetSELReqData = {0x00,0x00,0x00,0xFF}; // Request packet to get the very
+							// first SEL record and complete record,
+													// starting at offset 0 of each record.
+	uint8_t *GetSELResData = NULL;
+	SELEventRecord_T *ptrToSELRecord  = NULL;
+	uint32_t DataLen = 0;
+	uint16_t wRet = 0;
+
+	/* We want to read full records */
+	DataLen = sizeof(GetSELRes_T) + sizeof(SELEventRecord_T);
+	GetSELResData = (uint8_t *) malloc(DataLen);
+	if (NULL == GetSELResData)
+	{
+		return LIBIPMI_E_NO_ENOUGH_MEMORY;
+	}
+
+	/* Fill in the Record data first */
+	while(1)
+	{
+		wRet = IPMICMD_GetSELEntry(pSession, &GetSELReqData, GetSELResData, DataLen,timeout);
+		if(wRet == LIBIPMI_E_SUCCESS)
+		{
+			ptrToSELRecord = (SELEventRecord_T *) (GetSELResData + sizeof(GetSELRes_T));
+			memcpy(pSELEntriesBuffer,ptrToSELRecord,sizeof(SELEventRecord_T));
+			pSELEntriesBuffer++;
+			GetSELReqData.RecID = ((GetSELRes_T *) GetSELResData)->NextRecID;
+			if(  ((GetSELRes_T *) GetSELResData)->NextRecID == 0xFFFF)
+			{
+				/* End of SEL reached. */
+				break;
+			}
+		}
+		else
+		{
+			printf("LIBIPMI_HL_GetAllSELEntries: Error getting SEL entry\n");
+			break;
+		}
+	}
+
+	free(GetSELResData);
+	return wRet;
+}
+
+
+
+					
+uint16_t LIBIPMI_HL_GetAllSensorInfo(IPMI20_SESSION_T *pSession,
+					uint8_t **SDRBuff,
+					int *SDRCount,
+					int *MaxSDRLen,
+					int timeout)
+{
+	int wRet = 0;
+	SDRRepositoryAllocInfo_T SDRAllocationInfo;
+	SDRRepositoryInfo_T SDRReposInfo;
+    uint8_t *pSDRBuff=NULL;
+    	int MaxLen = 0;
+    	int SDRCnt = 0;
+
+	/* Get max buffer size to be allocated to read all SDRs in the system */
+	wRet = IPMICMD_GetSDRRepositoryAllocInfo(pSession, &SDRAllocationInfo, timeout);
+	if( wRet != 0 )
+	{
+		printf("Error getting SDR Repository Allocation Info\n");
+		return wRet;
+	}
+	
+	/* Get repository information */
+	wRet = IPMICMD_GetSDRRepositoryInfo(pSession, &SDRReposInfo,timeout);
+	if( wRet != 0 )
+	{
+		printf("Error getting SDR Repository Info\n");
+		return wRet;
+	}
+
+	/* Determine max SDR entry length */
+	MaxLen = SDRAllocationInfo.MaxRecSize * ipmitoh_u16( SDRAllocationInfo.AllocUnitSize );
+
+	/* Determine total number of SDRs stored */
+	SDRCnt = ipmitoh_u16( SDRReposInfo.RecCt );
+
+	/* Allocate the buffer */
+	pSDRBuff = (uint8_t *) malloc(MaxLen * SDRCnt);
+	if (NULL == pSDRBuff)
+	{
+		return LIBIPMI_E_NO_ENOUGH_MEMORY;
+	}
+
+
+	/* Call the function to read all the SDRs into this buffer */
+	wRet = LIBIPMI_HL_GetAllSDRs(pSession,
+                                     pSDRBuff,(MaxLen * SDRCnt),
+                                     timeout*4);
+	*MaxSDRLen=MaxLen;
+	*SDRCount=SDRCnt;
+	*SDRBuff=pSDRBuff;
+
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetSensorName(IPMI20_SESSION_T *pSession,
+					uint8_t SlaveAdd,
+					uint8_t LUNid,
+					uint8_t SensorNum,
+					uint8_t *SensorName,
+					int   timeout)
+{
+	int wRet = 0;
+	SDRRepositoryAllocInfo_T SDRAllocationInfo;
+	SDRRepositoryInfo_T SDRReposInfo;
+    	int MaxSDRLen = 0;
+    	int i,SDRCount = 0;
+	uint8_t *pSDRBuff = NULL;
+	SDRHeader *pSDRHeader = NULL;
+	uint8_t *pSDRStart = NULL;
+
+	/* Get max buffer size to be allocated to read all SDRs in the system */
+	wRet = IPMICMD_GetSDRRepositoryAllocInfo(pSession, &SDRAllocationInfo, timeout);
+	if( wRet != 0 )
+	{
+		printf("Error getting SDR Repository Allocation Info\n");
+		return wRet;
+	}
+	/* Get repository information */
+	wRet = IPMICMD_GetSDRRepositoryInfo(pSession, &SDRReposInfo,timeout);
+	if( wRet != 0 )
+	{
+		printf("Error getting SDR Repository Info\n");
+		return wRet;
+	}
+
+	/* Determine max SDR entry length */
+	MaxSDRLen = SDRAllocationInfo.MaxRecSize * ipmitoh_u16( SDRAllocationInfo.AllocUnitSize );
+
+	/* Determine total number of SDRs stored */
+	SDRCount = ipmitoh_u16( SDRReposInfo.RecCt );
+
+	/* Allocate the buffer */
+	pSDRBuff = (uint8_t *) malloc(MaxSDRLen * SDRCount);
+	if (NULL == pSDRBuff)
+	{
+		return LIBIPMI_E_NO_ENOUGH_MEMORY;
+	}
+	pSDRStart = pSDRBuff;
+
+	/* Call the function to read all the SDRs into this buffer */
+	wRet = LIBIPMI_HL_GetAllSDRs(pSession,
+                                     pSDRBuff,(MaxSDRLen * SDRCount),
+                                     timeout*4);
+
+	for( i = 0; i < SDRCount; i++)
+	{
+		pSDRHeader = (SDRHeader *) pSDRBuff;
+		if((pSDRHeader->RecordType >= 0x01) && (pSDRHeader->RecordType <= 0x03))
+		{
+			/* Compare SlaveAdd and LUNid fields */
+			uint8_t *pTmp = pSDRBuff + sizeof(SDRHeader);
+			uint8_t len = 0;
+
+			//if((SlaveAdd == *pTmp) && (LUNid == *(pTmp+1)))
+			//{
+				/* Now compare the sensor number */
+				if(SensorNum == *(pTmp+2))
+				{
+					/* Get the Name and return */
+					if(pSDRHeader->RecordType == 0x01)
+						pTmp = pSDRBuff + sizeof(SDRHeader) + 42;
+					else if(pSDRHeader->RecordType == 0x02)
+						pTmp = pSDRBuff + sizeof(SDRHeader) + 26;
+					else
+						pTmp = pSDRBuff + sizeof(SDRHeader) + 11;
+
+					len = GetBits(*pTmp,5,0);
+					if(len)
+					{
+						pTmp++;
+						memcpy(SensorName,pTmp,len);
+						SensorName[len] = 0;
+					}
+					else
+						strcpy((char*)SensorName,(char*)"\0");
+					break; //Sensorname is obtained for given sensornumber. So no Need to check remaining Sensor.
+				}
+			//}
+		}
+		pSDRBuff += MaxSDRLen;
+	}
+	free(pSDRStart);
+	return wRet;
+}
+
+/*this function wants to be nice to all nice people in the world who display
+sensor information. Instead of letting them go nuts getting all sel entires first
+an then looping thru all sel entires to go get all the sensor names and then each time to
+get a sensor name read SDR
+it just does that for them
+GetAllSelEntires
+Also GetAllSDR stuff once
+then loop and fill it all up internally*/
+uint16_t LIBIPMI_HL_GetAllSelEntriesWithSensorNames(IPMI20_SESSION_T *pSession,
+					SELEventRecordWithSensorName_T *pSELEntriesBuffer,
+					int timeout)
+{
+
+	// first SEL record and complete record,
+	// starting at offset 0 of each record.
+	//uint32_t DataLen = 0;
+	uint16_t wRet = 0;
+	SDRRepositoryAllocInfo_T SDRAllocationInfo;
+	SDRRepositoryInfo_T SDRReposInfo;
+	int MaxSDRLen = 0;
+	int i,SDRCount = 0;
+	uint8_t *pSDRBuff = NULL;
+	SDRHeader *pSDRHeader = NULL;
+	uint8_t *pSDRStart = NULL;
+	uint32_t nNumSelEntries = 0;
+	int q = 0;
+
+
+	/***********************************Get all Sel Entries now*********************************************/
+	/* We want to read full records */
+	//DataLen = sizeof(GetSELRes_T) + sizeof(SELEventRecord_T);
+
+	wRet = LIBIPMI_HL_AMIGetSELEntires(pSession,pSELEntriesBuffer,&nNumSelEntries,timeout);
+	if(wRet != LIBIPMI_E_SUCCESS)
+	{
+		printf("LIBIPMI_HL_AMIGetSELEntires : Error getting SEL Entries \n");
+		return wRet;
+	}
+
+
+	/*************************************Get The SDR once so that we can get sensor names*******************/
+	/* Get max buffer size to be allocated to read all SDRs in the system */
+	wRet = IPMICMD_GetSDRRepositoryAllocInfo(pSession, &SDRAllocationInfo, timeout);
+	if( wRet != 0 )
+	{
+		printf("Error getting SDR Repository Allocation Info\n");
+		return wRet;
+	}
+	/* Get repository information */
+	wRet = IPMICMD_GetSDRRepositoryInfo(pSession, &SDRReposInfo,timeout);
+	if( wRet != 0 )
+	{
+		printf("Error getting SDR Repository Info\n");
+		return wRet;
+	}
+
+	/* Determine max SDR entry length */
+	MaxSDRLen = SDRAllocationInfo.MaxRecSize * ipmitoh_u16( SDRAllocationInfo.AllocUnitSize );
+
+	/* Determine total number of SDRs stored */
+	SDRCount = ipmitoh_u16( SDRReposInfo.RecCt );
+
+	/* Allocate the buffer */
+	pSDRBuff = (uint8_t *) malloc(MaxSDRLen * SDRCount);
+	if(!pSDRBuff)
+	{
+		printf("Error allocating memopry for SDRs in GetAllEventsWithSensorNames\n");
+		wRet = STATUS_CODE(IPMI_ERROR_FLAG,CC_OUT_OF_SPACE);
+		return wRet;
+	}
+	pSDRStart = pSDRBuff;
+
+	/* Call the function to read all the SDRs into this buffer */
+	wRet = LIBIPMI_HL_GetAllSDRs(pSession,
+                                     pSDRBuff,(MaxSDRLen * SDRCount),
+                                     timeout*4);
+
+	/*************************************Get The SDR once so that we can get sensor names*******************/
+
+	/******************Now parse through sensor headers and get names corresponding to each event************/
+	for(q=0;q<nNumSelEntries;q++)
+	{
+
+		strcpy((char*)pSELEntriesBuffer[q].SensorName,(char*)"Unknown");
+
+		pSDRBuff = pSDRStart;
+		for( i = 0; i < SDRCount; i++)
+		{
+			pSDRHeader = (SDRHeader *) pSDRBuff;
+			if((pSDRHeader->RecordType >= 0x01) && (pSDRHeader->RecordType <= 0x03))
+			{
+				/* Compare SlaveAdd and LUNid fields */
+				uint8_t *pTmp = pSDRBuff + sizeof(SDRHeader);
+				uint8_t len = 0;
+
+
+
+				if((pSELEntriesBuffer[q].EventRecord.EvtRecord.GenID[0] == *pTmp) && (pSELEntriesBuffer[q].EventRecord.EvtRecord.GenID[1] == *(pTmp+1)))
+				{
+
+					/* Now compare the sensor number */
+					if(pSELEntriesBuffer[q].EventRecord.EvtRecord.SensorNum == *(pTmp+2))
+					{
+						/* Get the Name and return */
+						if(pSDRHeader->RecordType == 0x01)
+							pTmp = pSDRBuff + sizeof(SDRHeader) + 42;
+						else if(pSDRHeader->RecordType == 0x02)
+							pTmp = pSDRBuff + sizeof(SDRHeader) + 26;
+						else
+							pTmp = pSDRBuff + sizeof(SDRHeader) + 11;
+
+						len = GetBits(*pTmp,5,0);
+						if(len)
+						{
+							pTmp++;
+
+							memcpy(pSELEntriesBuffer[q].SensorName,pTmp,len);
+							pSELEntriesBuffer[q].SensorName[len] = 0;
+
+						}
+						else
+							strcpy((char*)pSELEntriesBuffer[q].SensorName,(char*)"Unknown");
+					}
+				}
+			}
+			pSDRBuff += MaxSDRLen;
+		}
+	}
+	free(pSDRStart);
+	return wRet;
+}
+
+/*****************************************************************************
+	Field Replacement Unit (FRU)
+******************************************************************************/
+uint16_t IPMICMD_GetFRUInventoryAreaInfo(IPMI20_SESSION_T *pSession,
+				FRUInventoryAreaInfoReq_T *pReqFRUInventoryAreaInfo,
+				FRUInventoryAreaInfoRes_T *pResFRUInventoryAreaInfo,
+				int timeout)
+{
+	uint16_t	wRet,tmp;
+	uint32_t	dwResLen;
+	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
+
+	dwResLen = sizeof(FRUInventoryAreaInfoRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NetFnLunStorage, CMD_FRU_INVENTORY_AREA_INFO,
+						(uint8_t *)pReqFRUInventoryAreaInfo, sizeof(FRUInventoryAreaInfoReq_T),
+						(uint8_t *)pResFRUInventoryAreaInfo, &dwResLen,
+						timeout);
+	/* Do we need to do the following??? I guess so...test and make sure */
+	tmp = ipmitoh_u16(pResFRUInventoryAreaInfo->Size);
+	pResFRUInventoryAreaInfo->Size = tmp;
+	return wRet;
+}
+
+uint16_t IPMICMD_ReadFRUData(IPMI20_SESSION_T *pSession,
+				FRUReadReq_T* pFRUReadReqData,
+				FRUReadRes_T* pFRUReadResData,
+				int timeout)
+{
+	uint16_t wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t NetFnLunStorage = (NETFN_STORAGE << 2);
+
+	dwResLen = sizeof(FRUReadRes_T) + (pFRUReadReqData->CountToRead);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NetFnLunStorage, CMD_READ_FRU_DATA,
+						(uint8_t *)pFRUReadReqData, sizeof(FRUReadReq_T),
+						(uint8_t *)pFRUReadResData, &dwResLen,
+						timeout);
+	return wRet;
+}
+
+uint16_t IPMICMD_WriteFRUData(IPMI20_SESSION_T *pSession,
+				FRUWriteReq_T* pFRUWriteReqData,
+				uint32_t ReqDataLen /* Bytes to be written + sizeof(FRUWriteReq_T) */,
+				FRUWriteRes_T* pFRUWriteResData,
+				int timeout)
+{
+	uint16_t wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t NetFnLunStorage = (NETFN_STORAGE << 2);
+
+	dwResLen = sizeof(FRUWriteRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NetFnLunStorage, CMD_WRITE_FRU_DATA,
+						(uint8_t *)pFRUWriteReqData, ReqDataLen,
+						(uint8_t *)pFRUWriteResData, &dwResLen,
+						timeout);
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetAllFRUDevices(IPMI20_SESSION_T *pSession,
+					uint8_t *pFRUIDs,
+					uint8_t *pFRUNames,
+					uint8_t *nFRUs,
+					int timeout)
+{
+	int wRet = 0;
+	SDRRepositoryAllocInfo_T SDRAllocationInfo;
+	SDRRepositoryInfo_T SDRReposInfo;
+	uint8_t *pSDRBuff = NULL;
+    	int MaxSDRLen = 0;
+    	int i,SDRCount = 0;
+	SDRHeader *pSDRHeader = NULL;
+	uint8_t *pSDRStart = NULL;
+
+	*nFRUs = 0;
+
+	/* Get max buffer size to be allocated to read all SDRs in the system */
+	wRet = IPMICMD_GetSDRRepositoryAllocInfo(pSession, &SDRAllocationInfo, timeout);
+	if( wRet != 0 )
+	{
+		printf("Error getting SDR Repository Allocation Info\n");
+		return wRet;
+	}
+	/* Get repository information */
+	wRet = IPMICMD_GetSDRRepositoryInfo(pSession, &SDRReposInfo,timeout);
+	if( wRet != 0 )
+	{
+		printf("Error getting SDR Repository Info\n");
+		return wRet;
+	}
+
+	/* Determine max SDR entry length */
+	MaxSDRLen = SDRAllocationInfo.MaxRecSize * ipmitoh_u16( SDRAllocationInfo.AllocUnitSize );
+
+//	printf("MaxSDRLen = %d\n",MaxSDRLen);
+	/* Determine total number of SDRs stored */
+	SDRCount = ipmitoh_u16( SDRReposInfo.RecCt );
+//	printf("SDRCount = %d\n",SDRCount);
+
+	/* Allocate the buffer */
+	pSDRBuff = (uint8_t *) malloc(MaxSDRLen * SDRCount);
+	if (NULL == pSDRBuff)
+	{
+		return LIBIPMI_E_NO_ENOUGH_MEMORY;
+	}
+	memset(pSDRBuff,0,(MaxSDRLen*SDRCount));
+	pSDRStart = pSDRBuff;
+
+	/* Call the function to read all the SDRs into this buffer */
+	wRet = LIBIPMI_HL_GetAllSDRs(pSession,
+                                     pSDRBuff,(MaxSDRLen * SDRCount),
+                                     timeout*4);
+	if(wRet != 0)
+	{
+		printf("Error getting All SDRs\n");
+		return wRet;
+	}
+	/* Search for all the SDRs of type '0x11' and '0x12' */
+	/* Check SDR type '0x12' to see if FRU device is supported.
+	   If yes, then FRU device id = 0.
+	 	OR
+	   Check SDR type '0x11' to get FRU device id.
+
+	   Store these device ids in FRUDeviceIDs[].
+	*/
+	for( i = 0; i < SDRCount; i++)
+	{
+		uint32_t len = 0;
+
+		pSDRHeader = (SDRHeader *) pSDRBuff;
+		if(pSDRHeader->RecordType == 0x11)
+		{
+			uint8_t *pTmp = pSDRBuff + sizeof(SDRHeader) + 1;
+			pFRUIDs[*nFRUs] = *pTmp;
+
+//			printf("FRU Id = %d\n",pFRUIDs[*nFRUs]);
+			/* Get device name now */
+			pTmp = pSDRBuff + sizeof(SDRHeader) + 10;
+			len = GetBits(*pTmp,5,0);
+			if(len)
+			{
+				pTmp++;
+				memcpy(pFRUNames,pTmp,len);
+				pFRUNames[len] = 0;
+			}
+			else
+				strcpy((char*)pFRUNames,(char*)"\0");
+
+//			printf("libipmi: FRUName = %s\n",pFRUNames);
+			pFRUNames += 33;
+			(*nFRUs)++;
+		}
+		else if(pSDRHeader->RecordType == 0x12)
+		{
+			uint8_t *pTmp = pSDRBuff + sizeof(SDRHeader) + 3;
+			if(GetBits(*pTmp,3,3))
+			{
+				pFRUIDs[*nFRUs] = 0;
+//				printf("FRU Id = %d\n",pFRUIDs[*nFRUs]);
+				/* Get device name now */
+				pTmp = pSDRBuff + sizeof(SDRHeader) + 10;
+				len = GetBits(*pTmp,5,0);
+				if(len)
+				{
+					pTmp++;
+					memcpy(pFRUNames,pTmp,len);
+					pFRUNames[len] = 0;
+				}
+				else
+					strcpy((char*)pFRUNames,(char*)"\0");
+
+//				printf("libipmi: FRUName = %s\n",pFRUNames);
+				pFRUNames += 33;
+				(*nFRUs)++;
+			}
+		}
+		pSDRBuff += MaxSDRLen;
+	}
+	free(pSDRStart);
+//	printf("numFRUs = %d\n",*nFRUs);
+	return wRet;
+}
+uint16_t LIBIPMI_HL_GetAllFRUDevice(IPMI20_SESSION_T *pSession,
+					uint8_t *pFRUIDs,
+					uint8_t *nFRUs,
+					uint8_t nFRUsName[][16],
+					int timeout)
+{
+    int wRet = 0,i=0;
+    AMIGetFruDetailReq_T GetFruDetReq;
+    AMIGetFruDetailRes_T GetFruDetRes;
+
+     GetFruDetReq.FruReq = 0xFF;		
+     /* To get the total fru's */
+    wRet = IPMICMD_FRUDetails(pSession, &GetFruDetReq,&GetFruDetRes, timeout);
+    if( wRet != 0 )
+    {
+        printf("Error getting total fru's\n");
+        return wRet;
+    }
+   *nFRUs = GetFruDetRes.TotalFru;
+    for (i=0;i< *nFRUs;i++)
+    {
+        GetFruDetReq.FruReq = i;
+        /* To get the total fru's */
+        wRet = IPMICMD_FRUDetails(pSession, &GetFruDetReq,&GetFruDetRes, timeout);
+        if( wRet != 0 )
+        {
+            printf("Error getting total fru's\n");
+            return wRet;
+        }   
+        pFRUIDs[i] = GetFruDetRes.DeviceNo;
+        strcpy((char *)nFRUsName[i],(char *)GetFruDetRes.FRUName); 
+    }
+    return 0;	
+}
+
+uint8_t IPMICMD_GetSELTime(IPMI20_SESSION_T *pSession,
+				GetSELTimeRes_T *pGetSELTimeRes, int timeout)
+{
+	uint16_t	wRet;
+	uint32_t	dwResLen;
+	uint8_t	DummyReqData[8];
+	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
+
+	dwResLen = sizeof(GetSELTimeRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NetFnLunStorage, CMD_GET_SEL_TIME,
+						(uint8_t*)DummyReqData, 0,
+						(uint8_t *)pGetSELTimeRes, &dwResLen,
+						timeout);
+	if (wRet != 0)
+	{
+		printf("Error getting SEL Time::%x\n",wRet);
+	}
+	return wRet;
+}
+
+uint8_t IPMICMD_SetSELTime(IPMI20_SESSION_T *pSession,
+				SetSELTimeReq_T *pSetSELTimeReq, int timeout)
+{
+	uint16_t	wRet;
+	uint32_t	dwResLen;
+	uint8_t	DummyResData[8];
+	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
+
+	dwResLen = sizeof(uint8_t);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NetFnLunStorage, CMD_SET_SEL_TIME,
+						(uint8_t *)pSetSELTimeReq, sizeof(SetSELTimeReq_T),
+						(uint8_t *)DummyResData, &dwResLen,
+						timeout);
+	if (wRet != 0)
+	{
+		printf("Error setting SEL Time::%x\n",wRet);
+	}
+	return wRet;
+}
+
+uint8_t IPMICMD_GetSELTimeUTCOffset(IPMI20_SESSION_T *pSession,
+				GetSELTimeUTCOffsetRes_T *pGetSELTimeUTCOffsetRes, int timeout)
+{
+	uint16_t	wRet;
+	uint32_t	dwResLen;
+	uint8_t	DummyReqData[8];
+	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
+
+	dwResLen = sizeof(GetSELTimeUTCOffsetRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NetFnLunStorage, CMD_GET_SEL_TIME_UTC_OFFSET,
+						(uint8_t*)DummyReqData, 0,
+						(uint8_t *)pGetSELTimeUTCOffsetRes, &dwResLen,
+						timeout);
+	if (wRet != 0)
+	{
+		printf("Error getting SEL Time UTC Offset::%x\n",wRet);
+	}
+	return wRet;
+}
+
+uint8_t IPMICMD_SetSELTimeUTCOffset(IPMI20_SESSION_T *pSession,
+				SetSELTimeUTCOffsetReq_T *pSetSELTimeUTCOffsetReq, int timeout)
+{
+	uint16_t	wRet;
+	uint32_t	dwResLen;
+	SetSELTimeUTCOffsetRes_T pSetSELTimeUTCOffsetRes;
+	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
+
+	dwResLen = sizeof(SetSELTimeUTCOffsetRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NetFnLunStorage, CMD_SET_SEL_TIME_UTC_OFFSET,
+						(uint8_t *)pSetSELTimeUTCOffsetReq, sizeof(SetSELTimeUTCOffsetReq_T),
+						(uint8_t *)&pSetSELTimeUTCOffsetRes, &dwResLen,
+						timeout);
+	if (wRet != 0)
+	{
+		printf("Error setting SEL Time UTC Offset::%x\n",wRet);
+	}
+	return wRet;
+}

+ 2583 - 0
app/goahead-5.1.0/src/libipmi/src/libipmi_XportDevice.c

@@ -0,0 +1,2583 @@
+/*****************************************************************
+******************************************************************
+***                                                            ***
+***        (C)Copyright 2008, American Megatrends Inc.         ***
+***                                                            ***
+***                    All Rights Reserved                     ***
+***                                                            ***
+***       5555 Oakbrook Parkway, Norcross, GA 30093, USA       ***
+***                                                            ***
+***                     Phone 770.246.8600                     ***
+***                                                            ***
+******************************************************************
+******************************************************************
+******************************************************************
+* 
+* Filename: libipmi_XportDevice.c
+*
+* Description: Contains implementation of NetFn Transport
+*   specific IPMI command functions
+*
+* Author: Anurag Bhatia
+*
+******************************************************************/
+#include "libipmi_session.h"
+#include "libipmi_errorcodes.h"
+#include "libipmi_XportDevice.h"
+#include "libipmi_AppDevice.h"
+#include "std_macros.h"
+#include "LANConfig.h"
+#include "IPMI_AMIConf.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include "dbgout.h"
+#include <ctype.h>
+
+extern uint8_t GetLanOEMParamValue (uint8_t ParamSelect);
+
+/* Test */
+/*****************************************************************************
+	LAN Configuration related IPMI Command Interface
+******************************************************************************/
+uint16_t IPMICMD_GetLANConfig(IPMI20_SESSION_T *pSession,
+				GetLanConfigReq_T* pGetLANConfigReqData,
+				GetLanConfigRes_T* pGetLANConfigResData,
+				int timeout)
+{
+	uint16_t wRet = 0;
+	uint8_t NetFnLunXport = (NETFN_TRANSPORT << 2);
+	uint32_t	dwResLen;
+	dwResLen = sizeof(GetLanConfigRes_T);
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NetFnLunXport, CMD_GET_LAN_CONFIGURATION_PARAMETERS,
+						(uint8_t*)pGetLANConfigReqData, sizeof(GetLanConfigReq_T),
+						(uint8_t *)pGetLANConfigResData, &dwResLen,
+						timeout);
+	return wRet;
+}
+
+uint16_t IPMICMD_SetLANConfig(IPMI20_SESSION_T *pSession,
+				SetLanConfigReq_T* pSetLANConfigReqData,
+				unsigned int ReqDataLen,
+				SetLanConfigRes_T* pSetLANConfigResData,
+				int timeout)
+{
+	uint16_t wRet = 0;
+	uint8_t NetFnLunXport = (NETFN_TRANSPORT << 2);
+	uint32_t	dwResLen;
+	dwResLen = sizeof(SetLanConfigRes_T);
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+						NetFnLunXport, CMD_SET_LAN_CONFIGURATION_PARAMETERS,
+						(uint8_t*)pSetLANConfigReqData, ReqDataLen,
+						(uint8_t *)pSetLANConfigResData, &dwResLen,
+						timeout);
+	return wRet;
+}
+
+
+/**************************************************************************************
+*********************************Higher level commands*********************************
+***************************************************************************************/
+uint16_t LIBIPMI_HL_GetNumOfLANDestinationEntries(IPMI20_SESSION_T *pSession,
+					uint8_t* pNumOfLANDestEntries,
+					uint8_t Channel,
+					int timeout)
+{
+	int wRet = 0;
+	GetLanConfigReq_T GetLANReqBuff;
+	GetLanConfigRes_T GetLANResBuff;
+	
+	GetLANReqBuff.ChannelNum = Channel;
+	GetLANReqBuff.ParameterSelect = LAN_PARAM_DEST_NUM;
+	GetLANReqBuff.SetSelect = 0;
+	GetLANReqBuff.BlockSelect = 0;
+
+	wRet = IPMICMD_GetLANConfig(pSession, &GetLANReqBuff,
+					&GetLANResBuff, timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_GetNumOfLANDestinationEntries, Error getting LAN configuration\n");
+		return wRet;
+	}
+
+	TDBG ("Number of Destinations::%d\n", GetLANResBuff.ConfigData.NumDest);
+	*pNumOfLANDestEntries = GetLANResBuff.ConfigData.NumDest;
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetLANDestinationType(IPMI20_SESSION_T *pSession,
+					uint8_t Channel,
+					uint8_t  index,
+					LANDestType_T *LANDestTypeRes,
+					int timeout)
+{
+	int wRet = 0;
+	GetLanConfigReq_T GetLANReqBuff;
+	GetLanConfigRes_T GetLANResBuff;
+
+	GetLANReqBuff.ChannelNum = Channel;
+	GetLANReqBuff.ParameterSelect = LAN_PARAM_SELECT_DEST_TYPE;
+	GetLANReqBuff.SetSelect = index;
+	GetLANReqBuff.BlockSelect = 0;
+
+	wRet = IPMICMD_GetLANConfig(pSession, &GetLANReqBuff,
+					&GetLANResBuff, timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_GetLANDestinationType, Error getting LAN configuration\n");
+		return wRet;
+	}
+
+	TDBG("Success getting LAN Destination type for index::%d\n",index);
+	memcpy(LANDestTypeRes, &(GetLANResBuff.ConfigData.DestType), sizeof(LANDestType_T));
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetLANDestinationAddress(IPMI20_SESSION_T *pSession,
+					uint8_t Channel,
+					uint8_t  index,
+					LANDestAddr_T *LANDestAddrRes,
+					int timeout)
+{
+	int wRet = 0;
+	GetLanConfigReq_T GetLANReqBuff;
+	GetLanConfigRes_T GetLANResBuff;
+
+	GetLANReqBuff.ChannelNum = Channel;
+	GetLANReqBuff.ParameterSelect = LAN_PARAM_SELECT_DEST_ADDR;
+	GetLANReqBuff.SetSelect = index;
+	GetLANReqBuff.BlockSelect = 0;
+
+	wRet = IPMICMD_GetLANConfig(pSession, &GetLANReqBuff,
+					&GetLANResBuff, timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_GetLANDestinationAddress, Error getting LAN configuration\n");
+		return wRet;
+	}
+
+	TDBG("Success getting LAN Destination address for index::%d\n",index);
+	memcpy(LANDestAddrRes, &(GetLANResBuff.ConfigData.DestAddr), sizeof(LANDestAddr_T));
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetLANDestinationV6Address(IPMI20_SESSION_T *pSession,
+					uint8_t Channel,
+					uint8_t  index,
+					LANDestv6Addr_T *LANDestv6AddrRes,
+					int timeout)
+{
+	int wRet = 0;
+	GetLanConfigReq_T GetLANReqBuff;
+	GetLanConfigRes_T GetLANResBuff;
+
+	GetLANReqBuff.ChannelNum = Channel;
+	GetLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR);
+	GetLANReqBuff.SetSelect = index;
+	GetLANReqBuff.BlockSelect = 0;
+
+	wRet = IPMICMD_GetLANConfig(pSession, &GetLANReqBuff,
+					&GetLANResBuff, timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_GetLANDestinationAddress, Error getting LAN configuration\n");
+		return wRet;
+	}
+
+	TDBG("Success getting LAN Destination V6 address for index::%d\n", index);
+	memcpy(LANDestv6AddrRes, &(GetLANResBuff.ConfigData.Destv6Addr), sizeof(LANDestv6Addr_T));
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetLANDestinationType_AddrTable(IPMI20_SESSION_T *pSession,
+					LANDestType_T* pDestTypeTable,
+					LANDestAddr_T* pDestAddrTable,
+					uint8_t* pNumOfLANDestEntries,
+					uint8_t Channel,
+					int timeout)
+{
+	uint16_t wRet = 0;
+	uint8_t i,nLANDestEntries = 0;
+	LANDestType_T LANDestTypeRes;
+	LANDestAddr_T LANDestAddrRes;
+
+	wRet = LIBIPMI_HL_GetNumOfLANDestinationEntries(pSession, &nLANDestEntries, 
+												Channel, timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_GetLANDestinationType_AddrTable: Error getting number of LAN Destination entries\n");
+		return wRet;
+	}
+
+	*pNumOfLANDestEntries = nLANDestEntries;
+	for(i = 1; i <= nLANDestEntries; i++)
+	{
+		/*Getting LAN Destination Type*/
+		memset(&LANDestTypeRes, 0, sizeof(LANDestType_T));
+		wRet = LIBIPMI_HL_GetLANDestinationType(pSession, Channel, (uint8_t)i,  &LANDestTypeRes, timeout);
+		if(wRet != 0)
+		{
+			printf("LIBIPMI_HL_GetLANDestinationType_AddrTable: Error getting an Destination Type Entry\n");
+			return wRet;
+		}
+		memcpy(pDestTypeTable,&LANDestTypeRes,sizeof(LANDestType_T));
+		pDestTypeTable++;
+
+		/*Getting LAN Destination Address*/
+		memset(&LANDestAddrRes, 0, sizeof(LANDestAddr_T));
+		wRet = LIBIPMI_HL_GetLANDestinationAddress(pSession, Channel, (uint8_t)i, &LANDestAddrRes, timeout);
+		if(wRet != 0)
+		{
+			printf("LIBIPMI_HL_GetLANDestinationType_AddrTable: Error getting an Destination Address Entry\n");
+			return wRet;
+		}
+		memcpy(pDestAddrTable,&LANDestAddrRes,sizeof(LANDestAddr_T));
+		pDestAddrTable++;
+	}
+	return wRet;
+}
+
+/*
+ *@fn LIBIPMI_HL_GetNumOfLANInterfaces
+ *@brief This function gets the total number of network interfaces present in the system
+ *@param ifname - Interface Name
+ *@returns 0 for MDIO, 1 for NCSI and -1 on error
+*/
+uint16_t LIBIPMI_HL_GetNumOfLANInterfaces(IPMI20_SESSION_T *pSession, uint8_t* pLanInfo,
+					uint8_t* pNumOfLANInterfaces, int timeout)
+{
+	int wRet = 0;
+	int index = 1;
+	GetChInfoReq_T reqGetChInfo = {0};
+	GetChInfoRes_T resGetChInfo = {0};
+	int count = 0;
+	
+	for(; index <= 15; index++)
+	{
+		memset(&resGetChInfo, 0, sizeof(GetChInfoRes_T));
+		reqGetChInfo.ChannelNum = index;
+		wRet = IPMICMD_GetChannelInfo(pSession, &reqGetChInfo, &resGetChInfo, DEFAULT_TIMEOUT);
+		if(wRet != 0)
+		{
+			TDBG("LIBIPMI_HL_GetNumOfLANInterfaces: Error getting channel info in FindNetworkChannel for channel %d\n",index);
+			// Make wRet as 0 because if channel 15 fails then the function return error.
+			wRet = 0;
+			continue;
+		}
+		else
+		{
+			/* To filter the LAN channels*/
+			if(resGetChInfo.ChannelMedium == CHANNEL_MEDIUM_TYPE_LAN)
+			{
+				pLanInfo[count++] = index;
+			}
+		}
+	}
+	*pNumOfLANInterfaces = count;
+	return wRet;
+}
+/*
+ *@fn LIBIPMI_HL_GetNCSIConfigNUM
+ *@brief This function gets the NCSIConfig Port number
+ *@param[in] - IPMI session header, 
+ *@param[in] - Channel number, 
+ *@param[out] - ConfigNum NCSI Port number, 
+ *@param[in] - Session Timeout value
+ *@returns 0 for Success; Others for specific error codes
+*/
+uint16_t LIBIPMI_HL_GetNCSIConfigNUM(IPMI20_SESSION_T *pSession, uint8_t Channel,
+                                                                            uint8_t *ConfigNum, int timeout)
+{
+    int wRet = 0;
+    GetLanConfigReq_T getLANReqBuff;
+    GetLanConfigRes_T getLANResBuff;
+
+    getLANReqBuff.ChannelNum = Channel;
+    getLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_NCSI_CONFIG_NUM);
+    getLANReqBuff.SetSelect = 0;
+    getLANReqBuff.BlockSelect = 0;
+
+    wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_GetNCSIConfigNUM: Error getting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    TDBG("Success getting NCSIConfigNUM Configuration settings for channel: %d\n", Channel);
+    *ConfigNum = getLANResBuff.ConfigData.NumNCSIPortConfigs;
+
+    return wRet;
+}
+/*
+ *@fn LIBIPMI_HL_GetNCSISetting
+ *@brief This function gets the NCSI Settings for the given Index.
+ *@param[in] - IPMI session header, 
+ *@param[in] - Channel number, 
+ *@param[out] - Index Configuration structure, 
+ *@param[out] - ChannelID - NCSI channel ID.
+ *@param[out] - PackageId - NCSI package ID.
+ *@param[in] - Session Timeout value
+ *@returns 0 for Success; Others for specific error codes
+*/
+
+uint16_t LIBIPMI_HL_GetNCSISetting(IPMI20_SESSION_T *pSession, uint8_t Channel,
+                                                                    uint8_t Index,uint8_t *ChannelID,uint8_t *PackageID, int timeout)
+{
+    int wRet = 0;
+    GetLanConfigReq_T getLANReqBuff;
+    GetLanConfigRes_T getLANResBuff;
+
+    getLANReqBuff.ChannelNum = Channel;
+    getLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_NCSI_SETTINGS);
+    getLANReqBuff.SetSelect = Index;
+    getLANReqBuff.BlockSelect = 0;
+    
+    wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_GetNCSISetting: Error getting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    TDBG("Success getting NCSI Configuration settings for channel: %d\n", Channel);
+    *ChannelID = getLANResBuff.ConfigData.NCSIPortConfig.ChannelId;
+    *PackageID = getLANResBuff.ConfigData.NCSIPortConfig.PackageId;
+
+    return wRet;
+}
+
+/*
+ *@fn LIBIPMI_HL_SetNCSISetting
+ *@brief This function gets the NCSI Settings for the given Index.
+ *@param[in] - IPMI session header, 
+ *@param[in] - Channel number, 
+ *@param[in] - Index Configuration structure, 
+ *@param[in] - ChannelID - NCSI channel ID.
+ *@param[in] - PackageId - NCSI package ID.
+ *@param[in] - Session Timeout value
+ *@returns 0 for Success; Others for specific error codes
+*/
+uint16_t LIBIPMI_HL_SetNCSISetting(IPMI20_SESSION_T *pSession, uint8_t Channel, uint8_t Index,
+                                                                   uint8_t ChannelID, uint8_t PackageID, int timeout)
+{
+    int wRet = 0;
+    SetLanConfigReq_T setLANReqBuff;
+    SetLanConfigRes_T setLANResBuff;
+    unsigned int ReqDataLen = 0;
+
+    memset(&(setLANReqBuff), 0, sizeof(SetLanConfigReq_T));
+    setLANReqBuff.ChannelNum = Channel;
+    setLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_NCSI_SETTINGS);
+
+    setLANReqBuff.ConfigData.NCSIPortConfig.Interface = Index;
+    setLANReqBuff.ConfigData.NCSIPortConfig.ChannelId = ChannelID;
+    setLANReqBuff.ConfigData.NCSIPortConfig.PackageId = PackageID;
+
+    ReqDataLen = 5; // Channel Number + Parameter Selector + Configuration Parameter Data 
+    wRet = IPMICMD_SetLANConfig(pSession, &setLANReqBuff, ReqDataLen, &setLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_SetNCSISetting: Error setting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    TDBG("Success setting NCSI configuration for channel::%d\n", Channel);
+    return wRet;
+}
+
+
+/*
+ *@fn LIBIPMI_HL_GetNCSIMode
+ *@brief This function gets the NCSI Mode for the given Index.
+ *@param[in] - IPMI session header, 
+ *@param[in] - Channel number, 
+ *@param[in] - Index Configuration structure, 
+ *@param[in] - Session Timeout value
+ *@param[out] - NCSI Mode
+ *@returns 0 for Success; Others for specific error codes
+*/
+
+uint16_t LIBIPMI_HL_GetNCSIMode(IPMI20_SESSION_T *pSession, uint8_t Channel,
+                                                                    uint8_t Index,uint8_t *AutoSelect, int timeout)
+{
+    int wRet = 0;
+    GetLanConfigReq_T getLANReqBuff;
+    GetLanConfigRes_T getLANResBuff;
+
+    getLANReqBuff.ChannelNum = Channel;
+    getLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_NCSI_MODE_CHANGE);
+    getLANReqBuff.SetSelect = Index;
+    getLANReqBuff.BlockSelect = 0;
+    
+    wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_GetNCSIMode: Error getting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    TDBG("Success getting NCSI Mode: %d\n", Channel);
+    *AutoSelect = getLANResBuff.ConfigData.NCSIModeConfig.NCSIMode;
+
+    return wRet;
+}
+
+/*
+ *@fn LIBIPMI_HL_SetNCSIMode
+ *@brief This function sets the NCSI Mode for the given Index.
+ *@param[in] - IPMI session header, 
+ *@param[in] - Channel number, 
+ *@param[in] - Index Configuration structure, 
+ *@param[in] - NCSI Mode, 
+ *@param[in] - Session Timeout value
+ *@returns 0 for Success; Others for specific error codes
+*/
+uint16_t LIBIPMI_HL_SetNCSIMode(IPMI20_SESSION_T *pSession, uint8_t Channel, uint8_t Index,
+                                                                   uint8_t AutoSelect, int timeout)
+{
+    int wRet = 0;
+    SetLanConfigReq_T setLANReqBuff;
+    SetLanConfigRes_T setLANResBuff;
+    unsigned int ReqDataLen = 0;
+
+    memset(&(setLANReqBuff), 0, sizeof(SetLanConfigReq_T));
+    setLANReqBuff.ChannelNum = Channel;
+    setLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_NCSI_MODE_CHANGE);
+
+    setLANReqBuff.ConfigData.NCSIModeConfig.Interface = Index;
+    setLANReqBuff.ConfigData.NCSIModeConfig.NCSIMode = AutoSelect;
+
+    ReqDataLen = 4; // Channel Number + Parameter Selector + Interfaced index + Mode
+    wRet = IPMICMD_SetLANConfig(pSession, &setLANReqBuff, ReqDataLen, &setLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_SetNCSIMode: Error setting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    TDBG("Success setting NCSI Mode::%d\n", Channel);
+    return wRet;
+}
+
+/*
+ *@fn LIBIPMI_HL_GetPHYConfig
+ *@brief This function gets the network link modes for the given Channel number.
+ *@param[in] - IPMI session header, 
+ *@param[in] - Channel number, 
+ *@param[out] - PHY Configuration structure, 
+ *@param[in] - Session Timeout value
+ *@returns 0 for Success; Others for specific error codes
+*/
+
+uint16_t LIBIPMI_HL_GetPHYConfig(IPMI20_SESSION_T *pSession, uint8_t Channel,
+     			       PHYConfig_T *PHYConfigRes, int timeout)
+{
+	int wRet = 0;
+	GetLanConfigReq_T getLANReqBuff;
+	GetLanConfigRes_T getLANResBuff;
+
+	getLANReqBuff.ChannelNum = Channel;
+	getLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_PHY_SETTINGS);
+	getLANReqBuff.SetSelect = 0;
+	getLANReqBuff.BlockSelect = 0;
+
+	wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_GetPHYConfig: Error getting LAN configuration for channel %d\n", Channel);
+		return wRet;
+	}
+
+	TDBG("Success getting PHY Configuration settings for channel: %d\n", Channel);
+	memcpy(PHYConfigRes, &(getLANResBuff.ConfigData.PHYConfig), sizeof(PHYConfig_T));
+	
+	return wRet;
+}
+
+/*
+ *@fn LIBIPMI_HL_GetPHYConfigTable
+ *@brief This function gets the network link modes for all the channels present in the system.
+ *@param[in] - IPMI session header,
+ *@param[out] - PHY Configuration Table,
+ *@param[out] - Total number of ethernet interfaces,
+ *@param[in] - Session Timeout value
+ *@returns 0 for Success; Others for specific error codes
+*/
+
+uint16_t LIBIPMI_HL_GetPHYConfigTable(IPMI20_SESSION_T *pSession, PHYConfig_T* pPHYConfigTable,
+ 				    uint8_t* pNumOfLANInterfaces, int timeout)
+{
+    uint8_t wRet = 0;
+    uint8_t index = 0;
+    uint8_t BondEnable[2] = {0};
+    uint8_t LANChannels[MAX_LAN_CHANNEL] = {0};
+    uint8_t numOfLANInterfaces = 0, IfcCount = 0, Channel = 0;
+    PHYConfig_T phyConfigRes;
+
+    wRet = LIBIPMI_HL_IsBondEnabled(pSession, BondEnable,  timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_GetPHYConfigTable: Error getting number of LAN Interface entries\n");
+        return wRet;
+    }
+
+    wRet = LIBIPMI_HL_GetLANCount( pSession, &numOfLANInterfaces, LANChannels, timeout);
+    if(wRet !=0)
+    {
+        printf("LIBIPMI_HL_GetPHYConfigTable: Error in getting LAN count\n");
+        return wRet;
+    }
+
+    for(; index < numOfLANInterfaces; index++)
+    {
+        /*Skip if bond is enabled*/
+        if(BondEnable[0] == 1)
+        {
+            if(BondEnable[1] == LANChannels[index])
+            {
+                continue;
+            }
+        }
+
+        wRet =LIBIPMI_HL_GetChannelNum(pSession, LANChannels[index],&Channel, timeout);
+        if(wRet !=0)
+        {
+            printf("Error in Getting Channel number for Index :%d\n",LANChannels[index]);
+            continue;
+        }
+
+        /*Getting PHY Configuration settings*/
+        memset(&phyConfigRes, 0, sizeof(phyConfigRes));
+        wRet = LIBIPMI_HL_GetPHYConfig(pSession, Channel, &phyConfigRes, timeout);
+        if(wRet != 0)
+        {
+            printf("LIBIPMI_HL_GetPHYConfigTable: Error getting PHY Configuration Entry for channel %d\n", LANChannels[index]);
+            return wRet;
+        }
+        memcpy(pPHYConfigTable,&phyConfigRes,sizeof(PHYConfig_T));
+        pPHYConfigTable++;
+        IfcCount++;
+    }
+
+    *pNumOfLANInterfaces = IfcCount;
+    return wRet;
+}
+
+
+uint16_t LIBIPMI_HL_SetPHYConfig(IPMI20_SESSION_T *pSession, uint8_t Channel, uint8_t AutoNegotiation,
+			       uint16_t Speed, uint8_t Duplex, int timeout)
+{
+	int wRet = 0;
+	SetLanConfigReq_T setLANReqBuff;
+	SetLanConfigRes_T setLANResBuff;
+	unsigned int ReqDataLen = 0;
+
+	memset(&(setLANReqBuff), 0, sizeof(SetLanConfigReq_T));
+	setLANReqBuff.ChannelNum = Channel;
+	setLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_PHY_SETTINGS);
+
+	setLANReqBuff.ConfigData.PHYConfig.AutoNegotiationEnable = AutoNegotiation;
+    if(AutoNegotiation == TRUE) 
+    { 
+            setLANReqBuff.ConfigData.PHYConfig.Speed = 0xFFFF; 
+            setLANReqBuff.ConfigData.PHYConfig.Duplex = 0xFF; 
+    } 
+    else 
+    { 	
+	setLANReqBuff.ConfigData.PHYConfig.Speed = Speed;
+	setLANReqBuff.ConfigData.PHYConfig.Duplex = Duplex;	
+    }
+    
+	ReqDataLen = 6; // Channel Number + Parameter Selector + Configuration Parameter Data 
+	wRet = IPMICMD_SetLANConfig(pSession, &setLANReqBuff, ReqDataLen, &setLANResBuff, timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_SetPHYConfig: Error setting LAN configuration for channel %d\n", Channel);
+		return wRet;
+	}
+
+	TDBG("Success setting PHY configuration for channel::%d\n", Channel);
+	return wRet;
+}
+uint16_t LIBIPMI_HL_SetIPv4Source(IPMI20_SESSION_T *pSession, uint8_t Source,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    SetLanConfigReq_T setLANReqBuff;
+    SetLanConfigRes_T setLANResBuff;
+    unsigned int ReqDataLen = 0;
+
+    memset(&(setLANReqBuff), 0, sizeof(SetLanConfigReq_T));
+    setLANReqBuff.ChannelNum = Channel;
+    setLANReqBuff.ParameterSelect = LAN_PARAM_IP_ADDRESS_SOURCE;
+
+    setLANReqBuff.ConfigData.IPAddrSrc= Source;
+
+    ReqDataLen = 2+(sizeof(setLANReqBuff.ConfigData.IPAddrSrc)); 
+    wRet = IPMICMD_SetLANConfig(pSession, &setLANReqBuff, ReqDataLen, &setLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_SetIPv4Source: Error setting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    TDBG("Success setting IPv4 Address Source configuration for channel::%d\n", Channel);
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetIPv4Source(IPMI20_SESSION_T *pSession, uint8_t *Source,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    GetLanConfigReq_T getLANReqBuff;
+    GetLanConfigRes_T getLANResBuff;
+
+    getLANReqBuff.ChannelNum = Channel;
+    getLANReqBuff.ParameterSelect = LAN_PARAM_IP_ADDRESS_SOURCE;
+    getLANReqBuff.SetSelect = 0;
+    getLANReqBuff.BlockSelect = 0;
+
+    wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_GetIPv4Source: Error getting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    TDBG("Success getting IPv4 Address Source Configuration settings for channel: %d\n", Channel);
+    *Source = getLANResBuff.ConfigData.IPAddrSrc;
+
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetMACAddress(IPMI20_SESSION_T *pSession, uint8_t *MACAddr,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    GetLanConfigReq_T getLANReqBuff;
+    GetLanConfigRes_T getLANResBuff;
+
+    getLANReqBuff.ChannelNum = Channel;
+    getLANReqBuff.ParameterSelect = LAN_PARAM_MAC_ADDRESS;
+    getLANReqBuff.SetSelect = 0;
+    getLANReqBuff.BlockSelect = 0;
+
+    wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_GetMACAddress: Error getting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    TDBG("Success getting MAC Address Configuration settings for channel: %d\n", Channel);
+    memcpy(MACAddr,&(getLANResBuff.ConfigData.MACAddr),MAC_ADDR_LEN);
+
+    return wRet;
+
+}
+
+uint16_t LIBIPMI_HL_SetIPv6Source(IPMI20_SESSION_T *pSession, uint8_t Source,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    SetLanConfigReq_T setLANReqBuff;
+    SetLanConfigRes_T setLANResBuff;
+    unsigned int ReqDataLen = 0;
+
+    memset(&(setLANReqBuff), 0, sizeof(SetLanConfigReq_T));
+    setLANReqBuff.ChannelNum = Channel;
+    setLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_SOURCE);
+
+    setLANReqBuff.ConfigData.IPv6_IPAddrSrc= Source;
+
+    ReqDataLen = 2+(sizeof(setLANReqBuff.ConfigData.IPv6_IPAddrSrc)); 
+    wRet = IPMICMD_SetLANConfig(pSession, &setLANReqBuff, ReqDataLen, &setLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_SetIPv6Source: Error setting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    TDBG("Success setting IPv6 Address Source configuration for channel::%d\n", Channel);
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetIPv6Source(IPMI20_SESSION_T *pSession, uint8_t *Source,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    GetLanConfigReq_T getLANReqBuff;
+    GetLanConfigRes_T getLANResBuff;
+
+    getLANReqBuff.ChannelNum = Channel;
+    getLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_SOURCE);
+    getLANReqBuff.SetSelect = 0;
+    getLANReqBuff.BlockSelect = 0;
+
+    wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_GetIPv6Source: Error getting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    TDBG("Success getting IPv6 Address Source Configuration settings for channel: %d\n", Channel);
+    *Source = getLANResBuff.ConfigData.IPv6_IPAddrSrc;
+
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_SetIPv4Address(IPMI20_SESSION_T *pSession, uint8_t *Address,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    SetLanConfigReq_T setLANReqBuff;
+    SetLanConfigRes_T setLANResBuff;
+    unsigned int ReqDataLen = 0;
+
+    memset(&(setLANReqBuff), 0, sizeof(SetLanConfigReq_T));
+    setLANReqBuff.ChannelNum = Channel;
+    setLANReqBuff.ParameterSelect = LAN_PARAM_IP_ADDRESS;
+
+    memcpy(setLANReqBuff.ConfigData.IPAddr,Address,IP_ADDR_LEN);
+
+    ReqDataLen = 2+(sizeof(setLANReqBuff.ConfigData.IPAddr)); 
+    wRet = IPMICMD_SetLANConfig(pSession, &setLANReqBuff, ReqDataLen, &setLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_SetIPv4Address: Error setting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    TDBG("Success setting IPv4 Address  configuration for channel::%d\n", Channel);
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_EnableVlan (IPMI20_SESSION_T *pSession, uint8_t VlanStatus, uint16_t vlanID, uint8_t Priority, uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    SetLanConfigReq_T setLANReqBuff;
+    SetLanConfigRes_T setLANResBuff;
+    unsigned int ReqDataLen = 0;
+
+    /*Enable & Give Vlan ID */
+    memset(&(setLANReqBuff), 0, sizeof(SetLanConfigReq_T));
+    setLANReqBuff.ChannelNum = Channel;
+    setLANReqBuff.ParameterSelect = LAN_PARAM_VLAN_ID;
+
+    if ((VlanStatus > 0x01) || (vlanID > 0x0FFF))
+    {
+        wRet = CC_PARAM_OUT_OF_RANGE;
+    }
+    
+    setLANReqBuff.ConfigData.VLANID = (vlanID | (VlanStatus <<15));
+    ReqDataLen = 2+(sizeof(setLANReqBuff.ConfigData.VLANID));
+    wRet = IPMICMD_SetLANConfig(pSession, &setLANReqBuff, ReqDataLen, &setLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_EnableVlan: Error setting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    /*If Vlan Enabled Set the Priority*/
+    if (VlanStatus == 0x01)
+    {
+        memset(&(setLANReqBuff), 0, sizeof(SetLanConfigReq_T));
+        setLANReqBuff.ChannelNum = Channel;
+        setLANReqBuff.ParameterSelect = LAN_PARAM_VLAN_PRIORITY;
+        if (Priority > 0x07)
+        {
+            wRet = CC_PARAM_OUT_OF_RANGE;
+        }
+        setLANReqBuff.ConfigData.VLANPriority = Priority;
+        ReqDataLen = 2+(sizeof(setLANReqBuff.ConfigData.VLANPriority));
+        wRet = IPMICMD_SetLANConfig(pSession, &setLANReqBuff, ReqDataLen, &setLANResBuff, timeout);
+        if(wRet != 0)
+        {
+            printf("LIBIPMI_HL_SetVlanPriority: Error setting LAN configuration for channel %d\n", Channel);
+            return wRet;
+        }
+    }
+    return wRet;
+}
+
+
+uint16_t LIBIPMI_HL_GetVlanStatus (IPMI20_SESSION_T *pSession, uint8_t *VlanStatus, uint16_t *vlanID, uint8_t *Priority, uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    GetLanConfigReq_T getLANReqBuff;
+    GetLanConfigRes_T getLANResBuff;
+
+    getLANReqBuff.ChannelNum = Channel;
+    getLANReqBuff.ParameterSelect = LAN_PARAM_VLAN_ID;
+    getLANReqBuff.SetSelect = 0;
+    getLANReqBuff.BlockSelect = 0;
+    wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_GetVlanStatus: Error getting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+    *vlanID = (getLANResBuff.ConfigData.VLANID & 0x0FFF);
+    *VlanStatus = 0;
+
+    if ((getLANResBuff.ConfigData.VLANID & VLAN_STATUS_BIT) == VLAN_STATUS_BIT)
+    {
+        *VlanStatus = 1;
+        memset(&(getLANReqBuff), 0, sizeof(GetLanConfigReq_T));
+        memset(&(getLANResBuff), 0, sizeof(GetLanConfigRes_T));
+        getLANReqBuff.ChannelNum = Channel;
+        getLANReqBuff.ParameterSelect = LAN_PARAM_VLAN_PRIORITY;
+        getLANReqBuff.SetSelect = 0;
+        getLANReqBuff.BlockSelect = 0;
+    
+        wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+        if(wRet != 0)
+        {
+            printf("LIBIPMI_HL_GetVlanPriority: Error getting LAN configuration for channel %d\n", Channel);
+            return wRet;
+        }
+        *Priority = getLANResBuff.ConfigData.VLANPriority;
+    }
+
+     return wRet;
+}
+
+
+
+uint16_t LIBIPMI_HL_GetIPv4Address(IPMI20_SESSION_T *pSession, uint8_t *Address,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    GetLanConfigReq_T getLANReqBuff;
+    GetLanConfigRes_T getLANResBuff;
+
+    getLANReqBuff.ChannelNum = Channel;
+    getLANReqBuff.ParameterSelect = LAN_PARAM_IP_ADDRESS;
+    getLANReqBuff.SetSelect = 0;
+    getLANReqBuff.BlockSelect = 0;
+
+    wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_GetIPv4Address: Error getting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    memcpy(Address,getLANResBuff.ConfigData.IPAddr,4);
+    TDBG("Success getting IPv4 Address Configuration settings for channel: %d\n", Channel);
+
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_SetIPv6Address(IPMI20_SESSION_T *pSession, uint8_t *Address,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    SetLanConfigReq_T setLANReqBuff;
+    SetLanConfigRes_T setLANResBuff;
+    unsigned int ReqDataLen = 0;
+
+    memset(&(setLANReqBuff), 0, sizeof(SetLanConfigReq_T));
+    setLANReqBuff.ChannelNum = Channel;
+    setLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR);
+
+    memcpy(setLANReqBuff.ConfigData.IPv6Addr.IPv6_IPAddr,Address,IP6_ADDR_LEN);
+    setLANReqBuff.ConfigData.IPv6Addr.IPv6_Cntr = 0;
+
+    ReqDataLen = 2 + (sizeof(IPv6Addr_T)); 
+    wRet = IPMICMD_SetLANConfig(pSession, &setLANReqBuff, ReqDataLen, &setLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_SetIPv6Address: Error setting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    TDBG("Success setting IPv6 Address  configuration for channel::%d\n", Channel);
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetAllIPv6Addresses(IPMI20_SESSION_T *pSession, uint8_t Channel, uint8_t *Address, uint8_t *pIPCount, int timeout)
+{
+	uint16_t wRet = 0, i = 0;	
+	uint8_t tmp[IP6_ADDR_LEN];
+	GetLanConfigReq_T getLANReqBuff;
+	GetLanConfigRes_T getLANResBuff;
+
+	GetAllIPv6Address_T *pReqAddress = (GetAllIPv6Address_T *)Address;
+	*pIPCount = 0;
+
+	getLANReqBuff.ChannelNum = Channel;
+	getLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR);
+	getLANReqBuff.BlockSelect = 0;
+	
+	memset(tmp,0x0,sizeof(tmp)); // To identify empty IPv6 Address
+
+	// Retrieving all the IPV6 Addresses for the channel 
+	for ( i = 0 ; i < MAX_IPV6_ADDRS ; i++ ) 
+	{
+		getLANReqBuff.SetSelect = i;
+		wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+		if(wRet != 0)
+		{
+		        printf("LIBIPMI_HL_GetAllIPv6Addresses: Error getting LAN configuration for channel %d\n", Channel);
+		        return wRet;
+		}
+
+		// If the retrieved address is valid
+		if ( memcmp(&(getLANResBuff.ConfigData.IPv6_LinkAddr),tmp,IP6_ADDR_LEN) != 0 )
+		{
+			GetLanConfigReq_T getLANCfgReqPrefix;
+			GetLanConfigRes_T getLANCfgResPrefix;
+
+			//Retrieving IPv6 Subnet Mask Prefix
+			getLANCfgReqPrefix.ChannelNum = Channel;
+		        getLANCfgReqPrefix.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH);
+		        getLANCfgReqPrefix.BlockSelect = 0;
+			getLANCfgReqPrefix.SetSelect = i;
+			
+			wRet = IPMICMD_GetLANConfig(pSession, &getLANCfgReqPrefix, &getLANCfgResPrefix, timeout);
+	                if(wRet != 0)
+        	        {
+                	        printf("LIBIPMI_HL_GetAllIPv6Addresses: Error getting LAN configuration for channel %d\n", Channel);
+                        	return wRet;
+	                }
+
+			// Copying the IPv6 Address and subnet mask prefix
+			memcpy(&(pReqAddress->Address[*pIPCount]),&(getLANResBuff.ConfigData.IPv6_LinkAddr),IP6_ADDR_LEN);
+				
+			pReqAddress->Prefix[*pIPCount] = getLANCfgResPrefix.ConfigData.IPv6_LinkAddrPrefix;
+			*pIPCount += 1;
+		}
+	}
+
+	// Retriving IPv6 Source info for the corresponding channel
+ 	if ( (wRet = LIBIPMI_HL_GetIPv6Source(pSession,&(pReqAddress->Source),Channel,timeout)) != 0 )		
+	{
+		printf("LIBIPMI_HL_GetAllIPv6Addresses: Error getting LAN configuration for channel %d\n", Channel);
+                return wRet;
+	}
+	
+	TDBG("Success retrieving all IPv6 Addresses for channel: %d\n", Channel);
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetIPv6Address(IPMI20_SESSION_T *pSession, uint8_t *Address,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    GetLanConfigReq_T getLANReqBuff;
+    GetLanConfigRes_T getLANResBuff;
+
+    getLANReqBuff.ChannelNum = Channel;
+    getLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR);
+    getLANReqBuff.SetSelect = 0;
+    getLANReqBuff.BlockSelect = 0;
+
+    wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_GetIPv6Address: Error getting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    memcpy(Address,&(getLANResBuff.ConfigData.IPv6_LinkAddr),IP6_ADDR_LEN);
+    TDBG("Success getting IPv6 Address Configuration settings for channel: %d\n", Channel);
+
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetIPv6LinkAddress(IPMI20_SESSION_T *pSession, uint8_t *Address,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+
+    GetLanConfigReq_T getLANReqBuff;
+    GetLanConfigRes_T getLANResBuff;
+
+    getLANReqBuff.ChannelNum = Channel;
+    getLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_IPV6_LINK_ADDR);
+    getLANReqBuff.SetSelect = 0;
+    getLANReqBuff.BlockSelect = 0;
+
+    wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_GetIPv6LinkAddr: Error getting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    memcpy(Address,&(getLANResBuff.ConfigData.IPv6_LinkAddr),IP6_ADDR_LEN);
+    TDBG("Success getting IPv6 Link Address Configuration settings for channel: %d\n", Channel);
+
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_SetIPv4NetMask(IPMI20_SESSION_T *pSession, uint8_t *Mask,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    SetLanConfigReq_T setLANReqBuff;
+    SetLanConfigRes_T setLANResBuff;
+    unsigned int ReqDataLen = 0;
+
+    memset(&(setLANReqBuff), 0, sizeof(SetLanConfigReq_T));
+    setLANReqBuff.ChannelNum = Channel;
+    setLANReqBuff.ParameterSelect = LAN_PARAM_SUBNET_MASK;
+
+    memcpy(setLANReqBuff.ConfigData.SubNetMask,Mask,IP_ADDR_LEN);
+
+    ReqDataLen = 2+(sizeof(setLANReqBuff.ConfigData.SubNetMask)); 
+    wRet = IPMICMD_SetLANConfig(pSession, &setLANReqBuff, ReqDataLen, &setLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_SetIPv4NetMask: Error setting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    TDBG("Success setting IPv4 NetMask configuration for channel::%d\n", Channel);
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetIPv4NetMask(IPMI20_SESSION_T *pSession, uint8_t *Mask,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    GetLanConfigReq_T getLANReqBuff;
+    GetLanConfigRes_T getLANResBuff;
+
+    getLANReqBuff.ChannelNum = Channel;
+    getLANReqBuff.ParameterSelect = LAN_PARAM_SUBNET_MASK;
+    getLANReqBuff.SetSelect = 0;
+    getLANReqBuff.BlockSelect = 0;
+
+    wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_GetIPv4NetMask: Error getting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    memcpy(Mask,&(getLANResBuff.ConfigData.SubNetMask),IP_ADDR_LEN);
+    TDBG("Success getting IPv4 NetMask Configuration settings for channel: %d\n", Channel);
+
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_SetIPv6Prefix(IPMI20_SESSION_T *pSession, uint8_t Prefix,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    SetLanConfigReq_T setLANReqBuff;
+    SetLanConfigRes_T setLANResBuff;
+    unsigned int ReqDataLen = 0;
+
+    memset(&(setLANReqBuff), 0, sizeof(SetLanConfigReq_T));
+    setLANReqBuff.ChannelNum = Channel;
+    setLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH);
+
+    setLANReqBuff.ConfigData.IPv6Prefix.IPv6_PrefixLen= Prefix;
+    setLANReqBuff.ConfigData.IPv6Prefix.IPv6_Prepos = 0;
+
+    ReqDataLen = 2+(sizeof (IPv6Prefix_T)); 
+    wRet = IPMICMD_SetLANConfig(pSession, &setLANReqBuff, ReqDataLen, &setLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_SetIPv6Prefix: Error setting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    TDBG("Success setting IPv6 Prefix Length configuration for channel::%d\n", Channel);
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetIPv6Prefix(IPMI20_SESSION_T *pSession, uint8_t *Prefix,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    GetLanConfigReq_T getLANReqBuff;
+    GetLanConfigRes_T getLANResBuff;
+
+    getLANReqBuff.ChannelNum = Channel;
+    getLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH);
+    getLANReqBuff.SetSelect = 0;
+    getLANReqBuff.BlockSelect = 0;
+
+    wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_GetIPv6Prefix: Error getting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    *Prefix = getLANResBuff.ConfigData.IPv6_LinkAddrPrefix;
+    TDBG("Success getting IPv6 Prefix Configuration settings for channel: %d\n", Channel);
+
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetIPv6LinkPrefix (IPMI20_SESSION_T *pSession, uint8_t *Prefix,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    GetLanConfigReq_T getLANReqBuff;
+    GetLanConfigRes_T getLANResBuff;
+
+    getLANReqBuff.ChannelNum = Channel;
+    getLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_IPV6_LINK_ADDR_PREFIX);
+    getLANReqBuff.SetSelect = 0;
+    getLANReqBuff.BlockSelect = 0;
+
+    wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_GetIPv6LinkPrefix: Error getting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    *Prefix = getLANResBuff.ConfigData.IPv6_LinkAddrPrefix;
+    TDBG("Success getting IPv6 LinkPrefix Configuration settings for channel: %d\n", Channel);
+
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_SetIPv4Gateway(IPMI20_SESSION_T *pSession, uint8_t *Gateway,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    SetLanConfigReq_T setLANReqBuff;
+    SetLanConfigRes_T setLANResBuff;
+    unsigned int ReqDataLen = 0;
+
+    memset(&(setLANReqBuff), 0, sizeof(SetLanConfigReq_T));
+    setLANReqBuff.ChannelNum = Channel;
+    setLANReqBuff.ParameterSelect = LAN_PARAM_DEFAULT_GATEWAY_IP;
+
+    memcpy(setLANReqBuff.ConfigData.DefaultGatewayIPAddr,Gateway,IP_ADDR_LEN);
+
+    ReqDataLen = 2+(sizeof(setLANReqBuff.ConfigData.DefaultGatewayIPAddr)); 
+    wRet = IPMICMD_SetLANConfig(pSession, &setLANReqBuff, ReqDataLen, &setLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_SetIPv4Gateway: Error setting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    TDBG("Success setting IPv4 Default Gateway Address configuration for channel::%d\n", Channel);
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetIPv4Gateway(IPMI20_SESSION_T *pSession, uint8_t *Gateway,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    GetLanConfigReq_T getLANReqBuff;
+    GetLanConfigRes_T getLANResBuff;
+
+    getLANReqBuff.ChannelNum = Channel;
+    getLANReqBuff.ParameterSelect = LAN_PARAM_DEFAULT_GATEWAY_IP;
+    getLANReqBuff.SetSelect = 0;
+    getLANReqBuff.BlockSelect = 0;
+
+    wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_GetIPv4Gateway: Error getting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    memcpy(Gateway,&(getLANResBuff.ConfigData.DefaultGatewayIPAddr),IP_ADDR_LEN);
+    TDBG("Success getting IPv4 Gateway Configuration settings for channel: %d\n", Channel);
+
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_SetIPv6Gateway(IPMI20_SESSION_T *pSession, uint8_t *Gateway,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    SetLanConfigReq_T setLANReqBuff;
+    SetLanConfigRes_T setLANResBuff;
+    unsigned int ReqDataLen = 0;
+
+    memset(&(setLANReqBuff), 0, sizeof(SetLanConfigReq_T));
+    setLANReqBuff.ChannelNum = Channel;
+    setLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_IPV6_GATEWAY_IP);
+
+    memcpy(setLANReqBuff.ConfigData.IPv6_GatewayIPAddr,Gateway,IP6_ADDR_LEN);
+
+    ReqDataLen = 2+(sizeof(setLANReqBuff.ConfigData.IPv6_GatewayIPAddr)); 
+    wRet = IPMICMD_SetLANConfig(pSession, &setLANReqBuff, ReqDataLen, &setLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_SetIPv6Gateway: Error setting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    TDBG("Success setting IPv6 Gateway Address configuration for channel::%d\n", Channel);
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetIPv6Gateway(IPMI20_SESSION_T *pSession, uint8_t *Gateway,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    GetLanConfigReq_T getLANReqBuff;
+    GetLanConfigRes_T getLANResBuff;
+
+    getLANReqBuff.ChannelNum = Channel;
+    getLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_IPV6_GATEWAY_IP);
+    getLANReqBuff.SetSelect = 0;
+    getLANReqBuff.BlockSelect = 0;
+
+    wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_GetIPv6Gateway: Error getting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    memcpy(Gateway,&(getLANResBuff.ConfigData.IPv6_GatewayIPAddr),IP6_ADDR_LEN);
+    TDBG("Success getting IPv6 Gateway Configuration settings for channel: %d\n", Channel);
+
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_SetIPv6Enable(IPMI20_SESSION_T *pSession, uint8_t Enable,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    SetLanConfigReq_T setLANReqBuff;
+    SetLanConfigRes_T setLANResBuff;
+    unsigned int ReqDataLen = 0;
+
+    memset(&(setLANReqBuff), 0, sizeof(SetLanConfigReq_T));
+    setLANReqBuff.ChannelNum = Channel;
+    setLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_IPV6_ENABLE);
+
+    setLANReqBuff.ConfigData.IPv6_Enable= Enable;
+
+    ReqDataLen = 2+(sizeof(setLANReqBuff.ConfigData.IPv6_Enable)); 
+    wRet = IPMICMD_SetLANConfig(pSession, &setLANReqBuff, ReqDataLen, &setLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_SetIPv6Source: Error setting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    TDBG("Success setting IPv6 Address Source configuration for channel::%d\n", Channel);
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetIPv6Enable(IPMI20_SESSION_T *pSession, uint8_t *Enable,uint8_t Channel, int timeout)
+{
+    int wRet = 0;
+    GetLanConfigReq_T getLANReqBuff;
+    GetLanConfigRes_T getLANResBuff;
+
+    getLANReqBuff.ChannelNum = Channel;
+    getLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_IPV6_ENABLE);
+    getLANReqBuff.SetSelect = 0;
+    getLANReqBuff.BlockSelect = 0;
+
+    wRet = IPMICMD_GetLANConfig(pSession, &getLANReqBuff, &getLANResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("LIBIPMI_HL_GetIPv6Enable: Error getting LAN configuration for channel %d\n", Channel);
+        return wRet;
+    }
+
+    *Enable = getLANResBuff.ConfigData.IPv6_Enable;
+    TDBG("Success getting IPv6 Eanble Configuration settings for channel: %d\n", Channel);
+
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetIPv4NetworkCfg(IPMI20_SESSION_T *pSession, 
+					uint8_t *Source,
+					uint8_t *Address,
+					uint8_t *Mask,
+					uint8_t *Gateway,
+					uint8_t Channel,
+					int timeout)
+{
+	int wRet = 0;
+	wRet = LIBIPMI_HL_GetIPv4Source(pSession, Source, Channel,timeout);
+	if (wRet != 0)
+	{
+		printf ("LIBIPMI, Error getting IPv4 Address Source::%x\n",wRet);
+		return wRet;
+	}
+
+	wRet = LIBIPMI_HL_GetIPv4Address(pSession, Address, Channel, timeout);
+	if (wRet != 0)
+	{
+		printf ("LIBIPMI, Error getting IPv4 Address ::%x\n",wRet);
+		return wRet;
+	}
+
+	wRet = LIBIPMI_HL_GetIPv4NetMask(pSession, Mask, Channel, timeout);
+	if (wRet != 0)
+	{
+		printf ("LIBIPMI, Error getting IPv4 Netmask ::%x\n",wRet);
+		return wRet;
+	}
+
+	wRet = LIBIPMI_HL_GetIPv4Gateway(pSession, Gateway, Channel, timeout);
+	if (wRet != 0)
+	{
+		printf ("LIBIPMI, Error getting IPv4 Gateway ::%x\n",wRet);
+		return wRet;
+	}
+
+	return 0;
+}
+
+uint16_t LIBIPMI_HL_SetIPv4NetworkCfg(IPMI20_SESSION_T *pSession,
+                                        uint8_t *Address,
+                                        uint8_t *Mask,
+                                        uint8_t *Gateway,
+                                        uint8_t Channel,
+                                        int timeout)
+{
+        int wRet = 0;
+        wRet = LIBIPMI_HL_SetIPv4Address(pSession, Address, Channel, timeout);
+        if (wRet != 0)
+        {
+                printf ("LIBIPMI, Error getting IPv4 Address ::%x\n",wRet);
+                return wRet;
+        }
+
+        wRet = LIBIPMI_HL_SetIPv4NetMask(pSession, Mask, Channel, timeout);
+        if (wRet != 0)
+        {
+                printf ("LIBIPMI, Error getting IPv4 Netmask ::%x\n",wRet);
+                return wRet;
+        }
+
+        wRet = LIBIPMI_HL_SetIPv4Gateway(pSession, Gateway, Channel, timeout);
+        if (wRet != 0)
+        {
+                printf ("LIBIPMI, Error getting IPv4 Gateway ::%x\n",wRet);
+                return wRet;
+        }
+
+	return 0;
+}
+             
+uint16_t LIBIPMI_HL_GetIPv6NetworkCfg(IPMI20_SESSION_T *pSession, 
+					uint8_t *Source,
+					uint8_t *Address,
+					uint8_t *Prefix,
+					uint8_t *Gateway,
+					uint8_t Channel,
+					int timeout)
+{
+	int wRet = 0;
+
+	wRet = LIBIPMI_HL_GetIPv6Source(pSession, Source, Channel, timeout);
+	if (wRet != 0)
+	{
+		printf ("LIBIPMI, Error getting IPv6 Address Source::%x\n",wRet);
+		return wRet;
+	}
+
+	wRet = LIBIPMI_HL_GetIPv6Address(pSession, Address, Channel, timeout);
+	if (wRet != 0)
+	{
+		printf ("LIBIPMI, Error getting IPv6 Address ::%x\n",wRet);
+		return wRet;
+	}
+
+	wRet = LIBIPMI_HL_GetIPv6Prefix(pSession, Prefix, Channel, timeout);
+	if (wRet != 0)
+	{
+		printf ("LIBIPMI, Error getting IPv6 Prefix ::%x\n",wRet);
+		return wRet;
+	}
+
+	wRet = LIBIPMI_HL_GetIPv6Gateway(pSession, Gateway, Channel, timeout);
+	if (wRet != 0)
+	{
+		printf ("LIBIPMI, Error getting IPv6 Gateway ::%x\n",wRet);
+		return wRet;
+	}
+
+	return 0;
+}
+
+uint16_t LIBIPMI_HL_SetIPv6NetworkCfg(IPMI20_SESSION_T *pSession,
+                                        uint8_t *Address,
+                                        uint8_t Prefix,
+                                        uint8_t *Gateway,
+                                        uint8_t Channel,
+                                        int timeout)
+{
+        int wRet = 0;
+        wRet = LIBIPMI_HL_SetIPv6Address(pSession, Address, Channel, timeout);
+        if (wRet != 0)
+        {
+                printf ("LIBIPMI, Error getting IPv6 Address ::%x\n",wRet);
+                return wRet;
+        }
+
+        wRet = LIBIPMI_HL_SetIPv6Prefix(pSession, Prefix, Channel, timeout);
+        if (wRet != 0)
+        {
+                printf ("LIBIPMI, Error getting IPv6 Prefix ::%x\n",wRet);
+                return wRet;
+        }
+ 
+        wRet = LIBIPMI_HL_SetIPv6Gateway(pSession, Gateway, Channel, timeout);
+        if (wRet != 0)
+        {
+                printf ("LIBIPMI, Error getting IPv6 Gateway ::%x\n",wRet);
+                return wRet;
+        }
+
+	return 0;
+}
+uint16_t LIBIPMI_HL_SetLANDestinationType(IPMI20_SESSION_T *pSession,
+					uint8_t Channel,
+					uint8_t  index,
+					uint8_t desttype,
+					int timeout)
+{
+	int wRet = 0;
+	SetLanConfigReq_T SetLANReqBuff;
+	SetLanConfigRes_T SetLANResBuff;
+	unsigned int ReqDataLen = 0;
+
+	memset(&(SetLANReqBuff),0,sizeof(SetLanConfigReq_T));
+	SetLANReqBuff.ChannelNum = Channel;
+	SetLANReqBuff.ParameterSelect = LAN_PARAM_SELECT_DEST_TYPE;
+
+	SetLANReqBuff.ConfigData.DestType.SetSelect = index;
+	SetLANReqBuff.ConfigData.DestType.DestType = desttype;
+	SetLANReqBuff.ConfigData.DestType.AlertAckTimeout = 3;	//Default ACK Timeout value is 3seconds
+	SetLANReqBuff.ConfigData.DestType.Retries = 3;
+
+	ReqDataLen = 2 + sizeof(LANDestType_T);
+	wRet = IPMICMD_SetLANConfig(pSession, &SetLANReqBuff, ReqDataLen,
+					&SetLANResBuff, timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_SetLANDestinationType, Error setting LAN configuration\n");
+		return wRet;
+	}
+
+	TDBG("Success setting LAN Destination type for index::%d\n",index);
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_SetLANDestinationAddress(IPMI20_SESSION_T *pSession,
+					uint8_t Channel,
+					uint8_t  index,
+					uint8_t addrFormat,
+					uint8_t* destAddr,
+					int timeout)
+{
+	int wRet = 0;
+	SetLanConfigReq_T SetLANReqBuff;
+	SetLanConfigRes_T SetLANResBuff;
+	unsigned int ReqDataLen = 0;
+
+	memset(&(SetLANReqBuff),0,sizeof(SetLanConfigReq_T));
+	SetLANReqBuff.ChannelNum = Channel;
+	SetLANReqBuff.ParameterSelect = LAN_PARAM_SELECT_DEST_ADDR;
+
+	SetLANReqBuff.ConfigData.DestAddr.SetSelect = index;
+	//SetLANReqBuff.ConfigData.DestAddr.AddrFormat = addrFormat;
+	memcpy(SetLANReqBuff.ConfigData.DestAddr.IPAddr, destAddr, IP_ADDR_LEN);
+	
+	ReqDataLen = 2 + sizeof(LANDestAddr_T);
+	wRet = IPMICMD_SetLANConfig(pSession, &SetLANReqBuff, ReqDataLen,
+					&SetLANResBuff, timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_SetLANDestinationAddress, Error setting LAN configuration\n");
+		return wRet;
+	}
+
+	TDBG("Success setting LAN Destination Address for index::%d\n",index);
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_SetLANDestinationV6Address(IPMI20_SESSION_T *pSession,
+					uint8_t Channel,
+					uint8_t  index,
+					uint8_t addrFormat,
+					uint8_t* destAddr,
+					int timeout)
+{
+	int wRet = 0;
+	SetLanConfigReq_T SetLANReqBuff;
+	SetLanConfigRes_T SetLANResBuff;
+	unsigned int ReqDataLen = 0;
+
+	memset(&(SetLANReqBuff),0,sizeof(SetLanConfigReq_T));
+	SetLANReqBuff.ChannelNum = Channel;
+	SetLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR);
+
+	SetLANReqBuff.ConfigData.Destv6Addr.SetSelect = index;
+	//SetLANReqBuff.ConfigData.Destv6Addr.AddrFormat = addrFormat;
+	memcpy(SetLANReqBuff.ConfigData.Destv6Addr.IPAddr, destAddr, IP6_ADDR_LEN);
+	
+	ReqDataLen = 2 + sizeof(LANDestv6Addr_T);
+	wRet = IPMICMD_SetLANConfig(pSession, &SetLANReqBuff, ReqDataLen,
+					&SetLANResBuff, timeout);
+	if(wRet != 0)
+	{
+		printf("LIBIPMI_HL_SetLANDestinationV6Address, Error setting LAN configuration\n");
+		return wRet;
+	}
+
+	TDBG("Success setting LAN Destination V6 Address for index::%d\n",index);
+	return wRet;
+}
+
+
+uint16_t LIBIPMI_HL_SetLANAlertEntry(IPMI20_SESSION_T *pSession,
+					uint8_t DestSel,
+					uint8_t* pDestAddr,uint8_t Channel,
+					int timeout)
+{
+	int wRet;
+	SetLanConfigReq_T SetLANReqBuff;
+	SetLanConfigRes_T SetLANResBuff;
+	unsigned int ReqDataLen = 0;
+
+	memset(&(SetLANReqBuff),0,sizeof(SetLanConfigReq_T));
+
+	SetLANReqBuff.ChannelNum = Channel;
+	SetLANReqBuff.ParameterSelect = 19;
+
+	SetLANReqBuff.ConfigData.DestAddr.SetSelect = DestSel;
+
+	memcpy(SetLANReqBuff.ConfigData.DestAddr.IPAddr,pDestAddr,IP_ADDR_LEN);
+
+	ReqDataLen = 2 + sizeof(LANDestAddr_T);
+	wRet = IPMICMD_SetLANConfig(pSession,
+					&SetLANReqBuff,
+					ReqDataLen,
+					&SetLANResBuff, timeout);
+	if(wRet != 0)
+	{
+		printf("Error setting LAN Alert destinations IP %d\n",wRet);
+	}
+
+	TDBG("Success setting LAN Alert destinations IP\n");
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_SetLANAlertEntry_IPv6(IPMI20_SESSION_T *pSession,
+					uint8_t DestSel,
+					uint8_t* pDestAddr,uint8_t Channel,
+					int timeout)
+{
+	int wRet;
+	SetLanConfigReq_T SetLANReqBuff;
+	SetLanConfigRes_T SetLANResBuff;
+	unsigned int ReqDataLen = 0;
+
+	memset(&(SetLANReqBuff),0,sizeof(SetLanConfigReq_T));
+
+	SetLANReqBuff.ChannelNum = Channel;
+	SetLANReqBuff.ParameterSelect = GetLanOEMParamValue (LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR);
+
+	SetLANReqBuff.ConfigData.Destv6Addr.SetSelect = DestSel;
+
+	memcpy(SetLANReqBuff.ConfigData.Destv6Addr.IPAddr,pDestAddr,IP6_ADDR_LEN);
+
+	ReqDataLen = 2 + sizeof(LANDestv6Addr_T);
+	wRet = IPMICMD_SetLANConfig(pSession,
+					&SetLANReqBuff,
+					ReqDataLen,
+					&SetLANResBuff, timeout);
+	if(wRet != 0)
+	{
+		printf("Error setting LAN Alert destinations IP %d\n",wRet);
+	}
+
+	TDBG("Success setting LAN Alert destinations IP\n");
+	return wRet;
+}
+
+uint16_t IPMICMD_SetLANAlertEntryType(IPMI20_SESSION_T *pSession,
+					uint8_t DestSel,
+					uint8_t AlertType,uint8_t Channel,
+					int timeout)
+{
+	int wRet;
+	SetLanConfigReq_T SetLANReqBuff;
+	SetLanConfigRes_T SetLANResBuff;
+	unsigned int ReqDataLen = 0;
+
+	memset(&(SetLANReqBuff),0,sizeof(SetLanConfigReq_T));
+
+	SetLANReqBuff.ChannelNum = Channel;
+	SetLANReqBuff.ParameterSelect = 18;
+
+	SetLANReqBuff.ConfigData.DestType.AlertAckTimeout = 3;
+	SetLANReqBuff.ConfigData.DestType.Retries = 3;
+	SetLANReqBuff.ConfigData.DestType.SetSelect = DestSel;
+
+	if(AlertType == 0)
+	{
+		/* SNMP  is Index 0 is for volatile */
+		SetLANReqBuff.ConfigData.DestType.DestType = 0x00;
+	}
+	else
+	{
+		SetLANReqBuff.ConfigData.DestType.DestType = 0x06;
+	}
+
+	ReqDataLen = 2 + sizeof(LANDestType_T);
+	wRet = IPMICMD_SetLANConfig(pSession,
+					&SetLANReqBuff,
+					ReqDataLen,
+					&SetLANResBuff, timeout);
+	if(wRet != 0)
+	{
+		printf("Error setting LAN Alert Type %d\n",wRet);
+	}
+
+	TDBG("Success setting LAN Alert Type\n");
+	return wRet;
+}
+
+uint16_t IPMICMD_Set_IFACE_State( IPMI20_SESSION_T *pSession,
+                             AMISetIfaceStateReq_T *pGetLANEnableReq,
+                             unsigned int ReqDataLen,
+                             AMISetIfaceStateRes_T *pGetLANEnableRes,
+                             int timeout )
+{
+    uint16_t wRet;
+    uint32_t dwResLen;
+    dwResLen = sizeof(AMISetIfaceStateRes_T);
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+                                                                            (NETFN_AMI << 2), CMD_AMI_SET_IFACE_STATE,
+                                                                            (uint8_t*)pGetLANEnableReq, ReqDataLen,
+                                                                            (uint8_t*)pGetLANEnableRes, &dwResLen,
+                                                                            timeout);
+    if(wRet != 0)
+    {
+    printf("Error in Setting Interface state in raw IPMI command layer::%d\n", wRet);
+    }
+    return (wRet);
+}
+
+uint16_t IPMICMD_Get_IFACE_State( IPMI20_SESSION_T *pSession,
+                             AMIGetIfaceStateReq_T *pGetLANEnableReq,
+                             AMIGetIfaceStateRes_T *pGetLANEnableRes,
+                             int timeout )
+{
+    uint16_t wRet;
+    uint32_t dwResLen;
+    dwResLen = sizeof(AMIGetIfaceStateRes_T);
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+                        (NETFN_AMI << 2), CMD_AMI_GET_IFACE_STATE,
+                        (uint8_t*)pGetLANEnableReq, sizeof(AMIGetIfaceStateReq_T),
+                        (uint8_t*)pGetLANEnableRes, &dwResLen,
+                        timeout);
+    if(wRet != 0)
+    {
+        printf("Error in getting Interface state in raw IPMI command layer::%d\n", wRet);
+    }
+    return (wRet);
+}
+
+uint16_t LIBIPMI_HL_GetLANEnable(IPMI20_SESSION_T *pSession,
+                                                                uint8_t EthIndex, uint8_t *LANEnable, int timeout)
+{
+    int wRet;
+    AMIGetIfaceStateReq_T GetLANEnableReqBuff;
+    AMIGetIfaceStateRes_T GetLANEnableResBuff;
+
+    memset(&(GetLANEnableReqBuff), 0, sizeof(GetLANEnableReqBuff));
+
+    GetLANEnableReqBuff.SetSelect= EthIndex;
+    GetLANEnableReqBuff.Params = AMI_IFACE_STATE_ETH;
+
+    wRet = IPMICMD_Get_IFACE_State(pSession, &GetLANEnableReqBuff, &GetLANEnableResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("Error in getting LAN Enable in Libipmi layer ::%d\n", wRet);
+    }
+
+    *LANEnable = GetLANEnableResBuff.ConfigData.EthIface.EnableState;
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_SetLANEnable(IPMI20_SESSION_T *pSession,
+                                                                uint8_t EthIndex, uint8_t LANEnable, int timeout)
+{
+    int wRet;
+    AMISetIfaceStateReq_T GetLANEnableReqBuff;
+    AMISetIfaceStateRes_T GetLANEnableResBuff;
+    unsigned int ReqLanData=0;
+
+    memset(&(GetLANEnableReqBuff), 0, sizeof(GetLANEnableReqBuff));
+
+    GetLANEnableReqBuff.Params = AMI_IFACE_STATE_ETH;
+    GetLANEnableReqBuff.ConfigData.EthIface.EthIndex = EthIndex;
+    GetLANEnableReqBuff.ConfigData.EthIface.EnableState = LANEnable;
+
+    ReqLanData = 3;
+    wRet = IPMICMD_Set_IFACE_State(pSession, &GetLANEnableReqBuff, ReqLanData,&GetLANEnableResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("Error in Setting LAN Enable in Libipmi layer ::%d\n", wRet);
+    }
+
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetBondEnable(IPMI20_SESSION_T * pSession, 
+                                                                    uint8_t Index, uint8_t * BondCfg, int timeout)
+{
+    int wRet;
+    AMIGetIfaceStateReq_T GetLANEnableReqBuff;
+    AMIGetIfaceStateRes_T GetLANEnableResBuff;
+
+    memset(&(GetLANEnableReqBuff), 0, sizeof(GetLANEnableReqBuff));
+
+    GetLANEnableReqBuff.SetSelect= Index;
+    GetLANEnableReqBuff.Params = AMI_IFACE_STATE_BOND;
+
+    wRet = IPMICMD_Get_IFACE_State(pSession, &GetLANEnableReqBuff, &GetLANEnableResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("Error in getting GetBondEnable Command ::%d\n", wRet);
+    }
+
+    memcpy(BondCfg,&GetLANEnableResBuff.ConfigData.BondIface,sizeof(BondIface));
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_SetBondEnable(IPMI20_SESSION_T * pSession,
+                                                               uint8_t * BondCfg, int timeout)
+{
+    int wRet;
+    AMISetIfaceStateReq_T GetLANEnableReqBuff;
+    AMISetIfaceStateRes_T GetLANEnableResBuff;
+    unsigned int ReqLanData=0;
+
+    memset(&(GetLANEnableReqBuff), 0, sizeof(GetLANEnableReqBuff));
+
+    GetLANEnableReqBuff.Params = AMI_IFACE_STATE_BOND;
+
+    memcpy(&GetLANEnableReqBuff.ConfigData.BondIface,BondCfg,sizeof(BondIface));
+    ReqLanData = 1 + sizeof(BondIface);
+    wRet = IPMICMD_Set_IFACE_State(pSession, &GetLANEnableReqBuff, ReqLanData,&GetLANEnableResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("Error in Setting SetBondEnable Command ::%d\n", wRet);
+    }
+
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetActiveSlave(IPMI20_SESSION_T * pSession, 
+                                                                    uint8_t Index, uint8_t * Activeslave, int timeout)
+{
+    int wRet;
+    AMIGetIfaceStateReq_T GetLANEnableReqBuff;
+    AMIGetIfaceStateRes_T GetLANEnableResBuff;
+
+    memset(&(GetLANEnableReqBuff), 0, sizeof(GetLANEnableReqBuff));
+
+    GetLANEnableReqBuff.SetSelect= Index;
+    GetLANEnableReqBuff.Params = AMI_BOND_ACTIVE_SLAVE;
+
+    wRet = IPMICMD_Get_IFACE_State(pSession, &GetLANEnableReqBuff, &GetLANEnableResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("Error in getting GetActiveSlave Command ::%d\n", wRet);
+    }
+
+    *Activeslave = GetLANEnableResBuff.ConfigData.ActiveSlave.ActiveIndex;
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_SetActiveSlave(IPMI20_SESSION_T * pSession,uint8_t Index,
+                                                               uint8_t ActiveSlave, int timeout)
+{
+    int wRet;
+    AMISetIfaceStateReq_T GetLANEnableReqBuff;
+    AMISetIfaceStateRes_T GetLANEnableResBuff;
+    unsigned int ReqLanData=0;
+
+    memset(&(GetLANEnableReqBuff), 0, sizeof(GetLANEnableReqBuff));
+
+    GetLANEnableReqBuff.Params = AMI_BOND_ACTIVE_SLAVE;
+
+    GetLANEnableReqBuff.ConfigData.ActiveSlave.BondIndex = Index;
+    GetLANEnableReqBuff.ConfigData.ActiveSlave.ActiveIndex = ActiveSlave;
+    ReqLanData = 1 + sizeof(ActiveSlave_T);
+    wRet = IPMICMD_Set_IFACE_State(pSession, &GetLANEnableReqBuff, ReqLanData,&GetLANEnableResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("Error in Setting SetActiveSalve Command ::%d\n", wRet);
+    }
+
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_IsBondEnabled(IPMI20_SESSION_T * pSession, 
+                                                                    uint8_t * BondEnabled, int timeout)
+{
+    int wRet;
+    AMIGetIfaceStateReq_T GetLANEnableReqBuff;
+    AMIGetIfaceStateRes_T GetLANEnableResBuff;
+
+    memset(&(GetLANEnableReqBuff), 0, sizeof(GetLANEnableReqBuff));
+
+    GetLANEnableReqBuff.SetSelect= 0;
+    GetLANEnableReqBuff.Params = AMI_IFACE_BOND_ENABLED;
+
+    wRet = IPMICMD_Get_IFACE_State(pSession, &GetLANEnableReqBuff, &GetLANEnableResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("Error in getting IsBondEnabled Command ::%d\n", wRet);
+    }
+
+    memcpy(BondEnabled,&GetLANEnableResBuff.ConfigData.BondEnable,sizeof(BondEnabled_T));
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_BondVLANEnabled(IPMI20_SESSION_T * pSession, 
+                                                                    uint8_t * BondVLANEnabled, int timeout)
+{
+    int wRet;
+    AMIGetIfaceStateReq_T GetLANEnableReqBuff;
+    AMIGetIfaceStateRes_T GetLANEnableResBuff;
+
+    memset(&(GetLANEnableReqBuff), 0, sizeof(GetLANEnableReqBuff));
+
+    GetLANEnableReqBuff.SetSelect= 0;
+    GetLANEnableReqBuff.Params = AMI_BOND_VLAN_ENABLED;
+
+    wRet = IPMICMD_Get_IFACE_State(pSession, &GetLANEnableReqBuff, &GetLANEnableResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("Error in getting BondVLANEnabled Command ::%d\n", wRet);
+    }
+
+    *BondVLANEnabled = GetLANEnableResBuff.ConfigData.BondVLAN.Enabled;
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetLANCount(IPMI20_SESSION_T * pSession, 
+                                                         uint8_t* LANCount,uint8_t * LANIndex, int timeout)
+{
+    int wRet;
+    AMIGetIfaceStateReq_T GetLANEnableReqBuff;
+    AMIGetIfaceStateRes_T GetLANEnableResBuff;
+
+    memset(&(GetLANEnableReqBuff), 0, sizeof(GetLANEnableReqBuff));
+
+    GetLANEnableReqBuff.SetSelect= 0;
+    GetLANEnableReqBuff.Params = AMI_GET_IFACE_COUNT;
+
+    wRet = IPMICMD_Get_IFACE_State(pSession, &GetLANEnableReqBuff, &GetLANEnableResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("Error in getting GetLANCount Command ::%d\n", wRet);
+    }
+
+    *LANCount=GetLANEnableResBuff.ConfigData.LANCount.Count;
+
+    memcpy(LANIndex,&GetLANEnableResBuff.ConfigData.LANCount.EthIndex,sizeof(MAX_LAN_CHANNEL));
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetChannelNum(IPMI20_SESSION_T * pSession, 
+                                                                    uint8_t Index, uint8_t * Channel, int timeout)
+{
+    int wRet;
+    AMIGetIfaceStateReq_T GetLANEnableReqBuff;
+    AMIGetIfaceStateRes_T GetLANEnableResBuff;
+
+    memset(&(GetLANEnableReqBuff), 0, sizeof(GetLANEnableReqBuff));
+
+    GetLANEnableReqBuff.SetSelect= Index;
+    GetLANEnableReqBuff.Params = AMI_GET_IFACE_CHANNEL;
+
+    wRet = IPMICMD_Get_IFACE_State(pSession, &GetLANEnableReqBuff, &GetLANEnableResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("Error in getting GetChannelNum Command ::%d\n", wRet);
+    }
+
+    memcpy(Channel,&GetLANEnableResBuff.ConfigData.IfcChannel,sizeof(GetIfcChannel_T));
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetLANIndex(IPMI20_SESSION_T * pSession, 
+                                                                    uint8_t Index, uint8_t * IfcName, int timeout)
+{
+    int wRet;
+    AMIGetIfaceStateReq_T GetLANEnableReqBuff;
+    AMIGetIfaceStateRes_T GetLANEnableResBuff;
+
+    memset(&(GetLANEnableReqBuff), 0, sizeof(GetLANEnableReqBuff));
+
+    GetLANEnableReqBuff.SetSelect= Index;
+    GetLANEnableReqBuff.Params = AMI_GET_IFACE_NAME;
+
+    wRet = IPMICMD_Get_IFACE_State(pSession, &GetLANEnableReqBuff, &GetLANEnableResBuff, timeout);
+    if(wRet != 0)
+    {
+        printf("Error in getting GetLANIndex Command ::%d\n", wRet);
+    }
+
+    memcpy(IfcName,&GetLANEnableResBuff.ConfigData.IfcName,sizeof(GetIfcName_T));
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetSNMPCommunity(IPMI20_SESSION_T *pSession,
+                    uint8_t* pCommunityStr,uint8_t Channel,
+					int timeout)
+{
+	int wRet;
+	GetLanConfigReq_T GetLANReqBuff;
+	GetLanConfigRes_T GetLANResBuff;
+	
+	memset(&(GetLANReqBuff),0,sizeof(GetLanConfigReq_T));
+
+	GetLANReqBuff.ChannelNum =Channel;
+	GetLANReqBuff.ParameterSelect = 16;
+
+    
+	wRet = IPMICMD_GetLANConfig(pSession,
+					&GetLANReqBuff,
+                    &GetLANResBuff, timeout);
+	if(wRet != 0)
+	{
+		printf("Error getting snmp community string %d\n",wRet);
+	}
+
+	memcpy(pCommunityStr,GetLANResBuff.ConfigData.CommunityStr,MAX_COMM_STRING_SIZE);
+
+	TDBG("Success getting SNMP community string\n");
+	return wRet;
+}
+
+
+uint16_t LIBIPMI_HL_SetSNMPCommunity(IPMI20_SESSION_T *pSession,
+                    uint8_t* CommunityStr,uint8_t Channel,
+					int timeout)
+{
+	int wRet;
+	SetLanConfigReq_T SetLANReqBuff;
+	SetLanConfigRes_T SetLANResBuff;
+	unsigned int ReqDataLen = 0;
+
+	memset(&(SetLANReqBuff),0,sizeof(SetLanConfigReq_T));
+
+	SetLANReqBuff.ChannelNum = Channel;
+	SetLANReqBuff.ParameterSelect = 16;
+
+	memcpy(SetLANReqBuff.ConfigData.CommunityStr,CommunityStr,MAX_COMM_STRING_SIZE);
+
+
+	ReqDataLen = 2 + MAX_COMM_STRING_SIZE;
+	wRet = IPMICMD_SetLANConfig(pSession,
+					&SetLANReqBuff,
+					ReqDataLen,
+					&SetLANResBuff, timeout);
+	if(wRet != 0)
+	{
+		printf("Error setting community string %d\n",wRet);
+	}
+
+	TDBG("Success setting community string\n");
+	return wRet;
+}
+
+/**************************************************************************************************/
+/* ****************************** Serial Port Setting Group Starts ********************************/
+/**************************************************************************************************/
+#ifdef TEMPORARILY_UNUSED
+static void DumpBuffer(char *Buffer, int32 size)
+{
+    int32 i;
+    int32 j;
+  
+    for (i=0;i<size;i++)
+    {
+        if ((!(i % 16))&& (i!=0))
+        {
+            printf("   ");
+            for (j=i-16;j<i;j++)
+            {
+                if (isprint((unsigned char)Buffer[j]))
+                    printf("%c",(unsigned char)Buffer[j]);
+                else
+                    printf(".");
+            }
+            printf("\n");
+        }
+	printf("%02X ",(unsigned char)Buffer[i]);
+    }
+    printf("   ");
+    
+    if (size%16)
+    {
+        for(j=0;j<(16-(size%16));j++)
+            printf("   ");
+    }
+  
+    for(j=(size-1)-((size-1)%16);j<size;j++)
+    {
+        if (isprint((unsigned char)Buffer[j]))
+            printf("%c",(unsigned char)Buffer[j]);
+        else
+            printf(".");
+    }
+    printf("\n"); 
+}
+#endif
+
+
+static int Map_ipmibaud_to_regular( uint8_t baud, unsigned long *reg_baud )
+{
+
+    int retVal = 0;
+
+
+    
+    if ( baud == 0x06 )
+	*reg_baud = 9600;
+    else if ( baud == 0x07 )
+	*reg_baud = 19200;
+    else if ( baud == 0x08 )
+	*reg_baud = 38400;
+    else if ( baud == 0x09 )
+	*reg_baud = 57600;
+    else if ( baud == 0x0A )
+	*reg_baud = 115200;
+    else
+	retVal = -1;
+
+
+    
+#if LIBIPMI_IS_OS_LINUX()	
+    TDBG("in function %s : baud rate is %ld\n",__FUNCTION__, *reg_baud );
+#endif    
+    return retVal;
+}
+
+
+static int Sol_Map_Ipmi_Spec_To_User( SERIAL_STRUCT *serial, uint8_t baud)
+{
+    unsigned long reg_baud=0;
+    int retVal = 0;
+    
+    retVal = Map_ipmibaud_to_regular( baud, &reg_baud );
+    
+    if ( retVal == 0 ){
+
+	serial->BaudRate = reg_baud;
+	serial->DataBits = 8;
+	serial->Parity = None_Parity;
+	serial->StopBits = 1;
+	serial->FlowControl = Hardware_FlowControl;
+    }
+
+    return retVal ;
+    
+}
+
+static int map_ipmiflowControl_to_regular( uint8_t i_flowcontrol, uint8_t *flow )
+{
+    int retVal = 0 ;
+    
+    if ( i_flowcontrol == 0x00 )
+	*flow = None_FlowControl;
+    else if ( i_flowcontrol == 0x01 )
+	*flow = Hardware_FlowControl;
+    else if ( i_flowcontrol == 0x02 )
+	*flow = XonXoff_FlowControl;
+    else
+	retVal = -1;
+    
+    return retVal;
+    
+}
+
+static int Map_Ipmi_Spec_To_User( Serial_Port_Settings_T  *i_serial, SERIAL_STRUCT *serial )
+{
+    int retVal = 0 ;
+    uint8_t flowcontrol = 0;
+    unsigned long baudrate = 0;
+    
+    do {
+	
+	retVal = map_ipmiflowControl_to_regular(  i_serial->Control.FlowControl, &flowcontrol );
+	
+	if ( retVal != 0 )
+	    break;
+	
+	serial->FlowControl = flowcontrol;
+
+	serial->StopBits = 1;
+
+	serial->DataBits = 8;
+	
+	serial->Parity = None_Parity;
+	
+	if ( i_serial->Control.DtrHangup == 0 )
+	    serial->DtrHangup = 0;
+	else
+	    serial->DtrHangup = 1;
+
+	retVal =  Map_ipmibaud_to_regular( i_serial->BaudRate.BitRate, &baudrate );
+	
+	if ( retVal != 0 )
+	    break;
+	
+	serial->BaudRate = baudrate;
+	
+	    
+    }while ( 0 );
+    
+    
+	
+    return retVal;
+}
+
+
+static int Map_UserValue_To_Ipmi_Spec( SERIAL_STRUCT *serial, Serial_Port_Settings_T *internal_serial )
+{
+    int retVal = 0;
+
+    do{
+	if ( serial->FlowControl == None_FlowControl )
+    {
+	    internal_serial->Control.FlowControl = 0x00;
+    }
+	else if ( serial->FlowControl == Hardware_FlowControl )
+    {
+	    internal_serial->Control.FlowControl = 0x01;
+    }
+	else if ( serial->FlowControl == XonXoff_FlowControl )
+    {
+	    internal_serial->Control.FlowControl = 0x02;
+    }
+	else{
+	    retVal = -1;
+	    break;
+	}
+	
+	if ( serial->DtrHangup == 0x00)
+	    internal_serial->Control.DtrHangup =0;
+	else
+	    internal_serial->Control.DtrHangup =1;
+
+	if ( serial->BaudRate == 9600 )
+	    internal_serial->BaudRate.BitRate = 0x06;
+	else if ( serial->BaudRate == 19200 )
+	    internal_serial->BaudRate.BitRate = 0x07;
+	else if ( serial->BaudRate == 38400 )
+	    internal_serial->BaudRate.BitRate = 0x08;
+	else if ( serial->BaudRate == 57600 )
+	    internal_serial->BaudRate.BitRate = 0x09;
+	else if ( serial->BaudRate == 115200 )
+	    internal_serial->BaudRate.BitRate = 0x0A;
+	else
+	{
+	    retVal = -1;
+	    break;
+	}
+	
+    }while ( 0 );
+    
+    
+    
+    return retVal;
+}
+
+
+
+static uint16_t	IPMICMD_GetSerialCfg_Messaging( IPMI20_SESSION_T *pSession, Serial_Port_Settings_T *settings,\
+				      int timeout )
+{
+    uint32_t		dwResLen=1 ;
+    uint16_t		wRet;
+    GetSerialModemConfigReq_T serialReq = {0};
+
+    
+    Wrapper_GetSerialModemConfigRes_T serialRes;
+
+    uint8_t NetFnLunXport = (NETFN_TRANSPORT << 2);
+
+    serialReq.ParamRevChannelNo = 2;
+    serialReq.ParamSel = 7;
+    serialReq.SetSel = 0;
+    serialReq.BlockSel = 0;
+
+    dwResLen = sizeof( Wrapper_GetSerialModemConfigRes_T);
+    
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+					   NetFnLunXport,  CMD_GET_SERIAL_MODEM_CONFIG,
+					    (uint8_t *)&serialReq, sizeof(GetSerialModemConfigReq_T),
+					    (uint8_t*)&serialRes, &dwResLen,
+					    timeout);
+    
+    memcpy( settings,  & ( serialRes.serial) , sizeof(Serial_Port_Settings_T) );
+
+    
+    
+    return wRet;
+}
+
+static uint16_t	IPMICMD_SetSerialCfg_Messaging( IPMI20_SESSION_T *pSession, Serial_Port_Settings_T *settings,\
+				      int timeout )
+{
+
+    uint32_t		dwResLen=1 ;
+    uint16_t		wRet;
+    Wrapper_SetSerialModemConfigReq_T serialReq;
+    uint8_t Res[2] = { 0 } ;
+
+    uint8_t NetFnLunXport = (NETFN_TRANSPORT << 2);
+
+    memset(&serialReq,0,sizeof(Wrapper_SetSerialModemConfigReq_T));
+
+    serialReq.Req.ChannelNo = 2;
+    serialReq.Req.ParamSel = 7;
+
+    memcpy ( & (serialReq.serial), settings, sizeof(  Serial_Port_Settings_T ) );
+
+    
+	//DumpBuffer( ( char * ) &serialReq, sizeof( Wrapper_SetSerialModemConfigReq_T) );
+    
+    TDBG("Calling command \n");
+
+   
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+					    NetFnLunXport,  CMD_SET_SERIAL_MODEM_CONFIG,
+					    (uint8_t *)&serialReq, sizeof(Wrapper_SetSerialModemConfigReq_T),
+					    (uint8_t*)Res, &dwResLen,
+					    timeout);
+
+
+    
+    return wRet;
+}
+
+
+
+
+static uint16_t IPMICMD_GetSerialCfg_SOL( IPMI20_SESSION_T *pSession, uint8_t* baud,uint8_t* Enabled,\
+				      int timeout )
+{
+    uint32_t		dwResLen;
+    uint16_t		wRet;
+    GetSOLConfigReq_T SolConfigReq;
+    GetSOLConfigRes_T SolConfigRes;
+    uint8_t NetFnLunXport = (NETFN_TRANSPORT << 2);
+    
+    SolConfigReq.ChannelNum = 0x02;
+    SolConfigReq.ParamSel = 0x05;
+    SolConfigReq.SetSel = 0x00;
+    SolConfigReq.BlkSEl = 0x00;
+
+    dwResLen = sizeof ( GetSOLConfigRes_T )+1;
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+					    NetFnLunXport, CMD_GET_SOL_CONFIGURATION,
+					    (uint8_t *)&SolConfigReq,sizeof(GetSOLConfigReq_T),
+					    (uint8_t*)&SolConfigRes,  &dwResLen,
+					    timeout);
+
+	//DumpBuffer( (char *) &SolConfigRes, 10 );
+    if(wRet != 0)
+    {
+        printf("Error getting sol config baud rate error is %x\n",wRet);
+        return wRet;
+    }
+
+    
+    *baud = * (((uint8_t*)(&SolConfigRes))+2);
+
+    //get the enabled disable configuration
+    SolConfigReq.ChannelNum = 0x02;
+    SolConfigReq.ParamSel = 0x01; //enable disable status
+    SolConfigReq.SetSel = 0x00;
+    SolConfigReq.BlkSEl = 0x00;
+
+    dwResLen = sizeof ( GetSOLConfigRes_T );
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+					    NetFnLunXport, CMD_GET_SOL_CONFIGURATION,
+					    (uint8_t *)&SolConfigReq,sizeof(GetSOLConfigReq_T),
+					    (uint8_t*)&SolConfigRes,  &dwResLen,
+					    timeout);
+
+	//DumpBuffer( (char *) &SolConfigRes, 10 );
+    
+    *Enabled = * (((uint8_t*)(&SolConfigRes))+2);
+   
+
+    
+    return wRet;
+
+}
+
+uint16_t IPMICMD_GetSerialCfg_SOL_Advanced( IPMI20_SESSION_T *pSession, uint8_t* char_acc_interval,uint8_t* char_send_threshold,int timeout )
+{
+    uint32_t		dwResLen;
+    uint16_t		wRet;
+    GetSOLConfigReq_T SolConfigReq;
+    GetSOLConfigRes_T SolConfigRes;
+    uint8_t NetFnLunXport = (NETFN_TRANSPORT << 2);
+    
+    SolConfigReq.ChannelNum = 0x02;
+    SolConfigReq.ParamSel = 0x03;
+    SolConfigReq.SetSel = 0x00;
+    SolConfigReq.BlkSEl = 0x00;
+
+    dwResLen = sizeof ( GetSOLConfigRes_T )+1;
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+					    NetFnLunXport, CMD_GET_SOL_CONFIGURATION,
+					    (uint8_t *)&SolConfigReq,sizeof(GetSOLConfigReq_T),
+					    (uint8_t*)&SolConfigRes,  &dwResLen,
+					    timeout);
+
+	
+    if(wRet != 0)
+    {
+        printf("Error getting sol config character acc and rate error is %x\n",wRet);
+        return wRet;
+    }
+
+	*char_acc_interval = * (((uint8_t*)(&SolConfigRes))+2);
+	*char_send_threshold = * (((uint8_t*)(&SolConfigRes))+3);
+
+    return wRet;
+
+}
+
+
+uint16_t IPMICMD_SetSerialCfg_SOL_Advanced( IPMI20_SESSION_T *pSession, uint8_t char_acc_interval,uint8_t char_send_threshold,int timeout )
+{
+    uint32_t		dwResLen;
+    uint16_t		wRet;
+	uint8_t tmp_buffer[16];
+    SetSOLConfigReq_T* SolConfigReq = (SetSOLConfigReq_T *)tmp_buffer;
+	uint8_t Res[2] = { 0 } ;
+    uint8_t NetFnLunXport = (NETFN_TRANSPORT << 2);
+    
+    SolConfigReq->ChannelNum = 0x02;
+    SolConfigReq->ParamSel = 0x03;
+	*(tmp_buffer+sizeof(SetSOLConfigReq_T)) = char_acc_interval;
+	*(tmp_buffer+sizeof(SetSOLConfigReq_T)+1) = char_send_threshold;
+
+
+
+   
+
+    dwResLen = 1;
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+					    NetFnLunXport, CMD_SET_SOL_CONFIGURATION,
+					    (uint8_t *)SolConfigReq,sizeof(SetSOLConfigReq_T)+2,
+					    (uint8_t*)Res,  &dwResLen,
+					    timeout);
+
+	
+    if(wRet != 0)
+    {
+        printf("Error setting sol config character acc and rate error is %x\n",wRet);
+        return wRet;
+    }
+
+	
+    return wRet;
+
+}
+
+static uint16_t	IPMICMD_SetSerialConfig_SOL( IPMI20_SESSION_T *pSession, uint8_t baudrate, uint8_t Enabled,int timeout )
+{
+
+    uint32_t		dwResLen=1 ;
+    uint16_t		wRet;
+    char        tmp_buffer[5];
+    SetSOLConfigReq_T* SolConfigReq = (SetSOLConfigReq_T*)tmp_buffer;
+    uint8_t Res[2] = { 0 } ;
+    uint8_t NetFnLunXport = (NETFN_TRANSPORT << 2);
+
+    SolConfigReq->ChannelNum = 0x00;
+    SolConfigReq->ParamSel = 0x05;
+    *(tmp_buffer+sizeof(SetSOLConfigReq_T)) = baudrate;
+
+	//send baud rate.
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+					   NetFnLunXport,  CMD_SET_SOL_CONFIGURATION,
+					    (uint8_t *)SolConfigReq,sizeof(SetSOLConfigReq_T)+1,
+					    (uint8_t*)Res, &dwResLen,
+					    timeout);
+
+    if(wRet != 0)
+    {
+        printf("Error setting SOL baud rate and error is %x!!\n",wRet);
+        return wRet;
+    }
+
+
+    SolConfigReq->ChannelNum = 0x00;
+    SolConfigReq->ParamSel = 0x01;
+    *(tmp_buffer+sizeof(SetSOLConfigReq_T)) = Enabled;
+
+    //send baud rate.
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+                       NetFnLunXport,  CMD_SET_SOL_CONFIGURATION,
+                        (uint8_t *)SolConfigReq,sizeof(SetSOLConfigReq_T)+1,
+                        (uint8_t*)Res, &dwResLen,
+                        timeout);
+
+    if(wRet != 0)
+    {
+        printf("Error setting SOL enalbe disable!!\n");
+        return wRet;
+    }
+
+
+    return wRet;
+}
+
+
+
+
+
+
+
+
+uint16_t LIBIPMI_HL_GetSerialCfg_Messaging(IPMI20_SESSION_T *pSession, \
+					 SERIAL_STRUCT *serial, int timeout )
+{
+    uint16_t wRet = 0;
+    Serial_Port_Settings_T internal_serial;
+
+        
+
+    TDBG( "In regular serial port \n");
+    wRet = IPMICMD_GetSerialCfg_Messaging( pSession, &internal_serial, timeout);
+
+    if ( wRet != LIBIPMI_E_SUCCESS )
+    {
+        printf("Unable to Get Serial Config Messaging.\n");
+        return wRet;
+
+    }
+
+
+
+    wRet = Map_Ipmi_Spec_To_User( &internal_serial, serial );
+    wRet = 0;
+
+    if ( wRet != 0 )
+    {
+        TINFO( "Error in traslating ipmi spec value to user defined value.\n");
+        return wRet;
+    }
+
+    return wRet;
+}
+
+uint16_t LIBIPMI_HL_SetSerialCfg_Messaging(IPMI20_SESSION_T *pSession, SERIAL_STRUCT *serial, int timeout)
+{
+    uint16_t	    wRet;
+    Serial_Port_Settings_T internal_serial;
+
+    memset(&internal_serial,0,sizeof(Serial_Port_Settings_T));
+
+    TDBG( "In set serial messaging \n");
+    wRet = Map_UserValue_To_Ipmi_Spec( serial, &internal_serial );
+
+    if ( wRet != 0 )
+    {
+        printf("Error in Trslating the user params to ipmi spect params.\n");
+        wRet = -1;
+        return wRet;
+
+    }
+
+    wRet = IPMICMD_SetSerialCfg_Messaging( pSession, &internal_serial, timeout);
+
+    if ( wRet != 0 )
+    {
+        printf("Error in Setting serial cfg for messaging.\n");
+        return wRet;
+
+    }
+
+    return wRet;
+
+}
+
+
+uint16_t LIBIPMI_HL_GetSerialCfg_SOL(IPMI20_SESSION_T *pSession, \
+					 SERIAL_STRUCT *serial, uint8_t* Enabled,int timeout )
+{
+    uint16_t wRet = 0;
+    
+    uint8_t baud = 0;
+    
+    
+    wRet = IPMICMD_GetSerialCfg_SOL( pSession, &baud,Enabled, timeout);
+
+    if ( wRet != LIBIPMI_E_SUCCESS )
+    {
+        printf("Unable to Get Serial Config Sol\n");
+        return wRet;
+
+    }
+
+
+
+    wRet  = Sol_Map_Ipmi_Spec_To_User(  serial, baud );
+    if ( wRet != 0 )
+    {
+		TINFO("Error in traslating ipmi spec value to user defined value.\n");
+    }
+
+
+    
+
+    return wRet;
+}
+
+
+uint16_t LIBIPMI_HL_SetSerialCfg_SOL(IPMI20_SESSION_T *pSession, SERIAL_STRUCT *serial, uint8_t Enabled,int timeout)
+{
+    uint16_t	    wRet;
+    uint8_t baud;
+
+    
+
+    if ( serial->BaudRate == 9600 )
+		baud = 0x06;
+	    else if ( serial->BaudRate == 19200 )
+		baud = 0x07;
+	    else if ( serial->BaudRate == 38400 )
+		baud = 0x08;
+	    else if ( serial->BaudRate == 57600 )
+		baud = 0x09;
+	    else if ( serial->BaudRate == 115200 )
+		baud = 0x0A;
+	    else
+	    {
+            wRet = -1;
+            TINFO("BaudRate Not supported.\n");
+            return wRet;
+		}
+
+	    wRet = IPMICMD_SetSerialConfig_SOL( pSession, baud, Enabled,timeout);
+
+        if(wRet != 0)
+        {
+            printf("Error setting serial config for SOL : %x\n",wRet);
+            return wRet;
+        }
+
+        return wRet;
+}
+
+
+/**************************************************************************************************/
+/* ****************************** Serial Port Setting Group Ends ********************************/
+/**************************************************************************************************/

+ 81 - 0
app/goahead-5.1.0/src/libipmi/src/libipmi_device_api.c

@@ -0,0 +1,81 @@
+/*****************************************************************
+******************************************************************
+***                                                            ***
+***        (C)Copyright 2008, American Megatrends Inc.         ***
+***                                                            ***
+***                    All Rights Reserved                     ***
+***                                                            ***
+***       5555 Oakbrook Parkway, Norcross, GA 30093, USA       ***
+***                                                            ***
+***                     Phone 770.246.8600                     ***
+***                                                            ***
+******************************************************************
+******************************************************************
+******************************************************************
+* 
+* Filename: libipmi_device_api.c
+*
+******************************************************************/
+#include "libipmi_session.h"
+#include "libipmi_errorcodes.h"
+#include "libipmi_api.h"
+
+#include <string.h>
+uint16_t LIBIPMI_GetDeviceID( IPMI20_SESSION_T *pSession, char *pszDeviceID, int timeout )
+{
+	uint8_t	Res [20], Req [20];
+	uint32_t	dwResLen;
+	uint8_t	i;
+	uint16_t	wRet;
+	char	szTemp[10];
+
+	pszDeviceID[0] = (char)0;
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+											DEFAULT_NET_FN_LUN, 0x01,
+											Req, 0,
+											Res, &dwResLen,
+											timeout);
+	if (wRet == LIBIPMI_E_SUCCESS)
+	{
+		for (i = 0; i < (uint8_t)dwResLen; i++ )
+		{
+			sprintf (szTemp, "%x ", Res[i]);
+			strcat(pszDeviceID, szTemp);
+		}
+	}
+	
+	return wRet;
+}
+
+
+#if 0
+int main()
+{
+	IPMI20_SESSION_T hSession;
+	uint16_t	wRet;
+	uint8_t				m_KG [] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
+
+	memset((void*)&hSession, 0, sizeof(IPMI20_SESSION_T) );
+
+	printf("*********************** Entering main **********************\n");
+	wRet = Create_IPMI20_Network_Session(&hSession, "10.0.0.217", 623,
+							"", "", 0,
+							0, 0, 0x04,
+							0xc2, 0x20,
+							m_KG, sizeof(m_KG),
+							1000);
+	printf("*************** Create_IPMI20_Session returned ***************\n");
+
+	if (wRet == LIBIPMI_E_SUCCESS)
+	{
+		GetDeviceID( &hSession );
+	}
+	else
+	{
+		printf("*********************** Error 1 ***************************");
+		printf("Error in creating the session\n");
+	}
+
+	return 0;
+}
+#endif

+ 1258 - 0
app/goahead-5.1.0/src/libipmi/src/libipmi_fru.c

@@ -0,0 +1,1258 @@
+/*****************************************************************
+******************************************************************
+***                                                            ***
+***        (C)Copyright 2008, American Megatrends Inc.         ***
+***                                                            ***
+***                    All Rights Reserved                     ***
+***                                                            ***
+***       5555 Oakbrook Parkway, Norcross, GA 30093, USA       ***
+***                                                            ***
+***                     Phone 770.246.8600                     ***
+***                                                            ***
+******************************************************************
+******************************************************************
+******************************************************************
+*
+* Filename: libipmi_fru.c
+*
+******************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include "dbgout.h"
+#include "libipmi_fru.h"
+
+#if LIBIPMI_IS_OS_LINUX()
+#include <syslog.h>
+#endif
+
+#ifdef _USE_ARR_MALLOCS_
+#define MAX_MALLOCS			32
+
+static uint8_t *arrMallocs[MAX_MALLOCS];
+static uint32_t nMallocs = 0;
+#endif
+
+#define SAFE_FREE(ptr) { if((ptr)) { free(ptr); ptr=NULL; } }
+#define IPMI_FRU_VALID_VERSION  0x01
+
+
+#define CUSTOM_AREA_FIELD		0xC1
+
+//! Helper function
+/*static uint8_t GetBits(uint8_t orig, uint8_t startbit, uint8_t endbit)
+{
+	uint8_t  temp = orig;
+	uint8_t  mask = 0x00;
+	int i;
+	for(i=startbit;i>=endbit;i--)
+	{
+		mask = mask | (1 << i);
+	}
+
+	return (temp & mask);
+}*/
+
+const char * buf2str(uint8_t * buf, int len)
+{
+    static char str[1024];
+    int i;
+
+    if (len <= 0 || (len*2) > 1024)
+        return NULL;
+
+    memset(str, 0, 1024);
+
+    for (i=0; i<len; i++)
+        sprintf(str+i+i, "%2.2x", buf[i]);
+
+    str[len*2] = '\0';
+
+    return (const char *)str;
+}
+
+static uint32_t GetStringFromType(uint8_t *startBuff, uint8_t **str)
+{
+	//static const char bcd_plus[] = "0123456789 -.:,_";
+	uint8_t type = 0;
+	uint8_t len = 0;
+	uint8_t size = 0;
+	uint8_t i, j, k;
+	char binarystring[4];
+	int loop;
+
+	union
+	{
+		uint32_t bits;
+		char chars[4];
+	}u;
+
+	type =((*startBuff & 0xC0) >> 6);
+
+	len = GetBits(*startBuff, 5, 0);
+
+
+	switch (type)
+	{
+		case 0:
+			/** 00b:
+			 * binary/unspecified
+			 **/
+			//! hex dump -> 2x length
+			size =(len*2);
+			break;
+		case 2:
+			/** 10b:
+			 * 6 - bit ASCII
+			 **/
+			//! 4 chars per group of 1 - 3 bytes
+			size =((((len + 2)*4)/3) & ~3);
+			break;
+		case 3:
+				/** 11b:
+			8 - bit ASCII */
+		case 1:
+			/** 01b:
+			 * BCD plus
+			 **/
+			//! no length adjustment
+			size = len;
+			break;
+	}
+
+
+	*str =(uint8_t *) malloc(size + 1);
+         if(*str == NULL)
+           {
+             printf ("libipmi_fru.c: Error allocating memory for str\n");
+	     return -1;
+   	   }    
+
+	startBuff++;
+
+	switch (type)
+	{
+		case 0:                 //! Binary
+			{
+				memset(*str,0x00,size);
+				for(loop = 0; loop < (size/2); ++loop)
+				{
+					sprintf(binarystring,"%02X",*(startBuff+loop));
+					strncat((char*)(*str),binarystring,2);
+				}
+			}
+			break;
+
+		case 1:                 //! BCD plus
+			strcpy((char*)(*str), "\0");
+			break;
+
+		case 2:                 //! 6 - bit ASCII
+			for (i = j = 0; i < len; i += 3)
+			{
+				u.bits = 0;
+				k =((len - i) < 3 ?(len - i) : 3);
+		#if 1
+				u.chars[3] = *(startBuff + i);
+				u.chars[2] =(k > 1 ? *(startBuff + i + 1) : 0);
+				u.chars[1] =(k > 2 ? *(startBuff + i + 2) : 0);
+		#define CHAR_IDX 3
+		#else
+				memcpy((void *)&u.bits, startBuff + i, k);
+		#define CHAR_IDX 0
+		#endif
+				for (k = 0; k < 4; k++)
+				{
+				*(*str + j) =((u.chars[CHAR_IDX] & 0x3f) + 0x20);
+				u.bits >>= 6;
+				j++;
+				}
+			}
+			*(*str + j) = '\0';
+
+
+			break;
+		case 3:
+			memcpy(*str, startBuff, len);
+			*(*str + len) = '\0';
+			break;
+	}
+	return (size + 1);
+}
+
+
+static int  GetInternalUseArea(uint8_t *pBuff, FRUData_T *FRU)
+{
+    FRUCommonHeader_T *pTmp =(FRUCommonHeader_T *) pBuff;
+    uint8_t *pInternalUseArea = pBuff +(pTmp->InternalUseAreaStartOffset * 8);
+    uint32_t len = 0;
+
+    uint32_t size = 0;
+    uint8_t *tmpPtr = NULL;
+
+
+    FRU->InternalInfo.FormatVersion =	*pInternalUseArea;
+    pInternalUseArea++;
+
+    len = GetBits(*pInternalUseArea, 5, 0);
+    if (len == 0)
+    {
+        FRU->InternalInfo.Data =(uint8_t *) malloc(8);
+           if(FRU->InternalInfo.Data  == NULL)
+           {
+             printf ("libipmi_fru.c: Error allocating memory for FRUData_T\n");
+             return -1;
+           }
+
+        strcpy((char*)(FRU->InternalInfo.Data), "\0");
+        pInternalUseArea += 1;
+    }
+    else
+    {
+        size = GetStringFromType(pInternalUseArea, &tmpPtr);
+        FRU->InternalInfo.Data =(uint8_t *) malloc(size);
+	   if(FRU->InternalInfo.Data  == NULL)
+           {
+             printf ("libipmi_fru.c: Error allocating memory for FRUData_T\n");
+             return -1;
+           }
+
+        memcpy(FRU->InternalInfo.Data, tmpPtr, size);
+        pInternalUseArea += len + 1;
+        SAFE_FREE (tmpPtr);
+    }
+
+#ifdef _USE_ARR_MALLOCS_
+	arrMallocs[nMallocs] = FRU->InternalInfo.Data;
+    nMallocs++;
+#endif
+
+return 0;
+
+}
+
+
+static int GetChassisInfoArea(uint8_t *pBuff, FRUData_T *FRU)
+{
+    FRUCommonHeader_T *pTmp =(FRUCommonHeader_T *) pBuff;
+    uint8_t *pChassisArea = pBuff +(pTmp->ChassisInfoAreaStartOffset * 8);
+    uint32_t len = 0, chassisAreaLen = 0;
+    uint32_t size = 0; 
+    uint8_t *tmpPtr = NULL;
+    int Index = 0;
+    static const char * chassis_type[] = {
+		"Unspecified", "Other", "Unknown",
+		"Desktop", "Low Profile Desktop", "Pizza Box",
+		"Mini Tower", "Tower",
+		"Portable", "LapTop", "Notebook", "Hand Held",
+		"Docking Station", "All in One", "Sub Notebook",
+		"Space-saving", "Lunch Box", "Main Server Chassis",
+		"Expansion Chassis", "SubChassis", "Bus Expansion Chassis",
+		"Peripheral Chassis", "RAID Chassis", "Rack Mount Chassis"};
+
+    FRU->ChassisInfo.ChassisInfoAreaFormatVersion =	*pChassisArea;
+    pChassisArea++;
+    FRU->ChassisInfo.ChassisInfoAreaLength = *pChassisArea;
+    pChassisArea++;
+    TDBG ("Chassis type : %d %d\n", (uint8_t)*pChassisArea, sizeof (chassis_type)/ sizeof (char *));
+    if ((*pChassisArea) >= sizeof (chassis_type)/ sizeof (char *))
+        *pChassisArea = 0;
+    size = strlen(chassis_type[*pChassisArea]);
+    FRU->ChassisInfo.ChassisType =(uint8_t *) malloc(size + 1);
+	   if(FRU->ChassisInfo.ChassisType  == NULL)
+           {
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ChassisType\n");
+             return -1;
+           }
+
+    memcpy(FRU->ChassisInfo.ChassisType, chassis_type[*pChassisArea], size);
+    FRU->ChassisInfo.ChassisType[size] = '\0';
+    pChassisArea++;
+
+    len = GetBits(*pChassisArea, 5, 0);
+    if (len == 0)
+    {
+        FRU->ChassisInfo.ChassisPartNum =(uint8_t *) malloc(8);
+        if(FRU->ChassisInfo.ChassisPartNum == NULL)
+           {
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ChassisPartNum\n");
+             return -1;
+           }
+
+        strcpy((char*)(FRU->ChassisInfo.ChassisPartNum), "\0");
+        pChassisArea += 1;
+    }
+    else
+    {
+        size = GetStringFromType(pChassisArea, &tmpPtr);
+        FRU->ChassisInfo.ChassisPartNum =(uint8_t *) malloc(size);
+        if(FRU->ChassisInfo.ChassisPartNum == NULL)
+        {
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ChassisPartNum\n");
+        	return -1;
+        }
+        memcpy(FRU->ChassisInfo.ChassisPartNum, tmpPtr, size);
+        pChassisArea += len + 1;
+        SAFE_FREE (tmpPtr);
+    }
+#ifdef _USE_ARR_MALLOCS_
+    arrMallocs[nMallocs] = FRU->ChassisInfo.ChassisPartNum;
+    nMallocs++;
+#endif
+    len = GetBits(*pChassisArea, 5, 0);
+    if (len == 0)
+    {
+        FRU->ChassisInfo.ChassisSerialNum =(uint8_t *) malloc(8);
+        if(FRU->ChassisInfo.ChassisSerialNum == NULL)
+        {
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ChassisSerialNum\n");
+             return -1;
+           }
+
+        strcpy((char*)(FRU->ChassisInfo.ChassisSerialNum), "\0");
+        pChassisArea += 1;
+    }
+    else
+    {
+        size = GetStringFromType(pChassisArea, &tmpPtr);
+        FRU->ChassisInfo.ChassisSerialNum =(uint8_t *) malloc(size);
+        if(FRU->ChassisInfo.ChassisSerialNum == NULL)
+        {
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ChassisSerialNum\n");
+             return -1;
+        }
+        memcpy(FRU->ChassisInfo.ChassisSerialNum, tmpPtr, size);
+        pChassisArea += len + 1;
+        SAFE_FREE (tmpPtr);
+    }
+#ifdef _USE_ARR_MALLOCS_
+    arrMallocs[nMallocs] = FRU->ChassisInfo.ChassisSerialNum;
+    nMallocs++;
+#endif
+
+
+    FRU->ChassisInfo.Total_Chassis_CustomField = 0;
+    tmpPtr =  pChassisArea;
+    chassisAreaLen = (unsigned long int)(((pBuff +(pTmp->ChassisInfoAreaStartOffset * 8)) + 
+                            (FRU->ChassisInfo.ChassisInfoAreaLength * 8)) -1);
+    while((*tmpPtr != CUSTOM_AREA_FIELD) && ((unsigned long int)tmpPtr <  chassisAreaLen))
+    {
+    	len = GetBits(*tmpPtr, 5, 0);
+        tmpPtr += len + 1;
+        FRU->ChassisInfo.Total_Chassis_CustomField += 1;
+    }
+    if(FRU->ChassisInfo.Total_Chassis_CustomField > 0)
+    {
+        FRU->ChassisInfo.CustomFields =(uint8_t **) malloc(FRU->ChassisInfo.Total_Chassis_CustomField * sizeof(char *));
+        if(FRU->ChassisInfo.CustomFields != NULL)
+        {
+        	while((*pChassisArea != CUSTOM_AREA_FIELD) && (Index < FRU->ChassisInfo.Total_Chassis_CustomField))
+         	{
+        		len = GetBits(*pChassisArea, 5, 0);
+         		if (len == 0)
+         		{	
+         			//FRU->ChassisInfo.CustomFields =(uint8_t **) malloc(1);
+         			FRU->ChassisInfo.CustomFields[Index] =(uint8_t *) malloc(8);
+         			if( FRU->ChassisInfo.CustomFields[Index] != NULL )
+         			{
+         				strcpy((char*)(FRU->ChassisInfo.CustomFields[Index]), "\0");
+         			}
+         			else{
+			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table ChassisInfo CustomFields\n");
+			             return -1;
+				    }
+         			pChassisArea += 1;
+
+         		}
+       			else
+       			{
+       				size = GetStringFromType(pChassisArea, &tmpPtr);
+       				//FRU->ChassisInfo.CustomFields =(uint8_t **) malloc(1);
+       				FRU->ChassisInfo.CustomFields[Index] =(uint8_t *) malloc(size);
+       				if(FRU->ChassisInfo.CustomFields[Index] != NULL)
+       				{
+       					memcpy((FRU->ChassisInfo.CustomFields[Index]), tmpPtr, size);
+       				}
+       				else{
+			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table ChassisInfo CustomFields\n");
+			             return -1;
+				    } 
+       				SAFE_FREE (tmpPtr);
+       				pChassisArea += len + 1;
+       				//FRU->ChassisInfo.Total_Chassis_CustomField +=1;
+       			}
+       			++ Index;
+       		}
+       	}
+       	else{
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table ChassisInfo CustomFields\n");
+             return -1;
+        } 
+   }
+
+   return 0; 
+}
+
+static int GetBoardInfoArea(uint8_t *pBuff, FRUData_T *FRU)
+{
+
+    FRUCommonHeader_T *pTmp =(FRUCommonHeader_T *) pBuff;
+    uint8_t *pBoardArea = pBuff +(pTmp->BoardInfoAreaStartOffset * 8);
+    uint32_t len = 0, boardAreaLen = 0;
+    int Index = 0;
+
+    uint32_t size = 0;  
+    uint8_t *tmpPtr = NULL;
+
+
+    FRU->BoardInfo.BoardInfoAreaFormatVersion = *pBoardArea;
+    pBoardArea++;
+    FRU->BoardInfo.BoardInfoAreaLength = *pBoardArea;
+    pBoardArea++;
+    FRU->BoardInfo.Language = *pBoardArea;
+    pBoardArea++;
+    memcpy(FRU->BoardInfo.MfgDateTime, pBoardArea, 3);
+    pBoardArea += 3;
+    len = GetBits(*pBoardArea, 5, 0);
+    if (len == 0)
+    {
+        FRU->BoardInfo.BoardMfr =(uint8_t *) malloc(8);
+        if(FRU->BoardInfo.BoardMfr == NULL)
+		{
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardMfr\n");
+             return -1; 
+        }
+
+        strcpy((char*)(FRU->BoardInfo.BoardMfr), "\0");
+        pBoardArea += 1;
+    }
+    else
+    {
+        size = GetStringFromType(pBoardArea, &tmpPtr);
+        FRU->BoardInfo.BoardMfr =(uint8_t *) malloc(size);
+        if(FRU->BoardInfo.BoardMfr == NULL)
+       	{
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardMfr\n");
+             return -1; 
+        }
+        memcpy(FRU->BoardInfo.BoardMfr, tmpPtr, size);
+        SAFE_FREE (tmpPtr);
+        pBoardArea += len + 1;
+    }
+#ifdef _USE_ARR_MALLOCS_
+    arrMallocs[nMallocs] = FRU->BoardInfo.BoardMfr;
+    nMallocs++;
+#endif
+    len = GetBits(*pBoardArea, 5, 0);
+    if (len == 0)
+    {
+        FRU->BoardInfo.BoardProductName =(uint8_t *) malloc(8);
+        if(FRU->BoardInfo.BoardProductName == NULL)
+        {
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardProductName\n");
+             return -1; 
+        }
+        strcpy((char*)(FRU->BoardInfo.BoardProductName), "\0");
+        pBoardArea += 1;
+    }
+    else
+    {
+        size = GetStringFromType(pBoardArea, &tmpPtr);
+        FRU->BoardInfo.BoardProductName =(uint8_t *) malloc(size);
+        if(FRU->BoardInfo.BoardProductName == NULL)
+        {
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardProductName\n");
+       		 return -1;
+        }
+        memcpy(FRU->BoardInfo.BoardProductName, tmpPtr, size);
+        SAFE_FREE (tmpPtr);
+        pBoardArea += len + 1;
+    }
+#ifdef _USE_ARR_MALLOCS_
+    arrMallocs[nMallocs] = FRU->BoardInfo.BoardProductName;
+    nMallocs++;
+#endif
+    len = GetBits(*pBoardArea, 5, 0);
+    if (len == 0)
+    {
+        FRU->BoardInfo.BoardSerialNum =(uint8_t *) malloc(8);
+        if(FRU->BoardInfo.BoardSerialNum == NULL)
+        {
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardSerialNum\n");
+        	return -1;
+        } 
+        strcpy((char*)(FRU->BoardInfo.BoardSerialNum), "\0");
+        pBoardArea += 1;
+    }
+    else
+    {
+        size = GetStringFromType(pBoardArea, &tmpPtr);
+        FRU->BoardInfo.BoardSerialNum =(uint8_t *) malloc(size);
+        if(FRU->BoardInfo.BoardSerialNum == NULL)
+        {
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardSerialNum\n");
+             return -1; 
+         }
+        memcpy(FRU->BoardInfo.BoardSerialNum, tmpPtr, size);
+        SAFE_FREE (tmpPtr);
+        pBoardArea += len + 1;
+    }
+#ifdef _USE_ARR_MALLOCS_
+    arrMallocs[nMallocs] = FRU->BoardInfo.BoardSerialNum;
+    nMallocs++;
+#endif
+    len = GetBits(*pBoardArea, 5, 0);
+    if (len == 0)
+    {
+        FRU->BoardInfo.BoardPartNum =(uint8_t *) malloc(8);
+		if(FRU->BoardInfo.BoardPartNum == NULL)
+        {
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardPartNum\n");
+             return -1; 
+        }
+        strcpy((char*)(FRU->BoardInfo.BoardPartNum), "\0");
+        pBoardArea += 1;
+    }
+    else
+    {
+        size = GetStringFromType(pBoardArea, &tmpPtr);
+        FRU->BoardInfo.BoardPartNum =(uint8_t *) malloc(size);
+		if(FRU->BoardInfo.BoardPartNum == NULL)
+        {
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field BoardPartNum\n");
+             return -1; 
+        }
+        memcpy(FRU->BoardInfo.BoardPartNum, tmpPtr, size);
+        SAFE_FREE (tmpPtr);
+        pBoardArea += len + 1;
+    }
+#ifdef _USE_ARR_MALLOCS_
+   arrMallocs[nMallocs] = FRU->BoardInfo.BoardPartNum;
+   nMallocs++;
+#endif
+    len = GetBits(*pBoardArea, 5, 0);
+    if (len == 0)
+    {
+        FRU->BoardInfo.FRUFileID =(uint8_t *) malloc(8);
+		if(FRU->BoardInfo.FRUFileID == NULL)
+        {
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field FRUFileID\n");
+             return -1; 
+        }
+        strcpy((char*)(FRU->BoardInfo.FRUFileID), "\0");
+        pBoardArea += 1;
+    }
+    else
+    {
+        size = GetStringFromType(pBoardArea, &tmpPtr);
+        FRU->BoardInfo.FRUFileID =(uint8_t *) malloc(size);
+		if(FRU->BoardInfo.FRUFileID == NULL)
+        {
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table field FRUFileID\n");
+             return -1; 
+        }
+        memcpy(FRU->BoardInfo.FRUFileID, tmpPtr, size);
+        SAFE_FREE (tmpPtr);
+        pBoardArea += len + 1;
+    }
+#ifdef _USE_ARR_MALLOCS_
+    arrMallocs[nMallocs] = FRU->BoardInfo.FRUFileID;
+    nMallocs++;
+#endif
+ 
+     FRU->BoardInfo.Total_Board_CustomField = 0;
+     tmpPtr =  pBoardArea;
+     boardAreaLen = (unsigned long int)(((pBuff +(pTmp->BoardInfoAreaStartOffset * 8)) + 
+                             (FRU->BoardInfo.BoardInfoAreaLength * 8)) -1); 
+     while((*tmpPtr != CUSTOM_AREA_FIELD) && ((unsigned long int)tmpPtr <  boardAreaLen))
+     {
+     	len = GetBits(*tmpPtr, 5, 0);
+     	tmpPtr += len + 1;
+     	FRU->BoardInfo.Total_Board_CustomField += 1;
+     }
+     if(FRU->BoardInfo.Total_Board_CustomField > 0)
+     {
+     	FRU->BoardInfo.CustomFields =(uint8_t **) malloc(FRU->BoardInfo.Total_Board_CustomField * sizeof(char *));
+     	if( FRU->BoardInfo.CustomFields != NULL )
+     	{
+     		while((*pBoardArea!= CUSTOM_AREA_FIELD) && (Index < FRU->BoardInfo.Total_Board_CustomField))
+     		{
+     			len = GetBits(*pBoardArea, 5, 0);
+     			if (len == 0)
+     			{	
+     				//FRU->BoardInfo.CustomFields =(uint8_t **) malloc(1);
+     				FRU->BoardInfo.CustomFields[Index] =(uint8_t *) malloc(8);
+     				if(FRU->BoardInfo.CustomFields[Index] !=  NULL )
+     				{
+     					strcpy((char*)(FRU->BoardInfo.CustomFields[Index]), "\0");
+     				}
+     				else{
+			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table BoardInfo CustomFields\n");
+        			     return -1;
+				    } 
+     				pBoardArea += 1;
+     			}
+     			else
+     			{
+     				size = GetStringFromType(pBoardArea, &tmpPtr);
+     				//FRU->BoardInfo.CustomFields =(uint8_t **) malloc(1);
+     				FRU->BoardInfo.CustomFields[Index] =(uint8_t *) malloc(size);
+     				if(FRU->BoardInfo.CustomFields[Index] != NULL)
+     				{
+     					memcpy((FRU->BoardInfo.CustomFields[Index]), tmpPtr, size);
+     				}
+     				else{
+			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table BoardInfo CustomFields\n");
+			             return -1;
+				    } 
+     				SAFE_FREE (tmpPtr);
+     				pBoardArea += len + 1;
+     				//FRU->BoardInfo.Total_Board_CustomField +=1;
+     			}
+     			++ Index;
+     		}
+     	}
+     	else{
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table BoardInfo CustomFields\n");
+             return -1;
+	    } 
+     }
+   return 0; 
+}
+
+
+static int GetProductInfoArea(uint8_t *pBuff, FRUData_T *FRU)
+{
+    FRUCommonHeader_T *pTmp =(FRUCommonHeader_T *) pBuff;
+    uint8_t *pProductArea = pBuff +(pTmp->ProductInfoAreaStartOffset * 8);
+    uint8_t len = 0;
+    uint32_t size = 0, productAreaLen = 0;
+    int Index = 0;
+
+    uint8_t *tmpPtr = NULL;
+
+    if(pProductArea == NULL)
+	return -1;
+
+    FRU->ProductInfo.ProductInfoAreaFormatVersion = *pProductArea;
+    pProductArea++;
+    FRU->ProductInfo.ProductInfoAreaLength = *pProductArea;
+    pProductArea++;
+    FRU->ProductInfo.Language = *pProductArea;
+    pProductArea++;
+
+    len = GetBits(*pProductArea, 5, 0);
+    if (len == 0)
+    {
+        FRU->ProductInfo.MfrName =(uint8_t *) malloc(8);
+        if(FRU->ProductInfo.MfrName == NULL)
+		{
+		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo MfrName\n");
+		     return -1; 
+		}
+        strcpy((char*)(FRU->ProductInfo.MfrName), "\0");
+        pProductArea += 1;
+    }
+    else
+    {
+        size = GetStringFromType(pProductArea, &tmpPtr);
+        FRU->ProductInfo.MfrName =(uint8_t *) malloc(size);
+        if(FRU->ProductInfo.MfrName == NULL)
+		{
+		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo MfrName\n");
+		     return -1; 
+		}
+        strcpy((char*)(FRU->ProductInfo.MfrName), (const char *)tmpPtr);
+        pProductArea += len + 1;
+        SAFE_FREE (tmpPtr);
+    }
+#ifdef _USE_ARR_MALLOCS_
+    arrMallocs[nMallocs] = FRU->ProductInfo.MfrName;
+    nMallocs++;
+#endif
+
+    len = GetBits(*pProductArea, 5, 0);
+    if (len == 0)
+    {
+        FRU->ProductInfo.ProductName =(uint8_t *) malloc(8);
+        if(FRU->ProductInfo.ProductName == NULL)
+		{
+		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductName\n");
+		     return -1; 
+		}
+        strcpy((char*)(FRU->ProductInfo.ProductName), "\0");
+        pProductArea += 1;
+    }
+    else
+    {
+        size = GetStringFromType(pProductArea, &tmpPtr);
+        FRU->ProductInfo.ProductName =(uint8_t *) malloc(size);
+        if(FRU->ProductInfo.ProductName == NULL)
+		{
+		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductName\n");
+		     return -1; 
+		}
+        strcpy((char*)(FRU->ProductInfo.ProductName), (const char*)tmpPtr);
+        pProductArea += len + 1;
+        SAFE_FREE (tmpPtr);
+    }
+#ifdef _USE_ARR_MALLOCS_
+    arrMallocs[nMallocs] = FRU->ProductInfo.ProductName;
+    nMallocs++;
+#endif
+    len = GetBits(*pProductArea, 5, 0);
+
+    if (len == 0)
+    {
+        FRU->ProductInfo.ProductPartNum =(uint8_t *) malloc(8);
+        if(FRU->ProductInfo.ProductPartNum == NULL)
+		{
+		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductPartNum\n");
+		     return -1; 
+		}
+        strcpy((char*)(FRU->ProductInfo.ProductPartNum), "\0");
+        pProductArea += 1;
+    }
+    else
+    {
+        size = GetStringFromType(pProductArea, &tmpPtr);
+        FRU->ProductInfo.ProductPartNum =(uint8_t *) malloc(size);
+        if(FRU->ProductInfo.ProductPartNum == NULL)
+		{
+		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductPartNum\n");
+		     return -1; 
+		}
+        strcpy((char*)(FRU->ProductInfo.ProductPartNum), (const char*)tmpPtr);
+        pProductArea += len + 1;
+        SAFE_FREE (tmpPtr);
+    }
+
+#ifdef _USE_ARR_MALLOCS_
+    arrMallocs[nMallocs] = FRU->ProductInfo.ProductPartNum;
+    nMallocs++;
+#endif
+    len = GetBits(*pProductArea, 5, 0);
+    if (len == 0)
+    {
+        FRU->ProductInfo.ProductVersion =(uint8_t *) malloc(8);
+        if(FRU->ProductInfo.ProductVersion == NULL)
+		{
+		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductVersion\n");
+		     return -1; 
+		}
+        strcpy((char*)(FRU->ProductInfo.ProductVersion), "\0");
+        pProductArea += 1;
+    }
+    else
+    {
+        size = GetStringFromType(pProductArea, &tmpPtr);
+        FRU->ProductInfo.ProductVersion =(uint8_t *) malloc(size);
+        if(FRU->ProductInfo.ProductVersion == NULL)
+		{
+		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductVersion\n");
+		     return -1; 
+		}
+        strcpy((char*)(FRU->ProductInfo.ProductVersion), (const char*)tmpPtr);
+        pProductArea += len + 1;
+        SAFE_FREE (tmpPtr);
+    }
+
+#ifdef _USE_ARR_MALLOCS_
+    arrMallocs[nMallocs] = FRU->ProductInfo.ProductVersion;
+    nMallocs++;
+#endif
+    len = GetBits(*pProductArea, 5, 0);
+    if (len == 0)
+    {
+        FRU->ProductInfo.ProductSerialNum =(uint8_t *) malloc(8);
+        if(FRU->ProductInfo.ProductSerialNum == NULL)
+		{
+		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductSerialNum\n");
+		     return -1; 
+		}
+        strcpy((char*)(FRU->ProductInfo.ProductSerialNum), "\0");
+        pProductArea += 1;
+    }
+    else
+    {
+        size = GetStringFromType(pProductArea, &tmpPtr);
+        FRU->ProductInfo.ProductSerialNum =(uint8_t *) malloc(size);
+        if(FRU->ProductInfo.ProductSerialNum == NULL)
+		{
+		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-ProductSerialNum\n");
+		     return -1; 
+		}
+        strcpy((char*)(FRU->ProductInfo.ProductSerialNum), (const char*)tmpPtr);
+        pProductArea += len + 1;
+        SAFE_FREE (tmpPtr);
+    }
+#ifdef _USE_ARR_MALLOCS_
+    arrMallocs[nMallocs] = FRU->ProductInfo.ProductSerialNum;
+    nMallocs++;
+#endif
+    len = GetBits(*pProductArea, 5, 0);
+    if (len == 0)
+    {
+        FRU->ProductInfo.AssetTag =(uint8_t *) malloc(8);
+        if(FRU->ProductInfo.AssetTag == NULL)
+		{
+		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-AssetTag\n");
+		     return -1; 
+		}
+        strcpy((char*)(FRU->ProductInfo.AssetTag), "\0");
+        pProductArea += 1;
+    }
+    else
+    {
+        size = GetStringFromType(pProductArea, &tmpPtr);
+        FRU->ProductInfo.AssetTag =(uint8_t *) malloc(size);
+        if(FRU->ProductInfo.AssetTag == NULL)
+		{
+		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-AssetTag\n");
+		     return -1; 
+		}
+        strcpy((char*)(FRU->ProductInfo.AssetTag), (const char*)tmpPtr);
+        pProductArea += len + 1;
+        SAFE_FREE (tmpPtr);
+    }
+#ifdef _USE_ARR_MALLOCS_
+    arrMallocs[nMallocs] = FRU->ProductInfo.AssetTag;
+    nMallocs++;
+#endif
+    len = GetBits(*pProductArea, 5, 0);
+    if (len == 0)
+    {
+        FRU->ProductInfo.FRUFileID =(uint8_t *) malloc(8);
+        if(FRU->ProductInfo.FRUFileID == NULL)
+		{
+		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-FRUFileID\n");
+		     return -1; 
+		}
+        strcpy((char*)(FRU->ProductInfo.FRUFileID), "\0");
+        pProductArea += 1;
+    }
+    else
+    {
+        size = GetStringFromType(pProductArea, &tmpPtr);
+        FRU->ProductInfo.FRUFileID =(uint8_t *) malloc(size);
+        if(FRU->ProductInfo.FRUFileID == NULL)
+		{
+		     printf ("libipmi_fru.c: Error allocating memory for FRUData Table field ProductInfo-FRUFileID\n");
+		     return -1; 
+		}
+        strcpy((char*)(FRU->ProductInfo.FRUFileID), (const char*)tmpPtr);
+        pProductArea += len + 1;
+        SAFE_FREE (tmpPtr);
+    }
+#ifdef _USE_ARR_MALLOCS_
+    arrMallocs[nMallocs] = FRU->ProductInfo.FRUFileID;
+    nMallocs++;
+#endif
+
+
+    FRU->ProductInfo.Total_Product_CustomField = 0;
+    tmpPtr =  pProductArea;
+    productAreaLen = (unsigned long int)(((pBuff +(pTmp->ProductInfoAreaStartOffset * 8)) + 
+                            (FRU->ProductInfo.ProductInfoAreaLength * 8)) -1);
+    while((*tmpPtr != CUSTOM_AREA_FIELD) && ((unsigned long int)tmpPtr <  productAreaLen))
+    {
+    	len = GetBits(*tmpPtr, 5, 0);
+        tmpPtr += len + 1;
+        FRU->ProductInfo.Total_Product_CustomField += 1;
+    }
+    if(FRU->ProductInfo.Total_Product_CustomField > 0)
+    {
+        FRU->ProductInfo.CustomFields =(uint8_t **) malloc(FRU->ProductInfo.Total_Product_CustomField * sizeof(char *));
+        if(FRU->ProductInfo.CustomFields  != NULL)
+        {
+        	while((*pProductArea!= CUSTOM_AREA_FIELD) && (Index < FRU->ProductInfo.Total_Product_CustomField))
+        	{
+        		len = GetBits(*pProductArea, 5, 0);
+        		if (len == 0)
+        		{	
+        			//FRU->ProductInfo.CustomFields =(uint8_t **) malloc(1);
+        			FRU->ProductInfo.CustomFields[Index] =(uint8_t *) malloc(8);
+        			if(FRU->ProductInfo.CustomFields[Index] != NULL)
+        			{
+        				strcpy((char*)(FRU->ProductInfo.CustomFields[Index]), "\0");
+        			}
+        			else{
+			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table ProductInfo CustomFields\n");
+			             return -1;			
+				    } 
+        			pProductArea += 1;
+        		}
+        		else
+        		{
+        			size = GetStringFromType(pProductArea, &tmpPtr);
+        			//FRU->ProductInfo.CustomFields =(uint8_t **) malloc(1);
+        			FRU->ProductInfo.CustomFields[Index] =(uint8_t *) malloc(size);
+        			if(FRU->ProductInfo.CustomFields[Index] != NULL)
+        			{
+        				memcpy((FRU->ProductInfo.CustomFields[Index]), tmpPtr, size);
+        			}
+        			else{
+			             printf ("libipmi_fru.c: Error allocating memory for FRUData Table ProductInfo CustomFields\n");
+			             return -1;
+				    } 
+        			SAFE_FREE (tmpPtr);
+        			pProductArea += len + 1;
+        			//FRU->ProductInfo.Total_Product_CustomField +=1;
+        		}
+        		++ Index;
+        	}
+        }
+        else{
+             printf ("libipmi_fru.c: Error allocating memory for FRUData Table ProductInfo CustomFields\n");
+             return -1;	
+	    } 
+    }
+
+   return 0;
+
+}
+
+int InterpretFRUData(uint8_t *pBuff, FRUData_T *FRU,uint32_t  FRU_Size)
+{
+	FRUCommonHeader_T *pTmp =(FRUCommonHeader_T *) pBuff;
+	int i;
+	printf("\n---> InterpretFRUData Enter: ");
+	for(i=0;i<256;i++)
+		printf("%#x ", pBuff[i]);
+	printf("\n");
+	if (pBuff == NULL)
+	{
+		memset(FRU, 0, sizeof(FRUData_T));
+	}
+	else
+	{
+		//! Copy full Common Header
+		memcpy(&(FRU->CommonHeader), pTmp, sizeof(FRUCommonHeader_T));
+	}
+
+	/**
+	 * ********************** Internal Use Area *******************************
+	 **/
+	if (FRU->CommonHeader.InternalUseAreaStartOffset != 0)
+	{
+		printf("---> InterpretFRUData log1");
+		if((uint32_t)((pTmp->InternalUseAreaStartOffset * 8)) > FRU_Size)
+		{		  	
+			printf(" return error!\n");
+			return FRU_INVALID_AREA;
+		}
+		printf("\n");
+		GetInternalUseArea(pBuff, FRU);
+	}
+
+	/**
+	 * ********************** Chassis Info Area *******************************
+	 **/
+	if (FRU->CommonHeader.ChassisInfoAreaStartOffset != 0)
+	{
+		printf("---> InterpretFRUData log2");
+		if((uint32_t)((pTmp->ChassisInfoAreaStartOffset * 8)) > FRU_Size)
+		{		  	
+			printf(" return error!\n");
+			return FRU_INVALID_AREA;
+		}
+		printf("\n");
+		if(GetChassisInfoArea(pBuff, FRU)!= 0)
+		{
+                      return -1;
+		}
+	}
+
+	/**
+	 * ********************** Board Info Area *******************************
+	 **/
+	if (FRU->CommonHeader.BoardInfoAreaStartOffset != 0)
+	{
+		printf("---> InterpretFRUData log3");
+		if((uint32_t)((pTmp->BoardInfoAreaStartOffset * 8)) > FRU_Size)
+		{		  	
+			printf(" return error!\n");
+			return FRU_INVALID_AREA;
+		}
+		printf("\n");
+		if(GetBoardInfoArea(pBuff, FRU)!=0)
+		{
+                      return -1;
+		}
+	}
+
+	/**
+	 * ********************** Product Info Area *******************************
+	 **/
+	if (FRU->CommonHeader.ProductInfoAreaStartOffset != 0)
+	{
+		printf("---> InterpretFRUData log4");
+		if((uint32_t)((pTmp->ProductInfoAreaStartOffset * 8)) > FRU_Size)
+		{		  	
+			printf(" return error!\n");
+			return FRU_INVALID_AREA;
+		}
+		
+		if( GetProductInfoArea(pBuff, FRU) != 0)
+		{
+			printf("GetProductInfoArea return error!\n");
+                      return -1;
+		}
+	}
+	
+return 0;
+
+}
+
+
+
+
+static uint16_t get_fru_info (IPMI20_SESSION_T* psession,
+				  u8 fru_device_id,
+				  u32* p_fru_size,
+				  FRUData_T* fru_data,
+				  int timeout)
+{
+	FRUInventoryAreaInfoReq_T 	fru_inv_area_req;
+	FRUInventoryAreaInfoRes_T 	fru_inv_area_res;
+	u8*							pFRUBuff = NULL;
+	u8*							tempFRUBuff = NULL;
+	u8*							fru_res_data = NULL;
+	u32							fru_res_data_len = 0;
+	FRUReadReq_T				fru_read_req;
+
+	u32							wRet = 0;
+	u32							fru_size = 0;
+	u8								BLOCK_OF_DATA_TO_READ = 128;
+	u8                         isValidFRU = 0;
+	FRUCommonHeader_T *pTmp = NULL;
+	int i = 0;
+
+	if(psession->byMediumType == IPMB_MEDIUM)
+	{
+		BLOCK_OF_DATA_TO_READ = 24;	//IPMB max message packet is 32 bytes. 
+												//24 + message header + completion code + checksum2 = 32
+	}
+	/**
+	 * returns the overall size(in bytes) of the FRU
+	 * inventory area in this device
+	 **/
+	fru_inv_area_req.FRUDeviceID = fru_device_id;
+
+	wRet = IPMICMD_GetFRUInventoryAreaInfo (psession,
+											&fru_inv_area_req,
+											&fru_inv_area_res,
+											timeout);
+	if ((wRet != 0) &&((fru_inv_area_res.CompletionCode & 0xFF) != 0xCB))
+	{
+		printf("---> error log 1, wRet = %#x\n", wRet);
+		goto _exit_get_fru_info_;
+	}
+	else
+	{
+
+		#if LIBIPMI_IS_OS_LINUX()
+		syslog (LOG_INFO, "libipmi:get_fru_info: fru-size obtained for device-%d\n", fru_device_id);
+		#endif
+
+		if ((fru_inv_area_res.CompletionCode & 0xFF) == 0xCB)
+		{
+			printf("---> error log 2\n");
+			goto InterpretFRU;
+		}
+
+		*p_fru_size = fru_size = (u32)fru_inv_area_res.Size;
+		printf("---> fru_size = %d\n", fru_size);
+
+		//! Allocate the buffer size to read FRU data for this FRU device
+		tempFRUBuff = pFRUBuff 	= (u8* ) malloc (fru_size);
+		if( tempFRUBuff == NULL)
+		{
+		     printf ("libipmi_fru.c: Error allocating memory for tempFRUBuff\n");
+		     return -1; 
+		}
+
+		if (0 == pFRUBuff ) goto _exit_get_fru_info_;
+
+
+		//! Read complete FRU Data now
+		fru_read_req.FRUDeviceID = fru_device_id;
+		fru_read_req.Offset 	 = 0x00; //! go to start of FRU area
+
+		fru_res_data_len		 = 	sizeof(FRUReadRes_T) + BLOCK_OF_DATA_TO_READ;
+		fru_res_data 			 = (u8* ) malloc ( fru_res_data_len );
+		if( fru_res_data == NULL)
+		{
+		     printf ("libipmi_fru.c: Error allocating memory for tempFRUBuff\n");
+		     return -1; 
+		}
+
+		if (NULL == fru_res_data)
+		{
+			SAFE_FREE (tempFRUBuff);
+			goto _exit_get_fru_info_;
+		}
+
+		// Initially read only the FRU header.
+		fru_read_req.CountToRead = sizeof (FRUCommonHeader_T);
+		
+		while (fru_size) //! while there is data to read
+		{
+			printf("---> get_fru_info log1, fru_size = %d, CountToRead = %d\n", fru_size, fru_read_req.CountToRead);
+			wRet = IPMICMD_ReadFRUData (psession,
+										&fru_read_req,
+										(FRUReadRes_T *) fru_res_data,
+										timeout);
+			for(i=0;i<((FRUReadRes_T *)fru_res_data)->CountReturned;i++)
+				printf("%#x ", fru_res_data[2+i]);
+			printf("\n");
+			if (wRet != 0)
+			{
+				#if LIBIPMI_IS_OS_LINUX()
+				syslog (LOG_ERR,
+						"libipmi:get_fru_info: error reading fru data for device-%d\n",
+						fru_device_id);
+				#endif
+
+				SAFE_FREE (fru_res_data);
+				SAFE_FREE (tempFRUBuff);
+				goto _exit_get_fru_info_;
+
+			}
+			else
+			{
+			    
+				// Validate the FRU Header and proceed for further bytes.
+				if (0 == isValidFRU)
+				{
+					printf("---> log log 2\n");
+					pTmp = (FRUCommonHeader_T *) (fru_res_data + sizeof(FRUReadRes_T));
+					if(pTmp->CommonHeaderFormatVersion != IPMI_FRU_VALID_VERSION)
+					{
+						SAFE_FREE (fru_res_data);
+						SAFE_FREE (tempFRUBuff);
+						wRet = FRU_INVALID_HEADER_VERSION;
+						goto _exit_get_fru_info_;
+					}
+					isValidFRU = 1;
+				}
+				memcpy (pFRUBuff,
+						(fru_res_data + sizeof(FRUReadRes_T)),
+						fru_read_req.CountToRead);
+				pFRUBuff += (fru_read_req.CountToRead);
+			}
+			
+			//! recalculate the size left out
+			fru_size 			-= fru_read_req.CountToRead;
+			fru_read_req.Offset  = htoipmi_u16((ipmitoh_u16(fru_read_req.Offset) + fru_read_req.CountToRead));
+			
+			//! read only 128 bytes at-a-time
+			fru_read_req.CountToRead = ( (fru_size > BLOCK_OF_DATA_TO_READ) ? BLOCK_OF_DATA_TO_READ : fru_size );
+		}
+		SAFE_FREE (fru_res_data);
+
+InterpretFRU:
+		memset(fru_data, 0, sizeof(FRUData_T));
+
+		//! Interpret FRU Data
+		wRet = InterpretFRUData (tempFRUBuff, fru_data,*p_fru_size);
+		if(wRet!=0)
+			goto _exit_get_fru_info_;
+
+		SAFE_FREE (tempFRUBuff);
+	}
+
+_exit_get_fru_info_:
+	return wRet;
+}
+
+uint16_t LIBIPMI_HL_GetFRUData(IPMI20_SESSION_T *pSession,
+					u8 fru_device_id,
+				  	u32* p_fru_size,
+				  	FRUData_T* fru_data,
+					int timeout)
+{
+	return(get_fru_info(pSession,fru_device_id,p_fru_size,fru_data,timeout));
+
+}
+
+/*!
+  * @brief       Free the fru data which includes chassis, board and product informations.
+  * @param[in] fru_data - which contains the fru data.
+  */
+void LIBIPMI_HL_FreeFRUData( FRUData_T* fru_data )
+{
+    int i;
+    
+    //Chassis type
+	SAFE_FREE(fru_data->ChassisInfo.ChassisType);
+    
+    //Chassis Part Num
+    SAFE_FREE(fru_data->ChassisInfo.ChassisPartNum);
+
+    //Chassis Serial Num
+    SAFE_FREE(fru_data->ChassisInfo.ChassisSerialNum)
+
+    // Chassis Custom field
+    for (i = 0; i< fru_data->ChassisInfo.Total_Chassis_CustomField; i++)
+    {
+        SAFE_FREE(fru_data->ChassisInfo.CustomFields[i]);
+    }
+    SAFE_FREE(fru_data->ChassisInfo.CustomFields);
+    
+    //InternalInof Data
+    SAFE_FREE(fru_data->InternalInfo.Data);
+    
+    // Board MfrName
+    SAFE_FREE(fru_data->BoardInfo.BoardMfr);
+
+    // Borad product name
+    SAFE_FREE(fru_data->BoardInfo.BoardProductName);
+
+    //Board Serial Num
+    SAFE_FREE(fru_data->BoardInfo.BoardSerialNum);
+
+    //Board Part Num
+    SAFE_FREE(fru_data->BoardInfo.BoardPartNum);
+
+    //Board FRUID
+    SAFE_FREE(fru_data->BoardInfo.FRUFileID);
+
+    //Board Custom fields
+    for (i = 0; i< fru_data->BoardInfo.Total_Board_CustomField; i++)
+    {
+        SAFE_FREE(fru_data->BoardInfo.CustomFields[i]);
+    }
+    SAFE_FREE(fru_data->BoardInfo.CustomFields);
+
+    //Product MfrName
+    SAFE_FREE(fru_data->ProductInfo.MfrName);
+    
+    //Product Name
+    SAFE_FREE(fru_data->ProductInfo.ProductName);
+
+    //Product Part Num
+    SAFE_FREE(fru_data->ProductInfo.ProductPartNum);
+
+    // Freeing Product version
+    SAFE_FREE(fru_data->ProductInfo.ProductVersion);
+
+    //Product Serial Num
+    SAFE_FREE(fru_data->ProductInfo.ProductSerialNum);
+
+    //Product asset tag
+    SAFE_FREE(fru_data->ProductInfo.AssetTag);
+
+    // Product FRUID
+    SAFE_FREE(fru_data->ProductInfo.FRUFileID);
+
+    // Product Custom filed
+    for (i = 0; i< fru_data->ProductInfo.Total_Product_CustomField; i++)
+    {
+        SAFE_FREE(fru_data->ProductInfo.CustomFields[i]);
+    }
+    SAFE_FREE(fru_data->ProductInfo.CustomFields);
+ }
+

+ 592 - 0
app/goahead-5.1.0/src/libipmi/src/libipmi_sdr.c

@@ -0,0 +1,592 @@
+/*****************************************************************
+******************************************************************
+***                                                            ***
+***        (C)Copyright 2008, American Megatrends Inc.         ***
+***                                                            ***
+***                    All Rights Reserved                     ***
+***                                                            ***
+***       5555 Oakbrook Parkway, Norcross, GA 30093, USA       ***
+***                                                            ***
+***                     Phone 770.246.8600                     ***
+***                                                            ***
+******************************************************************
+******************************************************************
+******************************************************************
+* 
+* Filename: libipmi_sdr.c
+*
+******************************************************************/
+#include <string.h>
+#include <stdlib.h>
+
+#include "dbgout.h"
+
+#include "libipmi_session.h"
+#include "libipmi_errorcodes.h"
+#include "libipmi_sdr.h"
+#include "IPMI_Storage.h"
+#include "std_macros.h"
+
+#include "libipmi_sal_session.h"
+
+
+#ifdef __GNUC__
+/** \brief gcc method for designating a packed struct */
+#define PACKED __attribute__ ((packed))
+#else
+#define PACKED
+#pragma pack( 1 )
+#endif
+
+
+#include "IPMI_SDRRecord.h"
+
+
+#undef PACKED
+#ifndef __GNUC__
+#pragma pack( )
+#endif
+
+
+
+/* Get SDR Repository Info Command */
+LIBIPMI_API uint16_t    IPMICMD_GetSDRRepositoryInfo( IPMI20_SESSION_T *pSession,
+                                        SDRRepositoryInfo_T *pResGetSDRRepositoryInfo,
+                                        int timeout)
+{
+    uint8_t    Req[20];
+    uint16_t    wRet;
+    uint32_t    dwResLen;
+
+    dwResLen = sizeof(SDRRepositoryInfo_T);
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+                                            NETFNLUN_IPMI_STORAGE, CMD_GET_SDR_REPOSITORY_INFO,
+                                            (uint8_t*)Req, 0,
+                                            (uint8_t *)pResGetSDRRepositoryInfo, &dwResLen,
+                                            timeout);
+
+    return wRet;
+}
+
+/* Get SDR Repository Allocation Info Command */
+LIBIPMI_API uint16_t    IPMICMD_GetSDRRepositoryAllocInfo( IPMI20_SESSION_T *pSession,
+                                        SDRRepositoryAllocInfo_T *pResGetSDRRepositoryAllocInfo,
+                                        int timeout)
+{
+    uint8_t    Req[20];
+    uint16_t    wRet;
+    uint32_t    dwResLen;
+
+    dwResLen = sizeof(SDRRepositoryAllocInfo_T);
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+                                            NETFNLUN_IPMI_STORAGE, CMD_GET_SDR_REPOSITORY_ALLOCATION_INFO,
+                                            (uint8_t*)Req, 0,
+                                            (uint8_t *)pResGetSDRRepositoryAllocInfo, &dwResLen,
+                                            timeout);
+
+    return wRet;
+}
+
+/* Reserve SDR Repository Command */
+LIBIPMI_API uint16_t    IPMICMD_ReserveSDRRepository( IPMI20_SESSION_T *pSession,
+                                        ReserveSDRRepositoryRes_T *pResReserveSDRRepository,
+                                        int timeout)
+{
+    uint8_t    Req[20];
+    uint16_t    wRet;
+    uint32_t    dwResLen;
+
+    dwResLen = sizeof(ReserveSDRRepositoryRes_T);
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+                                            NETFNLUN_IPMI_STORAGE, CMD_RESERVE_SDR_REPOSITORY,
+                                            (uint8_t*)Req, 0,
+                                            (uint8_t *)pResReserveSDRRepository, &dwResLen,
+                                            timeout);
+
+    return wRet;
+}
+
+
+/* Get SDR Command */
+LIBIPMI_API uint16_t    IPMICMD_GetSDR( IPMI20_SESSION_T *pSession,
+                                    GetSDRReq_T *pReqGetSDR,
+                                    GetSDRRes_T *pResGetSDR,
+                                    uint32_t        *pdwOutBuffLen,
+                                    int timeout)
+{
+    uint16_t    wRet;
+    uint32_t    dwResLen;
+
+    dwResLen = *pdwOutBuffLen;
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+                                            NETFNLUN_IPMI_STORAGE, CMD_GET_SDR,
+                                            (uint8_t*)pReqGetSDR, sizeof(GetSDRReq_T),
+                                            (uint8_t *)pResGetSDR, &dwResLen,
+                                            timeout);
+
+    *pdwOutBuffLen = dwResLen;
+
+    return wRet;
+}
+
+
+/* Add SDR Command */
+LIBIPMI_API uint16_t    IPMICMD_AddSDR( IPMI20_SESSION_T *pSession,
+                                    uint8_t        *pReqAddSDR,
+                                    uint32_t        dwInBuffLen,
+                                    AddSDRRes_T *pResAddSDR,
+                                    int timeout)
+{
+    uint16_t    wRet;
+    uint32_t    dwResLen;
+
+    dwResLen = sizeof(AddSDRRes_T);
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+                                            NETFNLUN_IPMI_STORAGE, CMD_ADD_SDR,
+                                            (uint8_t*)pReqAddSDR, dwInBuffLen,
+                                            (uint8_t *)pResAddSDR, &dwResLen,
+                                            timeout);
+
+    return wRet;
+}
+
+
+/* Partial Add SDR Command */
+LIBIPMI_API uint16_t    IPMICMD_PartialAddSDR( IPMI20_SESSION_T *pSession,
+                                    PartialAddSDRReq_T *pReqPartialAddSDR,
+                                    uint32_t        dwInBuffLen,
+                                    PartialAddSDRRes_T *pResPartialAddSDR,
+                                    int timeout)
+{
+    uint16_t    wRet;
+    uint32_t    dwResLen;
+
+    dwResLen = sizeof(PartialAddSDRRes_T);
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+                                            NETFNLUN_IPMI_STORAGE, CMD_PARTIAL_ADD_SDR,
+                                            (uint8_t*)pReqPartialAddSDR, dwInBuffLen,
+                                            (uint8_t *)pResPartialAddSDR, &dwResLen,
+                                            timeout);
+
+    return wRet;
+}
+
+
+/* Delete SDR Command */
+LIBIPMI_API uint16_t    IPMICMD_DeleteSDR( IPMI20_SESSION_T *pSession,
+                                    DeleteSDRReq_T *pReqDeleteSDR,
+                                    DeleteSDRReq_T *pResDeleteSDR,
+                                    int timeout)
+{
+    uint16_t    wRet;
+    uint32_t    dwResLen;
+
+    dwResLen = sizeof(DeleteSDRReq_T);
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+                                            NETFNLUN_IPMI_STORAGE, CMD_DELETE_SDR,
+                                            (uint8_t*)pReqDeleteSDR, sizeof(DeleteSDRReq_T),
+                                            (uint8_t *)pResDeleteSDR, &dwResLen,
+                                            timeout);
+
+    return wRet;
+}
+
+
+/* Clear SDR Repository Command */
+LIBIPMI_API uint16_t    IPMICMD_ClearSDRRepository( IPMI20_SESSION_T *pSession,
+                                    ClearSDRReq_T *pReqClearSDR,
+                                    ClearSDRRes_T *pResClearSDR,
+                                    int timeout)
+{
+    uint16_t    wRet;
+    uint32_t    dwResLen;
+
+    dwResLen = sizeof(ClearSDRRes_T);
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+                                            NETFNLUN_IPMI_STORAGE, CMD_CLEAR_SDR_REPOSITORY,
+                                            (uint8_t*)pReqClearSDR, sizeof(ClearSDRReq_T),
+                                            (uint8_t *)pResClearSDR, &dwResLen,
+                                            timeout);
+
+    return wRet;
+}
+
+
+/* Get SDR Repository Time Command */
+LIBIPMI_API uint16_t    IPMICMD_GetSDRRepositoryTime( IPMI20_SESSION_T *pSession,
+                                    GetSDRRepositoryTimeRes_T *pResGetSDRRepositoryTime,
+                                    int timeout)
+{
+    uint8_t    Req[20];
+    uint16_t    wRet;
+    uint32_t    dwResLen;
+
+    dwResLen = sizeof(GetSDRRepositoryTimeRes_T);
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+                                            NETFNLUN_IPMI_STORAGE, CMD_GET_SDR_REPOSITORY_TIME,
+                                            (uint8_t*)Req, 0,
+                                            (uint8_t *)pResGetSDRRepositoryTime, &dwResLen,
+                                            timeout);
+
+    return wRet;
+}
+
+
+/* Set SDR Repository Time Command */
+LIBIPMI_API uint16_t    IPMICMD_SetSDRRepositoryTime( IPMI20_SESSION_T *pSession,
+                                    SetSDRRepositoryTimeReq_T *pReqSetSDRRepositoryTime,
+                                    uint8_t *pResSetSDRRepositoryTime,
+                                    int timeout)
+{
+    uint16_t    wRet;
+    uint32_t    dwResLen;
+
+    dwResLen = sizeof(uint8_t);
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+                                            NETFNLUN_IPMI_STORAGE, CMD_SET_SDR_REPOSITORY_TIME,
+                                            (uint8_t*)pReqSetSDRRepositoryTime, sizeof(SetSDRRepositoryTimeReq_T),
+                                            (uint8_t *)pResSetSDRRepositoryTime, &dwResLen,
+                                            timeout);
+
+    return wRet;
+}
+
+
+/* Enter SDR Repository Update Mode Command */
+LIBIPMI_API uint16_t    IPMICMD_EnterSDRUpdateMode( IPMI20_SESSION_T *pSession,
+                                    EnterSDRUpdateModeRes_T *pResEnterSDRUpdateMode,
+                                    int timeout)
+{
+    uint8_t    Req[20];
+    uint16_t    wRet;
+    uint32_t    dwResLen;
+
+    dwResLen = sizeof(EnterSDRUpdateModeRes_T);
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+                                            NETFNLUN_IPMI_STORAGE, CMD_ENTER_SDR_REPOSITORY_UPDATE_MODE,
+                                            (uint8_t*)Req, 0,
+                                            (uint8_t *)pResEnterSDRUpdateMode, &dwResLen,
+                                            timeout);
+
+    return wRet;
+}
+
+/* Exit SDR Repository Update Mode Command */
+LIBIPMI_API uint16_t    IPMICMD_ExitSDRUpdateMode( IPMI20_SESSION_T *pSession,
+                                    ExitSDRUpdateModeRes_T *pResExitSDRUpdateMode,
+                                    int timeout)
+{
+    uint8_t    Req[20];
+    uint16_t    wRet;
+    uint32_t    dwResLen;
+
+    dwResLen = sizeof(ExitSDRUpdateModeRes_T);
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+                                            NETFNLUN_IPMI_STORAGE, CMD_EXIT_SDR_REPOSITORY_UPDATE_MODE,
+                                            (uint8_t*)Req, 0,
+                                            (uint8_t *)pResExitSDRUpdateMode, &dwResLen,
+                                            timeout);
+
+    return wRet;
+}
+
+/* Run Initialization Agent Command */
+LIBIPMI_API uint16_t    IPMICMD_RunInitAgent( IPMI20_SESSION_T *pSession,
+                                    RunInitAgentReq_T *pReqRunInitAgent,
+                                    RunInitAgentRes_T *pResRunInitAgent,
+                                    int timeout)
+{
+    uint16_t    wRet;
+    uint32_t    dwResLen;
+
+    dwResLen = sizeof(RunInitAgentRes_T);
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, PAYLOAD_TYPE_IPMI,
+                                            NETFNLUN_IPMI_STORAGE, CMD_RUN_INITIALIZATION_AGENT,
+                                            (uint8_t*)pReqRunInitAgent, sizeof(RunInitAgentReq_T),
+                                            (uint8_t *)pResRunInitAgent, &dwResLen,
+                                            timeout);
+
+    return wRet;
+}
+
+
+/***************** High level SDR commands *********************/
+static uint16_t ipmb_get_sdr( IPMI20_SESSION_T *pSession,
+                                              uint16_t reservation_id,
+                                              uint16_t record_id,
+					      GetSDRRes_T *pGetSDRRes,
+					      uint32_t *dwRecordLen,
+                                              int timeout )
+{
+#define IPMB_SDR_MAX_SINGLE_READ	(22)	//32 bytes - ipmb message header - response header - checksum2
+	uint8_t offset = (u8)0;
+	uint8_t remaining_bytes;
+	uint8_t bytes_to_read;
+	uint32_t dwRetLen;
+	uint16_t wRet;
+	
+	uint8_t	data_buffer[255];
+	GetSDRReq_T get_sdr_req;
+	SDRRecHdr_T	*sdr_record;
+	
+	uint8_t	*output_buffer;
+	uint32_t	output_buffer_ix=0;
+	
+	output_buffer = (uint8_t *)pGetSDRRes;
+	
+	/* Find the record length first */
+	get_sdr_req.ReservationID = htoipmi_u16(reservation_id);
+	get_sdr_req.RecID = htoipmi_u16( record_id );
+	get_sdr_req.Offset = 0;
+	get_sdr_req.Size = sizeof(SDRRecHdr_T);
+	dwRetLen = sizeof(SDRRecHdr_T) + sizeof(GetSDRRes_T);
+	wRet = IPMICMD_GetSDR( pSession, &get_sdr_req, (GetSDRRes_T *)&data_buffer[0],
+			&dwRetLen, timeout );
+	
+	if(wRet != LIBIPMI_E_SUCCESS)
+		return wRet;
+		
+	/* We got record length. Now we read the record */
+	sdr_record = (SDRRecHdr_T*)&data_buffer[sizeof(GetSDRRes_T)];
+	offset = sizeof(SDRRecHdr_T);
+	remaining_bytes = sdr_record->Len;
+	
+	/* copy to output buffer */
+	memcpy(&output_buffer[output_buffer_ix], data_buffer, dwRetLen);
+	output_buffer_ix += dwRetLen;
+	
+	do {
+		bytes_to_read = (remaining_bytes > IPMB_SDR_MAX_SINGLE_READ)? IPMB_SDR_MAX_SINGLE_READ : remaining_bytes;
+		
+		get_sdr_req.ReservationID = htoipmi_u16(reservation_id);
+		get_sdr_req.RecID = htoipmi_u16( record_id );
+		get_sdr_req.Offset = offset;
+		get_sdr_req.Size = bytes_to_read;
+		dwRetLen = bytes_to_read + sizeof(GetSDRRes_T);
+		wRet = IPMICMD_GetSDR( pSession, &get_sdr_req, (GetSDRRes_T*)&data_buffer[0],
+				&dwRetLen, timeout );
+		
+		if(wRet != LIBIPMI_E_SUCCESS)
+			return wRet;
+		
+		memcpy(&output_buffer[output_buffer_ix], &data_buffer[sizeof(GetSDRRes_T)], bytes_to_read);
+		output_buffer_ix += bytes_to_read;
+		
+		offset += bytes_to_read;
+		remaining_bytes -= bytes_to_read;
+	
+	}while( remaining_bytes > 0 );
+	
+	sdr_record = (SDRRecHdr_T*)&output_buffer[sizeof(GetSDRRes_T)];
+	*dwRecordLen = sdr_record->Len + sizeof(SDRRecHdr_T);
+
+	return LIBIPMI_E_SUCCESS;	
+}
+
+LIBIPMI_API uint16_t LIBIPMI_HL_GetSDR( IPMI20_SESSION_T *pSession,
+                                              uint16_t reservation_id,
+                                              uint16_t record_id,
+					      GetSDRRes_T *pGetSDRRes,
+					      uint32_t *dwDataLen,
+                                              int timeout )
+{
+	uint16_t	wRet=LIBIPMI_E_SUCCESS;
+	
+	
+	if( pSession->byMediumType == IPMB_MEDIUM )
+	{
+		wRet = ipmb_get_sdr(pSession, reservation_id, 
+					record_id,
+					pGetSDRRes,
+					dwDataLen,
+					timeout );
+	}
+	else
+	{
+		GetSDRReq_T get_sdr_req;
+			
+		get_sdr_req.ReservationID = htoipmi_u16(reservation_id);
+		get_sdr_req.RecID = htoipmi_u16( record_id );
+		get_sdr_req.Offset = 0;
+		get_sdr_req.Size = 0xff;
+    		wRet = IPMICMD_GetSDR( pSession, &get_sdr_req, pGetSDRRes,
+                           dwDataLen, timeout );
+	}
+
+	return wRet;	
+}
+
+LIBIPMI_API uint16_t LIBIPMI_HL_GetCompleteSDR( IPMI20_SESSION_T *pSession,
+                                              uint16_t record_id,
+                                              uint16_t *next_record_id,
+                                              uint8_t *sdr_buffer,
+                                              size_t buffer_len,
+                                              int timeout )
+{
+    uint16_t wRet;
+    ReserveSDRRepositoryRes_T reservation;
+    SDRRepositoryAllocInfo_T alloc_info;
+    uint8_t *temp_buffer;
+    GetSDRRes_T *get_sdr_res;
+    uint32_t blen = 0;
+    int max_sdr_len;
+
+    /* Get repository allocation information */
+    wRet = IPMICMD_GetSDRRepositoryAllocInfo( pSession, &alloc_info, timeout );
+    if( wRet != LIBIPMI_E_SUCCESS )
+        return( wRet );
+    
+    reservation.ReservationID = 0; //Setting reservation ID as zero as we are trying to get complete SDR.
+    
+    /* Determine max SDR entry length */
+    max_sdr_len = alloc_info.MaxRecSize * ipmitoh_u16( alloc_info.AllocUnitSize );
+
+    /* Make sure the calling function has space for this thing */
+    if( buffer_len < (size_t) max_sdr_len )
+        return( STATUS_CODE( IPMI_ERROR_FLAG, OEMCC_NOMEM ) );
+
+    
+    temp_buffer = malloc( max_sdr_len + sizeof( GetSDRRes_T ) );
+    if( temp_buffer == NULL )
+        return( STATUS_CODE( IPMI_ERROR_FLAG, OEMCC_NOMEM ) );
+    
+    get_sdr_res = (GetSDRRes_T *)temp_buffer;
+	if(pSession->byMediumType == NETWORK_MEDIUM_UDP_SAL)
+    {
+        blen = max_sdr_len + sizeof(GetSDRRes_T);
+    }
+
+#if 0        
+    get_sdr_req.ReservationID = reservation.ReservationID;
+    get_sdr_req.RecID = htoipmi_u16( record_id );
+    get_sdr_req.Offset = 0;
+    get_sdr_req.Size = 0xff;
+
+    /* Now try to get the whole record */
+    wRet = IPMICMD_GetSDR( pSession, &get_sdr_req, (GetSDRRes_T *)temp_buffer,
+                           &blen, timeout );
+#endif
+    wRet = LIBIPMI_HL_GetSDR(pSession, ipmitoh_u16(reservation.ReservationID),
+    					record_id, (GetSDRRes_T *)temp_buffer, &blen, timeout);
+    if( wRet != LIBIPMI_E_SUCCESS )
+    {
+        free( temp_buffer );
+        return( wRet );
+    }
+
+    *next_record_id = ipmitoh_u16( get_sdr_res->NextRecID );
+
+    memcpy( sdr_buffer, temp_buffer + sizeof( GetSDRRes_T ), blen );
+    free( temp_buffer );
+
+    return( wRet );
+}
+
+
+LIBIPMI_API uint16_t LIBIPMI_HL_GetAllSDRs( IPMI20_SESSION_T *pSession,
+                                          uint8_t *sdr_buffer, size_t buffer_len,
+                                          int timeout )
+{
+    uint16_t wRet;
+    uint16_t record_id = 0;
+    int max_sdr_len;
+    int sdr_count;
+    SDRRepositoryAllocInfo_T alloc_info;
+    SDRRepositoryInfo_T repo_info;
+    int i;
+
+    /* Get repository allocation information */
+    wRet = IPMICMD_GetSDRRepositoryAllocInfo( pSession, &alloc_info, timeout );
+    if( wRet != LIBIPMI_E_SUCCESS )
+        return( wRet );
+
+    /* Get repository information */
+    wRet = IPMICMD_GetSDRRepositoryInfo( pSession, &repo_info, timeout );
+    if( wRet != LIBIPMI_E_SUCCESS )
+        return( -1 );
+
+    /* Determine max SDR entry length */
+    max_sdr_len = alloc_info.MaxRecSize * ipmitoh_u16( alloc_info.AllocUnitSize );
+
+    /* Determine total number of SDRs stored */
+    sdr_count = ipmitoh_u16( repo_info.RecCt );
+
+    /* Make sure the passed buffer is large enough */
+    if( buffer_len < (size_t) ( max_sdr_len * sdr_count ) )
+        return( STATUS_CODE( IPMI_ERROR_FLAG, OEMCC_NOMEM ) );
+
+    /* Read all the SDRs in this loop */
+    for( i = 0; i < sdr_count; i++ )
+    {
+        uint16_t next_record_id;
+
+        /* Read the full SDR into the buffer */
+        wRet = LIBIPMI_HL_GetCompleteSDR( pSession, record_id, &next_record_id,
+                                          &sdr_buffer[ i * max_sdr_len ],
+                                          max_sdr_len, timeout );
+        if( wRet != LIBIPMI_E_SUCCESS )
+            return( wRet );
+
+        record_id = next_record_id;
+    }
+
+    return( wRet );
+}
+
+int CacheGetAllSDRS(IPMI20_SESSION_T* pSession,uint8_t* sdr_buffer,uint32_t* buff_size,uint32_t* max_sdr_len,uint32_t* sdr_count);
+
+LIBIPMI_API uint16_t LIBIPMI_HL_GetAllSDRs_Cached( IPMI20_SESSION_T *pSession,
+                                          uint8_t *sdr_buffer, 
+										  uint32_t* sdr_buff_size,
+										  uint32_t* max_sdr_len,
+										  uint32_t * sdr_count,
+                                          int timeout )
+{
+	uint16_t wRet;
+
+	wRet = CacheGetAllSDRS(pSession,sdr_buffer,sdr_buff_size,max_sdr_len,sdr_count);
+
+    
+	return wRet;
+}
+
+LIBIPMI_API uint16_t LIBIPMI_HL_GetSpecificSDR( IPMI20_SESSION_T *pSession,
+                                                uint8_t *sdr_buffer, 
+                                                uint32_t* sdr_buff_size,
+                                                int SensorNumber,
+                                                int timeout )
+{
+    ReserveSDRRepositoryRes_T ResReserveSDRRepository;
+    uint8_t data_buffer[255];
+    FullSensorRec_T	*sdr_record = (FullSensorRec_T*) &data_buffer[sizeof(GetSDRRes_T)];
+    GetSDRReq_T ReqGetSDR;
+    GetSDRRes_T *pResGetSDR = (GetSDRRes_T *) &data_buffer[0];
+    uint32_t      dwRetLen = sizeof data_buffer;
+    int wRet = 0;
+    
+    wRet = IPMICMD_ReserveSDRRepository(pSession, &ResReserveSDRRepository, timeout);
+        
+    pResGetSDR->NextRecID = 0;
+    while (1)
+    {
+        ReqGetSDR.ReservationID = ResReserveSDRRepository.ReservationID;
+        ReqGetSDR.RecID = pResGetSDR->NextRecID;
+        ReqGetSDR.Offset = 0;
+        ReqGetSDR.Size = 0xff;
+        //wRet = IPMICMD_GetSDR(pSession, &ReqGetSDR, pResGetSDR, &dwRetLen, timeout);
+        //TODO: IPMICMD_GetSDR replaced by LIBIPMI_HL_GetSDR, by jimbo
+        wRet = LIBIPMI_HL_GetSDR(pSession,	ReqGetSDR.ReservationID, ReqGetSDR.RecID, pResGetSDR, &dwRetLen, timeout );
+        if (wRet != LIBIPMI_E_SUCCESS)
+            break;
+        
+        if (sdr_record->SensorNum == SensorNumber)
+            break;  // found
+    }
+    
+    dwRetLen -= sizeof(GetSDRRes_T);
+    *sdr_buff_size = *sdr_buff_size >= dwRetLen ? dwRetLen : *sdr_buff_size;
+    memcpy(sdr_buffer, sdr_record, *sdr_buff_size);
+        
+    return wRet;
+}
+

Some files were not shown because too many files changed in this diff