ipmi.h 8.3 KB

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