mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47:22 +00:00
add ability to configure session retry and timeout settings,
add chassis power status command with return value indicating status
This commit is contained in:
parent
fecfc09c8b
commit
90448837ec
@ -52,5 +52,6 @@
|
|||||||
#define IPMI_CHASSIS_POLICY_ALWAYS_OFF 0x0
|
#define IPMI_CHASSIS_POLICY_ALWAYS_OFF 0x0
|
||||||
|
|
||||||
int ipmi_chassis_main(struct ipmi_intf *, int, char **);
|
int ipmi_chassis_main(struct ipmi_intf *, int, char **);
|
||||||
|
int ipmi_chassis_power_status(struct ipmi_intf * intf);
|
||||||
|
|
||||||
#endif /*IPMI_CHASSIS_H*/
|
#endif /*IPMI_CHASSIS_H*/
|
||||||
|
@ -85,6 +85,7 @@ struct ipmi_session {
|
|||||||
int password;
|
int password;
|
||||||
int port;
|
int port;
|
||||||
int active;
|
int active;
|
||||||
|
int retry;
|
||||||
|
|
||||||
uint32_t session_id;
|
uint32_t session_id;
|
||||||
uint32_t in_seq;
|
uint32_t in_seq;
|
||||||
@ -193,6 +194,8 @@ void ipmi_intf_session_set_privlvl(struct ipmi_intf * intf, uint8_t privlvl);
|
|||||||
void ipmi_intf_session_set_cipher_suite_id(struct ipmi_intf * intf, uint8_t cipher_suite_id);
|
void ipmi_intf_session_set_cipher_suite_id(struct ipmi_intf * intf, uint8_t cipher_suite_id);
|
||||||
void ipmi_intf_session_set_port(struct ipmi_intf * intf, int port);
|
void ipmi_intf_session_set_port(struct ipmi_intf * intf, int port);
|
||||||
void ipmi_intf_session_set_authtype(struct ipmi_intf * intf, uint8_t authtype);
|
void ipmi_intf_session_set_authtype(struct ipmi_intf * intf, uint8_t authtype);
|
||||||
|
void ipmi_intf_session_set_timeout(struct ipmi_intf * intf, uint32_t timeout);
|
||||||
|
void ipmi_intf_session_set_retry(struct ipmi_intf * intf, int retry);
|
||||||
void ipmi_cleanup(struct ipmi_intf * intf);
|
void ipmi_cleanup(struct ipmi_intf * intf);
|
||||||
|
|
||||||
#endif /* IPMI_INTF_H */
|
#endif /* IPMI_INTF_H */
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
extern int verbose;
|
extern int verbose;
|
||||||
|
|
||||||
static int
|
int
|
||||||
ipmi_chassis_power_status(struct ipmi_intf * intf)
|
ipmi_chassis_power_status(struct ipmi_intf * intf)
|
||||||
{
|
{
|
||||||
struct ipmi_rs * rsp;
|
struct ipmi_rs * rsp;
|
||||||
@ -68,7 +68,14 @@ ipmi_chassis_power_status(struct ipmi_intf * intf)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Chassis Power is %s\n", (rsp->data[0] & 0x1) ? "on" : "off");
|
return rsp->data[0] & 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
ipmi_chassis_print_power_status(struct ipmi_intf * intf)
|
||||||
|
{
|
||||||
|
printf("Chassis Power is %s\n",
|
||||||
|
ipmi_chassis_power_status(intf) ? "on" : "off");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -242,6 +242,24 @@ ipmi_intf_session_set_authtype(struct ipmi_intf * intf, uint8_t authtype)
|
|||||||
intf->session->authtype_set = authtype;
|
intf->session->authtype_set = authtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ipmi_intf_session_set_timeout(struct ipmi_intf * intf, uint32_t timeout)
|
||||||
|
{
|
||||||
|
if (intf->session == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
intf->session->timeout = timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ipmi_intf_session_set_retry(struct ipmi_intf * intf, int retry)
|
||||||
|
{
|
||||||
|
if (intf->session == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
intf->session->retry = retry;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ipmi_cleanup(struct ipmi_intf * intf)
|
ipmi_cleanup(struct ipmi_intf * intf)
|
||||||
{
|
{
|
||||||
|
@ -223,7 +223,7 @@ struct ipmi_rs * ipmi_lan_recv_packet(struct ipmi_intf * intf)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
alarm(IPMI_LAN_TIMEOUT);
|
alarm(intf->session->timeout);
|
||||||
rc = recv(intf->fd, &rsp.data, IPMI_BUF_SIZE, 0);
|
rc = recv(intf->fd, &rsp.data, IPMI_BUF_SIZE, 0);
|
||||||
alarm(0);
|
alarm(0);
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ struct ipmi_rs * ipmi_lan_recv_packet(struct ipmi_intf * intf)
|
|||||||
* response is read before the connection refused is returned)
|
* response is read before the connection refused is returned)
|
||||||
*/
|
*/
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
alarm(IPMI_LAN_TIMEOUT);
|
alarm(intf->session->timeout);
|
||||||
rc = recv(intf->fd, &rsp.data, IPMI_BUF_SIZE, 0);
|
rc = recv(intf->fd, &rsp.data, IPMI_BUF_SIZE, 0);
|
||||||
alarm(0);
|
alarm(0);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
@ -726,7 +726,7 @@ ipmi_lan_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
if (++try >= IPMI_LAN_RETRY) {
|
if (++try >= intf->session->retry) {
|
||||||
lprintf(LOG_DEBUG, " No response from remote controller");
|
lprintf(LOG_DEBUG, " No response from remote controller");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1336,6 +1336,10 @@ int ipmi_lan_open(struct ipmi_intf * intf)
|
|||||||
s->port = IPMI_LAN_PORT;
|
s->port = IPMI_LAN_PORT;
|
||||||
if (s->privlvl == 0)
|
if (s->privlvl == 0)
|
||||||
s->privlvl = IPMI_SESSION_PRIV_ADMIN;
|
s->privlvl = IPMI_SESSION_PRIV_ADMIN;
|
||||||
|
if (s->timeout == 0)
|
||||||
|
s->timeout = IPMI_LAN_TIMEOUT;
|
||||||
|
if (s->retry == 0)
|
||||||
|
s->retry = IPMI_LAN_RETRY;
|
||||||
|
|
||||||
if (s->hostname == NULL || strlen(s->hostname) == 0) {
|
if (s->hostname == NULL || strlen(s->hostname) == 0) {
|
||||||
lprintf(LOG_ERR, "No hostname specified!");
|
lprintf(LOG_ERR, "No hostname specified!");
|
||||||
|
@ -2010,7 +2010,7 @@ ipmi_lanplus_send_payload(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while (try < IPMI_LAN_RETRY) {
|
while (try < session->retry) {
|
||||||
|
|
||||||
|
|
||||||
if (ipmi_lan_send_packet(intf, msg_data, msg_length) < 0) {
|
if (ipmi_lan_send_packet(intf, msg_data, msg_length) < 0) {
|
||||||
@ -3022,6 +3022,10 @@ ipmi_lanplus_open(struct ipmi_intf * intf)
|
|||||||
session->port = IPMI_LANPLUS_PORT;
|
session->port = IPMI_LANPLUS_PORT;
|
||||||
if (!session->privlvl)
|
if (!session->privlvl)
|
||||||
session->privlvl = IPMI_SESSION_PRIV_USER;
|
session->privlvl = IPMI_SESSION_PRIV_USER;
|
||||||
|
if (!session->timeout)
|
||||||
|
session->timeout = IPMI_LAN_TIMEOUT;
|
||||||
|
if (!session->retry)
|
||||||
|
session->retry = IPMI_LAN_RETRY;
|
||||||
|
|
||||||
if (session->hostname == NULL || strlen(session->hostname) == 0) {
|
if (session->hostname == NULL || strlen(session->hostname) == 0) {
|
||||||
lprintf(LOG_ERR, "No hostname specified!");
|
lprintf(LOG_ERR, "No hostname specified!");
|
||||||
@ -3042,7 +3046,6 @@ ipmi_lanplus_open(struct ipmi_intf * intf)
|
|||||||
//session->sol_data.last_received_byte_count = 0;
|
//session->sol_data.last_received_byte_count = 0;
|
||||||
memset(session->v2_data.sik, 0, IPMI_SIK_BUFFER_SIZE);
|
memset(session->v2_data.sik, 0, IPMI_SIK_BUFFER_SIZE);
|
||||||
memset(session->v2_data.kg, 0, IPMI_KG_BUFFER_SIZE);
|
memset(session->v2_data.kg, 0, IPMI_KG_BUFFER_SIZE);
|
||||||
session->timeout = IPMI_LAN_TIMEOUT;
|
|
||||||
|
|
||||||
|
|
||||||
/* open port to BMC */
|
/* open port to BMC */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user