Session.c 44 KB

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