Session.c 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262
  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.c
  17. // * Session related functions
  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. //#define ENABLE_DEBUG_MACROS 0
  26. #include "com_IPMIDefs.h"
  27. //#include "MsgHndlr.h"
  28. #include "PMConfig.h"
  29. //#include "SharedMem.h"
  30. //#include "NVRAccess.h"
  31. #include "Session.h"
  32. //#include "Debug.h"
  33. ////#include "SerialRegs.h"
  34. //#include "SensorEvent.h"
  35. #include "com_IPMI_Sensor.h"
  36. #include "Support.h"
  37. //#include "Ethaddr.h"
  38. #include "AppDevice.h"
  39. #include "MsgHndlr.h"
  40. #include <stdio.h>
  41. #include "main.h"
  42. #include <string.h>
  43. #include <time.h>
  44. #include "com_IPMI_SensorEvent.h"
  45. //#define TOTAL_INFINITE_CMDS sizeof(m_InfiniteCmdsTbl)/sizeof(IPMICmdsFilterTbl_T)
  46. //static IPMICmdsFilterTbl_T m_InfiniteCmdsTbl [] =
  47. //{ /* NetFn */ /* Command# */
  48. // { NETFN_AMI, CMD_AMI_YAFU_COMMON_NAK },
  49. // { NETFN_AMI, CMD_AMI_YAFU_GET_FLASH_INFO },
  50. // { NETFN_AMI, CMD_AMI_YAFU_GET_FIRMWARE_INFO },
  51. // { NETFN_AMI, CMD_AMI_YAFU_GET_FMH_INFO },
  52. // { NETFN_AMI, CMD_AMI_YAFU_GET_STATUS, },
  53. // { NETFN_AMI, CMD_AMI_YAFU_ACTIVATE_FLASH },
  54. // { NETFN_AMI, CMD_AMI_YAFU_ALLOCATE_MEMORY },
  55. // { NETFN_AMI, CMD_AMI_YAFU_FREE_MEMORY },
  56. // { NETFN_AMI, CMD_AMI_YAFU_READ_FLASH },
  57. // { NETFN_AMI, CMD_AMI_YAFU_WRITE_FLASH },
  58. // { NETFN_AMI, CMD_AMI_YAFU_ERASE_FLASH },
  59. // { NETFN_AMI, CMD_AMI_YAFU_PROTECT_FLASH },
  60. // { NETFN_AMI, CMD_AMI_YAFU_ERASE_COPY_FLASH },
  61. // { NETFN_AMI, CMD_AMI_YAFU_VERIFY_FLASH },
  62. // { NETFN_AMI, CMD_AMI_YAFU_READ_MEMORY },
  63. // { NETFN_AMI, CMD_AMI_YAFU_WRITE_MEMORY },
  64. // { NETFN_AMI, CMD_AMI_YAFU_COPY_MEMORY },
  65. // { NETFN_AMI, CMD_AMI_YAFU_COMPARE_MEMORY },
  66. // { NETFN_AMI, CMD_AMI_YAFU_CLEAR_MEMORY },
  67. // { NETFN_AMI, CMD_AMI_YAFU_GET_BOOT_CONFIG },
  68. // { NETFN_AMI, CMD_AMI_YAFU_SET_BOOT_CONFIG },
  69. // { NETFN_AMI, CMD_AMI_YAFU_GET_BOOT_VARS },
  70. // { NETFN_AMI, CMD_AMI_YAFU_DEACTIVATE_FLASH_MODE },
  71. // { NETFN_AMI, CMD_AMI_YAFU_RESET_DEVICE },
  72. // { NETFN_AMI, CMD_AMI_YAFU_GET_ECF_STATUS },
  73. // { NETFN_AMI, CMD_AMI_YAFU_GET_VERIFY_STATUS },
  74. // { NETFN_AMI, CMD_AMI_GET_CHANNEL_NUM },
  75. // { NETFN_AMI, CMD_AMI_GET_ETH_INDEX },
  76. // { NETFN_AMI, CMD_AMI_START_TFTP_FW_UPDATE },
  77. // { NETFN_AMI, CMD_AMI_GET_TFTP_FW_PROGRESS_STATUS },
  78. // { NETFN_AMI, CMD_AMI_SET_FW_CONFIGURATION },
  79. // { NETFN_AMI, CMD_AMI_GET_FW_CONFIGURATION },
  80. // { NETFN_AMI, CMD_AMI_SET_FW_PROTOCOL},
  81. // { NETFN_AMI, CMD_AMI_GET_FW_PROTOCOL},
  82. // { NETFN_AMI, CMD_AMI_YAFU_FIRMWARE_SELECT_FLASH},
  83. //};
  84. /*********************************************************************************************
  85. Name : SessionTimeOutTask
  86. Input : void
  87. Output : void
  88. This program checks for session timeout
  89. *********************************************************************************************/
  90. void SessionTimerTask (void)
  91. {
  92. SessionTblInfo_T* pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
  93. uint8_t Index;
  94. // char solsessionfile[MAXFILESIZE] = {0};
  95. struct stat fp;
  96. // printf("-> SessionTimerTask\n");
  97. for (Index=0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
  98. {
  99. if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
  100. {
  101. continue;
  102. }
  103. // if(g_BMCInfo.IpmiConfig.SerialIfcSupport == 1)
  104. // {
  105. // if (g_BMCInfo.SERIALch == pSessionTblInfo->SessionTbl[Index].Channel)
  106. // {
  107. // continue;
  108. // if (!(g_BMCInfo.SMConfig.SessionTermination & 0x02)) /* If Session Inactivity timeout disabled */
  109. // {
  110. // continue;
  111. // }
  112. // else if (0 == g_BMCInfo.SMConfig.SessionInactivity) /* Never Time Out */
  113. // {
  114. // continue;
  115. // }
  116. // }
  117. // }
  118. if (pSessionTblInfo->SessionTbl[Index].TimeOutValue > 0)
  119. {
  120. pSessionTblInfo->SessionTbl[Index].TimeOutValue--;
  121. continue;
  122. }
  123. printf ("\nSessionTimerTask: Session Time Out Occured\n");
  124. printf ("SessionID = 0x%lX Num of Sessions = %X\n", pSessionTblInfo->SessionTbl[Index].SessionID,
  125. pSessionTblInfo->Count);
  126. // if(pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
  127. // {
  128. // if (pBMCInfo->SERIALch == pSessionTblInfo->SessionTbl[Index].Channel)
  129. // {
  130. // BMC_GET_SHARED_MEM (BMCInst)->SerialSessionActive = FALSE;
  131. // }
  132. // }
  133. /* Delete the Session from session table */
  134. DeleteSession (&pSessionTblInfo->SessionTbl[Index]);
  135. }
  136. }
  137. ///*********************************************************************************************
  138. // Name : getChannelInfo
  139. // Input : ch - ChannelNumber
  140. // Output : channelInformations
  141. // This program returns informations about the channel
  142. //*********************************************************************************************/
  143. // ChannelInfo_T* getChannelInfo (uint8_t ch )
  144. //{
  145. // uint8_t Index;
  146. // ChcfgInfo_T *pChannelInfo=NULL;
  147. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  148. // if(IsLANChannel(ch, BMCInst))
  149. // {
  150. // if(pBMCInfo->IpmiConfig.LANIfcSupport != 1)
  151. // {
  152. // return NULL;
  153. // }
  154. // }else
  155. // {
  156. // if( PRIMARY_IPMB_CHANNEL == ch && pBMCInfo->IpmiConfig.PrimaryIPMBSupport != 1 )
  157. // {
  158. // return NULL;
  159. // }
  160. // else if (pBMCInfo->IpmiConfig.SecondaryIPMBSupport != 1 && (pBMCInfo->SecondaryIPMBCh != CH_NOT_USED && ch == pBMCInfo->SecondaryIPMBCh))
  161. // {
  162. // return NULL;
  163. // }
  164. // else if (pBMCInfo->IpmiConfig.SerialIfcSupport != 1 && (pBMCInfo->SERIALch != CH_NOT_USED && ch == pBMCInfo->SERIALch))
  165. // {
  166. // return NULL;
  167. // }
  168. // else if (pBMCInfo->IpmiConfig.ICMBIfcSupport != 1 && (pBMCInfo->ICMBCh != CH_NOT_USED && ch == pBMCInfo->ICMBCh))
  169. // {
  170. // return NULL;
  171. // }
  172. // else if (pBMCInfo->IpmiConfig.SMBUSIfcSupport !=1 && (pBMCInfo->SMBUSCh != CH_NOT_USED && ch == pBMCInfo->SMBUSCh))
  173. // {
  174. // return NULL;
  175. // }
  176. // else if (pBMCInfo->IpmiConfig.USBIfcSupport != 1 && (ch == USB_CHANNEL))
  177. // {
  178. // return NULL;
  179. // }
  180. // else if (pBMCInfo->IpmiConfig.SMMIfcSupport != 1 && (pBMCInfo->SMMCh != CH_NOT_USED && ch == pBMCInfo->SMMCh))
  181. // {
  182. // return NULL;
  183. // }
  184. // else if(pBMCInfo->IpmiConfig.SYSIfcSupport !=1 && ch == SYS_IFC_CHANNEL)
  185. // {
  186. // return NULL;
  187. // }
  188. // }
  189. // for(Index=0;Index<MAX_NUM_CHANNELS;Index++)
  190. // {
  191. // if(pBMCInfo->ChConfig[Index].ChType != 0xff)
  192. // {
  193. // pChannelInfo = &pBMCInfo->ChConfig[Index];
  194. // //printf("Channel numb is %x %x \n",pChannelInfo->ChannelInfo.ChannelNumber,ch);
  195. // if(pChannelInfo->ChannelInfo.ChannelNumber == ch)
  196. // {
  197. // return (ChannelInfo_T *)&pBMCInfo->ChConfig[Index].ChannelInfo;
  198. // }
  199. // }
  200. // }
  201. // return NULL;
  202. //}
  203. // int UpdateUserInfoTable(void)
  204. // {
  205. // uint8_t buf[1000];
  206. // uint8_t UserNameLen = 0;
  207. // uint8_t PassWordLen = 0;
  208. // uint8_t *pUserName;
  209. // uint8_t *pPassword;
  210. // uint8_t *pStr;
  211. // uint8_t usercnt = 0;
  212. // uint32_t len = 0;
  213. // uint8_t namesize = 0;
  214. // FILE *fp = NULL;
  215. // printf("\n\nUpdateUserInfoTable\n");
  216. // fp = fopen(AUTH_FILE_PATH, "r");
  217. // if(fp == NULL)
  218. // {
  219. // printf("Open %s fail!\n", AUTH_FILE_PATH);
  220. // return -1;
  221. // }
  222. // while(fgets(buf, 1000, fp) != NULL){
  223. // pStr = buf;
  224. // //remove blank
  225. // while(*pStr == ' ')
  226. // {
  227. // pStr++;
  228. // }
  229. // if(strncmp(pStr, "user name=", 10) == 0)
  230. // {
  231. // pStr+=10;
  232. // //get name
  233. // pUserName = pStr;
  234. // UserNameLen = 0;
  235. // while(*pStr != ' ')
  236. // {
  237. // UserNameLen++;
  238. // pStr++;
  239. // }
  240. // memset(g_BMCInfo.UserInfoTbl[usercnt].UserName, 0, MAX_USERNAME_LEN);
  241. // memcpy(g_BMCInfo.UserInfoTbl[usercnt].UserName, pUserName, UserNameLen);
  242. // //remove blank
  243. // while(*pStr == ' ')
  244. // {
  245. // pStr++;
  246. // }
  247. // if(strncmp(pStr, "password=", 9) == 0)
  248. // {
  249. // pStr += 9;
  250. // //get password
  251. // pPassword = pStr;
  252. // PassWordLen = 0;
  253. // while(*pStr != ' ')
  254. // {
  255. // PassWordLen++;
  256. // pStr++;
  257. // }
  258. // memset(g_BMCInfo.UserInfoTbl[usercnt].UserPassword, 0, MAX_PASSWORD_LEN);
  259. // memcpy(g_BMCInfo.UserInfoTbl[usercnt].UserPassword, pPassword, PassWordLen);
  260. // g_BMCInfo.UserInfoTbl[usercnt].UserId = usercnt;
  261. // if(usercnt < 10)
  262. // usercnt++;
  263. // else
  264. // break;
  265. // }
  266. // else
  267. // continue;
  268. // }
  269. // else
  270. // continue;
  271. // }
  272. // g_BMCInfo.CurrentNoUser = usercnt;
  273. // fclose(fp);
  274. // return 0;
  275. // }
  276. /*********************************************************************************************
  277. Name : CheckForDuplicateUsers
  278. Input : UserName - Name of the User
  279. Output : returns 0 for success and -1 for failure
  280. This program returns Informations about the user
  281. *********************************************************************************************/
  282. uint8_t CheckForDuplicateUsers ( uint8_t* UserName)
  283. {
  284. int i = 0;
  285. for(i=0; i<MAX_USER_NUM; i++)
  286. {
  287. if(g_BMCInfo.UserInfoTbl[i].UserId != 0)
  288. {
  289. if ((0 == strcmp(g_BMCInfo.UserInfoTbl[i].UserName, UserName)) \
  290. && (TRUE == g_BMCInfo.UserInfoTbl[i].UserStatus))
  291. return FALSE;
  292. }
  293. }
  294. return TRUE;
  295. }
  296. /*********************************************************************************************
  297. Name : getUserIdInfo
  298. Input : UserID - User ID
  299. Output : User information
  300. This program returns Informations about the user
  301. *********************************************************************************************/
  302. UserInfo_T* getUserIdInfo (uint8_t UserId)
  303. {
  304. if (UserId == 0) { return NULL; }
  305. if (UserId <= MAX_USER_NUM)
  306. {
  307. return &g_BMCInfo.UserInfoTbl[UserId-1];
  308. }
  309. else
  310. {
  311. return NULL;
  312. }
  313. }
  314. /*********************************************************************************************
  315. Name : getUserNameInfo
  316. Input : UserName - User name
  317. Output : User information
  318. This program returns Informations about the user
  319. *********************************************************************************************/
  320. UserInfo_T* getUserNameInfo (uint8_t *UserName)
  321. {
  322. int i = 0;
  323. if (UserName[0] == 0) { return NULL; }
  324. if( (UserName[0] >= '0') && (UserName[0] <= '9') ) {return NULL;}
  325. for (i = 0; i < MAX_USERNAME_LEN; i++)
  326. {
  327. if(UserName[i] > 127)
  328. {
  329. return NULL;
  330. }
  331. }
  332. for(i=0; i < MAX_USER_NUM; i++)
  333. {
  334. //if(g_BMCInfo.UserInfoTbl[i].UserId != 0)
  335. {
  336. if (0 == strcmp(g_BMCInfo.UserInfoTbl[i].UserName, UserName))
  337. {
  338. return &g_BMCInfo.UserInfoTbl[i];
  339. }
  340. }
  341. }
  342. return NULL;
  343. }
  344. ///*********************************************************************************************
  345. // Name : getChUserPrivInfo
  346. // Input : userName - user name
  347. // Role - requested role
  348. // chIndex - channel's user index
  349. // pChUserInfo - channel's user information
  350. // Output : channel's matching user Information
  351. //This program returns information about the user for the given channel,
  352. // & Index of the user in Channel User Array.
  353. //*********************************************************************************************/
  354. // ChannelUserInfo_T* getChUserPrivInfo ( char *userName, uint8_t Role, uint8_t* chIndex, ChannelUserInfo_T *pChUserInfo, int BMCInst)
  355. //{
  356. // UserInfo_T* pUserTable = (UserInfo_T *) GetNVRUsrCfgAddr (NVRH_USERCONFIG, BMCInst);
  357. // int userIndex;
  358. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  359. // /* search the table */
  360. // for(userIndex = 0; userIndex < pBMCInfo->IpmiConfig.MaxUsers; userIndex++)
  361. // {
  362. // for(*chIndex = 0; *chIndex < pBMCInfo->IpmiConfig.MaxChUsers; (*chIndex)++)
  363. // {
  364. // if ((Role <= pChUserInfo[*chIndex].AccessLimit) &&
  365. // (1 == pUserTable[userIndex].UserStatus) &&
  366. // (pUserTable[userIndex].UserId == pChUserInfo[*chIndex].UserId))
  367. // {
  368. // /* if userName is not NULL then it is username/privilege
  369. // lookup else it is name_only lookup */
  370. // if (0 != *userName)
  371. // {
  372. // if (0 != _fmemcmp(pUserTable[userIndex].UserName, userName, MAX_USERNAME_LEN))
  373. // {
  374. // continue;
  375. // }
  376. // }
  377. // return (pChUserInfo + *chIndex);
  378. // }
  379. // }
  380. // }
  381. // return NULL;
  382. //}
  383. ///*********************************************************************************************
  384. // Name : getChUserInfo
  385. // Input : userName - user name
  386. // chIndex - to return Index of user in channelUser Array
  387. // pChUserInfo - channel's user information
  388. // Output : channel's matching user Information
  389. //This program returns information about the user for the given channel,
  390. // & Index of the user in Channel User Array.
  391. //*********************************************************************************************/
  392. // ChannelUserInfo_T* getChUserInfo ( char *userName, uint8_t* chIndex, ChannelUserInfo_T *pChUserInfo )
  393. //{
  394. // UserInfo_T* pUserTable = (UserInfo_T *) GetNVRUsrCfgAddr (NVRH_USERCONFIG, BMCInst);
  395. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  396. // int userIndex;
  397. // /* search the table */
  398. // for(userIndex = 0; userIndex < pBMCInfo->IpmiConfig.MaxUsers; userIndex++)
  399. // {
  400. // for(*chIndex = 0; *chIndex < pBMCInfo->IpmiConfig.MaxChUsers; (*chIndex)++)
  401. // {
  402. // if ((0 == _fmemcmp(pUserTable[userIndex].UserName, userName, MAX_USERNAME_LEN)) &&
  403. // /* Commented to return the pointer for disabled user */
  404. // /* (1 == pUserTable[userIndex].UserStatus) && */
  405. // (pUserTable[userIndex].UserId == pChUserInfo[*chIndex].UserId))
  406. // return (pChUserInfo + *chIndex);
  407. // }
  408. // }
  409. // return NULL;
  410. //}
  411. ///*********************************************************************************************
  412. // Name : getChUserIdInfo
  413. // Input : userId - User ID
  414. // Index - to return Index of user in channelUser Array.
  415. // pChUserInfo - channel's user information
  416. // Output : channel's matching user Information
  417. //This program returns information about the user for the given channel,
  418. // & Index of the user inChannel User Array.
  419. //*********************************************************************************************/
  420. // ChannelUserInfo_T* getChUserIdInfo (uint8_t userId, uint8_t *Index, ChannelUserInfo_T* pChUserInfo, int BMCInst)
  421. //{
  422. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  423. // if (userId == 0) { return NULL; }
  424. // for(*Index=0; *Index < pBMCInfo->IpmiConfig.MaxChUsers; (*Index)++)
  425. // {
  426. // if ((pChUserInfo->UserId == userId) && ((pChUserInfo->ID == USER_ID )))
  427. // {
  428. // return pChUserInfo;
  429. // }
  430. // pChUserInfo++;
  431. // }
  432. // return NULL;
  433. //}
  434. ///*********************************************************************************************
  435. // Name : GetNVRChConfigs
  436. // Input : pChannelInfo -Channel Information
  437. // Filename - Channel Name Information
  438. // Output : Respective Channel's Information
  439. //This program returns information about the respective channel.
  440. //*********************************************************************************************/
  441. //ChannelInfo_T* GetNVRChConfigs(ChannelInfo_T *pChannelInfo, int BMCInst)
  442. //{
  443. // int i=0;
  444. // ChannelInfo_T *pNVRChInfo=NULL;
  445. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  446. // for(i=0;i<MAX_NUM_CHANNELS;i++)
  447. // {
  448. // if( pBMCInfo->NVRChcfgInfo[i].ChType != 0xff)
  449. // {
  450. // pNVRChInfo = &pBMCInfo->NVRChcfgInfo[i].ChannelInfo;
  451. // if(pChannelInfo->ChannelNumber == pNVRChInfo->ChannelNumber)
  452. // {
  453. // return (ChannelInfo_T *)&pBMCInfo->NVRChcfgInfo[i].ChannelInfo;
  454. // }
  455. // }
  456. // }
  457. // return NULL;
  458. //}
  459. ///**
  460. //*@fn GetNVRChUserConfigs
  461. //*@brief This function is invoked to get NVR User informations of the channel
  462. //*@param pChannelInfo - Channel Information
  463. //*@param Filename - Size of the SDR repository
  464. //*@return Returns Address of user information for the channel on success
  465. //* Returns NULL on Failure
  466. //*/
  467. //ChannelUserInfo_T* GetNVRChUserConfigs(ChannelInfo_T *pChannelInfo, int BMCInst)
  468. //{
  469. // int i=0;
  470. // ChannelInfo_T *pNVRChInfo = NULL;
  471. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  472. // for(i=0;i<MAX_NUM_CHANNELS;i++)
  473. // {
  474. // if(pBMCInfo->NVRChcfgInfo [i].ChType != 0xff)
  475. // {
  476. // pNVRChInfo = &pBMCInfo->NVRChcfgInfo[i].ChannelInfo;
  477. // if(pChannelInfo->ChannelNumber == pNVRChInfo->ChannelNumber)
  478. // {
  479. // return (ChannelUserInfo_T *)&pBMCInfo->NVRChcfgInfo[i].ChannelInfo.ChannelUserInfo[0];
  480. // }
  481. // }
  482. // }
  483. // return NULL;
  484. //}
  485. /*********************************************************************************************
  486. Name : getSessionInfo
  487. Input : Arg - Tells the type of data passed in Session
  488. Session - Either one of these: session ID, session handle, session index or
  489. channel number
  490. Output : Session Information
  491. This program returns the session information.
  492. *********************************************************************************************/
  493. SessionInfo_T* getSessionInfo (uint8_t Arg, void *Session)
  494. {
  495. uint8_t Index;
  496. uint8_t ActiveSesIndex = 0;
  497. SessionTblInfo_T* pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
  498. for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
  499. {
  500. if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
  501. {
  502. continue;
  503. }
  504. if (TRUE == pSessionTblInfo->SessionTbl[Index].Activated)
  505. {
  506. ActiveSesIndex++;
  507. }
  508. switch (Arg)
  509. {
  510. case SESSION_ID_INFO:
  511. if(pSessionTblInfo->SessionTbl[Index].SessionID == *((uint32_t *)Session) )
  512. {
  513. return &pSessionTblInfo->SessionTbl[Index];
  514. }
  515. break;
  516. // case SESSION_REMOTE_INFO:
  517. // if(pSessionTblInfo->SessionTbl[Index].RemConSessionID == *((uint32_t *)Session) )
  518. // {
  519. // return &pSessionTblInfo->SessionTbl[Index];
  520. // }
  521. // break;
  522. case SESSION_HANDLE_INFO:
  523. if (pSessionTblInfo->SessionTbl[Index].SessionHandle == *(( uint8_t*)Session) && pSessionTblInfo->SessionTbl[Index].Activated)
  524. {
  525. //printf("---> SessionHandle = %#x\n",pSessionTblInfo->SessionTbl[Index].SessionHandle);
  526. return &pSessionTblInfo->SessionTbl[Index];
  527. }
  528. break;
  529. case SESSION_INDEX_INFO:
  530. if (ActiveSesIndex == *(( uint8_t*)Session))
  531. {
  532. return &pSessionTblInfo->SessionTbl[Index];
  533. }
  534. break;
  535. case SESSION_CHANNEL_INFO:
  536. if (pSessionTblInfo->SessionTbl[Index].Channel == *(( uint8_t*)Session))
  537. {
  538. return &pSessionTblInfo->SessionTbl[Index];
  539. }
  540. break;
  541. default:
  542. return NULL;
  543. }
  544. }
  545. return NULL;
  546. }
  547. ///*********************************************************************************************
  548. // Name : AddChUser
  549. // Input : ChannelUserInfo
  550. // Output : Pointer to the free entry from the channel's user table.
  551. //This program returns the free entry from the channel's user table.
  552. //*********************************************************************************************/
  553. // ChannelUserInfo_T* AddChUser ( ChannelUserInfo_T* pChUserInfo, uint8_t* Index, int BMCInst)
  554. //{
  555. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  556. // *Index =0;
  557. // while (*Index <pBMCInfo->IpmiConfig.MaxChUsers)
  558. // {
  559. // if(FALSE == pChUserInfo->IPMIMessaging )
  560. // {
  561. // if(pChUserInfo->ID != USER_ID )
  562. // return pChUserInfo;
  563. // }
  564. // (*Index)++;
  565. // pChUserInfo++;
  566. // }
  567. // return NULL;
  568. //}
  569. /*---------------------------------------
  570. * GetSelTimeStamp
  571. *---------------------------------------*/
  572. uint32_t
  573. GetTimeStamp(void)
  574. {
  575. return (time(NULL));
  576. }
  577. /*********************************************************************************************
  578. Name : GetNumOfActiveSessions
  579. Input : Nothing
  580. Output : Number of active Sessions
  581. This program returns the number of active session(s) from the session table
  582. *********************************************************************************************/
  583. uint8_t GetNumOfActiveSessions (void)
  584. {
  585. uint8_t Index, Count = 0;
  586. SessionTblInfo_T* pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
  587. for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
  588. {
  589. if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
  590. {
  591. continue;
  592. }
  593. if (pSessionTblInfo->SessionTbl[Index].Activated)
  594. Count++;
  595. }
  596. return Count;
  597. }
  598. /*********************************************************************************************
  599. Name : GetNumOfUsedSessions
  600. Input : Nothing
  601. Output : Number of used Sessions
  602. This program returns the number of used session(s) from the session table
  603. *********************************************************************************************/
  604. uint8_t GetNumOfUsedSessions (void)
  605. {
  606. uint8_t Index, Count = 0;
  607. SessionTblInfo_T* pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
  608. for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
  609. {
  610. if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
  611. {
  612. continue;
  613. }
  614. Count++;
  615. }
  616. return Count;
  617. }
  618. /*********************************************************************************************
  619. Name : CleanSession
  620. Input : Nothing
  621. Output : None
  622. This program delete the oldest session filled but not activate
  623. *********************************************************************************************/
  624. uint8_t CleanSession(void)
  625. {
  626. uint8_t Index;
  627. OldSessionInfo_T OldSession;
  628. SessionTblInfo_T* pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
  629. OldSession.Time=0xFFFFFFFF;
  630. OldSession.Index= 0xFF;
  631. for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
  632. {
  633. if (TRUE == pSessionTblInfo->SessionTbl[Index].Activated)
  634. {
  635. continue;
  636. }
  637. if(pSessionTblInfo->SessionTbl[Index].Time <OldSession.Time )
  638. {
  639. OldSession.Time=pSessionTblInfo->SessionTbl[Index].Time;
  640. OldSession.Index=Index;
  641. }
  642. }
  643. if(OldSession.Index !=0xFF)
  644. {
  645. pSessionTblInfo->SessionTbl[OldSession.Index].Used = FALSE;
  646. pSessionTblInfo->Count--;
  647. pSessionTblInfo->SessionTbl[OldSession.Index].Time=0xffffffff;
  648. }else
  649. {
  650. return FALSE;
  651. }
  652. return TRUE;
  653. }
  654. /*********************************************************************************************
  655. Name : DeleteSession
  656. Input : pSessionInfo - session information
  657. Output : Nothing
  658. This program deletes the session from the session table
  659. *********************************************************************************************/
  660. void DeleteSession( SessionInfo_T* pSessionInfo)
  661. {
  662. uint8_t Index;
  663. SessionTblInfo_T* pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
  664. UserInfo_T* pUserInfo;
  665. ChannelInfo_T * pChannelInfo;
  666. for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
  667. {
  668. if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
  669. {
  670. continue;
  671. }
  672. if (0 == memcmp (&pSessionTblInfo->SessionTbl[Index], pSessionInfo , sizeof(SessionInfo_T)))
  673. {
  674. /* We have decrement the Active session only .If session is activated */
  675. if(TRUE ==pSessionTblInfo->SessionTbl[Index].Activated)
  676. {
  677. // if(!pSessionTblInfo->SessionTbl[Index].IsLoopBack)
  678. // {
  679. // pChannelInfo= getChannelInfo(pSessionInfo->Channel);
  680. // if(NULL == pChannelInfo)
  681. // {
  682. // TDBG("Failed to get channel info while Deleting Session for Channel: %d\n",pSessionInfo->Channel);
  683. // return;
  684. // }
  685. // if(pChannelInfo!=NULL)
  686. // pChannelInfo->ActiveSession--;
  687. // pUserInfo = getUserIdInfo (pSessionInfo->UserId);
  688. // if (pUserInfo != NULL) { pUserInfo->CurrentSession--; }
  689. // }
  690. pSessionTblInfo->SessionTbl[Index].Activated=FALSE;
  691. pSessionTblInfo->SessionTbl[Index].EventFlag = 0;
  692. }
  693. pSessionTblInfo->SessionTbl[Index].Used = FALSE;
  694. pSessionTblInfo->Count--;
  695. pSessionTblInfo->SessionTbl[Index].Time=0xFFFFFFFF;
  696. //printf("DeleteSession: SessionID = %lX Num Session %X\t%x\n",
  697. //pSessionInfo->SessionID, pSessionTblInfo->Count,Index);
  698. return;
  699. }
  700. }
  701. return;
  702. }
  703. /*********************************************************************************************
  704. Name : AddSession
  705. Input : pSessionInfo - session information
  706. Output : Nothing
  707. This program adds the session to the session table
  708. *********************************************************************************************/
  709. void AddSession ( SessionInfo_T* pSessionInfo)
  710. {
  711. uint8_t Index;
  712. SessionTblInfo_T* pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
  713. for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
  714. {
  715. if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
  716. {
  717. memcpy (&pSessionTblInfo->SessionTbl[Index], ( uint8_t*)pSessionInfo, sizeof (SessionInfo_T));
  718. pSessionTblInfo->SessionTbl[Index].Used = TRUE;
  719. pSessionTblInfo->Count++;
  720. pSessionTblInfo->SessionTbl[Index].Time= GetTimeStamp ();
  721. pSessionTblInfo->SessionTbl[Index].TimeOutValue=g_BMCInfo.IpmiConfig.SessionTimeOut;
  722. // printf ("AddSession: SessionID = %lX Num Session %X\t%x\n",pSessionInfo->SessionID, pSessionTblInfo->Count,Index);
  723. break;
  724. }
  725. }
  726. }
  727. // /*********************************************************************************************
  728. // Name : getPayloadActiveInst
  729. // Input : PayloadType
  730. // Output : Activated Instance information of a given payload type.
  731. // This program returns the information about the activated instances of a given payload type.
  732. // *********************************************************************************************/
  733. // uint16_t getPayloadActiveInst (uint8_t PayloadType)
  734. // {
  735. // uint8_t PayloadIx;
  736. // uint8_t Index;
  737. // uint16_t ActivatedInst = 0;
  738. // SessionTblInfo_T* pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
  739. // for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
  740. // {
  741. // if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
  742. // {
  743. // continue;
  744. // }
  745. // if (FALSE == pSessionTblInfo->SessionTbl[Index].Activated)
  746. // {
  747. // continue;
  748. // }
  749. // for (PayloadIx = 0; PayloadIx < MAX_PYLDS_SUPPORT; PayloadIx++)
  750. // {
  751. // if (pSessionTblInfo->SessionTbl[Index].SessPyldInfo [PayloadIx].Type == PayloadType)
  752. // {
  753. // ActivatedInst |= pSessionTblInfo->SessionTbl[Index].SessPyldInfo [PayloadIx].ActivatedInst;
  754. // }
  755. // }
  756. // }
  757. // return ActivatedInst;
  758. // }
  759. ///*********************************************************************************************
  760. // Name : getPayloadInstInfo
  761. // Input : Payloadtype, PayloadInst
  762. // Output : sessionID
  763. //This program returns the session ID of the session that was activated under the given payload
  764. //type and payload instance.
  765. //*********************************************************************************************/
  766. // uint32_t getPayloadInstInfo (uint8_t PayloadType, uint16_t PayloadInst, int BMCInst)
  767. //{
  768. // uint8_t PayloadIx;
  769. // uint8_t Index;
  770. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  771. // SessionTblInfo_T* pSessionTblInfo = &pBMCInfo->SessionTblInfo;
  772. // for (Index = 0; Index < pBMCInfo->IpmiConfig.MaxSession; Index++)
  773. // {
  774. // if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
  775. // {
  776. // continue;
  777. // }
  778. // if (FALSE == pSessionTblInfo->SessionTbl[Index].Activated)
  779. // {
  780. // continue;
  781. // }
  782. // for (PayloadIx = 0; PayloadIx < MAX_PYLDS_SUPPORT; PayloadIx++)
  783. // {
  784. // if ((pSessionTblInfo->SessionTbl[Index].SessPyldInfo [PayloadIx].Type == PayloadType)
  785. // && (pSessionTblInfo->SessionTbl[Index].SessPyldInfo [PayloadIx].ActivatedInst & (1 << (PayloadInst - 1))))
  786. // {
  787. // return pSessionTblInfo->SessionTbl[Index].SessionID;
  788. // }
  789. // }
  790. // }
  791. // return 0;
  792. //}
  793. static
  794. MsgPkt_T m_MsgPkt = {
  795. PARAM_IFC,
  796. 0, /* Channel number not needed */
  797. 0, /* Source queue not needed */
  798. CMD_PLATFORM_EVENT, /* Cmd */
  799. (NETFN_SENSOR << 2),/* Net Function */
  800. PRIV_LOCAL, /* Privilage */
  801. 0, /* Session ID not needed */
  802. // 0,
  803. WAIT_INFINITE,
  804. 0,
  805. {0}, /* IP Addr not needed */
  806. 0, /* UDPPort not needed */
  807. 0, /* Socket not needed */
  808. sizeof(SELEventRecord_T) + sizeof (IPMIMsgHdr_T) + 1,
  809. {
  810. 0x20, /* Generator ID */
  811. IPMI_EVM_REVISION, /* IPMI Version */
  812. SENSOR_TYPE_SECUIRTY_VIOLATION,/*SensorType */
  813. SECUIRTY_VIOLATION_SENSOR_NUMBER,
  814. SENSOR_SPECIFIC_READ_TYPE,
  815. PW_VIOLATION_OFFSET,
  816. 0xff,
  817. 0xff
  818. },
  819. };
  820. /*--------------------------------------------------------------------------*
  821. * PasswordViolation *
  822. *--------------------------------------------------------------------------*/
  823. void
  824. PasswordViolation (void)
  825. {
  826. /* Log the AC fail event to SEL & send an alert */
  827. /* Post to Message Hndlr Queue */
  828. PostMsg ( gFd_MsgHndlrIfc, &m_MsgPkt);
  829. return;
  830. }
  831. /*********************************************************************************************
  832. Name : UDSSessionTimeOutTask
  833. Input : void
  834. Output : void
  835. This program checks for UDS session timeout
  836. *********************************************************************************************/
  837. void UDSSessionTimerTask (void)
  838. {
  839. uint8_t Index=0;
  840. UDSSessionTblInfo_T *pUDSSessionTblInfo = &g_BMCInfo.UDSSessionTblInfo;
  841. // printf("-> UDSSessionTimerTask\n");
  842. for(Index=0;Index<g_BMCInfo.IpmiConfig.MaxSession;Index++)
  843. {
  844. if(FALSE == pUDSSessionTblInfo->UDSSessionTbl[Index].Activated)
  845. {
  846. /* Continue until we find the Next Slot which is being used to reduce the timeout */
  847. continue;
  848. }
  849. if(pUDSSessionTblInfo->UDSSessionTbl[Index].SessionTimeoutValue > 0)
  850. {
  851. /* Reduce the Session Timeout Value if the session is not used */
  852. pUDSSessionTblInfo->UDSSessionTbl[Index].SessionTimeoutValue--;
  853. continue;
  854. }
  855. DeleteUDSSession(&pUDSSessionTblInfo->UDSSessionTbl[Index]);
  856. }
  857. }
  858. /*********************************************************************************************
  859. Name : GetUDSSessionInfo
  860. Input : Session - session ID
  861. Output : Session Information
  862. This program returns the session information.
  863. *********************************************************************************************/
  864. UDSSessionTbl_T* GetUDSSessionInfo (uint8_t Type,void* Data )
  865. {
  866. uint8_t Index;
  867. UDSSessionTblInfo_T* pUDSSessionTblInfo = &g_BMCInfo.UDSSessionTblInfo;
  868. for(Index=0;Index<g_BMCInfo.IpmiConfig.MaxSession;Index++)
  869. {
  870. if(FALSE == pUDSSessionTblInfo->UDSSessionTbl[Index].Activated)
  871. {
  872. continue;
  873. }
  874. switch(Type)
  875. {
  876. case UDS_SESSION_ID_INFO:
  877. if(*((uint32_t *)Data) == pUDSSessionTblInfo->UDSSessionTbl[Index].SessionID)
  878. {
  879. return &pUDSSessionTblInfo->UDSSessionTbl[Index];
  880. }
  881. break;
  882. case UDS_SESSION_HANDLE_INFO:
  883. if(*((uint8_t *)Data) == pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInSessionHandle)
  884. {
  885. return &pUDSSessionTblInfo->UDSSessionTbl[Index];
  886. }
  887. break;
  888. case UDS_SESSION_INDEX_INFO:
  889. if((*((uint8_t *)Data) < g_BMCInfo.IpmiConfig.MaxSession) && ((Index) == *((uint8_t *)Data )))
  890. {
  891. return &pUDSSessionTblInfo->UDSSessionTbl[Index];
  892. }
  893. break;
  894. case UDS_SOCKET_ID_INFO:
  895. if(*((int *)Data) == pUDSSessionTblInfo->UDSSessionTbl[Index].UDSSocket)
  896. {
  897. return &pUDSSessionTblInfo->UDSSessionTbl[Index];
  898. }
  899. break;
  900. default:
  901. break;
  902. }
  903. }
  904. return NULL;
  905. }
  906. /*********************************************************************************************
  907. Name : AddUDSSession
  908. Input : pUDSSessionInfo - session information
  909. Output : return 0 on success ,-1 on failure
  910. This program adds the session to the UDS session table
  911. *********************************************************************************************/
  912. int AddUDSSession ( UDSSessionTbl_T* pUDSSessionInfo)
  913. {
  914. uint8_t Index;
  915. UDSSessionTblInfo_T* pUDSSessionTblInfo = &g_BMCInfo.UDSSessionTblInfo;
  916. for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
  917. {
  918. if(TRUE == pUDSSessionTblInfo->UDSSessionTbl[Index].Activated)
  919. {
  920. /* Continue Inorder to get the next Free Slot in UDS Session Table */
  921. continue;
  922. }
  923. /* Copy the Session Information to Global BMC Info UDS Session Table */
  924. memcpy (&pUDSSessionTblInfo->UDSSessionTbl[Index], ( uint8_t*)pUDSSessionInfo, sizeof (UDSSessionTbl_T));
  925. pUDSSessionTblInfo->SessionCount++;
  926. pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInTime = GetTimeStamp ();
  927. pUDSSessionTblInfo->UDSSessionTbl[Index].SessionTimeoutValue = g_BMCInfo.IpmiConfig.SessionTimeOut;
  928. break;
  929. }
  930. if(Index == g_BMCInfo.IpmiConfig.MaxSession)
  931. {
  932. printf("Add Session Failed for UDS\n");
  933. return -1;
  934. }
  935. return 0;
  936. }
  937. /*********************************************************************************************
  938. Name : DeleteUDSSession
  939. Input : pUDSSessionInfo - session information
  940. Output : return 0 on success,-1 on failure
  941. This program deletes the session from the UDS session table
  942. *********************************************************************************************/
  943. int DeleteUDSSession( UDSSessionTbl_T *pUDSSessionInfo )
  944. {
  945. uint8_t Index;
  946. UDSSessionTblInfo_T* pUDSSessionTblInfo = &g_BMCInfo.UDSSessionTblInfo;
  947. for(Index=0;Index<g_BMCInfo.IpmiConfig.MaxSession;Index++)
  948. {
  949. if(FALSE == pUDSSessionTblInfo->UDSSessionTbl[Index].Activated)
  950. {
  951. /* Continue to get the Next Occupied Session Slot in UDS Session Slot*/
  952. continue;
  953. }
  954. if (0 == memcmp (&pUDSSessionTblInfo->UDSSessionTbl[Index], pUDSSessionInfo , sizeof(UDSSessionTbl_T)))
  955. {
  956. /* Resetting the UDS Session Table Slot as the session is no longer required */
  957. pUDSSessionTblInfo->UDSSessionTbl[Index].Activated = FALSE;
  958. pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInTime = 0xFFFFFFFF;
  959. pUDSSessionTblInfo->UDSSessionTbl[Index].SessionTimeoutValue = 0;
  960. pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInUserID = 0;
  961. pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInChannel = 0xFF;
  962. pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInPrivilege = 0xFF;
  963. pUDSSessionTblInfo->SessionCount--;
  964. break;
  965. }
  966. }
  967. if(Index == g_BMCInfo.IpmiConfig.MaxSession)
  968. {
  969. printf("Delete Session Failed for UDS\n");
  970. return -1;
  971. }
  972. return 0;
  973. }
  974. ///*---------------------------------------------------
  975. // * @fn UpdateGetMsgTime
  976. // * @brief Updates the Current Uptime and timeout value
  977. // * for an IPMI Message
  978. // *
  979. // * @param pReq : IPMI Message Packet
  980. // * @param ResTimeOut : Timeout Macro string
  981. // * @param BMCInst : BMC Instance
  982. // *
  983. // * @return none
  984. // *----------------------------------------------------*/
  985. //void UpdateGetMsgTime (MsgPkt_T* pReq,IfcType_T IfcType, int BMCInst)
  986. //{
  987. // pReq->ReqTime = 0;
  988. // pReq->ResTimeOut = WAIT_INFINITE;
  989. // if( g_corefeatures.ipmi_res_timeout == ENABLED )
  990. // {
  991. // int i;
  992. // struct sysinfo sys_info;
  993. //
  994. // for( i = 0; i < TOTAL_INFINITE_CMDS; i++)
  995. // {
  996. // if( NET_FN(pReq->NetFnLUN) == m_InfiniteCmdsTbl[i].NetFn && pReq->Cmd == m_InfiniteCmdsTbl[i].Cmd )
  997. // {
  998. // return;
  999. // }
  1000. // }
  1001. //
  1002. // if(g_PDKCmdsHandle[PDKCMDS_PDKISINFINITECOMMAND] != NULL)
  1003. // {
  1004. // if( ((BOOL(*)(uint8_t,uint8_t))g_PDKCmdsHandle[PDKCMDS_PDKISINFINITECOMMAND])(NET_FN(pReq->NetFnLUN), pReq->Cmd))
  1005. // {
  1006. // return;
  1007. // }
  1008. // }
  1009. //
  1010. // /* Request UpTime */
  1011. // if(!sysinfo(&sys_info))
  1012. // {
  1013. // pReq->ReqTime = sys_info.uptime;
  1014. // if(IfcType == IPMB_IFC)
  1015. // {
  1016. // pReq->ResTimeOut = g_coremacros.ipmb_res_timeout;
  1017. // }
  1018. // else if(IfcType == LAN_IFC)
  1019. // {
  1020. // pReq->ResTimeOut = g_coremacros.lan_res_timeout;
  1021. // }
  1022. // else if(IfcType == KCS_IFC)
  1023. // {
  1024. // pReq->ResTimeOut = g_coremacros.kcs_res_timeout;
  1025. // }
  1026. // else if(IfcType == SERIAL_IFC)
  1027. // {
  1028. // pReq->ResTimeOut = g_coremacros.serial_res_timeout;
  1029. // }
  1030. // }
  1031. // }
  1032. //}
  1033. ///*---------------------------------------------------
  1034. // * @fn IsMsgTimedOut
  1035. // * @brief Checks if the time taken to process
  1036. // * the IPMI Command expires
  1037. // *
  1038. // * @param pReq : IPMI Message Packet
  1039. // *
  1040. // * @return 1 if timed out
  1041. // * 0 if error or timeout not set
  1042. // *----------------------------------------------------*/
  1043. //BOOL IsMsgTimedOut (MsgPkt_T* pReq)
  1044. //{
  1045. // struct sysinfo sys_info;
  1046. //
  1047. // if( pReq->ReqTime && (!sysinfo(&sys_info)) )
  1048. // {
  1049. // return ( (sys_info.uptime - pReq->ReqTime) > pReq->ResTimeOut) ? TRUE : FALSE;
  1050. // }
  1051. //
  1052. // return FALSE;
  1053. //}
  1054. ///*-----------------------------------------------------
  1055. // * @fn IsResponseMatch
  1056. // * @brief Checks if the Response Message corresponds to
  1057. // * the Request Message
  1058. // *
  1059. // * @param pReq : IPMI Request Message Packet
  1060. // * @param pRes : IPMI Response Message Packet
  1061. // *
  1062. // * @return 1 if match
  1063. // * 0 if mismatch
  1064. // *----------------------------------------------------*/
  1065. //BOOL IsResponseMatch (MsgPkt_T* pReq, MsgPkt_T* pRes)
  1066. //{
  1067. // if( ( ((((IPMIMsgHdr_T*)pRes->Data)->RqSeqLUN) >> 2) != ((((IPMIMsgHdr_T*)pReq->Data)->RqSeqLUN) >> 2) ) &&
  1068. // ( (pReq->NetFnLUN & 0x4) && (NO_RESPONSE != pRes->Param) ) )
  1069. // {
  1070. // return FALSE;
  1071. // }
  1072. //
  1073. // return TRUE;
  1074. //}
  1075. /*-------------------------------------------------------
  1076. * @fn FillIPMIResFailure
  1077. * @brief Frames the Response packet when the time taken
  1078. * to process an IPMI Command expires
  1079. *
  1080. * @param pReq : IPMI Request Message Packet
  1081. * @param pRes : IPMI Response Message Packet
  1082. * BMCInst : BMC Instance Number
  1083. *
  1084. * @return none
  1085. *------------------------------------------------------*/
  1086. void FillIPMIResFailure ( MsgPkt_T* pReq, MsgPkt_T* pRes)
  1087. {
  1088. /* Set the Cmd and Net function in response packet */
  1089. pRes->Cmd = pReq->Cmd;
  1090. pRes->NetFnLUN = pReq->NetFnLUN & 0xFC;
  1091. /* Normal IPMI Command response */
  1092. pRes->Param = PARAM_NORMAL_RESPONSE;
  1093. pRes->Size = sizeof (IPMIMsgHdr_T) + sizeof (uint8_t);
  1094. pRes->Data[sizeof (IPMIMsgHdr_T)] = CC_TIMEOUT;
  1095. /* Check for Request Message */
  1096. if (0 == (pReq->NetFnLUN & 0x04))
  1097. {
  1098. /* Swap the header and copy in response */
  1099. SwapIPMIMsgHdr (( IPMIMsgHdr_T*)pReq->Data, ( IPMIMsgHdr_T*)pRes->Data);
  1100. /* Calculate Checksum 2 */
  1101. pRes->Data[pRes->Size] = CalculateCheckSum2 (pRes->Data, pRes->Size);
  1102. pRes->Size++;
  1103. }
  1104. }