Firewall.c 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103
  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. * Firewall.c
  17. * Firewall Commands Handler
  18. *
  19. * Author: Basavaraj Astekar <basavaraja@ami.com>
  20. * : Bakka Ravinder Reddy <bakkar@ami.com>
  21. *
  22. *****************************************************************/
  23. #define ENABLE_DEBUG_MACROS 0
  24. #include "Types.h"
  25. #include "Firewall.h"
  26. #include "MsgHndlr.h"
  27. #include "Support.h"
  28. #include "IPMIDefs.h"
  29. #include "IPMI_Firewall.h"
  30. #include "PMConfig.h"
  31. //#include "NVRAccess.h"
  32. #include "Session.h"
  33. #include "FFConfig.h"
  34. #include "Util.h"
  35. #include "bmc_type.h"
  36. //#include "PDKCmdsAccess.h"
  37. /* Reserved bit macro definitions */
  38. #define RESERVED_BITS_GETNETFNSUP 0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
  39. #define RESERVED_BITS_GETCMDSUP_CH 0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
  40. #define RESERVED_BITS_GETCMDSUP_LUN 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  41. #define RESERVED_BITS_GETCMDSUP_NETFUN 0x80 //BIT7 \BIT6 (11 and 10 are reserved as per IPMI spec)
  42. #define RESERVED_BITS_GETSUBFNSUP_CH 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  43. #define RESERVED_BITS_GETSUBFNSUP_NETFN 0xC0 //(BIT7 | BIT6)
  44. #define RESERVED_BITS_GETSUBFNSUP_LUN 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  45. #define RESERVED_BITS_GETCFGCMDS_CH 0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
  46. #define RESERVED_BITS_GETCFGCMDS_LUN 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  47. #define RESERVED_BITS_GETCFGCMDS_NETFUN 0x80 //BIT7 \BIT6 (11 and 10 are reserved as per IPMI spec)
  48. #define RESERVED_BITS_GETCFGSUBFNS_CH 0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
  49. #define RESERVED_BITS_GETCFGSUBFNS_NETFN 0xC0 //(BIT7 | BIT6)
  50. #define RESERVED_BITS_GETCFGSUBFNS_LUN 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  51. #define RESERVED_BITS_SETCMDEN_CH 0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
  52. #define RESERVED_BITS_SETCMDEN_LUN 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  53. #define RESERVED_BITS_SETCMDEN_NETFUN 0x80 //BIT7 \BIT6 (11 and 10 are reserved as per IPMI spec)
  54. #define RESERVED_BITS_GETCMDEN_CH 0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
  55. #define RESERVED_BITS_GETCMDEN_LUN 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  56. #define RESERVED_BITS_GETCMDEN_NETFUN 0x80 //BIT7 \BIT6 (11 and 10 are reserved as per IPMI spec)
  57. #define RESERVED_BITS_SETSUBFNEN_CH 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  58. #define RESERVED_BITS_SETSUBFNEN_NETFN 0xC0 //(BIT7 | BIT6)
  59. #define RESERVED_BITS_SETSUBFNEN_LUN 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  60. #define RESERVED_BITS_GETSUBFNEN_CH 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  61. #define RESERVED_BITS_GETSUBFNEN_NETFN 0xC0 //(BIT7 | BIT6)
  62. #define RESERVED_BITS_GETSUBFNEN_LUN 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  63. #define RESERVED_BITS_GETOEMNETFNIANASUPPORT_CH 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  64. #define RESERVED_BITS_GETOEMNETFNIANASUPPORT_NETFN 0xC0 //(BIT7 | BIT6)
  65. #define RESERVED_BITS_GETOEMNETFNIANASUPPORT_LISTINDEX 0xC0 //(BIT7 | BIT6)
  66. #if IPM_DEVICE == 1
  67. extern BMCInfo_t g_BMCInfo;
  68. static int GetRequiredLength (INT8U NetFn, INT8U CmdReqSize);
  69. static int ValidateFFNetFnData (INT8U NetFn, NetFnParams_T* pNetFnParams ,BMCInfo_t *pBMCInfo);
  70. /*** Local Macro definitions ***/
  71. #define LUN_NO_CMD_SUPPORT 0x00
  72. #define LUN_NO_RESTRICTION_SUPPORT 0x01
  73. #define LUN_RESTRICTION_SUPPORT 0x02
  74. #define LUN_00 LUN_RESTRICTION_SUPPORT
  75. #define LUN_01 LUN_NO_CMD_SUPPORT << 2
  76. #define LUN_10 LUN_NO_CMD_SUPPORT << 4
  77. #define LUN_11 LUN_NO_CMD_SUPPORT << 6
  78. #define DMTF_DEFINING_BODY 0x01
  79. //Group Extension codes
  80. #define GROUPEXTNCODE_PICMG 0x00
  81. #define GROUPEXTNCODE_DMTF 0x01
  82. #define GROUPEXTNCODE_SSI 0x02
  83. #define GROUPEXTNCODE_VSO 0x03
  84. #define GROUPEXTNCODE_DCMI 0xDC
  85. #define Max_GROUPEXTNCODE 5
  86. /* Add IANA No's to the Array */
  87. IANA_T m_IANAList[] = { /* LS byte first */
  88. {{0xFF,0xFF,0xFF}}, /* Reserved Oem IANA */
  89. #ifdef IANA_OEM_LIST
  90. IANA_OEM_LIST
  91. #endif
  92. };
  93. INT8U GroupExtnCode[Max_GROUPEXTNCODE]={
  94. GROUPEXTNCODE_PICMG,
  95. GROUPEXTNCODE_DMTF,
  96. GROUPEXTNCODE_SSI,
  97. GROUPEXTNCODE_VSO,
  98. GROUPEXTNCODE_DCMI,
  99. };
  100. #if GET_NETFN_SUP != UNIMPLEMENTED
  101. /*---------------------------------------
  102. * GetNetFnSup
  103. *---------------------------------------*/
  104. int
  105. GetNetFnSup (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  106. {
  107. _NEAR_ GetNetFnSupRes_T* pGetNetFnSupRes = (_NEAR_ GetNetFnSupRes_T*) pRes;
  108. _FAR_ CmdHndlrMap_T* pCmdHndlrMap;
  109. _FAR_ ChannelInfo_T* pChInfo;
  110. INT8U Channel, i,j,*curchannel;
  111. BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  112. /* if(pBMCInfo->IpmiConfig.IPMIFirewallSupport == ENABLED)
  113. {
  114. if(pReq[0] & RESERVED_BITS_GETNETFNSUP)
  115. {
  116. *pRes = CC_INV_DATA_FIELD;
  117. return sizeof(*pRes);
  118. }
  119. // Check for channel number
  120. Channel = pReq[0] & 0x0F;
  121. if (Channel == 0x0E)
  122. {
  123. OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  124. Channel = *curchannel & 0xF;
  125. }
  126. pChInfo = getChannelInfo (Channel, BMCInst);
  127. if (NULL == pChInfo)
  128. {
  129. *pRes = CC_INV_DATA_FIELD;
  130. return sizeof (*pRes);
  131. }
  132. pGetNetFnSupRes->CompletionCode = CC_NORMAL;
  133. pGetNetFnSupRes->LUNSupport = LUN_00 | LUN_01 | LUN_10 | LUN_11;
  134. _fmemset (pGetNetFnSupRes->NetFnPair, 0, 16);
  135. for (i = 0; i < 32; i++)
  136. {
  137. if (0 != GetMsgHndlrMap (i*2, &pCmdHndlrMap,BMCInst))
  138. {
  139. for (j=0;j<Max_GROUPEXTNCODE;j++)
  140. {
  141. if(0 != GroupExtnGetMsgHndlrMap ( i*2,GroupExtnCode[j],&pCmdHndlrMap,BMCInst))
  142. {
  143. continue;
  144. }
  145. else
  146. {
  147. pGetNetFnSupRes->NetFnPair [i / 8] |= 1 << (i % 8);
  148. }
  149. }
  150. if(0!=((int(*)(INT8U,CmdHndlrMap_T**,int))g_PDKCmdsHandle[PDKCMDS_GETOEMMSGHNDLRMAP])(i*2,&pCmdHndlrMap,BMCInst))
  151. {
  152. continue;
  153. }
  154. }
  155. pGetNetFnSupRes->NetFnPair [i / 8] |= 1 << (i % 8);
  156. }
  157. return sizeof (GetNetFnSupRes_T);
  158. }
  159. else*/
  160. {
  161. *pRes = CC_INV_CMD;
  162. return sizeof(*pRes);
  163. }
  164. }
  165. #endif /* GET_NETFN_SUP != UNIMPLEMENTED */
  166. #if GET_CMD_SUP != UNIMPLEMENTED
  167. /*---------------------------------------
  168. * GetCmdSup
  169. *---------------------------------------*/
  170. int
  171. GetCmdSup (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  172. {
  173. _NEAR_ GetCmdSupReq_T* pGetCmdSupReq = (_NEAR_ GetCmdSupReq_T*) pReq;
  174. _NEAR_ GetCmdSupRes_T* pGetCmdSupRes = (_NEAR_ GetCmdSupRes_T*) pRes;
  175. _FAR_ ChannelInfo_T* pChInfo;
  176. INT8U Channel, Start ,RetVal,*curchannel;
  177. INT16U FFConfig;
  178. int i;
  179. BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  180. /*if(pBMCInfo->IpmiConfig.IPMIFirewallSupport == ENABLED)
  181. {
  182. if (GetRequiredLength((pGetCmdSupReq->OpNetFn & 0x3E), sizeof(GetCmdSupReq_T)) != ReqLen)
  183. {
  184. *pRes = CC_REQ_INV_LEN;
  185. return sizeof (*pRes);
  186. }
  187. if(pGetCmdSupReq->ChannelNum & RESERVED_BITS_GETCMDSUP_CH)
  188. {
  189. *pRes = CC_INV_DATA_FIELD;
  190. return sizeof(*pRes);
  191. }
  192. if(pGetCmdSupReq->LUN & RESERVED_BITS_GETCMDSUP_LUN)
  193. {
  194. *pRes = CC_INV_DATA_FIELD;
  195. return sizeof(*pRes);
  196. }
  197. if(pGetCmdSupReq->OpNetFn & RESERVED_BITS_GETCMDSUP_NETFUN)
  198. {
  199. *pRes = CC_INV_DATA_FIELD;
  200. return sizeof(*pRes);
  201. }
  202. if (ValidateFFNetFnData (pGetCmdSupReq->OpNetFn & 0x3E, &pGetCmdSupReq->NetFnParams,pBMCInfo))
  203. {
  204. *pRes = CC_INV_DATA_FIELD;
  205. return sizeof (*pRes);
  206. }
  207. // Check for channel number
  208. Channel = pGetCmdSupReq->ChannelNum & 0x0F;
  209. if (Channel == 0x0E)
  210. {
  211. OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  212. Channel = *curchannel & 0xF;
  213. }
  214. pChInfo = getChannelInfo (Channel, BMCInst);
  215. pGetCmdSupRes->CompletionCode = CC_INV_DATA_FIELD;
  216. if ((NULL == pChInfo) || (0 != (pGetCmdSupReq->LUN & 0x03)))
  217. {
  218. return sizeof (*pRes);
  219. }
  220. switch (pGetCmdSupReq->OpNetFn >> 6)
  221. {
  222. case 0: Start = 0; break;
  223. case 1: Start = 0x80; break;
  224. default:
  225. return sizeof (*pRes);
  226. }
  227. _fmemset (pGetCmdSupRes->SupMask, 0xFF, 16);
  228. for (i = Start; i <= (Start + 0x7F); i++)
  229. {
  230. FFConfig = 0;
  231. RetVal = GetCmdSupCfgMask (pGetCmdSupReq->OpNetFn & 0x3E, i, &FFConfig,pGetCmdSupReq->NetFnParams.DefBodyCode,BMCInst);
  232. if (FF_NETFN_ERR == RetVal)
  233. {
  234. *pRes = CC_INV_DATA_FIELD;
  235. return sizeof(*pRes);
  236. }
  237. else if(FF_CMD_ERR == RetVal)
  238. {
  239. continue;
  240. }
  241. if ((FFConfig >> (pChInfo->ChannelIndex * 2 + 1)) & 0x01)
  242. {
  243. pGetCmdSupRes->SupMask[(i-Start)/8] &= ~( 1 << (i % 8));
  244. }
  245. }
  246. pGetCmdSupRes->CompletionCode = CC_NORMAL;
  247. return sizeof (GetCmdSupRes_T);
  248. }
  249. else*/
  250. {
  251. *pRes = CC_INV_CMD;
  252. return sizeof(*pRes);
  253. }
  254. }
  255. #endif /* GET_CMD_SUP != UNIMPLEMENTED */
  256. #if GET_SUBFN_SUP != UNIMPLEMENTED
  257. /*---------------------------------------
  258. * GetSubFnSup
  259. *---------------------------------------*/
  260. int
  261. GetSubFnSup (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  262. {
  263. _NEAR_ GetSubFnSupReq_T* pGetSubFnSupReq = (_NEAR_ GetSubFnSupReq_T*) pReq;
  264. _NEAR_ GetSubFnSupRes_T* pGetSubFnSupRes = (_NEAR_ GetSubFnSupRes_T*) pRes;
  265. _FAR_ ChannelInfo_T* pChInfo;
  266. INT8U Channel,*curchannel;
  267. INT32U SubFnMask;
  268. BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  269. /*if(pBMCInfo->IpmiConfig.IPMIFirewallSupport == ENABLED)
  270. {
  271. if (GetRequiredLength((pGetSubFnSupReq->NetFn & 0x3E), sizeof(GetSubFnSupReq_T)) != ReqLen)
  272. {
  273. *pRes = CC_REQ_INV_LEN;
  274. return sizeof (*pRes);
  275. }
  276. if(pGetSubFnSupReq->ChannelNum & RESERVED_BITS_GETSUBFNSUP_CH)
  277. {
  278. *pRes = CC_INV_DATA_FIELD;
  279. return sizeof(*pRes);
  280. }
  281. if(pGetSubFnSupReq->NetFn & RESERVED_BITS_GETSUBFNSUP_NETFN)
  282. {
  283. *pRes = CC_INV_DATA_FIELD;
  284. return sizeof(*pRes);
  285. }
  286. if(pGetSubFnSupReq->LUN & RESERVED_BITS_GETSUBFNSUP_LUN)
  287. {
  288. *pRes = CC_INV_DATA_FIELD;
  289. return sizeof(*pRes);
  290. }
  291. if (ValidateFFNetFnData (pGetSubFnSupReq->NetFn & 0x3E, &pGetSubFnSupReq->NetFnParams,pBMCInfo))
  292. {
  293. *pRes = CC_INV_DATA_FIELD;
  294. return sizeof (*pRes);
  295. }
  296. // Check for channel number *
  297. Channel = pGetSubFnSupReq->ChannelNum & 0x0F;
  298. if (Channel == 0x0E)
  299. {
  300. OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel)
  301. Channel = *curchannel & 0xF;
  302. }
  303. pChInfo = getChannelInfo (Channel, BMCInst);
  304. pGetSubFnSupRes->CompletionCode = CC_INV_DATA_FIELD;
  305. if ((NULL == pChInfo) || (0 != (pGetSubFnSupReq->LUN & 0x03)))
  306. {
  307. return sizeof (*pRes);
  308. }
  309. pGetSubFnSupRes->CompletionCode = CC_NORMAL;
  310. pGetSubFnSupRes->SpecType = 0x00;
  311. pGetSubFnSupRes->SpecVer = 0x20;
  312. pGetSubFnSupRes->SpecRev = 0x10;
  313. pGetSubFnSupRes->SupMask = 0xFFFFFFFF;
  314. if (FF_SUCCESS == GetSubFnMask (Channel, pGetSubFnSupReq->NetFn, pGetSubFnSupReq->Cmd, &SubFnMask,BMCInst))
  315. {
  316. pGetSubFnSupRes->SupMask = ~(htoipmi_u32(SubFnMask));
  317. }
  318. return sizeof (GetSubFnSupRes_T);
  319. }
  320. else*/
  321. {
  322. *pRes = CC_INV_CMD;
  323. return sizeof(*pRes);
  324. }
  325. }
  326. #endif /* GET_SUBFN_SUP != UNIMPLEMENTED */
  327. #if GET_CONFIG_CMDS != UNIMPLEMENTED
  328. /*---------------------------------------
  329. * GetConfigCmds
  330. *---------------------------------------*/
  331. int
  332. GetConfigCmds (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  333. {
  334. _NEAR_ GetConfigCmdsReq_T* pGetConfigCmdsReq = (_NEAR_ GetConfigCmdsReq_T*) pReq;
  335. _NEAR_ GetConfigCmdsRes_T* pGetConfigCmdsRes = (_NEAR_ GetConfigCmdsRes_T*) pRes;
  336. _FAR_ ChannelInfo_T* pChInfo;
  337. INT8U Channel, Start , RetVal,*curchannel;
  338. INT16U FFConfig;
  339. int i;
  340. BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  341. /*if(pBMCInfo->IpmiConfig.IPMIFirewallSupport == ENABLED)
  342. {
  343. if (GetRequiredLength((pGetConfigCmdsReq->OpNetFn & 0x3E), sizeof(GetConfigCmdsReq_T)) != ReqLen)
  344. {
  345. *pRes = CC_REQ_INV_LEN;
  346. return sizeof (*pRes);
  347. }
  348. if(pGetConfigCmdsReq->ChannelNum & RESERVED_BITS_GETCFGCMDS_CH)
  349. {
  350. *pRes = CC_INV_DATA_FIELD;
  351. return sizeof(*pRes);
  352. }
  353. if(pGetConfigCmdsReq->LUN & RESERVED_BITS_GETCFGCMDS_LUN)
  354. {
  355. *pRes = CC_INV_DATA_FIELD;
  356. return sizeof(*pRes);
  357. }
  358. if (pGetConfigCmdsReq->OpNetFn & RESERVED_BITS_GETCFGCMDS_NETFUN)
  359. {
  360. *pRes = CC_INV_DATA_FIELD;
  361. return sizeof(*pRes);
  362. }
  363. if (ValidateFFNetFnData (pGetConfigCmdsReq->OpNetFn & 0x3E, &pGetConfigCmdsReq->NetFnParams,pBMCInfo))
  364. {
  365. *pRes = CC_INV_DATA_FIELD;
  366. return sizeof (*pRes);
  367. }
  368. // Check for channel number
  369. Channel = pGetConfigCmdsReq->ChannelNum & 0x0F;
  370. if (Channel == 0x0E)
  371. {
  372. OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  373. Channel = *curchannel & 0xF;
  374. }
  375. pChInfo = getChannelInfo (Channel, BMCInst);
  376. pGetConfigCmdsRes->CompletionCode = CC_INV_DATA_FIELD;
  377. if ((NULL == pChInfo) || (0 != (pGetConfigCmdsReq->LUN & 0x03)))
  378. {
  379. return sizeof (*pRes);
  380. }
  381. switch (pGetConfigCmdsReq->OpNetFn >> 6)
  382. {
  383. case 0: Start = 0; break;
  384. case 1: Start = 0x80; break;
  385. default:
  386. return sizeof (*pRes);
  387. }
  388. _fmemset (pGetConfigCmdsRes->SupMask, 0, 16);
  389. for (i = Start; i <= (Start + 0x7F); i++)
  390. {
  391. FFConfig = 0;
  392. RetVal = GetCmdSupCfgMask (pGetConfigCmdsReq->OpNetFn & 0x3E, i, &FFConfig,pGetConfigCmdsReq->NetFnParams.DefBodyCode,BMCInst);
  393. if (FF_NETFN_ERR == RetVal)
  394. {
  395. *pRes = CC_INV_DATA_FIELD;
  396. return sizeof(*pRes);
  397. }
  398. else if(FF_CMD_ERR == RetVal)
  399. {
  400. continue;
  401. }
  402. if ((FFConfig >> (pChInfo->ChannelIndex * 2)) & 0x01)
  403. {
  404. pGetConfigCmdsRes->SupMask[(i-Start)/8] |= (1 << (i % 8));
  405. }
  406. }
  407. pGetConfigCmdsRes->CompletionCode = CC_NORMAL;
  408. return sizeof (GetConfigCmdsRes_T);
  409. }
  410. else*/
  411. {
  412. *pRes = CC_INV_CMD;
  413. return sizeof(*pRes);
  414. }
  415. }
  416. #endif /* GET_CONFIG_CMDS != UNIMPLEMENTED */
  417. #if GET_CONFIG_SUB_FNS != UNIMPLEMENTED
  418. /*---------------------------------------
  419. * GetConfigSubFns
  420. *---------------------------------------*/
  421. int
  422. GetConfigSubFns (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  423. {
  424. _NEAR_ GetConfigSubFnsReq_T* pGetConfigSubFnsReq = (_NEAR_ GetConfigSubFnsReq_T*) pReq;
  425. _NEAR_ GetConfigSubFnsRes_T* pGetConfigSubFnsRes = (_NEAR_ GetConfigSubFnsRes_T*) pRes;
  426. _FAR_ ChannelInfo_T* pChInfo;
  427. INT8U Channel,*curchannel;
  428. BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  429. /*if(pBMCInfo->IpmiConfig.IPMIFirewallSupport == ENABLED)
  430. {
  431. if (GetRequiredLength((pGetConfigSubFnsReq->NetFn & 0x3E), sizeof(GetConfigSubFnsReq_T)) != ReqLen)
  432. {
  433. *pRes = CC_REQ_INV_LEN;
  434. return sizeof (*pRes);
  435. }
  436. if(pGetConfigSubFnsReq->ChannelNum & RESERVED_BITS_GETCFGSUBFNS_CH)
  437. {
  438. *pRes = CC_INV_DATA_FIELD;
  439. return sizeof(*pRes);
  440. }
  441. if(pGetConfigSubFnsReq->NetFn & RESERVED_BITS_GETCFGSUBFNS_NETFN)
  442. {
  443. *pRes = CC_INV_DATA_FIELD;
  444. return sizeof(*pRes);
  445. }
  446. if(pGetConfigSubFnsReq->LUN & RESERVED_BITS_GETCFGSUBFNS_LUN)
  447. {
  448. *pRes = CC_INV_DATA_FIELD;
  449. return sizeof(*pRes);
  450. }
  451. if (ValidateFFNetFnData (pGetConfigSubFnsReq->NetFn & 0x3E, &pGetConfigSubFnsReq->NetFnParams ,pBMCInfo))
  452. {
  453. *pRes = CC_INV_DATA_FIELD;
  454. return sizeof (*pRes);
  455. }
  456. // Check for channel number
  457. Channel = pGetConfigSubFnsReq->ChannelNum & 0x0F;
  458. if (Channel == 0x0E)
  459. {
  460. OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  461. Channel = *curchannel & 0xF;
  462. }
  463. pChInfo = getChannelInfo (Channel, BMCInst);
  464. pGetConfigSubFnsRes->CompletionCode = CC_INV_DATA_FIELD;
  465. if ((NULL == pChInfo) || (0 != (pGetConfigSubFnsReq->LUN & 0x03)))
  466. {
  467. return sizeof (*pRes);
  468. }
  469. pGetConfigSubFnsRes->CompletionCode = CC_NORMAL;
  470. pGetConfigSubFnsRes->SupMask = 0;
  471. return sizeof (GetConfigSubFnsRes_T);
  472. }
  473. else*/
  474. {
  475. *pRes = CC_INV_CMD;
  476. return sizeof(*pRes);
  477. }
  478. }
  479. #endif /* GET_CONFIG_SUB_FNS != UNIMPLEMENTED */
  480. #if SET_CMD_ENABLES != UNIMPLEMENTED
  481. /*---------------------------------------
  482. * SetCmdEnables
  483. *---------------------------------------*/
  484. int
  485. SetCmdEnables (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  486. {
  487. _NEAR_ SetCmdEnablesReq_T* pSetCmdEnablesReq = (_NEAR_ SetCmdEnablesReq_T*) pReq;
  488. BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  489. _FAR_ ChannelInfo_T* pChInfo;
  490. INT8U Channel, Start, RetVal;
  491. int i;
  492. INT8U SuccessFlag = 0x01,*curchannel;
  493. INT16U FFConfig;
  494. _FAR_ INT8U* pCmdCfg;
  495. INT8U EnDisMask;
  496. /*if(pBMCInfo->IpmiConfig.IPMIFirewallSupport == ENABLED)
  497. {
  498. if (GetRequiredLength((pSetCmdEnablesReq->OpNetFn & 0x3E), sizeof(SetCmdEnablesReq_T)) != ReqLen)
  499. {
  500. *pRes = CC_REQ_INV_LEN;
  501. return sizeof (*pRes);
  502. }
  503. *pRes = CC_INV_DATA_FIELD;
  504. if(pSetCmdEnablesReq->ChannelNum & RESERVED_BITS_SETCMDEN_CH)
  505. {
  506. return sizeof(*pRes);
  507. }
  508. if(pSetCmdEnablesReq->LUN & RESERVED_BITS_SETCMDEN_LUN)
  509. {
  510. return sizeof(*pRes);
  511. }
  512. if(pSetCmdEnablesReq->OpNetFn & RESERVED_BITS_SETCMDEN_NETFUN) //As per IPMI SPEC we should block the 7 and 6 bit by this combination 11 ans 10//
  513. {
  514. return sizeof(*pRes);
  515. }
  516. if (ValidateFFNetFnData (pSetCmdEnablesReq->OpNetFn & 0x3E, &pSetCmdEnablesReq->NetFnParams , pBMCInfo))
  517. {
  518. *pRes = CC_INV_DATA_FIELD;
  519. return sizeof (*pRes);
  520. }
  521. // Check for channel number
  522. Channel = pSetCmdEnablesReq->ChannelNum & 0x0F;
  523. if (Channel == 0x0E)
  524. {
  525. OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  526. Channel = *curchannel & 0xF;
  527. }
  528. pChInfo = getChannelInfo (Channel, BMCInst);
  529. if ((NULL == pChInfo) || (0 != (pSetCmdEnablesReq->LUN & 0x03)))
  530. {
  531. return sizeof (*pRes);
  532. }
  533. switch (pSetCmdEnablesReq->OpNetFn >> 6)
  534. {
  535. case 0: Start = 0; break;
  536. case 1: Start = 0x80; break;
  537. default:
  538. return sizeof (*pRes);
  539. }
  540. for (i = Start; i <= (Start + 0x7F); i++)
  541. {
  542. RetVal = GetCmdSupCfgMask (pSetCmdEnablesReq->OpNetFn & 0x3E, i, &FFConfig,pSetCmdEnablesReq->NetFnParams.DefBodyCode,BMCInst);
  543. if (FF_NETFN_ERR == RetVal)
  544. {
  545. *pRes = CC_INV_DATA_FIELD;
  546. return sizeof(*pRes);
  547. }
  548. else if(FF_CMD_ERR == RetVal)
  549. {
  550. FFConfig = 0x0000;
  551. }
  552. FFConfig >>= pChInfo->ChannelIndex * 2;
  553. EnDisMask = (pSetCmdEnablesReq->EnDisMask [(i-Start)/8] >> (i % 8)) & 0x01;
  554. if (0 == (FFConfig & 0x02))
  555. {
  556. if (1 == EnDisMask || 0 == EnDisMask )
  557. {
  558. SuccessFlag = 0;
  559. break;
  560. }
  561. else
  562. {
  563. continue;
  564. }
  565. }
  566. // If supported but not configurable
  567. if (0 == (FFConfig & 0x01))
  568. {
  569. if (1 == EnDisMask || 0 == EnDisMask )
  570. {
  571. SuccessFlag = 0;
  572. break;
  573. }
  574. else
  575. {
  576. continue;
  577. }
  578. }
  579. pCmdCfg = GetCmdCfgAddr (pSetCmdEnablesReq->OpNetFn & 0x3E, i, BMCInst);
  580. if (NULL == pCmdCfg)
  581. {
  582. SuccessFlag = 0;
  583. break;
  584. }
  585. *pCmdCfg &= ~(1 << pChInfo->ChannelIndex);
  586. *pCmdCfg |= EnDisMask << pChInfo->ChannelIndex;
  587. FlushIPMI((INT8U*)&pBMCInfo->FFCmdConfigTbl[0],pCmdCfg,pBMCInfo->IPMIConfLoc.FFCmdConfigTblAddr,
  588. sizeof(INT8U),BMCInst);
  589. SuccessFlag = 1;
  590. }
  591. if (0 == SuccessFlag)
  592. {
  593. *pRes = CC_CMD_UNSUPPORTED_UNCONFIGURABLE;
  594. }
  595. else
  596. {
  597. *pRes = CC_NORMAL;
  598. }
  599. return sizeof (*pRes);
  600. }
  601. else*/
  602. {
  603. *pRes = CC_INV_CMD;
  604. return sizeof(*pRes);
  605. }
  606. }
  607. #endif /* SET_CMD_ENABLES != UNIMPLEMENTED */
  608. #if GET_CMD_ENABLES != UNIMPLEMENTED
  609. /*---------------------------------------
  610. * GetCmdEnables
  611. *---------------------------------------*/
  612. int
  613. GetCmdEnables (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  614. {
  615. _NEAR_ GetCmdEnablesReq_T* pGetCmdEnablesReq = (_NEAR_ GetCmdEnablesReq_T*) pReq;
  616. _NEAR_ GetCmdEnablesRes_T* pGetCmdEnablesRes = (_NEAR_ GetCmdEnablesRes_T*) pRes;
  617. _FAR_ ChannelInfo_T* pChInfo;
  618. INT8U Channel, Start,RetVal;
  619. INT16U FFConfig;
  620. _FAR_ INT8U* pCmdCfg;
  621. INT8U ResetFlag = 0,*curchannel;
  622. int i;
  623. BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  624. /*if(pBMCInfo->IpmiConfig.IPMIFirewallSupport == ENABLED)
  625. {
  626. if (GetRequiredLength((pGetCmdEnablesReq->OpNetFn & 0x3E), sizeof(GetCmdEnablesReq_T)) != ReqLen)
  627. {
  628. *pRes = CC_REQ_INV_LEN;
  629. return sizeof (*pRes);
  630. }
  631. if(pGetCmdEnablesReq->ChannelNum & RESERVED_BITS_GETCMDEN_CH)
  632. {
  633. *pRes = CC_INV_DATA_FIELD;
  634. return sizeof(*pRes);
  635. }
  636. if(pGetCmdEnablesReq->LUN & RESERVED_BITS_GETCMDEN_LUN)
  637. {
  638. *pRes = CC_INV_DATA_FIELD;
  639. return sizeof(*pRes);
  640. }
  641. if(pGetCmdEnablesReq->OpNetFn & RESERVED_BITS_GETCMDEN_NETFUN)
  642. {
  643. *pRes = CC_INV_DATA_FIELD;
  644. return sizeof(*pRes);
  645. }
  646. if (ValidateFFNetFnData (pGetCmdEnablesReq->OpNetFn & 0x3E, &pGetCmdEnablesReq->NetFnParams ,pBMCInfo))
  647. {
  648. *pRes = CC_INV_DATA_FIELD;
  649. return sizeof (*pRes);
  650. }
  651. // Check for channel number
  652. Channel = pGetCmdEnablesReq->ChannelNum & 0x0F;
  653. if (Channel == 0x0E)
  654. {
  655. OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  656. Channel = *curchannel & 0xF;
  657. }
  658. pChInfo = getChannelInfo (Channel, BMCInst);
  659. pGetCmdEnablesRes->CompletionCode = CC_INV_DATA_FIELD;
  660. if ((NULL == pChInfo) || (0 != (pGetCmdEnablesReq->LUN & 0x03)))
  661. {
  662. return sizeof (*pRes);
  663. }
  664. switch (pGetCmdEnablesReq->OpNetFn >> 6)
  665. {
  666. case 0: Start = 0; break;
  667. case 1: Start = 0x80; break;
  668. default:
  669. return sizeof (*pRes);
  670. }
  671. _fmemset (pGetCmdEnablesRes->EnDisMask, 0xFF, 16);
  672. // set the bit if command is enabled else reset
  673. for (i = Start; i <= (Start + 0x7F); i++)
  674. {
  675. FFConfig = 0;
  676. RetVal = GetCmdSupCfgMask (pGetCmdEnablesReq->OpNetFn & 0x3E, i, &FFConfig,pGetCmdEnablesReq->NetFnParams.DefBodyCode,BMCInst);
  677. if(FF_NETFN_ERR == RetVal)
  678. {
  679. *pRes = CC_INV_DATA_FIELD;
  680. return sizeof(*pRes);
  681. }
  682. else if (FF_CMD_ERR == RetVal)
  683. {
  684. ResetFlag = 1;
  685. }
  686. else
  687. {
  688. FFConfig >>= pChInfo->ChannelIndex * 2;
  689. // if not supported
  690. if (0 == (FFConfig & 0x02))
  691. {
  692. ResetFlag = 1;
  693. }
  694. else if (0x03 == (FFConfig & 0x03))
  695. { // if supported and configurable check if disabled
  696. pCmdCfg = GetCmdCfgAddr (pGetCmdEnablesReq->OpNetFn & 0x3E, i, BMCInst);
  697. if ((NULL == pCmdCfg) || (0 == ((*pCmdCfg >> pChInfo->ChannelIndex) & 0x01)))
  698. {
  699. ResetFlag = 1;
  700. }
  701. }
  702. }
  703. if (ResetFlag == 1)
  704. {
  705. pGetCmdEnablesRes->EnDisMask[(i-Start)/8] &= ~(1 << (i % 8));
  706. ResetFlag = 0;
  707. }
  708. }
  709. pGetCmdEnablesRes->CompletionCode = CC_NORMAL;
  710. return (sizeof (GetCmdEnablesRes_T) - sizeof (NetFnParams_T));
  711. }
  712. else*/
  713. {
  714. *pRes = CC_INV_CMD;
  715. return sizeof(*pRes);
  716. }
  717. }
  718. #endif /* GET_CMD_ENABLES != UNIMPLEMENTED */
  719. #if SET_SUBFN_ENABLES != UNIMPLEMENTED
  720. /*---------------------------------------
  721. * SetSubFnEnables
  722. *---------------------------------------*/
  723. int
  724. SetSubFnEnables (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  725. {
  726. _NEAR_ SetSubFnEnablesReq_T* pSetSubFnEnablesReq = (_NEAR_ SetSubFnEnablesReq_T*) pReq;
  727. _FAR_ ChannelInfo_T* pChInfo;
  728. INT8U Channel,*curchannel;
  729. BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  730. /*if(pBMCInfo->IpmiConfig.IPMIFirewallSupport == ENABLED)
  731. {
  732. if(pSetSubFnEnablesReq->ChannelNum & RESERVED_BITS_SETSUBFNEN_CH)
  733. {
  734. *pRes = CC_INV_DATA_FIELD;
  735. return sizeof(*pRes);
  736. }
  737. if(pSetSubFnEnablesReq->NetFn & RESERVED_BITS_SETSUBFNEN_NETFN)
  738. {
  739. *pRes = CC_INV_DATA_FIELD;
  740. return sizeof(*pRes);
  741. }
  742. if(pSetSubFnEnablesReq->LUN & RESERVED_BITS_SETSUBFNEN_LUN)
  743. {
  744. *pRes = CC_INV_DATA_FIELD;
  745. return sizeof(*pRes);
  746. }
  747. // Check for channel number
  748. Channel = pSetSubFnEnablesReq->ChannelNum & 0x0F;
  749. if (Channel == 0x0E)
  750. {
  751. OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  752. Channel = *curchannel & 0xF;
  753. }
  754. pChInfo = getChannelInfo (Channel, BMCInst);
  755. *pRes = CC_INV_DATA_FIELD;
  756. if ((NULL == pChInfo) || (0 != (pSetSubFnEnablesReq->LUN & 0x03)))
  757. {
  758. return sizeof (*pRes);
  759. }
  760. *pRes = CC_PARAM_NOT_SUPPORTED;
  761. return sizeof (*pRes);
  762. }
  763. else*/
  764. {
  765. *pRes = CC_INV_CMD;
  766. return sizeof(*pRes);
  767. }
  768. }
  769. #endif /* SET_SUBFN_ENABLES != UNIMPLEMENTED */
  770. #if GET_SUBFN_ENABLES != UNIMPLEMENTED
  771. /*---------------------------------------
  772. * GetSubFnEnables
  773. *---------------------------------------*/
  774. int
  775. GetSubFnEnables (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  776. {
  777. _NEAR_ GetSubFnEnablesReq_T* pGetSubFnEnablesReq = (_NEAR_ GetSubFnEnablesReq_T*) pReq;
  778. _NEAR_ GetSubFnEnablesRes_T* pGetSubFnEnablesRes = (_NEAR_ GetSubFnEnablesRes_T*) pRes;
  779. _FAR_ ChannelInfo_T* pChInfo;
  780. INT8U Channel,*curchannel;
  781. BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  782. /*if(pBMCInfo->IpmiConfig.IPMIFirewallSupport == ENABLED)
  783. {
  784. if(pGetSubFnEnablesReq->ChannelNum & RESERVED_BITS_GETSUBFNEN_CH)
  785. {
  786. *pRes = CC_INV_DATA_FIELD;
  787. return sizeof(*pRes);
  788. }
  789. if(pGetSubFnEnablesReq->NetFn & RESERVED_BITS_GETSUBFNEN_NETFN)
  790. {
  791. *pRes = CC_INV_DATA_FIELD;
  792. return sizeof(*pRes);
  793. }
  794. if(pGetSubFnEnablesReq->LUN & RESERVED_BITS_GETSUBFNEN_LUN)
  795. {
  796. *pRes = CC_INV_DATA_FIELD;
  797. return sizeof(*pRes);
  798. }
  799. // Check for channel number
  800. Channel = pGetSubFnEnablesReq->ChannelNum & 0x0F;
  801. if (Channel == 0x0E)
  802. {
  803. OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  804. Channel = *curchannel & 0xF;
  805. }
  806. pChInfo = getChannelInfo (Channel, BMCInst);
  807. *pRes = CC_INV_DATA_FIELD;
  808. if ((NULL == pChInfo) || (0 != (pGetSubFnEnablesReq->LUN & 0x03)))
  809. {
  810. return sizeof (*pRes);
  811. }
  812. pGetSubFnEnablesRes->Enables = 0;
  813. pGetSubFnEnablesRes->CompletionCode = CC_NORMAL;
  814. return sizeof (GetSubFnEnablesRes_T);
  815. }
  816. else*/
  817. {
  818. *pRes = CC_INV_CMD;
  819. return sizeof(*pRes);
  820. }
  821. }
  822. #endif /* GET_SUBFN_ENABLES != UNIMPLEMENTED */
  823. #if GET_OEM_NETFN_IANA_SUPPORT != UNIMPLEMENTED
  824. /*---------------------------------------
  825. * GetOEMNetFnIANASupport
  826. *---------------------------------------*/
  827. int
  828. GetOEMNetFnIANASupport (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  829. {
  830. _NEAR_ GetOEMNetFnIANASupportReq_T* pGetOEMNetFnIANASupportReq = (_NEAR_ GetOEMNetFnIANASupportReq_T*) pReq;
  831. _NEAR_ GetOEMNetFnIANASupportRes_T* pGetOEMNetFnIANASupportRes = (_NEAR_ GetOEMNetFnIANASupportRes_T*) pRes;
  832. BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  833. INT8U i;
  834. /*if(pBMCInfo->IpmiConfig.IPMIFirewallSupport == ENABLED)
  835. {
  836. _fmemset(pGetOEMNetFnIANASupportRes, 0x00, sizeof(GetOEMNetFnIANASupportRes_T));
  837. if(pGetOEMNetFnIANASupportReq->ChannelNum & RESERVED_BITS_GETOEMNETFNIANASUPPORT_CH)
  838. {
  839. *pRes = CC_INV_DATA_FIELD;
  840. return sizeof(*pRes);
  841. }
  842. if(pGetOEMNetFnIANASupportReq->NetFn & RESERVED_BITS_GETOEMNETFNIANASUPPORT_NETFN)
  843. {
  844. *pRes = CC_INV_DATA_FIELD;
  845. return sizeof(*pRes);
  846. }
  847. if(pGetOEMNetFnIANASupportReq->ListIndex & RESERVED_BITS_GETOEMNETFNIANASUPPORT_LISTINDEX)
  848. {
  849. *pRes = CC_INV_DATA_FIELD;
  850. return sizeof(*pRes);
  851. }
  852. pGetOEMNetFnIANASupportRes->CompletionCode = CC_NORMAL;
  853. pGetOEMNetFnIANASupportRes->LUNSupport = LUN_00 | LUN_01 |LUN_10 | LUN_11;
  854. if(NETFN_AMI == pGetOEMNetFnIANASupportReq->NetFn)
  855. {
  856. pGetOEMNetFnIANASupportRes->CompletionCode = CC_NORMAL;
  857. pGetOEMNetFnIANASupportRes->IANACode[0] = (INT8U) DMTF_DEFINING_BODY;
  858. return (sizeof(GetOEMNetFnIANASupportRes_T) -2);
  859. }
  860. else if(NETFN_PICMG == pGetOEMNetFnIANASupportReq->NetFn )
  861. {
  862. for (i = 0; i < sizeof (pBMCInfo->GroupExtnMsgHndlrTbl) / sizeof (pBMCInfo->GroupExtnMsgHndlrTbl [0]); i++)
  863. {
  864. if (pBMCInfo->GroupExtnMsgHndlrTbl [i].NetFn == pGetOEMNetFnIANASupportReq->NetFn)
  865. {
  866. pGetOEMNetFnIANASupportRes->IANACode[0] = pBMCInfo->GroupExtnMsgHndlrTbl [i].GroupExtnCode;
  867. return (sizeof(GetOEMNetFnIANASupportRes_T) -2);
  868. }
  869. }
  870. }
  871. else if (NETFN_OEM == pGetOEMNetFnIANASupportReq->NetFn)
  872. {
  873. if (pGetOEMNetFnIANASupportReq->ListIndex < (sizeof(m_IANAList)/ sizeof(m_IANAList[0])))
  874. {
  875. _fmemcpy(pGetOEMNetFnIANASupportRes->IANACode, m_IANAList[pGetOEMNetFnIANASupportReq->ListIndex].IANA, sizeof(IANA_T));
  876. if ( (pGetOEMNetFnIANASupportReq->ListIndex+1) == (sizeof(m_IANAList)/ sizeof(m_IANAList[0])))
  877. {
  878. pGetOEMNetFnIANASupportRes->IANAIndex = 1 << 7;
  879. }
  880. return (sizeof(GetOEMNetFnIANASupportRes_T));
  881. }
  882. }
  883. pGetOEMNetFnIANASupportRes->CompletionCode = CC_INV_DATA_FIELD;
  884. return(sizeof(pGetOEMNetFnIANASupportRes->CompletionCode));
  885. }
  886. else*/
  887. {
  888. *pRes = CC_INV_CMD;
  889. return sizeof(*pRes);
  890. }
  891. }
  892. #endif //GET_OEM_NETFN_IANA_SUPPORT != UNIMPLEMENTED
  893. static int GetRequiredLength(INT8U NetFn, INT8U CmdReqSize)
  894. {
  895. INT8U RequiredLength;
  896. switch (NetFn)
  897. {
  898. case NETFN_OEM:
  899. RequiredLength = CmdReqSize;
  900. break;
  901. case NETFN_AMI:
  902. RequiredLength = CmdReqSize - sizeof(NetFnParams_T) + 1;
  903. break;
  904. case NETFN_PICMG:
  905. RequiredLength = CmdReqSize - sizeof(NetFnParams_T) + 1;
  906. break;
  907. default:
  908. RequiredLength = CmdReqSize - sizeof(NetFnParams_T);
  909. break;
  910. }
  911. return RequiredLength;
  912. }
  913. static int ValidateFFNetFnData (INT8U NetFn, NetFnParams_T* pNetFnParams , BMCInfo_t *pBMCInfo)
  914. {
  915. INT8U i;
  916. // If NetFn is 0x2C, check for Defining Body code
  917. if (NETFN_PICMG == NetFn )
  918. {
  919. // for (i = 0; i < sizeof (pBMCInfo->GroupExtnMsgHndlrTbl) / sizeof (pBMCInfo->GroupExtnMsgHndlrTbl [0]); i++)
  920. {
  921. // if (pBMCInfo->GroupExtnMsgHndlrTbl [i].NetFn == NetFn)
  922. // return (pBMCInfo->GroupExtnMsgHndlrTbl [i].GroupExtnCode != pNetFnParams->DefBodyCode);
  923. }
  924. }
  925. else if (NETFN_OEM == NetFn) // If NetFn is 0x2E, check for OEM IANA
  926. {
  927. for (i=0; i <(sizeof(m_IANAList)/ sizeof(m_IANAList[0])); i++)
  928. {
  929. if (0 == _fmemcmp( pNetFnParams->IANA, m_IANAList[i].IANA, sizeof(IANA_T)))
  930. {
  931. break;
  932. }
  933. }
  934. if (i >= (sizeof(m_IANAList)/ sizeof(m_IANAList[0])))
  935. {
  936. // Given IANA in Req is not matching any of the IANA in the IANA list
  937. return 1;
  938. }
  939. }
  940. return 0;
  941. }
  942. #endif /* IPM_DEVICE */