Session.c 48 KB

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