diff options
author | Zdenek Styblik <stybla@turnovfree.net> | 2015-01-16 20:01:50 +0100 |
---|---|---|
committer | Zdenek Styblik <stybla@turnovfree.net> | 2015-01-16 20:01:50 +0100 |
commit | 238d3c4ea99066bce1ba929b10e74b9ea93372a7 (patch) | |
tree | df74255893403921bd8283cabb03c3dea767f649 /lib/ipmi_channel.c | |
parent | 69f668309bfff3cc7f2bab017aa0a02a74383fec (diff) | |
download | ipmitool-238d3c4ea99066bce1ba929b10e74b9ea93372a7.tar.gz |
Add _ipmi_get_channel_access() and _ipmi_get_channel_info()
Commit adds _ipmi_get_channel_access() and _ipmi_get_channel_info() as well as
supporting structures.
Diffstat (limited to 'lib/ipmi_channel.c')
-rw-r--r-- | lib/ipmi_channel.c | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/lib/ipmi_channel.c b/lib/ipmi_channel.c index 578b88d..5456671 100644 --- a/lib/ipmi_channel.c +++ b/lib/ipmi_channel.c @@ -57,6 +57,96 @@ extern int verbose; void printf_channel_usage (void); +/* _ipmi_get_channel_access - Get Channel Access for given channel. Results are + * stored into passed struct. + * + * @intf - IPMI interface + * @channel_access - ptr to channel_access_t with Channel set. + * @get_volatile_settings - get volatile if != 0, else non-volatile settings. + * + * returns - negative number means error, positive is a ccode. + */ +int +_ipmi_get_channel_access(struct ipmi_intf *intf, + struct channel_access_t *channel_access, + uint8_t get_volatile_settings) +{ + struct ipmi_rs *rsp; + struct ipmi_rq req = {0}; + uint8_t data[2]; + + if (channel_access == NULL) { + return (-3); + } + data[0] = channel_access->channel & 0x0F; + /* volatile - 0x80; non-volatile - 0x40 */ + data[1] = get_volatile_settings ? 0x80 : 0x40; + req.msg.netfn = IPMI_NETFN_APP; + req.msg.cmd = IPMI_GET_CHANNEL_ACCESS; + req.msg.data = data; + req.msg.data_len = 2; + + rsp = intf->sendrecv(intf, &req); + if (rsp == NULL) { + return (-1); + } else if (rsp->ccode != 0) { + return rsp->ccode; + } else if (rsp->data_len != 2) { + return (-2); + } + channel_access->alerting = rsp->data[0] & 0x20; + channel_access->per_message_auth = rsp->data[0] & 0x10; + channel_access->user_level_auth = rsp->data[0] & 0x08; + channel_access->access_mode = rsp->data[0] & 0x07; + channel_access->privilege_limit = rsp->data[1] & 0x0F; + return 0; +} + +/* _ipmi_get_channel_info - Get Channel Info for given channel. Results are + * stored into passed struct. + * + * @intf - IPMI interface + * @channel_info - ptr to channel_info_t with Channel set. + * + * returns - negative number means error, positive is a ccode. + */ +int +_ipmi_get_channel_info(struct ipmi_intf *intf, + struct channel_info_t *channel_info) +{ + struct ipmi_rs *rsp; + struct ipmi_rq req = {0}; + uint8_t data[1]; + + if (channel_info == NULL) { + return (-3); + } + data[0] = channel_info->channel & 0x0F; + req.msg.netfn = IPMI_NETFN_APP; + req.msg.cmd = IPMI_GET_CHANNEL_INFO; + req.msg.data = data; + req.msg.data_len = 1; + + rsp = intf->sendrecv(intf, &req); + if (rsp == NULL) { + return (-1); + } else if (rsp->ccode != 0) { + return rsp->ccode; + } else if (rsp->data_len != 9) { + return (-2); + } + channel_info->channel = rsp->data[0] & 0x0F; + channel_info->medium = rsp->data[1] & 0x7F; + channel_info->protocol = rsp->data[2] & 0x1F; + channel_info->session_support = rsp->data[3] & 0xC0; + channel_info->active_sessions = rsp->data[3] & 0x3F; + memcpy(channel_info->vendor_id, &rsp->data[4], + sizeof(channel_info->vendor_id)); + memcpy(channel_info->aux_info, &rsp->data[7], + sizeof(channel_info->aux_info)); + return 0; +} + /** * ipmi_1_5_authtypes * |