/****************************************************************
 ****************************************************************
 **                                                            **
 **    (C)Copyright 2005-2006, American Megatrends Inc.        **
 **                                                            **
 **            All Rights Reserved.                            **
 **                                                            **
 **        6145-F, Northbelt Parkway, Norcross,                **
 **                                                            **
 **        Georgia - 30071, USA. Phone-(770)-246-8600.         **
 **                                                            **
 ****************************************************************
 ****************************************************************
 ****************************************************************
 *
 * rmcp.h
 * RMCP Packet Handler
 *
 * Author: Govind Kothandapani <govindk@ami.com>
 *       : Bakka Ravinder Reddy <bakkar@ami.com>
 *
 *****************************************************************/
#ifndef IPMI_RMCP_PLUS_H
#define IPMI_RMCP_PLUS_H
#include <stdio.h>
#include <stdint.h>
#include "com_IPMIDefs.h"



#define MAX_PAYLOAD_ALGO_SUPPORTED				3



/**** RSSP and RAKP Message Status Codes *****/
#define SC_NO_ERROR								0
#define SC_INSUFFICIENT_RESOURCE				1
#define SC_INV_SESSION_ID						2
#define SC_INV_PAYLOAD_TYPE						3
#define SC_INV_AUTH_ALGORITHM					4
#define SC_INV_INTEGRITY_ALGORITHM				5
#define SC_NO_MATCHED_AUTH_PAYLOAD				6
#define SC_NO_MATCHED_INTEGRITY_PAYLOAD			7
#define SC_INACTIVE_SESSION_ID					8
#define SC_INV_ROLE								9
#define SC_UNAUTHORISED_ROLE					10
#define SC_INSUFFICIENT_RESOURCE_AT_ROLE		11
#define SC_INV_NAME_LEN							12
#define SC_UNAUTHORISED_NAME					13
#define SC_UNAUTHORISED_GUID					14
#define SC_INV_INTEGRITY_CHECK					15
#define SC_INV_CONFIDENTIALITY_ALGORTHM			16
#define SC_NO_CIPHER_SUITE_MATCH				17

#define SESSION_INTEGRITY_KEY_SIZE              20
#define SESSION_HMAC_MD5_I_KEY_SIZE              16
#define SESSION_MD5_KEY_SIZE    16
#define HASH_KEY1_SIZE                          20
#define HASH_KEY2_SIZE                          20
#define SHA2_HASH_KEY_SIZE						32
#define MAX_HASH_KEY_SIZE       SHA2_HASH_KEY_SIZE    

#pragma pack( 1 )
/**** RSSP Open Session Request ****/
typedef struct
{
    uint8_t   PayloadType;
    uint16_t   Reserved1;
    uint8_t   PayloadLen;
    uint8_t   Algorithm;
    uint8_t   Reserved2 [3];

}   RSSPPayloadInfo_T;

typedef struct
{
    uint8_t				MsgTag;
    uint8_t				Role;
    uint8_t				Reserved [2];
    uint32_t				RemConSessionID;
    RSSPPayloadInfo_T	Auth;
    RSSPPayloadInfo_T	Integrity;
    RSSPPayloadInfo_T	Confidentiality;

}   RSSPOpenSessionReq_T;

/**** RSSP Open Session Response ****/
typedef struct
{
    uint8_t			MsgTag;
    uint8_t			StatusCode;
    uint8_t			Role;    
    uint8_t			Reserved;
    uint32_t			RemConSessionID;

}   RSSPOpenSessionErrRes_T;

typedef struct
{
    uint8_t				MsgTag;
    uint8_t				StatusCode;
    uint8_t				Role;
    uint8_t				Reserved;
    uint32_t				RemConSessionID;
    uint32_t				MgdSysSessionID;
    RSSPPayloadInfo_T	Auth;
    RSSPPayloadInfo_T	Integrity;
    RSSPPayloadInfo_T	Confidentiality;


}   RSSPOpenSessionRes_T;


/**** RAKP Message1 ****/
typedef struct
{

    uint8_t			MsgTag;
    uint8_t			Reserved1 [3];
    uint32_t			ManSysSessionID;
    uint8_t			RemConRandomNo [16];
    uint8_t			Role;
    uint8_t			Reserved2 [2];
    uint8_t			UsrNameLen;
    uint8_t			UsrName [16];

}   RAKPMsg1Req_T;

/**** RAKP Message2 ****/
typedef struct
{
    uint8_t			MsgTag;
    uint8_t			StatusCode;
    uint8_t			Reserved1 [2];
    uint32_t			RemConSessionID;

}   RAKPMsg2ErrRes_T;

typedef struct
{

    uint8_t			MsgTag;
    uint8_t			StatusCode;
    uint8_t			Reserved1 [2];
    uint32_t			RemConSessionID;
    uint8_t			ManSysRandomNo [16];
    uint8_t			ManSysGUID [16];

}   RAKPMsg2Res_T;

typedef struct
{

    uint32_t			RemConSessionID;
    uint32_t			MgdSysSessionID;
    uint8_t			RemConRandNo [16];
    uint8_t			MgdSysRandNo [16];
    uint8_t			MgdSysGUID [16];
    uint8_t			Role;
    uint8_t			UsrNameLen;
    uint8_t			UsrName [16];

}   RAKPMsg1HMAC_T;

/**** RAKP Message3 ****/
typedef struct
{
    uint8_t			MsgTag;
    uint8_t			StatusCode;
    uint8_t			Reserved1 [2];
    uint32_t			ManSysSessionID;

}   RAKPMsg3Req_T;


typedef struct
{
    uint8_t			MgdSysRandNo [16];
    uint32_t			RemConSessionID;
    uint8_t			Role;
    uint8_t			UsrNameLen;
    uint8_t			UsrName [16];

}   Msg3hmac_T;


typedef struct
{
    uint8_t			RemConRandNo [16];
    uint8_t			MgdSysRandNo [16];
    uint8_t			Role;
    uint8_t			UsrNameLen;
    uint8_t			UsrName [16];

}   SIKhmac_T;

/**** RAKP Message4 ****/
typedef struct
{
    uint8_t			MsgTag;
    uint8_t			StatusCode;
    uint8_t			Reserved1 [2];
    uint32_t			RemConSessionID;

}   RAKPMsg4ErrRes_T;

typedef struct
{

    uint8_t			MsgTag;
    uint8_t			StatusCode;
    uint8_t			Reserved1 [2];
    uint32_t			RemConSessionID;

}   RAKPMsg4Res_T;

typedef struct
{
    uint8_t			RemConRandNo [16];
    uint32_t			MgdSysSessionID;
    uint8_t			MgdSysGUID [16];

}   RAKPMsg4hmac_T;



#pragma pack( )

#endif /* RMCP_PLUS_H */
