Firewall.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. #include "Firewall.h"
  24. #include "MsgHndlrTask.h"
  25. #include "Support.h"
  26. #include "com_IPMIDefs.h"
  27. #include "com_IPMI_Firewall.h"
  28. /* Reserved bit macro definitions */
  29. #define RESERVED_BITS_GETNETFNSUP 0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
  30. #define RESERVED_BITS_GETCMDSUP_CH 0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
  31. #define RESERVED_BITS_GETCMDSUP_LUN 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  32. #define RESERVED_BITS_GETCMDSUP_NETFUN 0x80 //BIT7 \BIT6 (11 and 10 are reserved as per IPMI spec)
  33. #define RESERVED_BITS_GETSUBFNSUP_CH 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  34. #define RESERVED_BITS_GETSUBFNSUP_NETFN 0xC0 //(BIT7 | BIT6)
  35. #define RESERVED_BITS_GETSUBFNSUP_LUN 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  36. #define RESERVED_BITS_GETCFGCMDS_CH 0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
  37. #define RESERVED_BITS_GETCFGCMDS_LUN 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  38. #define RESERVED_BITS_GETCFGCMDS_NETFUN 0x80 //BIT7 \BIT6 (11 and 10 are reserved as per IPMI spec)
  39. #define RESERVED_BITS_GETCFGSUBFNS_CH 0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
  40. #define RESERVED_BITS_GETCFGSUBFNS_NETFN 0xC0 //(BIT7 | BIT6)
  41. #define RESERVED_BITS_GETCFGSUBFNS_LUN 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  42. #define RESERVED_BITS_SETCMDEN_CH 0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
  43. #define RESERVED_BITS_SETCMDEN_LUN 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  44. #define RESERVED_BITS_SETCMDEN_NETFUN 0x80 //BIT7 \BIT6 (11 and 10 are reserved as per IPMI spec)
  45. #define RESERVED_BITS_GETCMDEN_CH 0xF0 //(BIT7 | BIT6 | BIT5 |BIT4)
  46. #define RESERVED_BITS_GETCMDEN_LUN 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  47. #define RESERVED_BITS_GETCMDEN_NETFUN 0x80 //BIT7 \BIT6 (11 and 10 are reserved as per IPMI spec)
  48. #define RESERVED_BITS_SETSUBFNEN_CH 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  49. #define RESERVED_BITS_SETSUBFNEN_NETFN 0xC0 //(BIT7 | BIT6)
  50. #define RESERVED_BITS_SETSUBFNEN_LUN 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  51. #define RESERVED_BITS_GETSUBFNEN_CH 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  52. #define RESERVED_BITS_GETSUBFNEN_NETFN 0xC0 //(BIT7 | BIT6)
  53. #define RESERVED_BITS_GETSUBFNEN_LUN 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  54. #define RESERVED_BITS_GETOEMNETFNIANASUPPORT_CH 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  55. #define RESERVED_BITS_GETOEMNETFNIANASUPPORT_NETFN 0xC0 //(BIT7 | BIT6)
  56. #define RESERVED_BITS_GETOEMNETFNIANASUPPORT_LISTINDEX 0xC0 //(BIT7 | BIT6)
  57. #if IPM_DEVICE == 1
  58. //static int GetRequiredLength (uint8_t NetFn, uint8_t CmdReqSize);
  59. //static int ValidateFFNetFnData (uint8_t NetFn, NetFnParams_T* pNetFnParams ,BMCInfo_t *pBMCInfo);
  60. /*** Local Macro definitions ***/
  61. #define LUN_NO_CMD_SUPPORT 0x00
  62. #define LUN_NO_RESTRICTION_SUPPORT 0x01
  63. #define LUN_RESTRICTION_SUPPORT 0x02
  64. #define LUN_00 LUN_RESTRICTION_SUPPORT
  65. #define LUN_01 LUN_NO_CMD_SUPPORT << 2
  66. #define LUN_10 LUN_NO_CMD_SUPPORT << 4
  67. #define LUN_11 LUN_NO_CMD_SUPPORT << 6
  68. #define DMTF_DEFINING_BODY 0x01
  69. //Group Extension codes
  70. #define GROUPEXTNCODE_PICMG 0x00
  71. #define GROUPEXTNCODE_DMTF 0x01
  72. #define GROUPEXTNCODE_SSI 0x02
  73. #define GROUPEXTNCODE_VSO 0x03
  74. #define GROUPEXTNCODE_DCMI 0xDC
  75. #define Max_GROUPEXTNCODE 5
  76. /* Add IANA No's to the Array */
  77. IANA_T m_IANAList[] = { /* LS byte first */
  78. {{0xFF,0xFF,0xFF}}, /* Reserved Oem IANA */
  79. #ifdef IANA_OEM_LIST
  80. IANA_OEM_LIST
  81. #endif
  82. };
  83. uint8_t GroupExtnCode[Max_GROUPEXTNCODE]={
  84. GROUPEXTNCODE_PICMG,
  85. GROUPEXTNCODE_DMTF,
  86. GROUPEXTNCODE_SSI,
  87. GROUPEXTNCODE_VSO,
  88. GROUPEXTNCODE_DCMI,
  89. };
  90. #if GET_NETFN_SUP != UNIMPLEMENTED
  91. /*---------------------------------------
  92. * GetNetFnSup
  93. *---------------------------------------*/
  94. int
  95. GetNetFnSup ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  96. {
  97. printf("GetNetFnSup not implement\r\n");
  98. *pRes = CC_INV_CMD;
  99. return sizeof(*pRes);
  100. }
  101. #endif /* GET_NETFN_SUP != UNIMPLEMENTED */
  102. #if GET_CMD_SUP != UNIMPLEMENTED
  103. /*---------------------------------------
  104. * GetCmdSup
  105. *---------------------------------------*/
  106. int
  107. GetCmdSup ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  108. {
  109. printf("GetCmdSup not implement\r\n");
  110. *pRes = CC_INV_CMD;
  111. return sizeof(*pRes);
  112. }
  113. #endif /* GET_CMD_SUP != UNIMPLEMENTED */
  114. #if GET_SUBFN_SUP != UNIMPLEMENTED
  115. /*---------------------------------------
  116. * GetSubFnSup
  117. *---------------------------------------*/
  118. int
  119. GetSubFnSup ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  120. {
  121. printf("GetSubFnSup not implement\r\n");
  122. *pRes = CC_INV_CMD;
  123. return sizeof(*pRes);
  124. }
  125. #endif /* GET_SUBFN_SUP != UNIMPLEMENTED */
  126. #if GET_CONFIG_CMDS != UNIMPLEMENTED
  127. /*---------------------------------------
  128. * GetConfigCmds
  129. *---------------------------------------*/
  130. int
  131. GetConfigCmds ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  132. {
  133. printf("GetConfigCmds not implement\r\n");
  134. *pRes = CC_INV_CMD;
  135. return sizeof(*pRes);
  136. }
  137. #endif /* GET_CONFIG_CMDS != UNIMPLEMENTED */
  138. #if GET_CONFIG_SUB_FNS != UNIMPLEMENTED
  139. /*---------------------------------------
  140. * GetConfigSubFns
  141. *---------------------------------------*/
  142. int
  143. GetConfigSubFns ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  144. {
  145. printf("GetConfigSubFns not implement\r\n");
  146. *pRes = CC_INV_CMD;
  147. return sizeof(*pRes);
  148. }
  149. #endif /* GET_CONFIG_SUB_FNS != UNIMPLEMENTED */
  150. #if SET_CMD_ENABLES != UNIMPLEMENTED
  151. /*---------------------------------------
  152. * SetCmdEnables
  153. *---------------------------------------*/
  154. int
  155. SetCmdEnables ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  156. {
  157. printf("SetCmdEnables not implement\r\n");
  158. *pRes = CC_INV_CMD;
  159. return sizeof(*pRes);
  160. }
  161. #endif /* SET_CMD_ENABLES != UNIMPLEMENTED */
  162. #if GET_CMD_ENABLES != UNIMPLEMENTED
  163. /*---------------------------------------
  164. * GetCmdEnables
  165. *---------------------------------------*/
  166. int
  167. GetCmdEnables ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  168. {
  169. printf("GetCmdEnables not implement\r\n");
  170. *pRes = CC_INV_CMD;
  171. return sizeof(*pRes);
  172. }
  173. #endif /* GET_CMD_ENABLES != UNIMPLEMENTED */
  174. #if SET_SUBFN_ENABLES != UNIMPLEMENTED
  175. /*---------------------------------------
  176. * SetSubFnEnables
  177. *---------------------------------------*/
  178. int
  179. SetSubFnEnables ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  180. {
  181. printf("SetSubFnEnables not implement\r\n");
  182. *pRes = CC_INV_CMD;
  183. return sizeof(*pRes);
  184. }
  185. #endif /* SET_SUBFN_ENABLES != UNIMPLEMENTED */
  186. #if GET_SUBFN_ENABLES != UNIMPLEMENTED
  187. /*---------------------------------------
  188. * GetSubFnEnables
  189. *---------------------------------------*/
  190. int
  191. GetSubFnEnables ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  192. {
  193. printf("GetSubFnEnables not implement\r\n");
  194. *pRes = CC_INV_CMD;
  195. return sizeof(*pRes);
  196. }
  197. #endif /* GET_SUBFN_ENABLES != UNIMPLEMENTED */
  198. #if GET_OEM_NETFN_IANA_SUPPORT != UNIMPLEMENTED
  199. /*---------------------------------------
  200. * GetOEMNetFnIANASupport
  201. *---------------------------------------*/
  202. int
  203. GetOEMNetFnIANASupport ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  204. {
  205. printf("GetOEMNetFnIANASupport not implement\r\n");
  206. *pRes = CC_INV_CMD;
  207. return sizeof(*pRes);
  208. }
  209. #endif //GET_OEM_NETFN_IANA_SUPPORT != UNIMPLEMENTED
  210. //static int GetRequiredLength(uint8_t NetFn, uint8_t CmdReqSize)
  211. //{
  212. // uint8_t RequiredLength;
  213. // switch (NetFn)
  214. // {
  215. // case NETFN_OEM:
  216. // RequiredLength = CmdReqSize;
  217. // break;
  218. // case NETFN_AMI:
  219. // RequiredLength = CmdReqSize - sizeof(NetFnParams_T) + 1;
  220. // break;
  221. // case NETFN_PICMG:
  222. // RequiredLength = CmdReqSize - sizeof(NetFnParams_T) + 1;
  223. // break;
  224. // default:
  225. // RequiredLength = CmdReqSize - sizeof(NetFnParams_T);
  226. // break;
  227. // }
  228. // return RequiredLength;
  229. //}
  230. //static int ValidateFFNetFnData (uint8_t NetFn, NetFnParams_T* pNetFnParams , BMCInfo_t *pBMCInfo)
  231. //{
  232. // uint8_t i;
  233. //
  234. // // If NetFn is 0x2C, check for Defining Body code
  235. // if (NETFN_PICMG == NetFn )
  236. // {
  237. // for (i = 0; i < sizeof (pBMCInfo->GroupExtnMsgHndlrTbl) / sizeof (pBMCInfo->GroupExtnMsgHndlrTbl [0]); i++)
  238. // {
  239. // if (pBMCInfo->GroupExtnMsgHndlrTbl [i].NetFn == NetFn)
  240. // return (pBMCInfo->GroupExtnMsgHndlrTbl [i].GroupExtnCode != pNetFnParams->DefBodyCode);
  241. // }
  242. // }
  243. // else if (NETFN_OEM == NetFn) // If NetFn is 0x2E, check for OEM IANA
  244. // {
  245. // for (i=0; i <(sizeof(m_IANAList)/ sizeof(m_IANAList[0])); i++)
  246. // {
  247. // if (0 == _fmemcmp( pNetFnParams->IANA, m_IANAList[i].IANA, sizeof(IANA_T)))
  248. // {
  249. // break;
  250. // }
  251. // }
  252. // if (i >= (sizeof(m_IANAList)/ sizeof(m_IANAList[0])))
  253. // {
  254. // // Given IANA in Req is not matching any of the IANA in the IANA list
  255. // return 1;
  256. // }
  257. // }
  258. // return 0;
  259. //}
  260. #endif /* IPM_DEVICE */