ipmi.h 8.3 KB

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