#ifndef __LIBIPMI_SDR_H__
#define __LIBIPMI_SDR_H__

/* LIIPMI core header files */
#include "libipmi_session.h"
#include "libipmi_errorcodes.h"
#include "com_BmcType.h"

/* command specific header files */
#pragma pack(1)
#include "com_IPMI_SDR.h"
#pragma pack()

#include "com_IPMI_SensorEvent.h"

#ifdef  __cplusplus
extern "C" {
#endif




/* Get SDR Repository Info Command */
  uint16_t	IPMICMD_GetSDRRepositoryInfo( IPMI20_UDS_SESSION_T *pUDSSession,
										SDRRepositoryInfo_T *pResGetSDRRepositoryInfo,
										int timeout);
uint16_t    IPMC_GetSDRRepositoryInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, 
                                        SDRRepositoryInfo_T *pResGetSDRRepositoryInfo,
                                        int timeout);

/* Get SDR Repository Allocation Info Command */
  uint16_t	IPMICMD_GetSDRRepositoryAllocInfo( IPMI20_UDS_SESSION_T *pUDSSession,
										SDRRepositoryAllocInfo_T *pResGetSDRRepositoryAllocInfo,
										int timeout);
  uint16_t    IPMC_GetSDRRepositoryAllocInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, 
                                        SDRRepositoryAllocInfo_T *pResGetSDRRepositoryAllocInfo,
                                        int timeout);

/* Reserve SDR Repository Command */
  uint16_t	IPMICMD_ReserveSDRRepository( IPMI20_UDS_SESSION_T *pUDSSession,
										ReserveSDRRepositoryRes_T *pResReserveSDRRepository,
										int timeout);

/* Get SDR Command */
  uint16_t	IPMICMD_GetSDR( IPMI20_UDS_SESSION_T *pUDSSession,
									GetSDRReq_T *pReqGetSDR,
									GetSDRRes_T *pResGetSDR,
									uint32_t		*pdwOutBuffLen,
									int timeout);

/* Add SDR Command */
  uint16_t	IPMICMD_AddSDR( IPMI20_UDS_SESSION_T *pUDSSession,
									uint8_t		*pReqAddSDR,
									uint32_t		dwInBuffLen,
									AddSDRRes_T *pResAddSDR,
									int timeout);

/* Partial Add SDR Command */
  uint16_t	IPMICMD_PartialAddSDR( IPMI20_UDS_SESSION_T *pUDSSession,
									PartialAddSDRReq_T *pReqPartialAddSDR,
									uint32_t		dwInBuffLen,
									PartialAddSDRRes_T *pResPartialAddSDR,
									int timeout);

/* Delete SDR Command */
  uint16_t	IPMICMD_DeleteSDR( IPMI20_UDS_SESSION_T *pUDSSession,
									DeleteSDRReq_T *pReqDeleteSDR,
									DeleteSDRReq_T *pResDeleteSDR,
									int timeout);

/* Clear SDR Repository Command */
  uint16_t	IPMICMD_ClearSDRRepository( IPMI20_UDS_SESSION_T *pUDSSession,
									ClearSDRReq_T *pReqClearSDR,
									ClearSDRRes_T *pResClearSDR,
									int timeout);

/* Get SDR Repository Time Command */
  uint16_t	IPMICMD_GetSDRRepositoryTime( IPMI20_UDS_SESSION_T *pUDSSession,
									GetSDRRepositoryTimeRes_T *pResGetSDRRepositoryTime,
									int timeout);

/* Set SDR Repository Time Command */
  uint16_t	IPMICMD_SetSDRRepositoryTime( IPMI20_UDS_SESSION_T *pUDSSession,
									SetSDRRepositoryTimeReq_T *pReqSetSDRRepositoryTime,
									uint8_t *pResSetSDRRepositoryTime,
									int timeout);

/* Enter SDR Repository Update Mode Command */
  uint16_t	IPMICMD_EnterSDRUpdateMode( IPMI20_UDS_SESSION_T *pUDSSession,
									EnterSDRUpdateModeRes_T *pResEnterSDRUpdateMode,
									int timeout);

/* Exit SDR Repository Update Mode Command */
  uint16_t	IPMICMD_ExitSDRUpdateMode( IPMI20_UDS_SESSION_T *pUDSSession,
									ExitSDRUpdateModeRes_T *pResExitSDRUpdateMode,
									int timeout);

/* Run Initialization Agent Command */
  uint16_t	IPMICMD_RunInitAgent( IPMI20_UDS_SESSION_T *pUDSSession,
									RunInitAgentReq_T *pReqRunInitAgent,
									RunInitAgentRes_T *pResRunInitAgent,
									int timeout);

/*---------- LIBIPMI Higher level routines -----------*/
uint16_t Storlead_GetCompleteSDR( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
                                              uint16_t record_id,
                                              uint16_t *next_record_id,
                                              uint8_t *sdr_buffer,
                                              size_t buffer_len,
                                              int timeout );

  uint16_t Storlead_GetAllSDRs( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
                                          uint8_t *sdr_buffer, size_t buffer_len,
                                          int timeout );


  uint16_t LIBIPMI_HL_GetSDR( IPMI20_UDS_SESSION_T *pUDSSession,
                                            uint16_t reservation_id,
                                            uint16_t record_id,
                                            GetSDRRes_T *pGetSDRRes,
                                            uint32_t *dwDataLen,
                                            int timeout );
  uint16_t IPMC_GetSDR( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
                                              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


  uint16_t LIBIPMI_HL_GetAllSDRs_Cached( IPMI20_UDS_SESSION_T *pUDSSession,
                                          uint8_t *sdr_buffer, 
										  uint32_t* sdr_buff_size,
										  uint32_t* max_sdr_len,
										  uint32_t * sdr_count,
                                          int timeout );

  uint16_t LIBIPMI_HL_GetSpecificSDR( IPMI20_UDS_SESSION_T *pUDSSession,
										uint8_t *sdr_buffer, 
										uint32_t* sdr_buff_size,
										int SensorNumber,
										int timeout );


#ifdef  __cplusplus
}
#endif

#endif







