ipmi_firewall.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * Redistribution of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. *
  11. * Redistribution in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * Neither the name of Sun Microsystems, Inc. or the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * This software is provided "AS IS," without a warranty of any kind.
  20. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
  21. * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
  22. * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
  23. * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
  24. * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
  25. * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
  26. * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
  27. * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
  28. * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
  29. * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
  30. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  31. */
  32. #ifndef IPMI_FIREWALL_H
  33. #define IPMI_FIREWALL_H
  34. #include <ipmitool/ipmi.h>
  35. int ipmi_firewall_main(struct ipmi_intf *, int, char **);
  36. #define BMC_GET_NETFN_SUPPORT 0x09
  37. #define BMC_GET_COMMAND_SUPPORT 0x0A
  38. #define BMC_GET_COMMAND_SUBFUNCTION_SUPPORT 0x0B
  39. #define BMC_GET_CONFIGURABLE_COMMANDS 0x0C
  40. #define BMC_GET_CONFIGURABLE_COMMAND_SUBFUNCTIONS 0x0D
  41. #define BMC_SET_COMMAND_ENABLES 0x60
  42. #define BMC_GET_COMMAND_ENABLES 0x61
  43. #define BMC_SET_COMMAND_SUBFUNCTION_ENABLES 0x62
  44. #define BMC_GET_COMMAND_SUBFUNCTION_ENABLES 0x63
  45. #define BMC_OEM_NETFN_IANA_SUPPORT 0x64
  46. #define SET_COMMAND_ENABLE_BYTE (BMC_SET_COMMAND_ENABLES / 8)
  47. #define SET_COMMAND_ENABLE_BIT (BMC_SET_COMMAND_ENABLES % 8)
  48. #define MAX_LUN 4
  49. #define MAX_NETFN 64
  50. #define MAX_NETFN_PAIR (MAX_NETFN/2)
  51. #define MAX_COMMAND 256
  52. #define MAX_SUBFN 32
  53. #define MAX_COMMAND_BYTES (MAX_COMMAND>>3)
  54. #define MAX_SUBFN_BYTES (MAX_SUBFN>>3)
  55. // support is a bitfield with the following bits set...
  56. #define BIT_AVAILABLE 0x01
  57. #define BIT_CONFIGURABLE 0x02
  58. #define BIT_ENABLED 0x04
  59. extern int verbose;
  60. struct command_support {
  61. unsigned char support;
  62. unsigned char version[3];
  63. unsigned char subfn_support[MAX_SUBFN_BYTES];
  64. unsigned char subfn_config[MAX_SUBFN_BYTES];
  65. unsigned char subfn_enable[MAX_SUBFN_BYTES];
  66. };
  67. struct lun_netfn_support {
  68. unsigned char support;
  69. struct command_support command[MAX_COMMAND];
  70. unsigned char command_mask[MAX_COMMAND_BYTES];
  71. unsigned char config_mask[MAX_COMMAND_BYTES];
  72. unsigned char enable_mask[MAX_COMMAND_BYTES];
  73. };
  74. struct lun_support {
  75. unsigned char support;
  76. struct lun_netfn_support netfn[MAX_NETFN_PAIR];
  77. };
  78. struct bmc_fn_support {
  79. struct lun_support lun[MAX_LUN];
  80. };
  81. struct ipmi_function_params {
  82. int channel;
  83. int lun;
  84. int netfn;
  85. int command;
  86. int subfn;
  87. unsigned char force;
  88. };
  89. static inline int bit_test(const unsigned char * bf, int n) {
  90. return !!(bf[n>>3]&(1<<(n%8)));
  91. }
  92. static inline void bit_set(unsigned char * bf, int n, int v) {
  93. bf[n>>3] = (bf[n>>3] & ~(1<<(n%8))) | ((v?1:0)<<(n%8));
  94. }
  95. #endif /*IPMI_FIREWALL_H */