Session.c 44 KB

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