diff options
author | Rob Johnston <rob.johnston@joyent.com> | 2017-12-06 00:15:50 +0000 |
---|---|---|
committer | Rob Johnston <rob.johnston@joyent.com> | 2017-12-08 01:04:32 +0000 |
commit | 19815442328f15b5cf5096d3a24f29862cb6b47c (patch) | |
tree | ac0225be51272f069702673953f560403ef19bb0 /usr/src/lib/libipmi/common/ipmi_misc.c | |
parent | 9a212cf317ce1d7fed4fcc798229efeda6ad43f2 (diff) | |
download | illumos-joyent-19815442328f15b5cf5096d3a24f29862cb6b47c.tar.gz |
OS-6494 libipmi: add support for GET_CHASSIS_STATUS command
Diffstat (limited to 'usr/src/lib/libipmi/common/ipmi_misc.c')
-rw-r--r-- | usr/src/lib/libipmi/common/ipmi_misc.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/usr/src/lib/libipmi/common/ipmi_misc.c b/usr/src/lib/libipmi/common/ipmi_misc.c index f83e9e1802..221093e630 100644 --- a/usr/src/lib/libipmi/common/ipmi_misc.c +++ b/usr/src/lib/libipmi/common/ipmi_misc.c @@ -20,8 +20,8 @@ */ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, Joyent, Inc. */ - #include <libipmi.h> #include <stdio.h> #include <string.h> @@ -222,3 +222,35 @@ ipmi_chassis_identify(ipmi_handle_t *ihp, boolean_t enable) return (0); } + +/* + * calller is responsible for free'ing returned structure + */ +ipmi_chassis_status_t * +ipmi_chassis_status(ipmi_handle_t *ihp) +{ + ipmi_cmd_t cmd, *rsp; + ipmi_chassis_status_t *chs; + + cmd.ic_netfn = IPMI_NETFN_CHASSIS; + cmd.ic_lun = 0; + cmd.ic_cmd = IPMI_CMD_GET_CHASSIS_STATUS; + cmd.ic_data = NULL; + cmd.ic_dlen = 0; + + if ((rsp = ipmi_send(ihp, &cmd)) == NULL) + return (NULL); + + if (rsp->ic_dlen < sizeof (ipmi_chassis_status_t)) { + (void) ipmi_set_error(ihp, EIPMI_BAD_RESPONSE_LENGTH, NULL); + return (NULL); + } + + if ((chs = ipmi_alloc(ihp, sizeof (ipmi_chassis_status_t))) == NULL) { + /* ipmi errno set */ + return (NULL); + } + + (void) memcpy(chs, rsp->ic_data, sizeof (ipmi_chassis_status_t)); + return (chs); +} |