/**
 * @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"
#include "com_IPMI_RMCP.h"

#define PACK __attribute__ ((packed))

/**
 * @def RMCPPing_T
 * @brief RMCP Ping Message
 */
/* IPMI2.0 Specification Table 13-6 */
typedef struct
{
	RMCPHdr_T	Hdr;				/*< RMCP Header 		*/
	uint8_t		IANANum[4];		/*< 4542 (ASF IANA) 	*/
	uint8_t		MsgType;			/*< 80h = Presence Ping */
	uint8_t		MsgTag;				/*< 0-FEh, generated by remote console */
	uint8_t		Reserved1;			/*< 00h 				*/
	uint8_t		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_t		IANANum[4];			/*< 4542 (ASF IANA) 	*/
	uint8_t		MsgType;			/*< 40h = Presence Ping */
	uint8_t		MsgTag;				/*< From Pin Request    */
	uint8_t		Reserved1;			/*< 00h 				*/
	uint8_t		DataLen;			/*< 10h					*/
	uint8_t		OEMIANANum [4];			/*< OEM's IANA Number	*/
	uint8_t		OEM [4];			/*< OEM Defined field	*/
	uint8_t		Support;			/*< 81h for IPMI		*/
	uint8_t		InteractionSupport;	/*< Reserved			*/
	uint8_t		Reserved [6];

} PACK RMCPPong_T;

#if defined (PACK)
#undef PACK
#endif

/**
\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_t 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_t 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_t 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_t 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_t RMCP_Pong(LAN_CHANNEL_T *LanInfo, int timeout);

#endif




