Session.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /****************************************************************
  2. ****************************************************************
  3. ** **
  4. ** (C)Copyright 2005-2006, American Megatrends Inc. **
  5. ** **
  6. ** All Rights Reserved. **
  7. ** **
  8. ** 6145-F, Northbelt Parkway, Norcross, **
  9. ** **
  10. ** Georgia - 30071, USA. Phone-(770)-246-8600. **
  11. ** **
  12. ****************************************************************
  13. ****************************************************************/
  14. /*****************************************************************
  15. *
  16. * Session.h
  17. *
  18. *
  19. * Author: Govind Kothandapani <govindk@ami.com>
  20. * : Rama Bisa <ramab@ami.com>
  21. * : Basavaraj Astekar <basavaraja@ami.com>
  22. * : Bakka Ravinder Reddy <bakkar@ami.com>
  23. *
  24. *****************************************************************/
  25. #ifndef SESSION_H
  26. #define SESSION_H
  27. #include "com_BmcType.h"
  28. #include "com_IPMI_LANIfc.h"
  29. #include "com_IPMI_RMCP+.h"
  30. #include "com_IPMI_AppDevice.h"
  31. #include "com_IPMIDefs.h"
  32. #include "com_Message.h"
  33. #include "PMConfig.h"
  34. #pragma pack( 1 )
  35. /* Macros */
  36. #define SESSION_ID_INFO 1
  37. #define SESSION_HANDLE_INFO 2
  38. #define SESSION_INDEX_INFO 3
  39. #define SESSION_CHANNEL_INFO 4
  40. #define MGD_SYS_SESSION_ID_INFO 5
  41. #define SESSION_PAYLOAD_INFO 6
  42. #define SESSION_REMOTE_INFO 7
  43. #define MAX_INST_SUPPORTED 2
  44. #define SESSIONLESS_CHANNEL 0x00
  45. #define SINGLE_SESSION_CHANNEL 0x01
  46. #define MULTI_SESSION_CHANNEL 0x02
  47. #define SESSION_BASED_CHANNEL 0x03
  48. #define HASH_DATA_LENGTH 16
  49. #define NULL_USER_ID 1
  50. #define UDS_SESSION_COUNT_INFO 0x00
  51. #define UDS_SESSION_ID_INFO 0x01
  52. #define UDS_SESSION_HANDLE_INFO 0x02
  53. #define UDS_SESSION_INDEX_INFO 0x03
  54. #define UDS_SOCKET_ID_INFO 0x04
  55. #define UDS_SESSION_PID_INFO 0x05
  56. #define UDS_ACTIVE_SESSION_INDEX_LIST 0x06
  57. /* UDS Session Table Info */
  58. typedef struct
  59. {
  60. uint32_t SessionID;
  61. uint32_t LoggedInTime;
  62. uint32_t SessionTimeoutValue;
  63. int UDSSocket;
  64. uint8_t LoggedInUsername[MAX_USERNAME_LEN];
  65. uint8_t LoggedInPassword[MAX_PASSWORD_LEN];
  66. uint8_t LoggedInUserID;
  67. uint8_t Activated;
  68. uint8_t LoggedInSessionHandle;
  69. uint8_t UDSChannelNum;
  70. uint8_t LoggedInChannel;
  71. uint8_t LoggedInPrivilege;
  72. uint8_t AuthenticationMechanism;
  73. uint32_t ProcessID;
  74. uint32_t ThreadID;
  75. uint8_t IPAddr [IP6_ADDR_LEN];
  76. } UDSSessionTbl_T;
  77. typedef struct
  78. {
  79. uint16_t SessionCount;
  80. UDSSessionTbl_T *UDSSessionTbl;
  81. } UDSSessionTblInfo_T;
  82. /* SessPayloadInfo_T */
  83. typedef struct
  84. {
  85. uint8_t Type;
  86. uint8_t OemPldIANA [3];
  87. uint8_t OemPldID [2];
  88. uint8_t Version;
  89. uint16_t PortNum;
  90. uint16_t ActivatedInst;
  91. uint8_t AuxConfig [4];
  92. } SessPayloadInfo_T;
  93. /* structure to keep track the information about a session. */
  94. /* SessionInfo_T */
  95. typedef struct
  96. {
  97. uint8_t Used; /* Flag to indicate the slot used or not */
  98. uint32_t SessionID;
  99. uint8_t Activated;
  100. uint8_t Channel;
  101. uint8_t AuthType;
  102. uint8_t Privilege;
  103. uint8_t MaxPrivilege;
  104. uint32_t InboundSeq;
  105. uint32_t OutboundSeq;
  106. uint32_t TimeOutValue;
  107. uint8_t Password[MAX_PASSWORD_LEN];
  108. uint8_t UserId;
  109. uint8_t SessionHandle;
  110. // uint8_t ChallengeString[CHALLENGE_STR_LEN];
  111. LANRMCPPkt_T LANRMCPPkt;
  112. int hSocket;
  113. // BOOL SerialModemMode;
  114. uint32_t Time;
  115. // #if (IPMI20_SUPPORT == 1)
  116. // uint8_t Lookup;
  117. // uint32_t RemConSessionID;
  118. // uint8_t RemConRandomNo [16];
  119. // uint8_t MgdSysRandomNo [16];
  120. // uint8_t AuthAlgorithm;
  121. // uint8_t IntegrityAlgorithm;
  122. // uint8_t ConfidentialityAlgorithm;
  123. // uint8_t Key1 [MAX_HASH_KEY_SIZE];
  124. // uint8_t Key2 [MAX_HASH_KEY_SIZE];
  125. // SessPayloadInfo_T SessPyldInfo [MAX_PYLDS_SUPPORT];
  126. // #endif
  127. // uint32_t InitialInboundSeq;
  128. // uint32_t InboundTrac[SIXTEEN_COUNT_WINDOW_LEN];
  129. uint16_t InboundRecv;
  130. uint8_t IsLoopBack;
  131. uint8_t Linkstat;
  132. uint8_t EventFlag;
  133. uint8_t UserName[MAX_USERNAME_LEN];
  134. } SessionInfo_T;
  135. /* SessionTblInfo_T */
  136. typedef struct
  137. {
  138. uint16_t Count;
  139. SessionInfo_T *SessionTbl;
  140. } SessionTblInfo_T;
  141. typedef struct
  142. {
  143. uint32_t Time;
  144. uint8_t Index;
  145. } OldSessionInfo_T;
  146. typedef enum
  147. {
  148. KCS_IFC = 0x00,
  149. IPMB_IFC,
  150. LAN_IFC,
  151. SERIAL_IFC,
  152. }IfcType_T;
  153. #pragma pack( )
  154. // /*--------------------------
  155. // * Extern Declarations
  156. // *--------------------------*/
  157. extern void SessionTimerTask (void);
  158. // extern ChannelInfo_T* getChannelInfo (uint8_t ch );
  159. // extern _FAR_ ChannelUserInfo_T* getChUserIdInfo (uint8_t userId, _NEAR_ uint8_t *index, _FAR_ ChannelUserInfo_T* pChUserInfo, int BMCInst);
  160. extern SessionInfo_T* getSessionInfo (uint8_t Arg, void *Session);
  161. // extern _FAR_ ChannelUserInfo_T* getChUserPrivInfo (_NEAR_ char *userName, _NEAR_ uint8_t Role, _NEAR_ uint8_t* chIndex, _FAR_ ChannelUserInfo_T *pChUserInfo, int BMCInst);
  162. // extern _FAR_ ChannelUserInfo_T* getChUserInfo (_NEAR_ char *userName, _NEAR_ uint8_t* chIndex, _FAR_ ChannelUserInfo_T *pChUserInfo, int BMCInst);
  163. extern UserInfo_T* getUserIdInfo (uint8_t userId);
  164. extern UserInfo_T* getUserNameInfo (uint8_t *UserName);
  165. extern uint8_t CheckForDuplicateUsers (uint8_t* UserName);
  166. // extern _FAR_ ChannelUserInfo_T* AddChUser (_FAR_ ChannelUserInfo_T* pChUserInfo, _NEAR_ uint8_t* Index );
  167. // extern _FAR_ ChannelInfo_T* GetNVRChConfigs(ChannelInfo_T *pChannelInfo, int BMCInst);
  168. // extern _FAR_ ChannelUserInfo_T* GetNVRChUserConfigs(ChannelInfo_T *pChannelInfo );
  169. // extern uint8_t disableUser (uint8_t UserId, int BMCInst);
  170. extern uint8_t GetNumOfActiveSessions (void);
  171. extern uint8_t GetNumOfUsedSessions (void);
  172. extern void DeleteSession (SessionInfo_T* pSessionInfo );
  173. extern void AddSession (SessionInfo_T* pSessionInfo );
  174. extern uint8_t CleanSession(void);
  175. // extern _FAR_ uint16_t getPayloadActiveInst (uint8_t PayloadType, int BMCInst);
  176. // extern _FAR_ uint32_t getPayloadInstInfo (uint8_t PayloadType, uint16_t PayloadInst );
  177. extern void PasswordViolation (void);
  178. extern void UDSSessionTimerTask (void);
  179. extern int AddUDSSession (UDSSessionTbl_T* pUDSSessionInfo);
  180. extern int DeleteUDSSession(UDSSessionTbl_T* pUDSSessionInfo );
  181. extern UDSSessionTbl_T* GetUDSSessionInfo (uint8_t Type,void *Data );
  182. // /*---------------------------------------------------
  183. // * @fn UpdateGetMsgTime
  184. // * @brief Updates the Current Uptime and timeout value
  185. // * for an IPMI Message
  186. // *
  187. // * @param pReq : IPMI Message Packet
  188. // * @param ResTimeOut : Timeout Macro string
  189. // * @param BMCInst : BMC Instance
  190. // *
  191. // * @return none
  192. // *----------------------------------------------------*/
  193. // extern void UpdateGetMsgTime (MsgPkt_T* pReq,IfcType_T IfcType, int BMCInst);
  194. // /*---------------------------------------------------
  195. // * @fn IsMsgTimedOut
  196. // * @brief Checks if the time taken to process
  197. // * the IPMI Command expires
  198. // *
  199. // * @param pReq : IPMI Message Packet
  200. // *
  201. // * @return 1 if timed out
  202. // * 0 if error or timeout not set
  203. // *----------------------------------------------------*/
  204. // extern BOOL IsMsgTimedOut (MsgPkt_T* pReq);
  205. // /*-----------------------------------------------------
  206. // * @fn IsResponseMatch
  207. // * @brief Checks if the Response Message corresponds to
  208. // * the Request Message
  209. // *
  210. // * @param pReq : IPMI Request Message Packet
  211. // * @param pRes : IPMI Response Message Packet
  212. // *
  213. // * @return 1 if match
  214. // * 0 if mismatch
  215. // *----------------------------------------------------*/
  216. // extern BOOL IsResponseMatch (MsgPkt_T* pReq, MsgPkt_T* pRes);
  217. /*-------------------------------------------------------
  218. * @fn FillIPMIResFailure
  219. * @brief Frames the Response packet when the time taken
  220. * to process an IPMI Command expires
  221. *
  222. * @param pReq : Request Message Packet
  223. * pRes : Response Message Packet
  224. * BMCInst : BMC Instance Number
  225. *
  226. * @return none
  227. *------------------------------------------------------*/
  228. extern void FillIPMIResFailure ( MsgPkt_T* pReq, MsgPkt_T* pRes);
  229. #endif /* SESSION_H */