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.
This commit is contained in:
Zdenek Styblik 2015-01-16 20:01:50 +01:00
parent 69f668309b
commit 238d3c4ea9
2 changed files with 116 additions and 0 deletions

View File

@ -49,6 +49,32 @@
#define IPMI_SET_USER_PASSWORD 0x47 #define IPMI_SET_USER_PASSWORD 0x47
#define IPMI_GET_CHANNEL_CIPHER_SUITES 0x54 #define IPMI_GET_CHANNEL_CIPHER_SUITES 0x54
/* These are for channel_info_t.session_support */
#define IPMI_CHANNEL_SESSION_LESS 0x00
#define IPMI_CHANNEL_SESSION_SINGLE 0x40
#define IPMI_CHANNEL_SESSION_MULTI 0x80
#define IPMI_CHANNEL_SESSION_BASED 0xC0
/* (22.24) Get Channel Info */
struct channel_info_t {
uint8_t channel;
uint8_t medium;
uint8_t protocol;
uint8_t session_support;
uint8_t active_sessions;
uint8_t vendor_id[3];
uint8_t aux_info[2];
};
/* (22.23) Get Channel Access */
struct channel_access_t {
uint8_t access_mode;
uint8_t alerting;
uint8_t channel;
uint8_t per_message_auth;
uint8_t privilege_limit;
uint8_t user_level_auth;
};
/* /*
* The Get Authentication Capabilities response structure * The Get Authentication Capabilities response structure

View File

@ -57,6 +57,96 @@ extern int verbose;
void printf_channel_usage (void); 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 * ipmi_1_5_authtypes
* *