mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 10:37:22 +00:00
ID: 290 - ipmi_sol.c needs a clean-up
ipmi_sol_payload_access() - change formatting and simplify.
This commit is contained in:
parent
2d7fe32687
commit
d42890ef17
@ -71,7 +71,7 @@
|
|||||||
#define SOL_PARAMETER_SOL_PAYLOAD_CHANNEL 0x07
|
#define SOL_PARAMETER_SOL_PAYLOAD_CHANNEL 0x07
|
||||||
#define SOL_PARAMETER_SOL_PAYLOAD_PORT 0x08
|
#define SOL_PARAMETER_SOL_PAYLOAD_PORT 0x08
|
||||||
|
|
||||||
#define MAX_SOL_RETRY 6
|
#define MAX_SOL_RETRY 6
|
||||||
|
|
||||||
const struct valstr sol_parameter_vals[] = {
|
const struct valstr sol_parameter_vals[] = {
|
||||||
{ SOL_PARAMETER_SET_IN_PROGRESS, "Set In Progress (0)" },
|
{ SOL_PARAMETER_SET_IN_PROGRESS, "Set In Progress (0)" },
|
||||||
@ -100,47 +100,45 @@ extern int verbose;
|
|||||||
* ipmi_sol_payload_access
|
* ipmi_sol_payload_access
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
ipmi_sol_payload_access(struct ipmi_intf * intf,
|
ipmi_sol_payload_access(struct ipmi_intf * intf, uint8_t channel,
|
||||||
uint8_t channel,
|
uint8_t userid, int enable)
|
||||||
uint8_t userid,
|
|
||||||
int enable)
|
|
||||||
{
|
{
|
||||||
struct ipmi_rq req;
|
struct ipmi_rq req;
|
||||||
struct ipmi_rs *rsp;
|
struct ipmi_rs *rsp;
|
||||||
|
int rc = (-1);
|
||||||
uint8_t data[6];
|
uint8_t data[6];
|
||||||
|
|
||||||
memset(&req, 0, sizeof(req));
|
memset(&req, 0, sizeof(req));
|
||||||
req.msg.netfn = IPMI_NETFN_APP;
|
req.msg.netfn = IPMI_NETFN_APP;
|
||||||
req.msg.cmd = IPMI_SET_USER_PAYLOAD_ACCESS;
|
req.msg.cmd = IPMI_SET_USER_PAYLOAD_ACCESS;
|
||||||
req.msg.data = data;
|
req.msg.data = data;
|
||||||
req.msg.data_len = 6;
|
req.msg.data_len = 6;
|
||||||
|
|
||||||
memset(data, 0, 6);
|
memset(data, 0, 6);
|
||||||
|
/* channel */
|
||||||
data[0] = channel & 0xf; /* channel */
|
data[0] = channel & 0xf;
|
||||||
data[1] = userid & 0x3f; /* user id */
|
/* user id */
|
||||||
if (!enable)
|
data[1] = userid & 0x3f;
|
||||||
data[1] |= 0x40; /* disable */
|
if (!enable) {
|
||||||
data[2] = 0x02; /* payload 1 is SOL */
|
/* disable */
|
||||||
|
data[1] |= 0x40;
|
||||||
rsp = intf->sendrecv(intf, &req);
|
|
||||||
|
|
||||||
if (NULL != rsp) {
|
|
||||||
switch (rsp->ccode) {
|
|
||||||
case 0x00:
|
|
||||||
return 0;
|
|
||||||
default:
|
|
||||||
lprintf(LOG_ERR, "Error %sabling SOL payload for user %d on channel %d: %s",
|
|
||||||
enable ? "en" : "dis", userid, channel,
|
|
||||||
val2str(rsp->ccode, completion_code_vals));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lprintf(LOG_ERR, "Error %sabling SOL payload for user %d on channel %d",
|
|
||||||
enable ? "en" : "dis", userid, channel);
|
|
||||||
}
|
}
|
||||||
|
/* payload 1 is SOL */
|
||||||
return -1;
|
data[2] = 0x02;
|
||||||
|
rsp = intf->sendrecv(intf, &req);
|
||||||
|
if (rsp == NULL) {
|
||||||
|
lprintf(LOG_ERR, "Error %sabling SOL payload for user %d on channel %d",
|
||||||
|
enable ? "en" : "dis", userid, channel);
|
||||||
|
rc = (-1);
|
||||||
|
} else if (rsp->ccode != 0) {
|
||||||
|
lprintf(LOG_ERR, "Error %sabling SOL payload for user %d on channel %d: %s",
|
||||||
|
enable ? "en" : "dis", userid, channel,
|
||||||
|
val2str(rsp->ccode, completion_code_vals));
|
||||||
|
rc = (-1);
|
||||||
|
} else {
|
||||||
|
rc = 0;
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user