Session.c 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261
  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. return FALSE;
  291. }
  292. }
  293. return TRUE;
  294. }
  295. /*********************************************************************************************
  296. Name : getUserIdInfo
  297. Input : UserID - User ID
  298. Output : User information
  299. This program returns Informations about the user
  300. *********************************************************************************************/
  301. UserInfo_T* getUserIdInfo (uint8_t UserId)
  302. {
  303. if (UserId == 0) { return NULL; }
  304. if (UserId <= MAX_USER_NUM)
  305. {
  306. return &g_BMCInfo.UserInfoTbl[UserId-1];
  307. }
  308. else
  309. {
  310. return NULL;
  311. }
  312. }
  313. /*********************************************************************************************
  314. Name : getUserNameInfo
  315. Input : UserName - User name
  316. Output : User information
  317. This program returns Informations about the user
  318. *********************************************************************************************/
  319. UserInfo_T* getUserNameInfo (uint8_t *UserName)
  320. {
  321. int i = 0;
  322. if (UserName[0] == 0) { return NULL; }
  323. if( (UserName[0] >= '0') && (UserName[0] <= '9') ) {return NULL;}
  324. for (i = 0; i < MAX_USERNAME_LEN; i++)
  325. {
  326. if(UserName[i] > 127)
  327. {
  328. return NULL;
  329. }
  330. }
  331. for(i=0; i < MAX_USER_NUM; i++)
  332. {
  333. //if(g_BMCInfo.UserInfoTbl[i].UserId != 0)
  334. {
  335. if (0 == strcmp(g_BMCInfo.UserInfoTbl[i].UserName, UserName))
  336. {
  337. return &g_BMCInfo.UserInfoTbl[i];
  338. }
  339. }
  340. }
  341. return NULL;
  342. }
  343. ///*********************************************************************************************
  344. // Name : getChUserPrivInfo
  345. // Input : userName - user name
  346. // Role - requested role
  347. // chIndex - channel's user index
  348. // pChUserInfo - channel's user information
  349. // Output : channel's matching user Information
  350. //This program returns information about the user for the given channel,
  351. // & Index of the user in Channel User Array.
  352. //*********************************************************************************************/
  353. // ChannelUserInfo_T* getChUserPrivInfo ( char *userName, uint8_t Role, uint8_t* chIndex, ChannelUserInfo_T *pChUserInfo, int BMCInst)
  354. //{
  355. // UserInfo_T* pUserTable = (UserInfo_T *) GetNVRUsrCfgAddr (NVRH_USERCONFIG, BMCInst);
  356. // int userIndex;
  357. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  358. // /* search the table */
  359. // for(userIndex = 0; userIndex < pBMCInfo->IpmiConfig.MaxUsers; userIndex++)
  360. // {
  361. // for(*chIndex = 0; *chIndex < pBMCInfo->IpmiConfig.MaxChUsers; (*chIndex)++)
  362. // {
  363. // if ((Role <= pChUserInfo[*chIndex].AccessLimit) &&
  364. // (1 == pUserTable[userIndex].UserStatus) &&
  365. // (pUserTable[userIndex].UserId == pChUserInfo[*chIndex].UserId))
  366. // {
  367. // /* if userName is not NULL then it is username/privilege
  368. // lookup else it is name_only lookup */
  369. // if (0 != *userName)
  370. // {
  371. // if (0 != _fmemcmp(pUserTable[userIndex].UserName, userName, MAX_USERNAME_LEN))
  372. // {
  373. // continue;
  374. // }
  375. // }
  376. // return (pChUserInfo + *chIndex);
  377. // }
  378. // }
  379. // }
  380. // return NULL;
  381. //}
  382. ///*********************************************************************************************
  383. // Name : getChUserInfo
  384. // Input : userName - user name
  385. // chIndex - to return Index of user in channelUser Array
  386. // pChUserInfo - channel's user information
  387. // Output : channel's matching user Information
  388. //This program returns information about the user for the given channel,
  389. // & Index of the user in Channel User Array.
  390. //*********************************************************************************************/
  391. // ChannelUserInfo_T* getChUserInfo ( char *userName, uint8_t* chIndex, ChannelUserInfo_T *pChUserInfo )
  392. //{
  393. // UserInfo_T* pUserTable = (UserInfo_T *) GetNVRUsrCfgAddr (NVRH_USERCONFIG, BMCInst);
  394. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  395. // int userIndex;
  396. // /* search the table */
  397. // for(userIndex = 0; userIndex < pBMCInfo->IpmiConfig.MaxUsers; userIndex++)
  398. // {
  399. // for(*chIndex = 0; *chIndex < pBMCInfo->IpmiConfig.MaxChUsers; (*chIndex)++)
  400. // {
  401. // if ((0 == _fmemcmp(pUserTable[userIndex].UserName, userName, MAX_USERNAME_LEN)) &&
  402. // /* Commented to return the pointer for disabled user */
  403. // /* (1 == pUserTable[userIndex].UserStatus) && */
  404. // (pUserTable[userIndex].UserId == pChUserInfo[*chIndex].UserId))
  405. // return (pChUserInfo + *chIndex);
  406. // }
  407. // }
  408. // return NULL;
  409. //}
  410. ///*********************************************************************************************
  411. // Name : getChUserIdInfo
  412. // Input : userId - User ID
  413. // Index - to return Index of user in channelUser Array.
  414. // pChUserInfo - channel's user information
  415. // Output : channel's matching user Information
  416. //This program returns information about the user for the given channel,
  417. // & Index of the user inChannel User Array.
  418. //*********************************************************************************************/
  419. // ChannelUserInfo_T* getChUserIdInfo (uint8_t userId, uint8_t *Index, ChannelUserInfo_T* pChUserInfo, int BMCInst)
  420. //{
  421. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  422. // if (userId == 0) { return NULL; }
  423. // for(*Index=0; *Index < pBMCInfo->IpmiConfig.MaxChUsers; (*Index)++)
  424. // {
  425. // if ((pChUserInfo->UserId == userId) && ((pChUserInfo->ID == USER_ID )))
  426. // {
  427. // return pChUserInfo;
  428. // }
  429. // pChUserInfo++;
  430. // }
  431. // return NULL;
  432. //}
  433. ///*********************************************************************************************
  434. // Name : GetNVRChConfigs
  435. // Input : pChannelInfo -Channel Information
  436. // Filename - Channel Name Information
  437. // Output : Respective Channel's Information
  438. //This program returns information about the respective channel.
  439. //*********************************************************************************************/
  440. //ChannelInfo_T* GetNVRChConfigs(ChannelInfo_T *pChannelInfo, int BMCInst)
  441. //{
  442. // int i=0;
  443. // ChannelInfo_T *pNVRChInfo=NULL;
  444. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  445. // for(i=0;i<MAX_NUM_CHANNELS;i++)
  446. // {
  447. // if( pBMCInfo->NVRChcfgInfo[i].ChType != 0xff)
  448. // {
  449. // pNVRChInfo = &pBMCInfo->NVRChcfgInfo[i].ChannelInfo;
  450. // if(pChannelInfo->ChannelNumber == pNVRChInfo->ChannelNumber)
  451. // {
  452. // return (ChannelInfo_T *)&pBMCInfo->NVRChcfgInfo[i].ChannelInfo;
  453. // }
  454. // }
  455. // }
  456. // return NULL;
  457. //}
  458. ///**
  459. //*@fn GetNVRChUserConfigs
  460. //*@brief This function is invoked to get NVR User informations of the channel
  461. //*@param pChannelInfo - Channel Information
  462. //*@param Filename - Size of the SDR repository
  463. //*@return Returns Address of user information for the channel on success
  464. //* Returns NULL on Failure
  465. //*/
  466. //ChannelUserInfo_T* GetNVRChUserConfigs(ChannelInfo_T *pChannelInfo, int BMCInst)
  467. //{
  468. // int i=0;
  469. // ChannelInfo_T *pNVRChInfo = NULL;
  470. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  471. // for(i=0;i<MAX_NUM_CHANNELS;i++)
  472. // {
  473. // if(pBMCInfo->NVRChcfgInfo [i].ChType != 0xff)
  474. // {
  475. // pNVRChInfo = &pBMCInfo->NVRChcfgInfo[i].ChannelInfo;
  476. // if(pChannelInfo->ChannelNumber == pNVRChInfo->ChannelNumber)
  477. // {
  478. // return (ChannelUserInfo_T *)&pBMCInfo->NVRChcfgInfo[i].ChannelInfo.ChannelUserInfo[0];
  479. // }
  480. // }
  481. // }
  482. // return NULL;
  483. //}
  484. /*********************************************************************************************
  485. Name : getSessionInfo
  486. Input : Arg - Tells the type of data passed in Session
  487. Session - Either one of these: session ID, session handle, session index or
  488. channel number
  489. Output : Session Information
  490. This program returns the session information.
  491. *********************************************************************************************/
  492. SessionInfo_T* getSessionInfo (uint8_t Arg, void *Session)
  493. {
  494. uint8_t Index;
  495. uint8_t ActiveSesIndex = 0;
  496. SessionTblInfo_T* pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
  497. for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
  498. {
  499. if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
  500. {
  501. continue;
  502. }
  503. if (TRUE == pSessionTblInfo->SessionTbl[Index].Activated)
  504. {
  505. ActiveSesIndex++;
  506. }
  507. switch (Arg)
  508. {
  509. case SESSION_ID_INFO:
  510. if(pSessionTblInfo->SessionTbl[Index].SessionID == *((uint32_t *)Session) )
  511. {
  512. return &pSessionTblInfo->SessionTbl[Index];
  513. }
  514. break;
  515. // case SESSION_REMOTE_INFO:
  516. // if(pSessionTblInfo->SessionTbl[Index].RemConSessionID == *((uint32_t *)Session) )
  517. // {
  518. // return &pSessionTblInfo->SessionTbl[Index];
  519. // }
  520. // break;
  521. case SESSION_HANDLE_INFO:
  522. if (pSessionTblInfo->SessionTbl[Index].SessionHandle == *(( uint8_t*)Session) && pSessionTblInfo->SessionTbl[Index].Activated)
  523. {
  524. //printf("---> SessionHandle = %#x\n",pSessionTblInfo->SessionTbl[Index].SessionHandle);
  525. return &pSessionTblInfo->SessionTbl[Index];
  526. }
  527. break;
  528. case SESSION_INDEX_INFO:
  529. if (ActiveSesIndex == *(( uint8_t*)Session))
  530. {
  531. return &pSessionTblInfo->SessionTbl[Index];
  532. }
  533. break;
  534. case SESSION_CHANNEL_INFO:
  535. if (pSessionTblInfo->SessionTbl[Index].Channel == *(( uint8_t*)Session))
  536. {
  537. return &pSessionTblInfo->SessionTbl[Index];
  538. }
  539. break;
  540. default:
  541. return NULL;
  542. }
  543. }
  544. return NULL;
  545. }
  546. ///*********************************************************************************************
  547. // Name : AddChUser
  548. // Input : ChannelUserInfo
  549. // Output : Pointer to the free entry from the channel's user table.
  550. //This program returns the free entry from the channel's user table.
  551. //*********************************************************************************************/
  552. // ChannelUserInfo_T* AddChUser ( ChannelUserInfo_T* pChUserInfo, uint8_t* Index, int BMCInst)
  553. //{
  554. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  555. // *Index =0;
  556. // while (*Index <pBMCInfo->IpmiConfig.MaxChUsers)
  557. // {
  558. // if(FALSE == pChUserInfo->IPMIMessaging )
  559. // {
  560. // if(pChUserInfo->ID != USER_ID )
  561. // return pChUserInfo;
  562. // }
  563. // (*Index)++;
  564. // pChUserInfo++;
  565. // }
  566. // return NULL;
  567. //}
  568. /*---------------------------------------
  569. * GetSelTimeStamp
  570. *---------------------------------------*/
  571. uint32_t
  572. GetTimeStamp(void)
  573. {
  574. return (time(NULL));
  575. }
  576. /*********************************************************************************************
  577. Name : GetNumOfActiveSessions
  578. Input : Nothing
  579. Output : Number of active Sessions
  580. This program returns the number of active session(s) from the session table
  581. *********************************************************************************************/
  582. uint8_t GetNumOfActiveSessions (void)
  583. {
  584. uint8_t Index, Count = 0;
  585. SessionTblInfo_T* pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
  586. for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
  587. {
  588. if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
  589. {
  590. continue;
  591. }
  592. if (pSessionTblInfo->SessionTbl[Index].Activated)
  593. Count++;
  594. }
  595. return Count;
  596. }
  597. /*********************************************************************************************
  598. Name : GetNumOfUsedSessions
  599. Input : Nothing
  600. Output : Number of used Sessions
  601. This program returns the number of used session(s) from the session table
  602. *********************************************************************************************/
  603. uint8_t GetNumOfUsedSessions (void)
  604. {
  605. uint8_t Index, Count = 0;
  606. SessionTblInfo_T* pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
  607. for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
  608. {
  609. if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
  610. {
  611. continue;
  612. }
  613. Count++;
  614. }
  615. return Count;
  616. }
  617. /*********************************************************************************************
  618. Name : CleanSession
  619. Input : Nothing
  620. Output : None
  621. This program delete the oldest session filled but not activate
  622. *********************************************************************************************/
  623. uint8_t CleanSession(void)
  624. {
  625. uint8_t Index;
  626. OldSessionInfo_T OldSession;
  627. SessionTblInfo_T* pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
  628. OldSession.Time=0xFFFFFFFF;
  629. OldSession.Index= 0xFF;
  630. for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
  631. {
  632. if (TRUE == pSessionTblInfo->SessionTbl[Index].Activated)
  633. {
  634. continue;
  635. }
  636. if(pSessionTblInfo->SessionTbl[Index].Time <OldSession.Time )
  637. {
  638. OldSession.Time=pSessionTblInfo->SessionTbl[Index].Time;
  639. OldSession.Index=Index;
  640. }
  641. }
  642. if(OldSession.Index !=0xFF)
  643. {
  644. pSessionTblInfo->SessionTbl[OldSession.Index].Used = FALSE;
  645. pSessionTblInfo->Count--;
  646. pSessionTblInfo->SessionTbl[OldSession.Index].Time=0xffffffff;
  647. }else
  648. {
  649. return FALSE;
  650. }
  651. return TRUE;
  652. }
  653. /*********************************************************************************************
  654. Name : DeleteSession
  655. Input : pSessionInfo - session information
  656. Output : Nothing
  657. This program deletes the session from the session table
  658. *********************************************************************************************/
  659. void DeleteSession( SessionInfo_T* pSessionInfo)
  660. {
  661. uint8_t Index;
  662. SessionTblInfo_T* pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
  663. UserInfo_T* pUserInfo;
  664. ChannelInfo_T * pChannelInfo;
  665. for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
  666. {
  667. if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
  668. {
  669. continue;
  670. }
  671. if (0 == memcmp (&pSessionTblInfo->SessionTbl[Index], pSessionInfo , sizeof(SessionInfo_T)))
  672. {
  673. /* We have decrement the Active session only .If session is activated */
  674. if(TRUE ==pSessionTblInfo->SessionTbl[Index].Activated)
  675. {
  676. // if(!pSessionTblInfo->SessionTbl[Index].IsLoopBack)
  677. // {
  678. // pChannelInfo= getChannelInfo(pSessionInfo->Channel);
  679. // if(NULL == pChannelInfo)
  680. // {
  681. // TDBG("Failed to get channel info while Deleting Session for Channel: %d\n",pSessionInfo->Channel);
  682. // return;
  683. // }
  684. // if(pChannelInfo!=NULL)
  685. // pChannelInfo->ActiveSession--;
  686. // pUserInfo = getUserIdInfo (pSessionInfo->UserId);
  687. // if (pUserInfo != NULL) { pUserInfo->CurrentSession--; }
  688. // }
  689. pSessionTblInfo->SessionTbl[Index].Activated=FALSE;
  690. pSessionTblInfo->SessionTbl[Index].EventFlag = 0;
  691. }
  692. pSessionTblInfo->SessionTbl[Index].Used = FALSE;
  693. pSessionTblInfo->Count--;
  694. pSessionTblInfo->SessionTbl[Index].Time=0xFFFFFFFF;
  695. //printf("DeleteSession: SessionID = %lX Num Session %X\t%x\n",
  696. //pSessionInfo->SessionID, pSessionTblInfo->Count,Index);
  697. return;
  698. }
  699. }
  700. return;
  701. }
  702. /*********************************************************************************************
  703. Name : AddSession
  704. Input : pSessionInfo - session information
  705. Output : Nothing
  706. This program adds the session to the session table
  707. *********************************************************************************************/
  708. void AddSession ( SessionInfo_T* pSessionInfo)
  709. {
  710. uint8_t Index;
  711. SessionTblInfo_T* pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
  712. for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
  713. {
  714. if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
  715. {
  716. memcpy (&pSessionTblInfo->SessionTbl[Index], ( uint8_t*)pSessionInfo, sizeof (SessionInfo_T));
  717. pSessionTblInfo->SessionTbl[Index].Used = TRUE;
  718. pSessionTblInfo->Count++;
  719. pSessionTblInfo->SessionTbl[Index].Time= GetTimeStamp ();
  720. pSessionTblInfo->SessionTbl[Index].TimeOutValue=g_BMCInfo.IpmiConfig.SessionTimeOut;
  721. printf ("AddSession: SessionID = %lX Num Session %X\t%x\n",pSessionInfo->SessionID, pSessionTblInfo->Count,Index);
  722. break;
  723. }
  724. }
  725. }
  726. // /*********************************************************************************************
  727. // Name : getPayloadActiveInst
  728. // Input : PayloadType
  729. // Output : Activated Instance information of a given payload type.
  730. // This program returns the information about the activated instances of a given payload type.
  731. // *********************************************************************************************/
  732. // uint16_t getPayloadActiveInst (uint8_t PayloadType)
  733. // {
  734. // uint8_t PayloadIx;
  735. // uint8_t Index;
  736. // uint16_t ActivatedInst = 0;
  737. // SessionTblInfo_T* pSessionTblInfo = &g_BMCInfo.SessionTblInfo;
  738. // for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
  739. // {
  740. // if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
  741. // {
  742. // continue;
  743. // }
  744. // if (FALSE == pSessionTblInfo->SessionTbl[Index].Activated)
  745. // {
  746. // continue;
  747. // }
  748. // for (PayloadIx = 0; PayloadIx < MAX_PYLDS_SUPPORT; PayloadIx++)
  749. // {
  750. // if (pSessionTblInfo->SessionTbl[Index].SessPyldInfo [PayloadIx].Type == PayloadType)
  751. // {
  752. // ActivatedInst |= pSessionTblInfo->SessionTbl[Index].SessPyldInfo [PayloadIx].ActivatedInst;
  753. // }
  754. // }
  755. // }
  756. // return ActivatedInst;
  757. // }
  758. ///*********************************************************************************************
  759. // Name : getPayloadInstInfo
  760. // Input : Payloadtype, PayloadInst
  761. // Output : sessionID
  762. //This program returns the session ID of the session that was activated under the given payload
  763. //type and payload instance.
  764. //*********************************************************************************************/
  765. // uint32_t getPayloadInstInfo (uint8_t PayloadType, uint16_t PayloadInst, int BMCInst)
  766. //{
  767. // uint8_t PayloadIx;
  768. // uint8_t Index;
  769. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  770. // SessionTblInfo_T* pSessionTblInfo = &pBMCInfo->SessionTblInfo;
  771. // for (Index = 0; Index < pBMCInfo->IpmiConfig.MaxSession; Index++)
  772. // {
  773. // if (FALSE == pSessionTblInfo->SessionTbl[Index].Used)
  774. // {
  775. // continue;
  776. // }
  777. // if (FALSE == pSessionTblInfo->SessionTbl[Index].Activated)
  778. // {
  779. // continue;
  780. // }
  781. // for (PayloadIx = 0; PayloadIx < MAX_PYLDS_SUPPORT; PayloadIx++)
  782. // {
  783. // if ((pSessionTblInfo->SessionTbl[Index].SessPyldInfo [PayloadIx].Type == PayloadType)
  784. // && (pSessionTblInfo->SessionTbl[Index].SessPyldInfo [PayloadIx].ActivatedInst & (1 << (PayloadInst - 1))))
  785. // {
  786. // return pSessionTblInfo->SessionTbl[Index].SessionID;
  787. // }
  788. // }
  789. // }
  790. // return 0;
  791. //}
  792. static
  793. MsgPkt_T m_MsgPkt = {
  794. PARAM_IFC,
  795. 0, /* Channel number not needed */
  796. 0, /* Source queue not needed */
  797. CMD_PLATFORM_EVENT, /* Cmd */
  798. (NETFN_SENSOR << 2),/* Net Function */
  799. PRIV_LOCAL, /* Privilage */
  800. 0, /* Session ID not needed */
  801. // 0,
  802. WAIT_INFINITE,
  803. 0,
  804. {0}, /* IP Addr not needed */
  805. 0, /* UDPPort not needed */
  806. 0, /* Socket not needed */
  807. sizeof(SELEventRecord_T) + sizeof (IPMIMsgHdr_T) + 1,
  808. {
  809. 0x20, /* Generator ID */
  810. IPMI_EVM_REVISION, /* IPMI Version */
  811. SENSOR_TYPE_SECUIRTY_VIOLATION,/*SensorType */
  812. SECUIRTY_VIOLATION_SENSOR_NUMBER,
  813. SENSOR_SPECIFIC_READ_TYPE,
  814. PW_VIOLATION_OFFSET,
  815. 0xff,
  816. 0xff
  817. },
  818. };
  819. /*--------------------------------------------------------------------------*
  820. * PasswordViolation *
  821. *--------------------------------------------------------------------------*/
  822. void
  823. PasswordViolation (void)
  824. {
  825. /* Log the AC fail event to SEL & send an alert */
  826. /* Post to Message Hndlr Queue */
  827. PostMsg ( gFd_MsgHndlrIfc, &m_MsgPkt);
  828. return;
  829. }
  830. /*********************************************************************************************
  831. Name : UDSSessionTimeOutTask
  832. Input : void
  833. Output : void
  834. This program checks for UDS session timeout
  835. *********************************************************************************************/
  836. void UDSSessionTimerTask (void)
  837. {
  838. uint8_t Index=0;
  839. UDSSessionTblInfo_T *pUDSSessionTblInfo = &g_BMCInfo.UDSSessionTblInfo;
  840. // printf("-> UDSSessionTimerTask\n");
  841. for(Index=0;Index<g_BMCInfo.IpmiConfig.MaxSession;Index++)
  842. {
  843. if(FALSE == pUDSSessionTblInfo->UDSSessionTbl[Index].Activated)
  844. {
  845. /* Continue until we find the Next Slot which is being used to reduce the timeout */
  846. continue;
  847. }
  848. if(pUDSSessionTblInfo->UDSSessionTbl[Index].SessionTimeoutValue > 0)
  849. {
  850. /* Reduce the Session Timeout Value if the session is not used */
  851. pUDSSessionTblInfo->UDSSessionTbl[Index].SessionTimeoutValue--;
  852. continue;
  853. }
  854. DeleteUDSSession(&pUDSSessionTblInfo->UDSSessionTbl[Index]);
  855. }
  856. }
  857. /*********************************************************************************************
  858. Name : GetUDSSessionInfo
  859. Input : Session - session ID
  860. Output : Session Information
  861. This program returns the session information.
  862. *********************************************************************************************/
  863. UDSSessionTbl_T* GetUDSSessionInfo (uint8_t Type,void* Data )
  864. {
  865. uint8_t Index;
  866. UDSSessionTblInfo_T* pUDSSessionTblInfo = &g_BMCInfo.UDSSessionTblInfo;
  867. for(Index=0;Index<g_BMCInfo.IpmiConfig.MaxSession;Index++)
  868. {
  869. if(FALSE == pUDSSessionTblInfo->UDSSessionTbl[Index].Activated)
  870. {
  871. continue;
  872. }
  873. switch(Type)
  874. {
  875. case UDS_SESSION_ID_INFO:
  876. if(*((uint32_t *)Data) == pUDSSessionTblInfo->UDSSessionTbl[Index].SessionID)
  877. {
  878. return &pUDSSessionTblInfo->UDSSessionTbl[Index];
  879. }
  880. break;
  881. case UDS_SESSION_HANDLE_INFO:
  882. if(*((uint8_t *)Data) == pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInSessionHandle)
  883. {
  884. return &pUDSSessionTblInfo->UDSSessionTbl[Index];
  885. }
  886. break;
  887. case UDS_SESSION_INDEX_INFO:
  888. if((*((uint8_t *)Data) < g_BMCInfo.IpmiConfig.MaxSession) && ((Index) == *((uint8_t *)Data )))
  889. {
  890. return &pUDSSessionTblInfo->UDSSessionTbl[Index];
  891. }
  892. break;
  893. case UDS_SOCKET_ID_INFO:
  894. if(*((int *)Data) == pUDSSessionTblInfo->UDSSessionTbl[Index].UDSSocket)
  895. {
  896. return &pUDSSessionTblInfo->UDSSessionTbl[Index];
  897. }
  898. break;
  899. default:
  900. break;
  901. }
  902. }
  903. return NULL;
  904. }
  905. /*********************************************************************************************
  906. Name : AddUDSSession
  907. Input : pUDSSessionInfo - session information
  908. Output : return 0 on success ,-1 on failure
  909. This program adds the session to the UDS session table
  910. *********************************************************************************************/
  911. int AddUDSSession ( UDSSessionTbl_T* pUDSSessionInfo)
  912. {
  913. uint8_t Index;
  914. UDSSessionTblInfo_T* pUDSSessionTblInfo = &g_BMCInfo.UDSSessionTblInfo;
  915. for (Index = 0; Index < g_BMCInfo.IpmiConfig.MaxSession; Index++)
  916. {
  917. if(TRUE == pUDSSessionTblInfo->UDSSessionTbl[Index].Activated)
  918. {
  919. /* Continue Inorder to get the next Free Slot in UDS Session Table */
  920. continue;
  921. }
  922. /* Copy the Session Information to Global BMC Info UDS Session Table */
  923. memcpy (&pUDSSessionTblInfo->UDSSessionTbl[Index], ( uint8_t*)pUDSSessionInfo, sizeof (UDSSessionTbl_T));
  924. pUDSSessionTblInfo->SessionCount++;
  925. pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInTime = GetTimeStamp ();
  926. pUDSSessionTblInfo->UDSSessionTbl[Index].SessionTimeoutValue = g_BMCInfo.IpmiConfig.SessionTimeOut;
  927. break;
  928. }
  929. if(Index == g_BMCInfo.IpmiConfig.MaxSession)
  930. {
  931. printf("Add Session Failed for UDS\n");
  932. return -1;
  933. }
  934. return 0;
  935. }
  936. /*********************************************************************************************
  937. Name : DeleteUDSSession
  938. Input : pUDSSessionInfo - session information
  939. Output : return 0 on success,-1 on failure
  940. This program deletes the session from the UDS session table
  941. *********************************************************************************************/
  942. int DeleteUDSSession( UDSSessionTbl_T *pUDSSessionInfo )
  943. {
  944. uint8_t Index;
  945. UDSSessionTblInfo_T* pUDSSessionTblInfo = &g_BMCInfo.UDSSessionTblInfo;
  946. for(Index=0;Index<g_BMCInfo.IpmiConfig.MaxSession;Index++)
  947. {
  948. if(FALSE == pUDSSessionTblInfo->UDSSessionTbl[Index].Activated)
  949. {
  950. /* Continue to get the Next Occupied Session Slot in UDS Session Slot*/
  951. continue;
  952. }
  953. if (0 == memcmp (&pUDSSessionTblInfo->UDSSessionTbl[Index], pUDSSessionInfo , sizeof(UDSSessionTbl_T)))
  954. {
  955. /* Resetting the UDS Session Table Slot as the session is no longer required */
  956. pUDSSessionTblInfo->UDSSessionTbl[Index].Activated = FALSE;
  957. pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInTime = 0xFFFFFFFF;
  958. pUDSSessionTblInfo->UDSSessionTbl[Index].SessionTimeoutValue = 0;
  959. pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInUserID = 0;
  960. pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInChannel = 0xFF;
  961. pUDSSessionTblInfo->UDSSessionTbl[Index].LoggedInPrivilege = 0xFF;
  962. pUDSSessionTblInfo->SessionCount--;
  963. break;
  964. }
  965. }
  966. if(Index == g_BMCInfo.IpmiConfig.MaxSession)
  967. {
  968. printf("Delete Session Failed for UDS\n");
  969. return -1;
  970. }
  971. return 0;
  972. }
  973. ///*---------------------------------------------------
  974. // * @fn UpdateGetMsgTime
  975. // * @brief Updates the Current Uptime and timeout value
  976. // * for an IPMI Message
  977. // *
  978. // * @param pReq : IPMI Message Packet
  979. // * @param ResTimeOut : Timeout Macro string
  980. // * @param BMCInst : BMC Instance
  981. // *
  982. // * @return none
  983. // *----------------------------------------------------*/
  984. //void UpdateGetMsgTime (MsgPkt_T* pReq,IfcType_T IfcType, int BMCInst)
  985. //{
  986. // pReq->ReqTime = 0;
  987. // pReq->ResTimeOut = WAIT_INFINITE;
  988. // if( g_corefeatures.ipmi_res_timeout == ENABLED )
  989. // {
  990. // int i;
  991. // struct sysinfo sys_info;
  992. //
  993. // for( i = 0; i < TOTAL_INFINITE_CMDS; i++)
  994. // {
  995. // if( NET_FN(pReq->NetFnLUN) == m_InfiniteCmdsTbl[i].NetFn && pReq->Cmd == m_InfiniteCmdsTbl[i].Cmd )
  996. // {
  997. // return;
  998. // }
  999. // }
  1000. //
  1001. // if(g_PDKCmdsHandle[PDKCMDS_PDKISINFINITECOMMAND] != NULL)
  1002. // {
  1003. // if( ((BOOL(*)(uint8_t,uint8_t))g_PDKCmdsHandle[PDKCMDS_PDKISINFINITECOMMAND])(NET_FN(pReq->NetFnLUN), pReq->Cmd))
  1004. // {
  1005. // return;
  1006. // }
  1007. // }
  1008. //
  1009. // /* Request UpTime */
  1010. // if(!sysinfo(&sys_info))
  1011. // {
  1012. // pReq->ReqTime = sys_info.uptime;
  1013. // if(IfcType == IPMB_IFC)
  1014. // {
  1015. // pReq->ResTimeOut = g_coremacros.ipmb_res_timeout;
  1016. // }
  1017. // else if(IfcType == LAN_IFC)
  1018. // {
  1019. // pReq->ResTimeOut = g_coremacros.lan_res_timeout;
  1020. // }
  1021. // else if(IfcType == KCS_IFC)
  1022. // {
  1023. // pReq->ResTimeOut = g_coremacros.kcs_res_timeout;
  1024. // }
  1025. // else if(IfcType == SERIAL_IFC)
  1026. // {
  1027. // pReq->ResTimeOut = g_coremacros.serial_res_timeout;
  1028. // }
  1029. // }
  1030. // }
  1031. //}
  1032. ///*---------------------------------------------------
  1033. // * @fn IsMsgTimedOut
  1034. // * @brief Checks if the time taken to process
  1035. // * the IPMI Command expires
  1036. // *
  1037. // * @param pReq : IPMI Message Packet
  1038. // *
  1039. // * @return 1 if timed out
  1040. // * 0 if error or timeout not set
  1041. // *----------------------------------------------------*/
  1042. //BOOL IsMsgTimedOut (MsgPkt_T* pReq)
  1043. //{
  1044. // struct sysinfo sys_info;
  1045. //
  1046. // if( pReq->ReqTime && (!sysinfo(&sys_info)) )
  1047. // {
  1048. // return ( (sys_info.uptime - pReq->ReqTime) > pReq->ResTimeOut) ? TRUE : FALSE;
  1049. // }
  1050. //
  1051. // return FALSE;
  1052. //}
  1053. ///*-----------------------------------------------------
  1054. // * @fn IsResponseMatch
  1055. // * @brief Checks if the Response Message corresponds to
  1056. // * the Request Message
  1057. // *
  1058. // * @param pReq : IPMI Request Message Packet
  1059. // * @param pRes : IPMI Response Message Packet
  1060. // *
  1061. // * @return 1 if match
  1062. // * 0 if mismatch
  1063. // *----------------------------------------------------*/
  1064. //BOOL IsResponseMatch (MsgPkt_T* pReq, MsgPkt_T* pRes)
  1065. //{
  1066. // if( ( ((((IPMIMsgHdr_T*)pRes->Data)->RqSeqLUN) >> 2) != ((((IPMIMsgHdr_T*)pReq->Data)->RqSeqLUN) >> 2) ) &&
  1067. // ( (pReq->NetFnLUN & 0x4) && (NO_RESPONSE != pRes->Param) ) )
  1068. // {
  1069. // return FALSE;
  1070. // }
  1071. //
  1072. // return TRUE;
  1073. //}
  1074. /*-------------------------------------------------------
  1075. * @fn FillIPMIResFailure
  1076. * @brief Frames the Response packet when the time taken
  1077. * to process an IPMI Command expires
  1078. *
  1079. * @param pReq : IPMI Request Message Packet
  1080. * @param pRes : IPMI Response Message Packet
  1081. * BMCInst : BMC Instance Number
  1082. *
  1083. * @return none
  1084. *------------------------------------------------------*/
  1085. void FillIPMIResFailure ( MsgPkt_T* pReq, MsgPkt_T* pRes)
  1086. {
  1087. /* Set the Cmd and Net function in response packet */
  1088. pRes->Cmd = pReq->Cmd;
  1089. pRes->NetFnLUN = pReq->NetFnLUN & 0xFC;
  1090. /* Normal IPMI Command response */
  1091. pRes->Param = PARAM_NORMAL_RESPONSE;
  1092. pRes->Size = sizeof (IPMIMsgHdr_T) + sizeof (uint8_t);
  1093. pRes->Data[sizeof (IPMIMsgHdr_T)] = CC_TIMEOUT;
  1094. /* Check for Request Message */
  1095. if (0 == (pReq->NetFnLUN & 0x04))
  1096. {
  1097. /* Swap the header and copy in response */
  1098. SwapIPMIMsgHdr (( IPMIMsgHdr_T*)pReq->Data, ( IPMIMsgHdr_T*)pRes->Data);
  1099. /* Calculate Checksum 2 */
  1100. pRes->Data[pRes->Size] = CalculateCheckSum2 (pRes->Data, pRes->Size);
  1101. pRes->Size++;
  1102. }
  1103. }