MsgHndlrTask.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965
  1. /*
  2. * Brief: Receive message from Interface and send response to original interface.
  3. Process all IPMI standard command and oem command.
  4. * Author: Jimbo_Zhang@outlook.com
  5. * Date: 2019-9-13, the Mid-autumn Festival;
  6. */
  7. #include <stdio.h>
  8. #include <sys/stat.h>
  9. #include <sys/socket.h>
  10. #include <sys/un.h>
  11. #include <sys/prctl.h>
  12. #include <errno.h>
  13. #include <fcntl.h>
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <unistd.h>
  17. #include <string.h>
  18. #include <pthread.h>
  19. #include "MsgHndlr.h"
  20. #include "PDKCmds.h"
  21. #include "App.h"
  22. #include "PICMG.h"
  23. #include "Bridge.h"
  24. #include "SensorEvent.h"
  25. #include "Chassis.h"
  26. #include "Storage.h"
  27. #include "cmdselect.h"
  28. #include "com_IPMI_App.h"
  29. #include "com_IPMI_Storage.h"
  30. #include "com_IPMI_SDR.h"
  31. #include "DeviceConfig.h"
  32. //#include "main.h"
  33. #include <string.h>
  34. #include "main.h"
  35. static void ProcessIPMIReq (MsgPkt_T* pReq, MsgPkt_T* pRes);
  36. static void PendingBridgeResTimerTask (void);
  37. static void PendingSeqNoTimerTask (void);
  38. MsgHndlrTbl_T m_MsgHndlrTbl [] = //notice!
  39. {
  40. { NETFN_APP, g_App_CmdHndlr },
  41. { NETFN_CHASSIS, g_Chassis_CmdHndlr },
  42. { NETFN_BRIDGE, g_Bridge_CmdHndlr },
  43. { NETFN_SENSOR, g_SensorEvent_CmdHndlr },
  44. { NETFN_STORAGE, g_Storage_CmdHndlr },
  45. { NETFN_TRANSPORT, g_Config_CmdHndlr },
  46. // { NETFN_AMI, (CmdHndlrMap_T*)g_AMI_CmdHndlr },
  47. { 0, 0 },
  48. };
  49. GroupExtnMsgHndlrTbl_T m_GroupExtnMsgHndlrTbl [] = //jimbo add
  50. {
  51. {0, 0},
  52. };
  53. TimerTaskTbl_T m_TimerTaskTbl [20] =
  54. {
  55. // { 1, PEFTimerTask },
  56. // { 1, PETAckTimerTask },
  57. // { 1, PEFStartDlyTimerTask },
  58. { 1, SessionTimerTask },
  59. // { 1, PendingBridgeResTimerTask },
  60. // { 1, PendingSeqNoTimerTask },
  61. // { 1, FlashTimerTask },
  62. // #if FRB_SUPPORT == 1
  63. // { 1, FRB3TimerTask },
  64. // #endif /* #if FRB_SUPPORT == 1 */
  65. //
  66. // #if SERIAL_MODEM_CONNECTION_ACTIVITY != UNIMPLEMENTED
  67. // { 2, SerialModemPingTask },
  68. // #endif /* SERIAL_MODEM_CONNECTION_ACTIVITY */
  69. //
  70. // { 1, MonitorPassword },
  71. { 1, UDSSessionTimerTask },
  72. };
  73. //PendingBridgedResTbl_T m_PendingBridgedResTbl[MAX_PENDING_BRIDGE_RES];
  74. PendingBridgedResTbl_T m_PendingBridgedResTbl[MAX_PENDING_BRIDGE_TBL][MAX_PENDING_BRIDGE_RES];
  75. PendingSeqNoTbl_T m_PendingSeqNoTbl[16][MAX_PENDING_SEQ_NO];
  76. KCSBridgeResInfo_T m_KCSBridgeResInfo;
  77. int gFd_MsgHndlrIfc;
  78. TLS_T g_tls;
  79. /*!
  80. \brief Message handler Task. Process all standard and oem ipmi message form interface, and send response back.
  81. \param[in] none
  82. \param[out] none
  83. \retval none
  84. */
  85. void *MsgHndlrTask( void *pArg )
  86. {
  87. MsgPkt_T reqMsgPkt;
  88. MsgPkt_T resMsgPkt;
  89. uint8_t channelinit = 0xF;
  90. printf("MsgHndlrTask start...\r\n");
  91. prctl(PR_SET_NAME,__FUNCTION__,0,0,0);
  92. //create
  93. if(-1 != access(MSG_HNDLR_Q, F_OK))
  94. {
  95. remove(MSG_HNDLR_Q);
  96. }
  97. if(0 != mkfifo (MSG_HNDLR_Q, 0777))
  98. {
  99. printf("%s: Create %s fifo failed! %s\n", __FUNCTION__, MSG_HNDLR_Q, strerror(errno));
  100. return (void*)-1;
  101. }
  102. gFd_MsgHndlrIfc = open (MSG_HNDLR_Q, O_RDWR);
  103. if(-1 == gFd_MsgHndlrIfc)
  104. {
  105. printf("%s: Open %s fifo failed! %s\n", __FUNCTION__, MSG_HNDLR_Q, strerror(errno));
  106. return (void*)-1;
  107. }
  108. pthread_key_create(&g_tls.CurSessionID,NULL);
  109. pthread_key_create(&g_tls.CurPrivLevel,NULL);
  110. pthread_key_create(&g_tls.CurChannel,NULL);
  111. pthread_key_create(&g_tls.CurKCSIfcNum,NULL);
  112. pthread_key_create(&g_tls.CurSessionType,NULL);
  113. pthread_key_create(&g_tls.OwnerLUN,NULL);
  114. pthread_setspecific(g_tls.CurChannel,&channelinit);
  115. while(1)
  116. {
  117. while(GetMsg(gFd_MsgHndlrIfc, &reqMsgPkt, WAIT_INFINITE) != 0);
  118. // printf("===> Mrx: ");
  119. // int i;
  120. // for(i=0;i<reqMsgPkt.Size;i++)
  121. // printf("%#x ", reqMsgPkt.Data[i]);
  122. // printf("\n");
  123. pthread_setspecific(g_tls.CurChannel,&reqMsgPkt.Channel);
  124. pthread_setspecific(g_tls.CurPrivLevel,&reqMsgPkt.Privilege);
  125. pthread_setspecific(g_tls.CurSessionID,&reqMsgPkt.SessionID);
  126. pthread_setspecific(g_tls.CurSessionType,&reqMsgPkt.SessionType);
  127. pthread_setspecific(g_tls.OwnerLUN,&reqMsgPkt.NetFnLUN);
  128. SwapIPMIMsgHdr ((IPMIMsgHdr_T*)reqMsgPkt.Data, (IPMIMsgHdr_T*)resMsgPkt.Data);
  129. ProcessIPMIReq(&reqMsgPkt, &resMsgPkt);
  130. /* Skip current request if no response from Command Handler */
  131. if ((reqMsgPkt.SrcQ == gFd_LanResQ) && (sizeof(IPMIMsgHdr_T) == resMsgPkt.Size) && (NORMAL_RESPONSE == resMsgPkt.Param) )
  132. {
  133. continue;
  134. }
  135. if ((reqMsgPkt.SrcQ == gFdUdsRes) && (resMsgPkt.Size == sizeof(IPMIUDSMsg_T)) && (NORMAL_RESPONSE == resMsgPkt.Param) )
  136. {
  137. continue;
  138. }
  139. //update checksum2
  140. resMsgPkt.Data[resMsgPkt.Size] = CalculateCheckSum2(resMsgPkt.Data, resMsgPkt.Size);
  141. resMsgPkt.Size++;
  142. if(g_BMCInfo.IpmiConfig.UDSIfcSupport == 0x01 && (reqMsgPkt.SrcQ == gFdUdsRes))
  143. {
  144. resMsgPkt.Size = resMsgPkt.Size+1;
  145. SwapUDSIPMIMsg(&reqMsgPkt,&resMsgPkt);
  146. resMsgPkt.Data[resMsgPkt.Size-1] = 0;
  147. }
  148. if(SYS_IFC_CHANNEL == reqMsgPkt.Channel)
  149. {
  150. /* Skip current request if no response from Command Handler */
  151. if (!resMsgPkt.Size && (NO_RESPONSE == resMsgPkt.Param) )
  152. {
  153. continue;
  154. }
  155. resMsgPkt.SessionID = reqMsgPkt.SessionID;
  156. }
  157. //int i;
  158. // printf("===> Mtx to %d: ", resMsgPkt.SrcQ);
  159. // for(i=0;i<resMsgPkt.Size;i++)
  160. // printf("%#x ", resMsgPkt.Data[i]);
  161. // printf("\n");
  162. //send response pkt to source queue.
  163. PostMsg(resMsgPkt.SrcQ, &resMsgPkt);
  164. }
  165. }
  166. /**
  167. *@fn ValidateMsgHdr
  168. *@brief Validates the Message header and keeps track of the messages that has been bridged
  169. *@param pReq Request packet of the command to be executed
  170. *@return Returns -1 in case of the response to the bridged message
  171. * Returns 0 otherwise
  172. */
  173. int
  174. ValidateMsgHdr (MsgPkt_T* pReq)
  175. {
  176. int j;
  177. uint8_t PBTbl = PRIMARY_PB_TBL;
  178. IPMIMsgHdr_T* pIPMIMsgReq = (IPMIMsgHdr_T*)&pReq->Data;
  179. ChannelInfo_T* pChannelInfo;
  180. uint8_t SeqNum = NET_FN(pIPMIMsgReq->RqSeqLUN);
  181. int Queuefd = 0;
  182. /* Check for the request message LUN */
  183. switch (pReq->NetFnLUN & 0x03)
  184. {
  185. case BMC_LUN_00:
  186. if (0 == (pReq->NetFnLUN & 0x04))
  187. {
  188. return 0; //IPMB做从
  189. }
  190. PBTbl = ( (pReq->Channel == SECONDARY_IPMB_CHANNEL) ? SECONDARY_PB_TBL : PRIMARY_PB_TBL );
  191. if ( (TRUE == m_PendingBridgedResTbl[PBTbl][SeqNum].Used) &&
  192. (NET_FN(pIPMIMsgReq->NetFnLUN) == NET_FN((m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.NetFnLUN + 0x04))) &&
  193. (pIPMIMsgReq->Cmd == m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.Cmd) &&
  194. (pIPMIMsgReq->ReqAddr == m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.ResAddr))
  195. {
  196. /* Change the requester's address, sequence number and LUN */
  197. pIPMIMsgReq->ResAddr = m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.ReqAddr;
  198. pIPMIMsgReq->RqSeqLUN = m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.RqSeqLUN;
  199. /* Calculate the Second CheckSum */
  200. pReq->Data[ pReq->Size - 1 ] = CalculateCheckSum2( pReq->Data, pReq->Size - 1 );
  201. pReq->Data[2] = (~(pReq->Data[0] + pReq->Data[1])) +1; //2's complement checksum
  202. pReq->Param = BRIDGING_REQUEST;
  203. if (m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFd_LanIfcQ)
  204. {
  205. for (j=pReq->Size - 1; j>=0; j--)
  206. {
  207. pReq->Data[j+1] = pReq->Data[j];
  208. }
  209. pReq->Data[0] = m_PendingBridgedResTbl[PBTbl][SeqNum].SrcSessionHandle;
  210. pReq->Size++;
  211. pReq->Cmd = PAYLOAD_IPMI_MSG;
  212. Queuefd = gFd_LanIfcQ;
  213. }
  214. else if(m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFdUdsIfc)
  215. {
  216. pReq->Cmd = PAYLOAD_IPMI_MSG;
  217. pReq->Socket = m_PendingBridgedResTbl[PBTbl][SeqNum].UDSSocket;
  218. memcpy(&pReq->Data[sizeof(IPMIUDSMsg_T)], &pReq->Data[0], pReq->Size);
  219. memcpy(&pReq->Data[0], &m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr.UDSMsgHdr, sizeof(IPMIUDSMsg_T));
  220. pReq->Size += sizeof(IPMIUDSMsg_T);
  221. pReq->Size++;
  222. pReq->Data[pReq->Size-1] = 0;
  223. ((IPMIUDSMsg_T*)&pReq->Data[0])->IPMIMsgLen = pReq->Size;
  224. Queuefd = gFdUdsIfc;
  225. }
  226. else
  227. {
  228. Queuefd = m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ;
  229. }
  230. /* Post the data to Destination Interface queue */
  231. // printf("===> ValidateMsgHdr post message to %d\n", Queuefd);
  232. PostMsg (Queuefd, pReq);
  233. m_PendingBridgedResTbl[PBTbl][SeqNum].Used = FALSE;
  234. m_PendingBridgedResTbl[PBTbl][SeqNum].ResDataOk = 0;
  235. }
  236. return -1;
  237. case BMC_LUN_01:
  238. case BMC_LUN_10:
  239. case BMC_LUN_11:
  240. //TODO:
  241. default:
  242. return -1;
  243. }
  244. }
  245. /**
  246. *@fn ProcessIPMIReq
  247. *@brief Processes the requested IPMI command
  248. *@param pReq Request of the command
  249. *@param pRes Response for the requested command
  250. *@return none
  251. */
  252. static void
  253. ProcessIPMIReq (MsgPkt_T* pReq, MsgPkt_T* pRes)
  254. {
  255. CmdHndlrMap_T * pCmdHndlrMap;
  256. uint32_t HdrOffset = 0;
  257. uint8_t CmdOverride = 1;
  258. int8_t MsgHndlrMapGot=0;
  259. uint8_t PBTbl = PRIMARY_PB_TBL;
  260. // msgHndlr_dbg_printf ("Processing IPMI Packet.\r\n");
  261. /* Set the Cmd and Net function in response packet */
  262. pRes->Cmd = pReq->Cmd;
  263. pRes->NetFnLUN = pReq->NetFnLUN;
  264. pRes->Channel = pReq->Channel;
  265. pRes->SrcQ = pReq->SrcQ;
  266. pRes->Socket = pReq->Socket;
  267. /* Normal IPMI Command response */
  268. pRes->Param = PARAM_NORMAL_RESPONSE;
  269. if ((SYS_IFC_CHANNEL != pReq->Channel) && (USB_CHANNEL != pReq->Channel) && (UDS_CHANNEL != pReq->Channel))
  270. {
  271. //printf("log 1, pReq->Channel: %#x\n", pReq->Channel);
  272. HdrOffset = sizeof (IPMIMsgHdr_T);
  273. pReq->Size = pReq->Size - HdrOffset - 1;
  274. }
  275. if(UDS_CHANNEL == pReq->Channel)
  276. {
  277. //printf("log 2, pReq->Size: %d, HdrOffset: %d\n", pReq->Size, HdrOffset);
  278. HdrOffset = sizeof(IPMIUDSMsg_T);
  279. pReq->Size = pReq->Size -HdrOffset - 1;
  280. }
  281. SwapIPMIMsgHdr((IPMIMsgHdr_T*)pReq->Data, (IPMIMsgHdr_T*)pRes->Data);
  282. pRes->Size = HdrOffset + sizeof(uint8_t);
  283. pthread_setspecific(g_tls.CurSessionID,&pReq->SessionID);
  284. if(IsCommandEnabled(NET_FN(pReq->NetFnLUN), &pReq->Data[HdrOffset], pReq->Cmd) != 0)
  285. {
  286. pRes->Data [HdrOffset] = CC_INV_CMD;
  287. printf ("Invalid Net Function 0x%x or Invalid Command 0x%x\n",NET_FN(pReq->NetFnLUN), pReq->Cmd);
  288. pRes->Size += 2;
  289. return;
  290. }
  291. //Get oem command map
  292. MsgHndlrMapGot = PDKGetOEMMsgHndlrMap(NET_FN(pReq->NetFnLUN),&pCmdHndlrMap);
  293. if(MsgHndlrMapGot == 0)
  294. {
  295. CmdOverride = GetCmdHndlr(pReq,pRes,pCmdHndlrMap,HdrOffset,CmdOverride,&pCmdHndlrMap);
  296. }
  297. //get standard ipmi command map
  298. if((CmdOverride == 0 || MsgHndlrMapGot == -1) ) //OEM commands have no command map.
  299. {
  300. if (0 != GetMsgHndlrMap (NET_FN (pReq->NetFnLUN), &pCmdHndlrMap))
  301. {
  302. // if(pBMCInfo->IpmiConfig.GrpExtnSupport == 1)
  303. // {
  304. if (0 != GroupExtnGetMsgHndlrMap (NET_FN (pReq->NetFnLUN), pReq->Data [HdrOffset], &pCmdHndlrMap) )
  305. {
  306. pRes->Data [HdrOffset] = CC_INV_CMD;
  307. printf ("MsgHndlr.c : Invalid Net Function 0x%x or Invalid Command 0x%x\n",NET_FN(pReq->NetFnLUN), pReq->Cmd);
  308. pRes->Size += 2;
  309. return;
  310. }
  311. // }
  312. // else
  313. // {
  314. // pRes->Data [HdrOffset] = CC_INV_CMD;
  315. // printf ("MsgHndlr.c : Invalid Net Function 0x%x\n",NET_FN(pReq->NetFnLUN));
  316. // pRes->Size += 2;
  317. // return;
  318. // }
  319. }
  320. if(GetCmdHndlr(pReq,pRes,pCmdHndlrMap,HdrOffset,CmdOverride,&pCmdHndlrMap) == FALSE)
  321. {
  322. pRes->Data [HdrOffset] = CC_INV_CMD;
  323. pRes->Size += 2;
  324. //printf("log 3\n");
  325. return;
  326. }
  327. }
  328. /* Check for the request size */
  329. if (0xff != pCmdHndlrMap->ReqLen)
  330. {
  331. /* Check for invalid request size */
  332. if (pCmdHndlrMap->ReqLen != pReq->Size)
  333. {
  334. printf("Warning: Request data len error, require %d\n", pCmdHndlrMap->ReqLen);
  335. pRes->Data [HdrOffset] = CC_REQ_INV_LEN;
  336. pRes->Size += 2;
  337. return;
  338. }
  339. }
  340. pRes->Size = pCmdHndlrMap->CmdHndlr (&pReq->Data [HdrOffset], pReq->Size, &pRes->Data [HdrOffset]) + HdrOffset;
  341. //prepare response data for send message command
  342. if( (CMD_SEND_MSG == pReq->Cmd) && (NETFN_APP == pReq->NetFnLUN >> 2))
  343. {
  344. // printf("log 4, size %d, Channel %d\n",pRes->Size, pRes->Channel);
  345. int Offset = 0;
  346. uint8_t SeqNum = g_BMCInfo.SendMsgSeqNum;
  347. if ((0 == pRes->Size) &&
  348. ((g_BMCInfo.IpmiConfig.PrimaryIPMBSupport == 0x01 && PRIMARY_IPMB_CHANNEL == pRes->Channel) ||
  349. (g_BMCInfo.IpmiConfig.SecondaryIPMBSupport == 0x01 && SECONDARY_IPMB_CHANNEL == pRes->Channel)) )
  350. {
  351. pRes->Param = PARAM_NO_RESPONSE;
  352. Offset = HdrOffset + 2;
  353. }
  354. else if (HdrOffset == pRes->Size)
  355. {
  356. Offset = HdrOffset + 1;
  357. }
  358. PBTbl = ( ((pReq->Data[sizeof (IPMIMsgHdr_T)] & 0x0F) == SECONDARY_IPMB_CHANNEL) ? SECONDARY_PB_TBL : PRIMARY_PB_TBL );
  359. int i;
  360. while(TRUE)
  361. {
  362. if ( (TRUE == m_PendingBridgedResTbl[PBTbl][SeqNum].Used)
  363. && (0 == memcmp (&m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr, &pReq->Data[Offset], sizeof (IPMIMsgHdr_T))) )
  364. {
  365. if(m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFd_LanIfcQ)
  366. {
  367. memcpy (&m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr, pRes->Data, sizeof (IPMIMsgHdr_T));
  368. }
  369. else if(m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFdUdsIfc)
  370. {
  371. //pRes->Size ++;
  372. SwapUDSIPMIMsg ( pReq, pRes);
  373. //pRes->Data[pRes->Size-1] = 0;
  374. memcpy (&m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr, pRes->Data, sizeof (IPMIUDSMsg_T));
  375. m_PendingBridgedResTbl[PBTbl][SeqNum].UDSSocket = pRes->Socket;
  376. printf("log666 \n");
  377. for(i=0;i<sizeof (IPMIUDSMsg_T);i++)
  378. printf("%#x ", pRes->Data[i]);
  379. printf("\n");
  380. }
  381. m_PendingBridgedResTbl[PBTbl][SeqNum].ResDataOk = 1;
  382. break;
  383. }
  384. else
  385. {
  386. SeqNum = (SeqNum - 1) & 0x3F;
  387. if(SeqNum == g_BMCInfo.SendMsgSeqNum)
  388. {
  389. break;
  390. }
  391. }
  392. }
  393. }
  394. return;
  395. }
  396. /**
  397. *@fn CalculateChecksum2
  398. *@brief Calculates the checksum
  399. *@param Pkt Pointer to the data for the checksum to be calculated
  400. *@param Len Size of data for checksum calculation
  401. *@return Returns the checksum value
  402. */
  403. uint8_t CalculateCheckSum2 (uint8_t* Pkt, uint32_t Len)
  404. {
  405. uint8_t Sum;
  406. uint32_t i;
  407. /* Get Checksum 2 */
  408. Sum = 0;
  409. for (i = 3; i < Len; i++)
  410. {
  411. Sum += Pkt [i];
  412. }
  413. return (uint8_t)(0xFF & (0x100 - Sum));
  414. }
  415. /**
  416. *@fn GetMsgHndlrMap
  417. *@brief Gets the exact command Handler by comparing NetFn
  418. *@param Netfn -NetFunction of the Cmd to execute
  419. *@param pCmdHndlrMap Pointer to the Command Handler
  420. *@return Returns 0 on success
  421. * Returns -1 on failure
  422. */
  423. int
  424. GetMsgHndlrMap (uint8_t NetFn, CmdHndlrMap_T ** pCmdHndlrMap)
  425. {
  426. int i;
  427. /* Get the command handler corresponding to the net function */
  428. for (i = 0; i < sizeof(m_MsgHndlrTbl)/sizeof(m_MsgHndlrTbl[0]); i++) //pBMCInfo->MsgHndlrTblSize
  429. {
  430. if (m_MsgHndlrTbl [i].NetFn == NetFn) { break; }
  431. }
  432. /* Check if we have not found our net function */
  433. if (i == sizeof(m_MsgHndlrTbl)/sizeof(m_MsgHndlrTbl[0]) )
  434. {
  435. return -1;
  436. }
  437. /* Get the handler corresponding to the command */
  438. *pCmdHndlrMap = (CmdHndlrMap_T*)m_MsgHndlrTbl [i].CmdHndlrMap;
  439. return 0;
  440. }
  441. /**
  442. *@fn GetCmdHndlr
  443. *@brief Picks up the exact command to execute by comparing Cmd no.
  444. *@param pReq Request buffer for the command
  445. *@param pRes Response buffer for the command
  446. *@param pCmdHndlrMap
  447. *@param HdrOffset
  448. *@param CmdOverride
  449. *@param CmdHndlr
  450. *@return Returns TRUE on success
  451. * Returns FALSE on failure
  452. */
  453. int GetCmdHndlr(MsgPkt_T* pReq,MsgPkt_T* pRes,CmdHndlrMap_T* pCmdHndlrMap,
  454. uint32_t HdrOffset,uint8_t CmdOverride,CmdHndlrMap_T** CmdHndrl )
  455. {
  456. int i=0;
  457. while (1)
  458. {
  459. /**
  460. * If we reached the end of the Command Handler map - invalid command
  461. **/
  462. if (0 == pCmdHndlrMap->CmdHndlr)
  463. {
  464. if(CmdOverride == FALSE)
  465. {
  466. pRes->Data [HdrOffset] = CC_INV_CMD;
  467. printf( "Warning: MsgHndlr.c : Invalid Command %#x\r\n", pReq->Cmd );
  468. }
  469. return FALSE;
  470. }
  471. if (pCmdHndlrMap->Cmd == pReq->Cmd)
  472. {
  473. break;
  474. }
  475. i++;
  476. pCmdHndlrMap++;
  477. }
  478. *CmdHndrl = pCmdHndlrMap;
  479. return TRUE;
  480. }
  481. /**
  482. *@fn GroupExtnGetMsgHndlrMap
  483. *@brief Gets the exact command Handler by comparing NetFn
  484. *@param Netfn -NetFunction of the Cmd to execute
  485. *@GroupExtnCode - Group Extension code
  486. *@param pCmdHndlrMap Pointer to the Command Handler
  487. *@return Returns 0 on success
  488. * Returns -1 on failure
  489. */
  490. int
  491. GroupExtnGetMsgHndlrMap (uint8_t NetFn, uint8_t GroupExtnCode, CmdHndlrMap_T ** pCmdHndlrMap)
  492. {
  493. int i;
  494. /* Get the command handler corresponding to the net function */
  495. for (i = 0; i < sizeof (m_GroupExtnMsgHndlrTbl) / sizeof (m_GroupExtnMsgHndlrTbl [0]); i++)
  496. {
  497. if ((m_GroupExtnMsgHndlrTbl [i].NetFn == NetFn) && (m_GroupExtnMsgHndlrTbl [i].GroupExtnCode == GroupExtnCode))
  498. {
  499. break;
  500. }
  501. }
  502. /* Check if we have not found our net function */
  503. if (i == sizeof (m_GroupExtnMsgHndlrTbl) / sizeof (m_GroupExtnMsgHndlrTbl[0]))
  504. {
  505. return -1;
  506. }
  507. // printf("---> GroupExtnGetMsgHndlrMap successful, i=%d\n",i);
  508. /* Get the handler corresponding to the command */
  509. *pCmdHndlrMap = (CmdHndlrMap_T*)m_GroupExtnMsgHndlrTbl [i].CmdHndlrMap;
  510. return 0;
  511. }
  512. /*------------------------------------------------------------------
  513. *@fn RespondSendMessage
  514. *@brief Frames the Response packet when a IPMB destination is
  515. * unavialable
  516. *
  517. *@param pReq: Request Message Packet address
  518. *@param Status Status of SendIPMBPkt method
  519. *@param BMCInst: BMC Instance Number
  520. *
  521. *@return none
  522. *-----------------------------------------------------------------*/
  523. void RespondSendMessage ( MsgPkt_T* pReq, uint8_t Status)
  524. {
  525. uint8_t PBTbl = PRIMARY_PB_TBL;
  526. MsgPkt_T ResPkt;
  527. IPMIMsgHdr_T* pIPMIResHdr = ( IPMIMsgHdr_T*)ResPkt.Data;
  528. IPMIMsgHdr_T* pIPMIReqHdr = ( IPMIMsgHdr_T*)pReq->Data;
  529. uint8_t SeqNum = NET_FN(pIPMIReqHdr->RqSeqLUN); //IPMB的sequence
  530. int QueueFd;
  531. int HdrOffset = 0;
  532. //printf("---> RespondSendMessage Status = %d, log111\n", Status);
  533. /* Check for pending responses */
  534. PBTbl = ( (pReq->Channel == SECONDARY_IPMB_CHANNEL) ? SECONDARY_PB_TBL : PRIMARY_PB_TBL );
  535. if ( (TRUE == m_PendingBridgedResTbl[PBTbl][SeqNum].Used) &&
  536. (NET_FN(pIPMIReqHdr->NetFnLUN) == NET_FN(m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.NetFnLUN )) &&
  537. (pIPMIReqHdr->Cmd == m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.Cmd) &&
  538. (pIPMIReqHdr->ResAddr == m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.ResAddr) )
  539. {
  540. //printf("---> RespondSendMessage/ m_PendingBridgedResTbl: PBTbl: %d, SeqNum %d, log222\n", PBTbl, SeqNum);
  541. // int i;
  542. // for(i=0;i<6;i++)
  543. // printf("%#x ", ((uint8_t*)&m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr.IPMIMsgHdr)[i]);
  544. // printf("\n");
  545. uint32_t tcnt = 0;
  546. while(m_PendingBridgedResTbl[PBTbl][SeqNum].ResDataOk == 0)
  547. {
  548. usleep(1);
  549. tcnt++;
  550. if(tcnt > 100000)
  551. {
  552. printf("Warning: %s-%s Response data not ok!\n", __FILE__, __FUNCTION__);
  553. break; //100ms
  554. }
  555. }
  556. if((m_PendingBridgedResTbl[PBTbl][SeqNum].OriginSrc == ORIGIN_INT_REQ) && (Status == STATUS_OK))
  557. {
  558. return;
  559. }
  560. if(m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFd_LanIfcQ)
  561. {
  562. memcpy (pIPMIResHdr, &m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr.IPMIMsgHdr, sizeof (IPMIMsgHdr_T));
  563. HdrOffset = sizeof(IPMIMsgHdr_T);
  564. }
  565. else if(m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFdUdsIfc)
  566. {
  567. memcpy (pIPMIResHdr, &m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr.UDSMsgHdr, sizeof (IPMIUDSMsg_T));
  568. HdrOffset = sizeof(IPMIUDSMsg_T);
  569. }
  570. else
  571. {
  572. //SwapIPMIMsgHdr ( pIPMIReqHdr, pIPMIResHdr);
  573. //QueueFd = m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ;
  574. memcpy (pIPMIResHdr, &m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr.IPMIMsgHdr, sizeof (IPMIMsgHdr_T));
  575. HdrOffset = sizeof(IPMIMsgHdr_T);
  576. }
  577. if (STATUS_OK == Status)
  578. {
  579. if ( ( m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFd_PrimaryIpmbIfcQ) ||
  580. (m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFd_SecondaryIpmbIfcQ) ||
  581. (ORIGIN_SENDMSG != m_PendingBridgedResTbl[PBTbl][SeqNum].OriginSrc) )
  582. {
  583. return;
  584. }
  585. ResPkt.Data [HdrOffset] = CC_NORMAL;
  586. }
  587. else if (STATUS_FAIL == Status)
  588. {
  589. ResPkt.Data [HdrOffset] = CC_NO_ACK_FROM_SLAVE;
  590. }
  591. else
  592. {
  593. ResPkt.Data [HdrOffset] = CC_UNSPECIFIED_ERR;
  594. }
  595. ResPkt.Size = HdrOffset + 1 + 1; // IPMI Header + Completion Code + Second Checksum
  596. ResPkt.Cmd = pIPMIResHdr->Cmd;
  597. ResPkt.NetFnLUN = pIPMIReqHdr->NetFnLUN;
  598. ResPkt.Channel = pReq->Channel;
  599. //ResPkt.Socket = pReq->Socket;
  600. /* Calculate the Second CheckSum */
  601. ResPkt.Data[ResPkt.Size - 1] = CalculateCheckSum2 (ResPkt.Data, ResPkt.Size-1);
  602. ResPkt.Param = BRIDGING_REQUEST;
  603. if (m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFd_LanIfcQ)
  604. {
  605. QueueFd = gFd_LanResQ;
  606. }
  607. else if(m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFdUdsIfc)
  608. {
  609. ResPkt.Size++;
  610. ResPkt.Data[ResPkt.Size-1] = 0;
  611. ((IPMIUDSMsg_T*)&ResPkt.Data[0])->IPMIMsgLen = ResPkt.Size;
  612. ResPkt.Socket = m_PendingBridgedResTbl[PBTbl][SeqNum].UDSSocket;
  613. QueueFd = gFdUdsRes;
  614. }
  615. else
  616. {
  617. QueueFd = m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ;
  618. }
  619. if (STATUS_OK != Status)
  620. {
  621. m_PendingBridgedResTbl[PBTbl][SeqNum].Used = FALSE;
  622. m_PendingBridgedResTbl[PBTbl][SeqNum].ResDataOk = 0;
  623. }
  624. // /* Post the data to Destination Interface queue */
  625. // int i;
  626. // printf("===> RespondSendMessage post to %d: ", QueueFd);
  627. // for(i=0;i<ResPkt.Size;i++)
  628. // printf("%#x ", ResPkt.Data[i]);
  629. // printf("\n");
  630. PostMsg (QueueFd, &ResPkt);
  631. }
  632. }
  633. /**
  634. *@fn PendingBridgeResTimerTask
  635. *@brief Sends the timeout message to response queue
  636. * if the message does not turn out within send message timeout
  637. *@return none
  638. */
  639. static void
  640. PendingBridgeResTimerTask (void)
  641. {
  642. uint8_t i;
  643. uint8_t PBTbl = PRIMARY_PB_TBL;
  644. int QueueFd = 0;
  645. printf("-> PendingBridgeResTimerTask\n");
  646. /* Check for any pending responses */
  647. for( PBTbl=0; PBTbl < MAX_PENDING_BRIDGE_TBL; PBTbl++)
  648. {
  649. for (i = 0; i < sizeof (m_PendingBridgedResTbl[0])/sizeof (m_PendingBridgedResTbl[0][0]); i++)
  650. {
  651. if (TRUE == m_PendingBridgedResTbl[PBTbl][i].Used)
  652. {
  653. m_PendingBridgedResTbl[PBTbl][i].TimeOut--;
  654. if (0 == m_PendingBridgedResTbl[PBTbl][i].TimeOut)
  655. {
  656. MsgPkt_T Timeout;
  657. IPMIMsgHdr_T* pIPMIMsgHdr = (IPMIMsgHdr_T*) Timeout.Data;
  658. /* Fill the response packet */
  659. SwapIPMIMsgHdr (&m_PendingBridgedResTbl[PBTbl][i].ReqMsgHdr, pIPMIMsgHdr);
  660. // slog(LANQueueName,"%s%d",LAN_IFC_Q,BMCInst);
  661. // sprintf(PrimaryIPMBQueueName,"%s%d",IPMB_PRIMARY_IFC_Q,BMCInst);
  662. // sprintf(SecondaryIPMBQueueName,"%s%d",IPMB_SECONDARY_IFC_Q,BMCInst);
  663. // sprintf(SerialQueueName,"%s%d",SERIAL_IFC_Q,BMCInst);
  664. if(PBTbl == PRIMARY_PB_TBL)
  665. {
  666. pIPMIMsgHdr->ReqAddr = g_BMCInfo.PrimaryIPMBAddr;
  667. }
  668. else if(PBTbl == SECONDARY_PB_TBL)
  669. {
  670. pIPMIMsgHdr->ReqAddr = g_BMCInfo.SecondaryIPMBAddr;
  671. }
  672. else
  673. {
  674. printf("Invalid PBTbl\n");;//pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
  675. }
  676. Timeout.Data [sizeof(IPMIMsgHdr_T)] = CC_TIMEOUT;
  677. Timeout.Size = sizeof (IPMIMsgHdr_T) + 1 + 1; // IPMI Header + Completion Code + Second Checksum
  678. /* Calculate the Second CheckSum */
  679. Timeout.Data[Timeout.Size - 1] = CalculateCheckSum2 (Timeout.Data, Timeout.Size-1);
  680. Timeout.Param = BRIDGING_REQUEST;
  681. if (m_PendingBridgedResTbl[PBTbl][i].DestQ == gFd_LanIfcQ)
  682. {
  683. int j;
  684. for (j = Timeout.Size - 1; j >= 0; --j)
  685. {
  686. Timeout.Data [j+1] = Timeout.Data [j];
  687. }
  688. Timeout.Data[0] = m_PendingBridgedResTbl[PBTbl][i].SrcSessionHandle;
  689. Timeout.Size++;
  690. Timeout.Cmd = PAYLOAD_IPMI_MSG;
  691. QueueFd = gFd_LanIfcQ;
  692. }
  693. // else if (0 == strcmp ((char *)m_PendingBridgedResTbl[PBTbl][i].DestQ, SerialQueueName))
  694. // {
  695. // int j;
  696. // for (j = Timeout.Size - 1; j >= 0; --j)
  697. // {
  698. // Timeout.Data [j+1] = Timeout.Data [j];
  699. // }
  700. // Timeout.Data[0] = m_PendingBridgedResTbl[PBTbl][i].SrcSessionHandle;
  701. // Timeout.Size++;
  702. // Timeout.Cmd = PAYLOAD_IPMI_MSG;
  703. // strcpy(QueueName, SERIAL_IFC_Q);
  704. // }
  705. // else if (g_BMCInfo.IpmiConfig.PrimaryIPMBSupport == 1 && m_PendingBridgedResTbl[PBTbl][i].DestQ == gFd_PrimaryIpmbIfcQ)
  706. // {
  707. // int j;
  708. // for (j = Timeout.Size - 1; j >= 0; --j)
  709. // {
  710. // Timeout.Data [j + sizeof (IPMIMsgHdr_T) + 1] = Timeout.Data [j];
  711. // }
  712. // memcpy (Timeout.Data, &m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr, sizeof (IPMIMsgHdr_T));
  713. // Timeout.Data[sizeof (IPMIMsgHdr_T)] = CC_NORMAL;
  714. // Timeout.Size++;
  715. // QueueFd = gFd_PrimaryIpmbIfcQ;
  716. // }
  717. // else if (g_BMCInfo.IpmiConfig.SecondaryIPMBSupport == 1 && m_PendingBridgedResTbl[PBTbl][i].DestQ == gFd_SecondaryIpmbIfcQ)
  718. // {
  719. // int j;
  720. // for (j = Timeout.Size - 1; j >= 0; --j)
  721. // {
  722. // Timeout.Data [j + sizeof (IPMIMsgHdr_T) + 1] = Timeout.Data [j];
  723. // }
  724. // memcpy (Timeout.Data, &m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.IPMIMsgHdr, sizeof (IPMIMsgHdr_T));
  725. // Timeout.Data[sizeof (IPMIMsgHdr_T)] = CC_NORMAL;
  726. // Timeout.Size++;
  727. // QueueFd = gFd_SecondaryIpmbIfcQ;
  728. // }
  729. else if (m_PendingBridgedResTbl[PBTbl][i].DestQ = gFdUdsIfc)
  730. {
  731. printf("---> UDS pending bridge TimeOut\n");
  732. int j;
  733. UDSSessionTbl_T *pUDSSessionInfo = NULL;
  734. for (j = sizeof (IPMIMsgHdr_T); j < Timeout.Size ;j++)
  735. {
  736. Timeout.Data [j + sizeof (IPMIUDSMsg_T)-sizeof (IPMIMsgHdr_T)] = Timeout.Data [j];
  737. }
  738. Timeout.Size = Timeout.Size + sizeof (IPMIUDSMsg_T)- sizeof (IPMIMsgHdr_T);
  739. m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.UDSMsgHdr.IPMIMsgLen = Timeout.Size;
  740. memcpy (Timeout.Data, &m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.UDSMsgHdr, sizeof (IPMIUDSMsg_T));
  741. Timeout.NetFnLUN = m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.UDSMsgHdr.NetFnLUN;
  742. Timeout.SessionID = m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.UDSMsgHdr.SessionID;
  743. Timeout.Cmd = m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.UDSMsgHdr.Cmd;
  744. pUDSSessionInfo = GetUDSSessionInfo (UDS_SESSION_ID_INFO,&Timeout.SessionID);
  745. if(pUDSSessionInfo != NULL)
  746. {
  747. Timeout.Socket = pUDSSessionInfo->UDSSocket;
  748. }
  749. QueueFd = m_PendingBridgedResTbl[PBTbl][i].DestQ;
  750. }
  751. else
  752. {
  753. int j;
  754. for (j = Timeout.Size - 1; j >= 0; --j)
  755. {
  756. Timeout.Data [j + sizeof (IPMIMsgHdr_T) + 1] = Timeout.Data [j];
  757. }
  758. memcpy (Timeout.Data, &m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.IPMIMsgHdr, sizeof (IPMIMsgHdr_T));
  759. Timeout.Data[sizeof (IPMIMsgHdr_T)] = CC_TIMEOUT;
  760. QueueFd = m_PendingBridgedResTbl[PBTbl][i].DestQ;
  761. }
  762. /* Post the data to Destination Interface queue */
  763. PostMsg (QueueFd, &Timeout);
  764. m_PendingBridgedResTbl[PBTbl][i].Used = FALSE;
  765. printf( "MsgHndlr: clean pending index = %d.\n", i );
  766. }
  767. }
  768. }
  769. }
  770. }
  771. /**
  772. *@fn PendingSeqNoTimerTask
  773. *@brief Timertask which helpful in IPMB sequence number validation
  774. *@return none
  775. */
  776. static void
  777. PendingSeqNoTimerTask (void)
  778. {
  779. uint8_t i,j;
  780. printf("-> PendingSeqNoTimerTask\n");
  781. /* Check for any Sequence Number expiraied */
  782. for (i = 0; i < sizeof (m_PendingSeqNoTbl)/sizeof (m_PendingSeqNoTbl[0]); i++)
  783. {
  784. for (j = 0; j < sizeof (m_PendingSeqNoTbl[0])/sizeof (m_PendingSeqNoTbl[0][0]); j++)
  785. {
  786. if (TRUE == m_PendingSeqNoTbl[i][j].Used)
  787. {
  788. m_PendingSeqNoTbl[i][j].TimeOut--;
  789. if (0 == m_PendingSeqNoTbl[i][j].TimeOut)
  790. {
  791. m_PendingSeqNoTbl[i][j].Used = FALSE;
  792. }
  793. }
  794. }
  795. }
  796. }
  797. /**
  798. *@fn SwapIPMIMsgHdr
  799. *@brief Swaps the header and copies into response
  800. *@param pIPMIMsgReq Header of the Request
  801. *@param pIPMIMsgRes Header of the response
  802. *@return none
  803. */
  804. void
  805. SwapIPMIMsgHdr (IPMIMsgHdr_T* pIPMIMsgReq, IPMIMsgHdr_T* pIPMIMsgRes)
  806. {
  807. pIPMIMsgRes->ResAddr = pIPMIMsgReq->ReqAddr;
  808. pIPMIMsgRes->NetFnLUN = (pIPMIMsgReq->NetFnLUN & 0xFC) + 0x04;
  809. pIPMIMsgRes->NetFnLUN |= pIPMIMsgReq->RqSeqLUN & 0x03;
  810. /* Calculate the Checksum for above two bytes */
  811. pIPMIMsgRes->ChkSum = (~(pIPMIMsgRes->ResAddr + pIPMIMsgRes->NetFnLUN) + 1);
  812. pIPMIMsgRes->ReqAddr = pIPMIMsgReq->ResAddr;
  813. pIPMIMsgRes->RqSeqLUN = (pIPMIMsgReq->RqSeqLUN & 0xFC);
  814. pIPMIMsgRes->RqSeqLUN |= (pIPMIMsgReq->NetFnLUN & 0x03);
  815. pIPMIMsgRes->Cmd = pIPMIMsgReq->Cmd;
  816. return;
  817. }
  818. /**
  819. * *@fn Swap UDSIPMIMsg
  820. * *@brief Swaps the header and copies into response
  821. * *@param pIPMIMsgReq Header of the Request
  822. * *@param pIPMIMsgRes Header of the response
  823. * *@return none
  824. * */
  825. void
  826. SwapUDSIPMIMsg ( MsgPkt_T* pIPMIMsgReq, MsgPkt_T* pIPMIMsgRes)
  827. {
  828. IPMIUDSMsg_T *pIPMIUDSMsgRes = (IPMIUDSMsg_T *)&pIPMIMsgRes->Data[0];
  829. IPMIUDSMsg_T *pIPMIUDSMsgReq = (IPMIUDSMsg_T *)&pIPMIMsgReq->Data[0];
  830. pIPMIMsgRes->NetFnLUN = pIPMIMsgReq->NetFnLUN;
  831. // pIPMIMsgRes->Privilege = pIPMIMsgReq->Privilege;
  832. pIPMIMsgRes->Cmd = pIPMIMsgReq->Cmd;
  833. pIPMIMsgRes->Channel = pIPMIMsgReq->Channel;
  834. pIPMIMsgRes->SessionID = pIPMIMsgReq->SessionID;
  835. pIPMIMsgRes->Socket = pIPMIMsgReq->Socket;
  836. pIPMIUDSMsgRes->NetFnLUN = pIPMIMsgReq->NetFnLUN;
  837. // pIPMIUDSMsgRes->Privilege = pIPMIMsgReq->Privilege;
  838. pIPMIUDSMsgRes->Cmd = pIPMIMsgReq->Cmd;
  839. pIPMIUDSMsgRes->ChannelNum = pIPMIMsgReq->Channel;
  840. pIPMIUDSMsgRes->SessionID = pIPMIMsgReq->SessionID;
  841. //pIPMIUDSMsgRes->AuthFlag = pIPMIUDSMsgReq->AuthFlag;
  842. pIPMIUDSMsgRes->IPMIMsgLen = pIPMIMsgRes->Size;
  843. // strcpy( (char *)pIPMIUDSMsgRes->UserName, (char *)pIPMIUDSMsgReq->UserName);
  844. // memcpy(pIPMIUDSMsgRes->IPAddr, pIPMIUDSMsgReq->IPAddr, 16);
  845. return;
  846. }