/*****************************************************************
 *****************************************************************
 ***                                                            **
 ***    (C)Copyright 2005-2006, American Megatrends Inc.        **
 ***                                                            **
 ***            All Rights Reserved.                            **
 ***                                                            **
 ***        6145-F, Northbelt Parkway, Norcross,                **
 ***                                                            **
 ***        Georgia - 30071, USA. Phone-(770)-246-8600.         **
 ***                                                            **
 *****************************************************************
 *****************************************************************
 ******************************************************************
 *
 * message.h
 * Inter task messaging functions.
 *
 *  Author: Govind Kothandapani <govindk@ami.com>
 ******************************************************************/
#ifndef MESSAGE_H
#define MESSAGE_H

#ifndef uint8_t
  #define uint8_t unsigned char
#endif
#ifndef uint16_t
  #define uint16_t unsigned short
#endif
#ifndef uint32_t
  #define uint32_t unsigned long
#endif

#pragma pack( 1 )

#define IP_ADDR_LEN 4
#define IP6_ADDR_LEN 16
#define COMMON_QUEUE 0

/*-----------------------------------
 * Definitions
 *-----------------------------------*/
#define MSG_PAYLOAD_SIZE	1024*2
#define PIPE_NAME_LEN       	64

/*-----------------------------------
 * Type definitions
 *-----------------------------------*/
typedef struct
{
    uint32_t      Param;                    /* Parameter */
    uint8_t       Channel;                  /* Originator's channel number */
    int           SrcQ ;     /* Originator Queue, fd */
    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 [IP6_ADDR_LEN];    /* IPv6 Address */
    uint16_t      UDPPort;                  /* UDP Port Number  */
    uint16_t      Socket;                   /* socket handle    */
    uint32_t      Size;                     /* Size of the data */
    uint8_t       Data [MSG_PAYLOAD_SIZE];  /* Data */
} MsgPkt_T;


#pragma pack( )

// /**
//  * @brief Initialisation
//  * @return   0 if success, -1 if failed.
// **/
// extern int InitMsg (void);

// /**
//  * @fn PostMsg
//  * @brief Post a message to the destination task.
//  * @param MsgPkt   - Message to be posted.
//  * @param Queue	   - Queue to post this message to.
//  * @return   0 if success, -1 if failed.
// **/
// extern int PostMsg (_FAR_ MsgPkt_T* pMsgPkt, INT8S *Queuepath ,int BMCInst);

// /**
//  * @fn PostMsgNonBlock
//  * @brief Post a message to the destination task without blocking.
//  * @param MsgPkt   - Message to be posted.
//  * @param Queue	   - Queue to post this message to.
//  * @return   0 if success, -1 if failed.
// **/
// extern int PostMsgNonBlock (_FAR_ MsgPkt_T* pMsgPkt, INT8S *Queuepath, int BMCInst );

// /**
//  * @fn AddToQueue
//  * @brief Post a buffer to the destination task.
//  * @param pBuf   - Buffer to be posted.
//  * @param Queuepath    - Queuepath to post this buffer to.
//  * @return   0 if success, -1 if failed.
// **/
// extern int AddToQueue (void* pBuf, INT8S *Queuepath,uint32_t Size,int BMCInst);


// *
//  * @fn GetMsg
//  * @brief Gets the message posted to this task.
//  * @param MsgPkt   - Pointer to the buffer to hold the message packet.
//  * @param Queue    - Queue to fetch the message from.
//  * @param NumMs    - Number of milli-seconds to wait.
//  *  				 WAIT_NONE     - If the function has to return immediately.
//  *					 WAIT_INFINITE - If the function has to wait infinitely.
//  * NOTE :
//  * @return   0 if success, -1 if failed.
// *
// extern int GetMsg (_FAR_ MsgPkt_T*	pMsgPkt, INT8S *Queuepath, INT16S Timeout, int BMCInst);

// /**
//  * @fn GetMsgInMsec
//  * @brief GetMsgInMsec() is wrapper function over GetMsg() and it is maintained for backward compatibality.
//  * */
// extern int GetMsgInMsec (_FAR_ MsgPkt_T* pMsgPkt, INT8S *Queuepath, INT16S Timeout, int BMCInst);


// /**
//  * @brief Returns the number of messages in the Queue.
//  * @param Queue Queue.
// **/
// extern int NumMsg (HQueue_T Queue);

// /**
//  * @fn AddQueue
//  * @brief Adds the Queue to the common Queue Handle structure
//  * @param Queuepath - Queue Path
// **/
// extern int AddQueue(INT8S *Queuepath);

// /**
//  * @fn GetQueue
//  * @brief Opens the Created Queue Handle from the Common
//  *            Queue Handle Structure
//  * @param Queuepath - Queue Path
//  * @return Return 0
// **/
// extern int GetQueue(INT8S *Queuepath,int flags);

// /**
//  * @fn GetQueueHandle
//  * @brief Gets the Queue Handle from the Common
//  *            Queue Handle Structure
//  * @param Queuepath - Queue Path
//  * @param IfcQ  Handle for the needed Queue
//  * @return Return 0
// **/
// extern int GetQueueHandle(INT8S *Queuepath,HQueue_T *IfcQ,int BMCInst);

#endif	/* MESSAGE_H */
