From 9fd9b29cb5524967b3bf49beb680cb57f56229eb Mon Sep 17 00:00:00 2001 From: Duncan Laurie Date: Tue, 11 Apr 2006 00:47:49 +0000 Subject: [PATCH] clear ipmi_rq before using to remove garbage data like LUN. throttle keystroke errors unless verbose --- ipmitool/lib/ipmi_tsol.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/ipmitool/lib/ipmi_tsol.c b/ipmitool/lib/ipmi_tsol.c index 5efec0f..486051f 100644 --- a/ipmitool/lib/ipmi_tsol.c +++ b/ipmitool/lib/ipmi_tsol.c @@ -73,6 +73,8 @@ static struct winsize _saved_winsize; static int _in_raw_mode = 0; static int _altterm = 0; +extern int verbose; + static int ipmi_tsol_command(struct ipmi_intf * intf, char *recvip, int port, unsigned char cmd) { @@ -93,6 +95,7 @@ ipmi_tsol_command(struct ipmi_intf * intf, char *recvip, int port, unsigned char return -1; } + memset(&req, 0, sizeof(struct ipmi_rq)); req.msg.netfn = IPMI_NETFN_TSOL; req.msg.cmd = cmd; req.msg.data_len = 6; @@ -139,7 +142,8 @@ ipmi_tsol_send_keystroke(struct ipmi_intf * intf, char *buff, int length) struct ipmi_rq req; unsigned char data[16]; static unsigned char keyseq = 0; - + + memset(&req, 0, sizeof(struct ipmi_rq)); req.msg.netfn = IPMI_NETFN_TSOL; req.msg.cmd = IPMI_TSOL_CMD_SENDKEY; req.msg.data_len = length + 2; @@ -151,15 +155,17 @@ ipmi_tsol_send_keystroke(struct ipmi_intf * intf, char *buff, int length) data[length + 1] = keyseq++; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { - lprintf(LOG_ERR, "Unable to send keystroke"); - return -1; + if (verbose) { + if (rsp == NULL) { + lprintf(LOG_ERR, "Unable to send keystroke"); + return -1; + } + if (rsp->ccode > 0) { + lprintf(LOG_ERR, "Unable to send keystroke: %s", + val2str(rsp->ccode, completion_code_vals)); + return -1; + } } - if (rsp->ccode > 0) { - lprintf(LOG_ERR, "Unable to send keystroke: %s", - val2str(rsp->ccode, completion_code_vals)); - return -1; - } return length; }