ipmi.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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_H
  33. #define IPMI_H
  34. #include <stdlib.h>
  35. #include <stdio.h>
  36. #include <inttypes.h>
  37. #include <sys/types.h>
  38. #include <netinet/in.h>
  39. #include <ipmitool/helper.h>
  40. #include <ipmitool/ipmi_cc.h>
  41. /****************** jimbo add ******************/
  42. #define IPMI_INTF_LAN 1
  43. #define ENABLE_ALL_OPTIONS 1
  44. /****************** jimbo end ******************/
  45. #define IPMI_BUF_SIZE 1024
  46. #define IPMI_MAX_MD_SIZE 0x20
  47. #if HAVE_PRAGMA_PACK
  48. #define ATTRIBUTE_PACKING
  49. #else
  50. #define ATTRIBUTE_PACKING __attribute__ ((packed))
  51. #endif
  52. /****** jimbo add *********/
  53. #define VERSION "1.8.18"
  54. /* From table 13.16 of the IPMI v2 specification */
  55. #define IPMI_PAYLOAD_TYPE_IPMI 0x00
  56. #define IPMI_PAYLOAD_TYPE_SOL 0x01
  57. #define IPMI_PAYLOAD_TYPE_OEM 0x02
  58. #define IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST 0x10
  59. #define IPMI_PAYLOAD_TYPE_RMCP_OPEN_RESPONSE 0x11
  60. #define IPMI_PAYLOAD_TYPE_RAKP_1 0x12
  61. #define IPMI_PAYLOAD_TYPE_RAKP_2 0x13
  62. #define IPMI_PAYLOAD_TYPE_RAKP_3 0x14
  63. #define IPMI_PAYLOAD_TYPE_RAKP_4 0x15
  64. extern int verbose;
  65. extern int csv_output;
  66. struct ipmi_rq {
  67. struct {
  68. uint8_t netfn:6;
  69. uint8_t lun:2;
  70. uint8_t cmd;
  71. uint8_t target_cmd;
  72. uint16_t data_len;
  73. uint8_t *data;
  74. } msg;
  75. };
  76. /*
  77. * This is what the sendrcv_v2() function would take as an argument. The common case
  78. * is for payload_type to be IPMI_PAYLOAD_TYPE_IPMI.
  79. */
  80. struct ipmi_v2_payload {
  81. uint16_t payload_length;
  82. uint8_t payload_type;
  83. union {
  84. struct {
  85. uint8_t rq_seq;
  86. struct ipmi_rq *request;
  87. } ipmi_request;
  88. struct {
  89. uint8_t rs_seq;
  90. struct ipmi_rs *response;
  91. } ipmi_response;
  92. /* Only used internally by the lanplus interface */
  93. struct {
  94. uint8_t *request;
  95. } open_session_request;
  96. /* Only used internally by the lanplus interface */
  97. struct {
  98. uint8_t *message;
  99. } rakp_1_message;
  100. /* Only used internally by the lanplus interface */
  101. struct {
  102. uint8_t *message;
  103. } rakp_2_message;
  104. /* Only used internally by the lanplus interface */
  105. struct {
  106. uint8_t *message;
  107. } rakp_3_message;
  108. /* Only used internally by the lanplus interface */
  109. struct {
  110. uint8_t *message;
  111. } rakp_4_message;
  112. struct {
  113. uint8_t data[IPMI_BUF_SIZE];
  114. uint16_t character_count;
  115. uint8_t packet_sequence_number;
  116. uint8_t acked_packet_number;
  117. uint8_t accepted_character_count;
  118. uint8_t is_nack; /* bool */
  119. uint8_t assert_ring_wor; /* bool */
  120. uint8_t generate_break; /* bool */
  121. uint8_t deassert_cts; /* bool */
  122. uint8_t deassert_dcd_dsr; /* bool */
  123. uint8_t flush_inbound; /* bool */
  124. uint8_t flush_outbound; /* bool */
  125. } sol_packet;
  126. } payload;
  127. };
  128. struct ipmi_rq_entry {
  129. struct ipmi_rq req;
  130. struct ipmi_intf *intf;
  131. uint8_t rq_seq;
  132. uint8_t *msg_data;
  133. int msg_len;
  134. int bridging_level;
  135. struct ipmi_rq_entry *next;
  136. };
  137. struct ipmi_rs {
  138. uint8_t ccode;
  139. uint8_t data[IPMI_BUF_SIZE];
  140. /*
  141. * Looks like this is the length of the entire packet, including the RMCP
  142. * stuff, then modified to be the length of the extra IPMI message data
  143. */
  144. int data_len;
  145. struct {
  146. uint8_t netfn;
  147. uint8_t cmd;
  148. uint8_t seq;
  149. uint8_t lun;
  150. } msg;
  151. struct {
  152. uint8_t authtype;
  153. uint32_t seq;
  154. uint32_t id;
  155. uint8_t bEncrypted; /* IPMI v2 only */
  156. uint8_t bAuthenticated; /* IPMI v2 only */
  157. uint8_t payloadtype; /* IPMI v2 only */
  158. /* This is the total length of the payload or
  159. IPMI message. IPMI v2.0 requires this to
  160. be 2 bytes. Not really used for much. */
  161. uint16_t msglen;
  162. } session;
  163. /*
  164. * A union of the different possible payload meta-data
  165. */
  166. union {
  167. struct {
  168. uint8_t rq_addr;
  169. uint8_t netfn;
  170. uint8_t rq_lun;
  171. uint8_t rs_addr;
  172. uint8_t rq_seq;
  173. uint8_t rs_lun;
  174. uint8_t cmd;
  175. } ipmi_response;
  176. struct {
  177. uint8_t message_tag;
  178. uint8_t rakp_return_code;
  179. uint8_t max_priv_level;
  180. uint32_t console_id;
  181. uint32_t bmc_id;
  182. uint8_t auth_alg;
  183. uint8_t integrity_alg;
  184. uint8_t crypt_alg;
  185. } open_session_response;
  186. struct {
  187. uint8_t message_tag;
  188. uint8_t rakp_return_code;
  189. uint32_t console_id;
  190. uint8_t bmc_rand[16]; /* Random number generated by the BMC */
  191. uint8_t bmc_guid[16];
  192. uint8_t key_exchange_auth_code[IPMI_MAX_MD_SIZE];
  193. } rakp2_message;
  194. struct {
  195. uint8_t message_tag;
  196. uint8_t rakp_return_code;
  197. uint32_t console_id;
  198. uint8_t integrity_check_value[IPMI_MAX_MD_SIZE];
  199. } rakp4_message;
  200. struct {
  201. uint8_t packet_sequence_number;
  202. uint8_t acked_packet_number;
  203. uint8_t accepted_character_count;
  204. uint8_t is_nack; /* bool */
  205. uint8_t transfer_unavailable; /* bool */
  206. uint8_t sol_inactive; /* bool */
  207. uint8_t transmit_overrun; /* bool */
  208. uint8_t break_detected; /* bool */
  209. } sol_packet;
  210. } payload;
  211. };
  212. #define IPMI_NETFN_CHASSIS 0x0
  213. #define IPMI_NETFN_BRIDGE 0x2
  214. #define IPMI_NETFN_SE 0x4
  215. #define IPMI_NETFN_APP 0x6
  216. #define IPMI_NETFN_FIRMWARE 0x8
  217. #define IPMI_NETFN_STORAGE 0xa
  218. #define IPMI_NETFN_TRANSPORT 0xc
  219. #define IPMI_NETFN_PICMG 0x2C
  220. #define IPMI_NETFN_DCGRP 0x2C
  221. #define IPMI_NETFN_OEM 0x2E
  222. #define IPMI_NETFN_ISOL 0x34
  223. #define IPMI_NETFN_TSOL 0x30
  224. #define IPMI_BMC_SLAVE_ADDR 0x20
  225. #define IPMI_REMOTE_SWID 0x81
  226. /* These values are IANA numbers */
  227. /************************************************************************
  228. * Add ID String for IANA Enterprise Number of IBM & ADLINK
  229. * https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers
  230. ************************************************************************/
  231. typedef enum IPMI_OEM {
  232. IPMI_OEM_UNKNOWN = 0,
  233. /* 2 for [IBM] */
  234. IPMI_OEM_IBM_2 = 2,
  235. IPMI_OEM_HP = 11,
  236. IPMI_OEM_SUN = 42,
  237. IPMI_OEM_NOKIA = 94,
  238. IPMI_OEM_BULL = 107,
  239. IPMI_OEM_HITACHI_116 = 116,
  240. IPMI_OEM_NEC = 119,
  241. IPMI_OEM_TOSHIBA = 186,
  242. IPMI_OEM_ERICSSON = 193,
  243. IPMI_OEM_INTEL = 343,
  244. IPMI_OEM_TATUNG = 373,
  245. IPMI_OEM_HITACHI_399 = 399,
  246. IPMI_OEM_DELL = 674,
  247. IPMI_OEM_LMC = 2168,
  248. IPMI_OEM_RADISYS = 4337,
  249. IPMI_OEM_BROADCOM = 4413,
  250. /* 4769 for [IBM Corporation] */
  251. IPMI_OEM_IBM_4769 = 4769,
  252. IPMI_OEM_MAGNUM = 5593,
  253. IPMI_OEM_TYAN = 6653,
  254. IPMI_OEM_QUANTA = 7244,
  255. IPMI_OEM_NEWISYS = 9237,
  256. IPMI_OEM_ADVANTECH = 10297,
  257. IPMI_OEM_FUJITSU_SIEMENS = 10368,
  258. IPMI_OEM_AVOCENT = 10418,
  259. IPMI_OEM_PEPPERCON = 10437,
  260. IPMI_OEM_SUPERMICRO = 10876,
  261. IPMI_OEM_OSA = 11102,
  262. IPMI_OEM_GOOGLE = 11129,
  263. IPMI_OEM_PICMG = 12634,
  264. IPMI_OEM_RARITAN = 13742,
  265. IPMI_OEM_KONTRON = 15000,
  266. IPMI_OEM_PPS = 16394,
  267. /* 20301 for [IBM eServer X] */
  268. IPMI_OEM_IBM_20301 = 20301,
  269. IPMI_OEM_AMI = 20974,
  270. /* 24339 for [ADLINK TECHNOLOGY INC.] */
  271. IPMI_OEM_ADLINK_24339 = 24339,
  272. IPMI_OEM_NOKIA_SOLUTIONS_AND_NETWORKS = 28458,
  273. IPMI_OEM_VITA = 33196,
  274. IPMI_OEM_SUPERMICRO_47488 = 47488
  275. } IPMI_OEM;
  276. extern const struct valstr completion_code_vals[];
  277. #endif /* IPMI_H */