mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47:22 +00:00
send periodic keepalive packet when SOL is active to keep session open
This commit is contained in:
parent
79befbb112
commit
66cb3143dc
@ -40,6 +40,7 @@
|
||||
#include <ipmitool/ipmi.h>
|
||||
|
||||
#define SOL_ESCAPE_CHARACTER_DEFAULT '~'
|
||||
#define SOL_KEEPALIVE_TIMEOUT 30
|
||||
|
||||
#define IPMI_SOL_SERIAL_ALERT_MASK_SUCCEED 0x08
|
||||
#define IPMI_SOL_SERIAL_ALERT_MASK_DEFERRED 0x04
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -81,6 +82,7 @@ const struct valstr sol_parameter_vals[] = {
|
||||
};
|
||||
|
||||
|
||||
static struct timeval _start_keepalive;
|
||||
static struct termios _saved_tio;
|
||||
static int _in_raw_mode = 0;
|
||||
|
||||
@ -1251,21 +1253,40 @@ processSolUserInput(
|
||||
|
||||
if (! rsp)
|
||||
{
|
||||
lprintf(LOG_ERR, "Error sending SOL data");
|
||||
retval = -1;
|
||||
rsp = intf->send_sol(intf, &v2_payload);
|
||||
lprintf(LOG_ERR, "Error sending SOL data: RETRY");
|
||||
if (! rsp)
|
||||
{
|
||||
lprintf(LOG_ERR, "Error sending SOL data: FAIL");
|
||||
retval = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* If the sequence number is set we know we have new data */
|
||||
else if ((rsp->session.authtype == IPMI_SESSION_AUTHTYPE_RMCP_PLUS) &&
|
||||
(rsp->session.payloadtype == IPMI_PAYLOAD_TYPE_SOL) &&
|
||||
(rsp->payload.sol_packet.packet_sequence_number))
|
||||
output(rsp);
|
||||
if (retval == 0)
|
||||
if ((rsp->session.authtype == IPMI_SESSION_AUTHTYPE_RMCP_PLUS) &&
|
||||
(rsp->session.payloadtype == IPMI_PAYLOAD_TYPE_SOL) &&
|
||||
(rsp->payload.sol_packet.packet_sequence_number))
|
||||
output(rsp);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ipmi_sol_keepalive(struct ipmi_intf * intf)
|
||||
{
|
||||
struct timeval end;
|
||||
|
||||
gettimeofday(&end, 0);
|
||||
|
||||
if (end.tv_sec - _start_keepalive.tv_sec > SOL_KEEPALIVE_TIMEOUT) {
|
||||
intf->keepalive(intf);
|
||||
gettimeofday(&_start_keepalive, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ipmi_sol_red_pill
|
||||
@ -1289,6 +1310,9 @@ ipmi_sol_red_pill(struct ipmi_intf * intf)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Initialize keepalive start time */
|
||||
gettimeofday(&_start_keepalive, 0);
|
||||
|
||||
enter_raw_mode();
|
||||
|
||||
while (! bShouldExit)
|
||||
@ -1297,6 +1321,9 @@ ipmi_sol_red_pill(struct ipmi_intf * intf)
|
||||
FD_SET(0, &read_fds);
|
||||
FD_SET(intf->fd, &read_fds);
|
||||
|
||||
/* Send periodic keepalive packet */
|
||||
ipmi_sol_keepalive(intf);
|
||||
|
||||
/* Wait up to half a second */
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 500000;
|
||||
|
Loading…
x
Reference in New Issue
Block a user