Hook ipmi_set_user_access() to _ipmi_set_user_access()

Commit hooks ipmi_set_user_access() to _ipmi_set_user_access() and removes
duplicate code.
This commit is contained in:
Zdenek Styblik 2015-01-30 13:16:44 +01:00
parent 8081427543
commit 410606e868

View File

@ -1119,38 +1119,34 @@ ipmi_set_channel_access(struct ipmi_intf * intf, uint8_t channel, uint8_t enable
return 0; return 0;
} }
/* TODO - we already have functions for this elsewhere!!! */ /* ipmi_set_user_access - set admin access for given user and channel.
*
* @intf - IPMI interface
* @channel - IPMI channel
* @user_id - IPMI User ID
*
* returns - 0 on success, (-1) on error.
*/
static int static int
ipmi_set_user_access(struct ipmi_intf * intf, uint8_t channel, uint8_t userid) ipmi_set_user_access(struct ipmi_intf *intf, uint8_t channel, uint8_t user_id)
{ {
struct ipmi_rs * rsp; struct user_access_t user_access;
struct ipmi_rq req; int ccode = 0;
uint8_t rqdata[4]; memset(&user_access, 0, sizeof(user_access));
user_access.channel = channel;
user_access.user_id = user_id;
user_access.privilege_limit = 0x04;
memset(rqdata, 0, 4); ccode = _ipmi_set_user_access(intf, &user_access, 1);
rqdata[0] = 0x90 | (channel & 0xf); if (eval_ccode(ccode) != 0) {
rqdata[1] = userid & 0x3f; lprintf(LOG_ERR, "Set User Access for channel %d failed",
rqdata[2] = 0x4; channel);
rqdata[3] = 0; return (-1);
} else {
memset(&req, 0, sizeof(req)); printf("Set User Access for channel %d was successful.",
req.msg.netfn = IPMI_NETFN_APP; channel);
req.msg.cmd = 0x43; return 0;
req.msg.data = rqdata;
req.msg.data_len = 4;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to Set User Access for channel %d", channel);
return -1;
} }
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Set User Access for channel %d failed: %s",
channel, val2str(rsp->ccode, completion_code_vals));
return -1;
}
return 0;
} }
/* get_cmdline_macaddr - parse-out MAC address from given string and store it /* get_cmdline_macaddr - parse-out MAC address from given string and store it