MsgHndlrTask.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  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. //TODO:UDS的数据结构在最后多了一个0,找机会要给他去掉。
  145. resMsgPkt.Size = resMsgPkt.Size+1;
  146. SwapUDSIPMIMsg(&reqMsgPkt,&resMsgPkt);
  147. resMsgPkt.Data[resMsgPkt.Size-1] = 0;
  148. }
  149. if(SYS_IFC_CHANNEL == reqMsgPkt.Channel)
  150. {
  151. /* Skip current request if no response from Command Handler */
  152. if (!resMsgPkt.Size && (NO_RESPONSE == resMsgPkt.Param) )
  153. {
  154. continue;
  155. }
  156. resMsgPkt.SessionID = reqMsgPkt.SessionID;
  157. }
  158. //int i;
  159. // printf("===> Mtx to %d: ", resMsgPkt.SrcQ);
  160. // for(i=0;i<resMsgPkt.Size;i++)
  161. // printf("%#x ", resMsgPkt.Data[i]);
  162. // printf("\n");
  163. //send response pkt to source queue.
  164. PostMsg(resMsgPkt.SrcQ, &resMsgPkt);
  165. }
  166. }
  167. /**
  168. *@fn ValidateMsgHdr
  169. *@brief Validates the Message header and keeps track of the messages that has been bridged
  170. *@param pReq Request packet of the command to be executed
  171. *@return Returns -1 in case of the response to the bridged message
  172. * Returns 0 otherwise
  173. */
  174. int
  175. ValidateMsgHdr (MsgPkt_T* pReq)
  176. {
  177. int j;
  178. uint8_t PBTbl = PRIMARY_PB_TBL;
  179. IPMIMsgHdr_T* pIPMIMsgReq = (IPMIMsgHdr_T*)&pReq->Data;
  180. ChannelInfo_T* pChannelInfo;
  181. uint8_t SeqNum = NET_FN(pIPMIMsgReq->RqSeqLUN);
  182. int Queuefd = 0;
  183. /* Check for the request message LUN */
  184. switch (pReq->NetFnLUN & 0x03)
  185. {
  186. case BMC_LUN_00:
  187. if (0 == (pReq->NetFnLUN & 0x04))
  188. {
  189. return 0; //IPMB做从
  190. }
  191. PBTbl = ( (pReq->Channel == SECONDARY_IPMB_CHANNEL) ? SECONDARY_PB_TBL : PRIMARY_PB_TBL );
  192. if ( (TRUE == m_PendingBridgedResTbl[PBTbl][SeqNum].Used) &&
  193. (NET_FN(pIPMIMsgReq->NetFnLUN) == NET_FN((m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.NetFnLUN + 0x04))) &&
  194. (pIPMIMsgReq->Cmd == m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.Cmd) &&
  195. (pIPMIMsgReq->ReqAddr == m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.ResAddr))
  196. {
  197. /* Change the requester's address, sequence number and LUN */
  198. pIPMIMsgReq->ResAddr = m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.ReqAddr;
  199. pIPMIMsgReq->RqSeqLUN = m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.RqSeqLUN;
  200. /* Calculate the Second CheckSum */
  201. pReq->Data[ pReq->Size - 1 ] = CalculateCheckSum2( pReq->Data, pReq->Size - 1 );
  202. pReq->Data[2] = (~(pReq->Data[0] + pReq->Data[1])) +1; //2's complement checksum
  203. pReq->Param = BRIDGING_REQUEST;
  204. if (m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFd_LanIfcQ)
  205. {
  206. for (j=pReq->Size - 1; j>=0; j--)
  207. {
  208. pReq->Data[j+1] = pReq->Data[j];
  209. }
  210. pReq->Data[0] = m_PendingBridgedResTbl[PBTbl][SeqNum].SrcSessionHandle;
  211. pReq->Size++;
  212. pReq->Cmd = PAYLOAD_IPMI_MSG;
  213. Queuefd = gFd_LanIfcQ;
  214. }
  215. else if(m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFdUdsIfc)
  216. {
  217. pReq->Cmd = PAYLOAD_IPMI_MSG;
  218. pReq->Socket = m_PendingBridgedResTbl[PBTbl][SeqNum].UDSSocket;
  219. memcpy(&pReq->Data[sizeof(IPMIUDSMsg_T)], &pReq->Data[0], pReq->Size);
  220. memcpy(&pReq->Data[0], &m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr.UDSMsgHdr, sizeof(IPMIUDSMsg_T));
  221. pReq->Size += sizeof(IPMIUDSMsg_T);
  222. pReq->Size++;
  223. pReq->Data[pReq->Size-1] = 0;
  224. ((IPMIUDSMsg_T*)&pReq->Data[0])->IPMIMsgLen = pReq->Size;
  225. Queuefd = gFdUdsIfc;
  226. }
  227. else
  228. {
  229. Queuefd = m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ;
  230. }
  231. /* Post the data to Destination Interface queue */
  232. // printf("===> ValidateMsgHdr post message to %d\n", Queuefd);
  233. PostMsg (Queuefd, pReq);
  234. m_PendingBridgedResTbl[PBTbl][SeqNum].Used = FALSE;
  235. m_PendingBridgedResTbl[PBTbl][SeqNum].ResDataOk = 0;
  236. }
  237. return -1;
  238. case BMC_LUN_01:
  239. case BMC_LUN_10:
  240. case BMC_LUN_11:
  241. //TODO:
  242. default:
  243. return -1;
  244. }
  245. }
  246. /**
  247. *@fn ProcessIPMIReq
  248. *@brief Processes the requested IPMI command
  249. *@param pReq Request of the command
  250. *@param pRes Response for the requested command
  251. *@return none
  252. */
  253. static void
  254. ProcessIPMIReq (MsgPkt_T* pReq, MsgPkt_T* pRes)
  255. {
  256. CmdHndlrMap_T * pCmdHndlrMap;
  257. uint32_t HdrOffset = 0;
  258. uint8_t CmdOverride = 1;
  259. int8_t MsgHndlrMapGot=0;
  260. uint8_t PBTbl = PRIMARY_PB_TBL;
  261. // msgHndlr_dbg_printf ("Processing IPMI Packet.\r\n");
  262. /* Set the Cmd and Net function in response packet */
  263. pRes->Cmd = pReq->Cmd;
  264. pRes->NetFnLUN = pReq->NetFnLUN;
  265. pRes->Channel = pReq->Channel;
  266. pRes->SrcQ = pReq->SrcQ;
  267. pRes->Socket = pReq->Socket;
  268. /* Normal IPMI Command response */
  269. pRes->Param = PARAM_NORMAL_RESPONSE;
  270. if ((SYS_IFC_CHANNEL != pReq->Channel) && (USB_CHANNEL != pReq->Channel) && (UDS_CHANNEL != pReq->Channel))
  271. {
  272. //printf("log 1, pReq->Channel: %#x\n", pReq->Channel);
  273. HdrOffset = sizeof (IPMIMsgHdr_T);
  274. pReq->Size = pReq->Size - HdrOffset - 1;
  275. }
  276. if(UDS_CHANNEL == pReq->Channel)
  277. {
  278. //printf("log 2, pReq->Size: %d, HdrOffset: %d\n", pReq->Size, HdrOffset);
  279. HdrOffset = sizeof(IPMIUDSMsg_T);
  280. pReq->Size = pReq->Size -HdrOffset - 1;
  281. }
  282. SwapIPMIMsgHdr((IPMIMsgHdr_T*)pReq->Data, (IPMIMsgHdr_T*)pRes->Data);
  283. pRes->Size = HdrOffset + sizeof(uint8_t);
  284. pthread_setspecific(g_tls.CurSessionID,&pReq->SessionID);
  285. if(IsCommandEnabled(NET_FN(pReq->NetFnLUN), &pReq->Data[HdrOffset], pReq->Cmd) != 0)
  286. {
  287. pRes->Data [HdrOffset] = CC_INV_CMD;
  288. printf ("Invalid Net Function 0x%x or Invalid Command 0x%x\n",NET_FN(pReq->NetFnLUN), pReq->Cmd);
  289. pRes->Size += 2;
  290. return;
  291. }
  292. //Get oem command map
  293. MsgHndlrMapGot = PDKGetOEMMsgHndlrMap(NET_FN(pReq->NetFnLUN),&pCmdHndlrMap);
  294. if(MsgHndlrMapGot == 0)
  295. {
  296. CmdOverride = GetCmdHndlr(pReq,pRes,pCmdHndlrMap,HdrOffset,CmdOverride,&pCmdHndlrMap);
  297. }
  298. //get standard ipmi command map
  299. if((CmdOverride == 0 || MsgHndlrMapGot == -1) ) //OEM commands have no command map.
  300. {
  301. if (0 != GetMsgHndlrMap (NET_FN (pReq->NetFnLUN), &pCmdHndlrMap))
  302. {
  303. // if(pBMCInfo->IpmiConfig.GrpExtnSupport == 1)
  304. // {
  305. if (0 != GroupExtnGetMsgHndlrMap (NET_FN (pReq->NetFnLUN), pReq->Data [HdrOffset], &pCmdHndlrMap) )
  306. {
  307. pRes->Data [HdrOffset] = CC_INV_CMD;
  308. printf ("MsgHndlr.c : Invalid Net Function 0x%x or Invalid Command 0x%x\n",NET_FN(pReq->NetFnLUN), pReq->Cmd);
  309. pRes->Size += 2;
  310. return;
  311. }
  312. // }
  313. // else
  314. // {
  315. // pRes->Data [HdrOffset] = CC_INV_CMD;
  316. // printf ("MsgHndlr.c : Invalid Net Function 0x%x\n",NET_FN(pReq->NetFnLUN));
  317. // pRes->Size += 2;
  318. // return;
  319. // }
  320. }
  321. if(GetCmdHndlr(pReq,pRes,pCmdHndlrMap,HdrOffset,CmdOverride,&pCmdHndlrMap) == FALSE)
  322. {
  323. pRes->Data [HdrOffset] = CC_INV_CMD;
  324. pRes->Size += 2;
  325. //printf("log 3\n");
  326. return;
  327. }
  328. }
  329. /* Check for the request size */
  330. if (0xff != pCmdHndlrMap->ReqLen)
  331. {
  332. /* Check for invalid request size */
  333. if (pCmdHndlrMap->ReqLen != pReq->Size)
  334. {
  335. printf("Warning: Request data len error, require %d\n", pCmdHndlrMap->ReqLen);
  336. pRes->Data [HdrOffset] = CC_REQ_INV_LEN;
  337. pRes->Size += 2;
  338. return;
  339. }
  340. }
  341. pRes->Size = pCmdHndlrMap->CmdHndlr (&pReq->Data [HdrOffset], pReq->Size, &pRes->Data [HdrOffset]) + HdrOffset;
  342. //prepare response data for send message command
  343. if( (CMD_SEND_MSG == pReq->Cmd) && (NETFN_APP == pReq->NetFnLUN >> 2))
  344. {
  345. // printf("log 4, size %d, Channel %d\n",pRes->Size, pRes->Channel);
  346. int Offset = 0;
  347. uint8_t SeqNum = g_BMCInfo.SendMsgSeqNum;
  348. if ((0 == pRes->Size) &&
  349. ((g_BMCInfo.IpmiConfig.PrimaryIPMBSupport == 0x01 && PRIMARY_IPMB_CHANNEL == pRes->Channel) ||
  350. (g_BMCInfo.IpmiConfig.SecondaryIPMBSupport == 0x01 && SECONDARY_IPMB_CHANNEL == pRes->Channel)) )
  351. {
  352. pRes->Param = PARAM_NO_RESPONSE;
  353. Offset = HdrOffset + 2;
  354. }
  355. else if (HdrOffset == pRes->Size)
  356. {
  357. Offset = HdrOffset + 1;
  358. }
  359. PBTbl = ( ((pReq->Data[sizeof (IPMIMsgHdr_T)] & 0x0F) == SECONDARY_IPMB_CHANNEL) ? SECONDARY_PB_TBL : PRIMARY_PB_TBL );
  360. int i;
  361. while(TRUE)
  362. {
  363. if ( (TRUE == m_PendingBridgedResTbl[PBTbl][SeqNum].Used)
  364. && (0 == memcmp (&m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr, &pReq->Data[Offset], sizeof (IPMIMsgHdr_T))) )
  365. {
  366. if(m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFd_LanIfcQ)
  367. {
  368. memcpy (&m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr, pRes->Data, sizeof (IPMIMsgHdr_T));
  369. }
  370. else if(m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFdUdsIfc)
  371. {
  372. //pRes->Size ++;
  373. SwapUDSIPMIMsg ( pReq, pRes);
  374. //pRes->Data[pRes->Size-1] = 0;
  375. memcpy (&m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr, pRes->Data, sizeof (IPMIUDSMsg_T));
  376. m_PendingBridgedResTbl[PBTbl][SeqNum].UDSSocket = pRes->Socket;
  377. printf("log666 \n");
  378. for(i=0;i<sizeof (IPMIUDSMsg_T);i++)
  379. printf("%#x ", pRes->Data[i]);
  380. printf("\n");
  381. }
  382. m_PendingBridgedResTbl[PBTbl][SeqNum].ResDataOk = 1;
  383. break;
  384. }
  385. else
  386. {
  387. SeqNum = (SeqNum - 1) & 0x3F;
  388. if(SeqNum == g_BMCInfo.SendMsgSeqNum)
  389. {
  390. break;
  391. }
  392. }
  393. }
  394. }
  395. return;
  396. }
  397. /**
  398. *@fn CalculateChecksum2
  399. *@brief Calculates the checksum
  400. *@param Pkt Pointer to the data for the checksum to be calculated
  401. *@param Len Size of data for checksum calculation
  402. *@return Returns the checksum value
  403. */
  404. uint8_t CalculateCheckSum2 (uint8_t* Pkt, uint32_t Len)
  405. {
  406. uint8_t Sum;
  407. uint32_t i;
  408. /* Get Checksum 2 */
  409. Sum = 0;
  410. for (i = 3; i < Len; i++)
  411. {
  412. Sum += Pkt [i];
  413. }
  414. return (uint8_t)(0xFF & (0x100 - Sum));
  415. }
  416. /**
  417. *@fn GetMsgHndlrMap
  418. *@brief Gets the exact command Handler by comparing NetFn
  419. *@param Netfn -NetFunction of the Cmd to execute
  420. *@param pCmdHndlrMap Pointer to the Command Handler
  421. *@return Returns 0 on success
  422. * Returns -1 on failure
  423. */
  424. int
  425. GetMsgHndlrMap (uint8_t NetFn, CmdHndlrMap_T ** pCmdHndlrMap)
  426. {
  427. int i;
  428. /* Get the command handler corresponding to the net function */
  429. for (i = 0; i < sizeof(m_MsgHndlrTbl)/sizeof(m_MsgHndlrTbl[0]); i++) //pBMCInfo->MsgHndlrTblSize
  430. {
  431. if (m_MsgHndlrTbl [i].NetFn == NetFn) { break; }
  432. }
  433. /* Check if we have not found our net function */
  434. if (i == sizeof(m_MsgHndlrTbl)/sizeof(m_MsgHndlrTbl[0]) )
  435. {
  436. return -1;
  437. }
  438. /* Get the handler corresponding to the command */
  439. *pCmdHndlrMap = (CmdHndlrMap_T*)m_MsgHndlrTbl [i].CmdHndlrMap;
  440. return 0;
  441. }
  442. /**
  443. *@fn GetCmdHndlr
  444. *@brief Picks up the exact command to execute by comparing Cmd no.
  445. *@param pReq Request buffer for the command
  446. *@param pRes Response buffer for the command
  447. *@param pCmdHndlrMap
  448. *@param HdrOffset
  449. *@param CmdOverride
  450. *@param CmdHndlr
  451. *@return Returns TRUE on success
  452. * Returns FALSE on failure
  453. */
  454. int GetCmdHndlr(MsgPkt_T* pReq,MsgPkt_T* pRes,CmdHndlrMap_T* pCmdHndlrMap,
  455. uint32_t HdrOffset,uint8_t CmdOverride,CmdHndlrMap_T** CmdHndrl )
  456. {
  457. int i=0;
  458. while (1)
  459. {
  460. /**
  461. * If we reached the end of the Command Handler map - invalid command
  462. **/
  463. if (0 == pCmdHndlrMap->CmdHndlr)
  464. {
  465. if(CmdOverride == FALSE)
  466. {
  467. pRes->Data [HdrOffset] = CC_INV_CMD;
  468. printf( "Warning: MsgHndlr.c : Invalid Command %#x\r\n", pReq->Cmd );
  469. }
  470. return FALSE;
  471. }
  472. if (pCmdHndlrMap->Cmd == pReq->Cmd)
  473. {
  474. break;
  475. }
  476. i++;
  477. pCmdHndlrMap++;
  478. }
  479. *CmdHndrl = pCmdHndlrMap;
  480. return TRUE;
  481. }
  482. /**
  483. *@fn GroupExtnGetMsgHndlrMap
  484. *@brief Gets the exact command Handler by comparing NetFn
  485. *@param Netfn -NetFunction of the Cmd to execute
  486. *@GroupExtnCode - Group Extension code
  487. *@param pCmdHndlrMap Pointer to the Command Handler
  488. *@return Returns 0 on success
  489. * Returns -1 on failure
  490. */
  491. int
  492. GroupExtnGetMsgHndlrMap (uint8_t NetFn, uint8_t GroupExtnCode, CmdHndlrMap_T ** pCmdHndlrMap)
  493. {
  494. int i;
  495. /* Get the command handler corresponding to the net function */
  496. for (i = 0; i < sizeof (m_GroupExtnMsgHndlrTbl) / sizeof (m_GroupExtnMsgHndlrTbl [0]); i++)
  497. {
  498. if ((m_GroupExtnMsgHndlrTbl [i].NetFn == NetFn) && (m_GroupExtnMsgHndlrTbl [i].GroupExtnCode == GroupExtnCode))
  499. {
  500. break;
  501. }
  502. }
  503. /* Check if we have not found our net function */
  504. if (i == sizeof (m_GroupExtnMsgHndlrTbl) / sizeof (m_GroupExtnMsgHndlrTbl[0]))
  505. {
  506. return -1;
  507. }
  508. // printf("---> GroupExtnGetMsgHndlrMap successful, i=%d\n",i);
  509. /* Get the handler corresponding to the command */
  510. *pCmdHndlrMap = (CmdHndlrMap_T*)m_GroupExtnMsgHndlrTbl [i].CmdHndlrMap;
  511. return 0;
  512. }
  513. /*------------------------------------------------------------------
  514. *@fn RespondSendMessage
  515. *@brief Frames the Response packet when a IPMB destination is
  516. * unavialable
  517. *
  518. *@param pReq: Request Message Packet address
  519. *@param Status Status of SendIPMBPkt method
  520. *@param BMCInst: BMC Instance Number
  521. *
  522. *@return none
  523. *-----------------------------------------------------------------*/
  524. void RespondSendMessage ( MsgPkt_T* pReq, uint8_t Status)
  525. {
  526. uint8_t PBTbl = PRIMARY_PB_TBL;
  527. MsgPkt_T ResPkt;
  528. IPMIMsgHdr_T* pIPMIResHdr = ( IPMIMsgHdr_T*)ResPkt.Data;
  529. IPMIMsgHdr_T* pIPMIReqHdr = ( IPMIMsgHdr_T*)pReq->Data;
  530. uint8_t SeqNum = NET_FN(pIPMIReqHdr->RqSeqLUN); //IPMB的sequence
  531. int QueueFd;
  532. int HdrOffset = 0;
  533. //printf("---> RespondSendMessage Status = %d, log111\n", Status);
  534. /* Check for pending responses */
  535. PBTbl = ( (pReq->Channel == SECONDARY_IPMB_CHANNEL) ? SECONDARY_PB_TBL : PRIMARY_PB_TBL );
  536. if ( (TRUE == m_PendingBridgedResTbl[PBTbl][SeqNum].Used) &&
  537. (NET_FN(pIPMIReqHdr->NetFnLUN) == NET_FN(m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.NetFnLUN )) &&
  538. (pIPMIReqHdr->Cmd == m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.Cmd) &&
  539. (pIPMIReqHdr->ResAddr == m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.ResAddr) )
  540. {
  541. //printf("---> RespondSendMessage/ m_PendingBridgedResTbl: PBTbl: %d, SeqNum %d, log222\n", PBTbl, SeqNum);
  542. // int i;
  543. // for(i=0;i<6;i++)
  544. // printf("%#x ", ((uint8_t*)&m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr.IPMIMsgHdr)[i]);
  545. // printf("\n");
  546. uint32_t tcnt = 0;
  547. while(m_PendingBridgedResTbl[PBTbl][SeqNum].ResDataOk == 0)
  548. {
  549. usleep(1);
  550. tcnt++;
  551. if(tcnt > 100000)
  552. {
  553. printf("Warning: %s-%s Response data not ok!\n", __FILE__, __FUNCTION__);
  554. break; //100ms
  555. }
  556. }
  557. if((m_PendingBridgedResTbl[PBTbl][SeqNum].OriginSrc == ORIGIN_INT_REQ) && (Status == STATUS_OK))
  558. {
  559. return;
  560. }
  561. if(m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFd_LanIfcQ)
  562. {
  563. memcpy (pIPMIResHdr, &m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr.IPMIMsgHdr, sizeof (IPMIMsgHdr_T));
  564. HdrOffset = sizeof(IPMIMsgHdr_T);
  565. }
  566. else if(m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFdUdsIfc)
  567. {
  568. memcpy (pIPMIResHdr, &m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr.UDSMsgHdr, sizeof (IPMIUDSMsg_T));
  569. HdrOffset = sizeof(IPMIUDSMsg_T);
  570. }
  571. else
  572. {
  573. //SwapIPMIMsgHdr ( pIPMIReqHdr, pIPMIResHdr);
  574. //QueueFd = m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ;
  575. memcpy (pIPMIResHdr, &m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr.IPMIMsgHdr, sizeof (IPMIMsgHdr_T));
  576. HdrOffset = sizeof(IPMIMsgHdr_T);
  577. }
  578. if (STATUS_OK == Status)
  579. {
  580. if ( ( m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFd_PrimaryIpmbIfcQ) ||
  581. (m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFd_SecondaryIpmbIfcQ) ||
  582. (ORIGIN_SENDMSG != m_PendingBridgedResTbl[PBTbl][SeqNum].OriginSrc) )
  583. {
  584. return;
  585. }
  586. ResPkt.Data [HdrOffset] = CC_NORMAL;
  587. }
  588. else if (STATUS_FAIL == Status)
  589. {
  590. ResPkt.Data [HdrOffset] = CC_NO_ACK_FROM_SLAVE;
  591. }
  592. else
  593. {
  594. ResPkt.Data [HdrOffset] = CC_UNSPECIFIED_ERR;
  595. }
  596. ResPkt.Size = HdrOffset + 1 + 1; // IPMI Header + Completion Code + Second Checksum
  597. ResPkt.Cmd = pIPMIResHdr->Cmd;
  598. ResPkt.NetFnLUN = pIPMIReqHdr->NetFnLUN;
  599. ResPkt.Channel = pReq->Channel;
  600. //ResPkt.Socket = pReq->Socket;
  601. /* Calculate the Second CheckSum */
  602. ResPkt.Data[ResPkt.Size - 1] = CalculateCheckSum2 (ResPkt.Data, ResPkt.Size-1);
  603. ResPkt.Param = BRIDGING_REQUEST;
  604. if (m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFd_LanIfcQ)
  605. {
  606. QueueFd = gFd_LanResQ;
  607. }
  608. else if(m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ == gFdUdsIfc)
  609. {
  610. ResPkt.Size++;
  611. ResPkt.Data[ResPkt.Size-1] = 0;
  612. ((IPMIUDSMsg_T*)&ResPkt.Data[0])->IPMIMsgLen = ResPkt.Size;
  613. ResPkt.Socket = m_PendingBridgedResTbl[PBTbl][SeqNum].UDSSocket;
  614. QueueFd = gFdUdsRes;
  615. }
  616. else
  617. {
  618. QueueFd = m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ;
  619. }
  620. if (STATUS_OK != Status)
  621. {
  622. m_PendingBridgedResTbl[PBTbl][SeqNum].Used = FALSE;
  623. m_PendingBridgedResTbl[PBTbl][SeqNum].ResDataOk = 0;
  624. }
  625. // /* Post the data to Destination Interface queue */
  626. // int i;
  627. // printf("===> RespondSendMessage post to %d: ", QueueFd);
  628. // for(i=0;i<ResPkt.Size;i++)
  629. // printf("%#x ", ResPkt.Data[i]);
  630. // printf("\n");
  631. PostMsg (QueueFd, &ResPkt);
  632. }
  633. }
  634. /**
  635. *@fn PendingBridgeResTimerTask
  636. *@brief Sends the timeout message to response queue
  637. * if the message does not turn out within send message timeout
  638. *@return none
  639. */
  640. static void
  641. PendingBridgeResTimerTask (void)
  642. {
  643. uint8_t i;
  644. uint8_t PBTbl = PRIMARY_PB_TBL;
  645. int QueueFd = 0;
  646. printf("-> PendingBridgeResTimerTask\n");
  647. /* Check for any pending responses */
  648. for( PBTbl=0; PBTbl < MAX_PENDING_BRIDGE_TBL; PBTbl++)
  649. {
  650. for (i = 0; i < sizeof (m_PendingBridgedResTbl[0])/sizeof (m_PendingBridgedResTbl[0][0]); i++)
  651. {
  652. if (TRUE == m_PendingBridgedResTbl[PBTbl][i].Used)
  653. {
  654. m_PendingBridgedResTbl[PBTbl][i].TimeOut--;
  655. if (0 == m_PendingBridgedResTbl[PBTbl][i].TimeOut)
  656. {
  657. MsgPkt_T Timeout;
  658. IPMIMsgHdr_T* pIPMIMsgHdr = (IPMIMsgHdr_T*) Timeout.Data;
  659. /* Fill the response packet */
  660. SwapIPMIMsgHdr (&m_PendingBridgedResTbl[PBTbl][i].ReqMsgHdr, pIPMIMsgHdr);
  661. // slog(LANQueueName,"%s%d",LAN_IFC_Q,BMCInst);
  662. // sprintf(PrimaryIPMBQueueName,"%s%d",IPMB_PRIMARY_IFC_Q,BMCInst);
  663. // sprintf(SecondaryIPMBQueueName,"%s%d",IPMB_SECONDARY_IFC_Q,BMCInst);
  664. // sprintf(SerialQueueName,"%s%d",SERIAL_IFC_Q,BMCInst);
  665. if(PBTbl == PRIMARY_PB_TBL)
  666. {
  667. pIPMIMsgHdr->ReqAddr = g_BMCInfo.PrimaryIPMBAddr;
  668. }
  669. else if(PBTbl == SECONDARY_PB_TBL)
  670. {
  671. pIPMIMsgHdr->ReqAddr = g_BMCInfo.SecondaryIPMBAddr;
  672. }
  673. else
  674. {
  675. printf("Invalid PBTbl\n");;//pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
  676. }
  677. Timeout.Data [sizeof(IPMIMsgHdr_T)] = CC_TIMEOUT;
  678. Timeout.Size = sizeof (IPMIMsgHdr_T) + 1 + 1; // IPMI Header + Completion Code + Second Checksum
  679. /* Calculate the Second CheckSum */
  680. Timeout.Data[Timeout.Size - 1] = CalculateCheckSum2 (Timeout.Data, Timeout.Size-1);
  681. Timeout.Param = BRIDGING_REQUEST;
  682. if (m_PendingBridgedResTbl[PBTbl][i].DestQ == gFd_LanIfcQ)
  683. {
  684. int j;
  685. for (j = Timeout.Size - 1; j >= 0; --j)
  686. {
  687. Timeout.Data [j+1] = Timeout.Data [j];
  688. }
  689. Timeout.Data[0] = m_PendingBridgedResTbl[PBTbl][i].SrcSessionHandle;
  690. Timeout.Size++;
  691. Timeout.Cmd = PAYLOAD_IPMI_MSG;
  692. QueueFd = gFd_LanIfcQ;
  693. }
  694. // else if (0 == strcmp ((char *)m_PendingBridgedResTbl[PBTbl][i].DestQ, SerialQueueName))
  695. // {
  696. // int j;
  697. // for (j = Timeout.Size - 1; j >= 0; --j)
  698. // {
  699. // Timeout.Data [j+1] = Timeout.Data [j];
  700. // }
  701. // Timeout.Data[0] = m_PendingBridgedResTbl[PBTbl][i].SrcSessionHandle;
  702. // Timeout.Size++;
  703. // Timeout.Cmd = PAYLOAD_IPMI_MSG;
  704. // strcpy(QueueName, SERIAL_IFC_Q);
  705. // }
  706. // else if (g_BMCInfo.IpmiConfig.PrimaryIPMBSupport == 1 && m_PendingBridgedResTbl[PBTbl][i].DestQ == gFd_PrimaryIpmbIfcQ)
  707. // {
  708. // int j;
  709. // for (j = Timeout.Size - 1; j >= 0; --j)
  710. // {
  711. // Timeout.Data [j + sizeof (IPMIMsgHdr_T) + 1] = Timeout.Data [j];
  712. // }
  713. // memcpy (Timeout.Data, &m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr, sizeof (IPMIMsgHdr_T));
  714. // Timeout.Data[sizeof (IPMIMsgHdr_T)] = CC_NORMAL;
  715. // Timeout.Size++;
  716. // QueueFd = gFd_PrimaryIpmbIfcQ;
  717. // }
  718. // else if (g_BMCInfo.IpmiConfig.SecondaryIPMBSupport == 1 && m_PendingBridgedResTbl[PBTbl][i].DestQ == gFd_SecondaryIpmbIfcQ)
  719. // {
  720. // int j;
  721. // for (j = Timeout.Size - 1; j >= 0; --j)
  722. // {
  723. // Timeout.Data [j + sizeof (IPMIMsgHdr_T) + 1] = Timeout.Data [j];
  724. // }
  725. // memcpy (Timeout.Data, &m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.IPMIMsgHdr, sizeof (IPMIMsgHdr_T));
  726. // Timeout.Data[sizeof (IPMIMsgHdr_T)] = CC_NORMAL;
  727. // Timeout.Size++;
  728. // QueueFd = gFd_SecondaryIpmbIfcQ;
  729. // }
  730. else if (m_PendingBridgedResTbl[PBTbl][i].DestQ = gFdUdsIfc)
  731. {
  732. printf("---> UDS pending bridge TimeOut\n");
  733. int j;
  734. UDSSessionTbl_T *pUDSSessionInfo = NULL;
  735. for (j = sizeof (IPMIMsgHdr_T); j < Timeout.Size ;j++)
  736. {
  737. Timeout.Data [j + sizeof (IPMIUDSMsg_T)-sizeof (IPMIMsgHdr_T)] = Timeout.Data [j];
  738. }
  739. Timeout.Size = Timeout.Size + sizeof (IPMIUDSMsg_T)- sizeof (IPMIMsgHdr_T);
  740. m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.UDSMsgHdr.IPMIMsgLen = Timeout.Size;
  741. memcpy (Timeout.Data, &m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.UDSMsgHdr, sizeof (IPMIUDSMsg_T));
  742. Timeout.NetFnLUN = m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.UDSMsgHdr.NetFnLUN;
  743. Timeout.SessionID = m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.UDSMsgHdr.SessionID;
  744. Timeout.Cmd = m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.UDSMsgHdr.Cmd;
  745. pUDSSessionInfo = GetUDSSessionInfo (UDS_SESSION_ID_INFO,&Timeout.SessionID);
  746. if(pUDSSessionInfo != NULL)
  747. {
  748. Timeout.Socket = pUDSSessionInfo->UDSSocket;
  749. }
  750. QueueFd = m_PendingBridgedResTbl[PBTbl][i].DestQ;
  751. }
  752. else
  753. {
  754. int j;
  755. for (j = Timeout.Size - 1; j >= 0; --j)
  756. {
  757. Timeout.Data [j + sizeof (IPMIMsgHdr_T) + 1] = Timeout.Data [j];
  758. }
  759. memcpy (Timeout.Data, &m_PendingBridgedResTbl[PBTbl][i].ResMsgHdr.IPMIMsgHdr, sizeof (IPMIMsgHdr_T));
  760. Timeout.Data[sizeof (IPMIMsgHdr_T)] = CC_TIMEOUT;
  761. QueueFd = m_PendingBridgedResTbl[PBTbl][i].DestQ;
  762. }
  763. /* Post the data to Destination Interface queue */
  764. PostMsg (QueueFd, &Timeout);
  765. m_PendingBridgedResTbl[PBTbl][i].Used = FALSE;
  766. printf( "MsgHndlr: clean pending index = %d.\n", i );
  767. }
  768. }
  769. }
  770. }
  771. }
  772. /**
  773. *@fn PendingSeqNoTimerTask
  774. *@brief Timertask which helpful in IPMB sequence number validation
  775. *@return none
  776. */
  777. static void
  778. PendingSeqNoTimerTask (void)
  779. {
  780. uint8_t i,j;
  781. printf("-> PendingSeqNoTimerTask\n");
  782. /* Check for any Sequence Number expiraied */
  783. for (i = 0; i < sizeof (m_PendingSeqNoTbl)/sizeof (m_PendingSeqNoTbl[0]); i++)
  784. {
  785. for (j = 0; j < sizeof (m_PendingSeqNoTbl[0])/sizeof (m_PendingSeqNoTbl[0][0]); j++)
  786. {
  787. if (TRUE == m_PendingSeqNoTbl[i][j].Used)
  788. {
  789. m_PendingSeqNoTbl[i][j].TimeOut--;
  790. if (0 == m_PendingSeqNoTbl[i][j].TimeOut)
  791. {
  792. m_PendingSeqNoTbl[i][j].Used = FALSE;
  793. }
  794. }
  795. }
  796. }
  797. }
  798. /**
  799. *@fn SwapIPMIMsgHdr
  800. *@brief Swaps the header and copies into response
  801. *@param pIPMIMsgReq Header of the Request
  802. *@param pIPMIMsgRes Header of the response
  803. *@return none
  804. */
  805. void
  806. SwapIPMIMsgHdr (IPMIMsgHdr_T* pIPMIMsgReq, IPMIMsgHdr_T* pIPMIMsgRes)
  807. {
  808. pIPMIMsgRes->ResAddr = pIPMIMsgReq->ReqAddr;
  809. pIPMIMsgRes->NetFnLUN = (pIPMIMsgReq->NetFnLUN & 0xFC) + 0x04;
  810. pIPMIMsgRes->NetFnLUN |= pIPMIMsgReq->RqSeqLUN & 0x03;
  811. /* Calculate the Checksum for above two bytes */
  812. pIPMIMsgRes->ChkSum = (~(pIPMIMsgRes->ResAddr + pIPMIMsgRes->NetFnLUN) + 1);
  813. pIPMIMsgRes->ReqAddr = pIPMIMsgReq->ResAddr;
  814. pIPMIMsgRes->RqSeqLUN = (pIPMIMsgReq->RqSeqLUN & 0xFC);
  815. pIPMIMsgRes->RqSeqLUN |= (pIPMIMsgReq->NetFnLUN & 0x03);
  816. pIPMIMsgRes->Cmd = pIPMIMsgReq->Cmd;
  817. return;
  818. }
  819. /*
  820. UDS data format, LSB first
  821. uint32_t + uint16_t + uint8_t + uint8_t + uint8_t + uint8_t* + uint8_t + uint8_t
  822. SessionID + IPMIMsgLen + NetFnLUN + Cmd + ChannelNum + Data[n] + checksum + 0(多余的,想办法去掉)
  823. */
  824. /**
  825. * *@fn Swap UDSIPMIMsg
  826. * *@brief Swaps the header and copies into response
  827. * *@param pIPMIMsgReq Header of the Request
  828. * *@param pIPMIMsgRes Header of the response
  829. * *@return none
  830. * */
  831. void
  832. SwapUDSIPMIMsg ( MsgPkt_T* pIPMIMsgReq, MsgPkt_T* pIPMIMsgRes)
  833. {
  834. IPMIUDSMsg_T *pIPMIUDSMsgRes = (IPMIUDSMsg_T *)&pIPMIMsgRes->Data[0];
  835. IPMIUDSMsg_T *pIPMIUDSMsgReq = (IPMIUDSMsg_T *)&pIPMIMsgReq->Data[0];
  836. pIPMIMsgRes->NetFnLUN = pIPMIMsgReq->NetFnLUN;
  837. pIPMIMsgRes->Cmd = pIPMIMsgReq->Cmd;
  838. pIPMIMsgRes->Channel = pIPMIMsgReq->Channel;
  839. pIPMIMsgRes->SessionID = pIPMIMsgReq->SessionID;
  840. pIPMIMsgRes->Socket = pIPMIMsgReq->Socket;
  841. pIPMIUDSMsgRes->NetFnLUN = pIPMIMsgReq->NetFnLUN;
  842. pIPMIUDSMsgRes->Cmd = pIPMIMsgReq->Cmd;
  843. pIPMIUDSMsgRes->ChannelNum = pIPMIMsgReq->Channel;
  844. pIPMIUDSMsgRes->SessionID = pIPMIMsgReq->SessionID;
  845. pIPMIUDSMsgRes->IPMIMsgLen = pIPMIMsgRes->Size;
  846. return;
  847. }