diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-02-20 02:12:40 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-02-20 02:12:40 +0100 |
commit | 97d6a2e491c6ed08473beb2c4bac47c5cbc1201a (patch) | |
tree | 728b931c62b22ea55a13b292f6f77930897067fd /src/plugins/serial/serial_terminal.c | |
parent | 55031e72e6c02b4ae63e9052bad1a4b40002ac18 (diff) |
Imported Upstream version 1.8.16upstream/1.8.16
Diffstat (limited to 'src/plugins/serial/serial_terminal.c')
-rw-r--r-- | src/plugins/serial/serial_terminal.c | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/src/plugins/serial/serial_terminal.c b/src/plugins/serial/serial_terminal.c index 34c6fc5..dfcc202 100644 --- a/src/plugins/serial/serial_terminal.c +++ b/src/plugins/serial/serial_terminal.c @@ -29,9 +29,11 @@ * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, * EVEN IF PPS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. */ +#define _GNU_SOURCE 1 /* Serial Interface, Terminal Mode plugin. */ +#include <alloca.h> #include <stdio.h> #include <fcntl.h> #include <unistd.h> @@ -225,10 +227,10 @@ ipmi_serial_term_open(struct ipmi_intf * intf) /* set the new options for the port with flushing */ tcsetattr(intf->fd, TCSAFLUSH, &ti); - if (intf->session->timeout == 0) - intf->session->timeout = IPMI_SERIAL_TIMEOUT; - if (intf->session->retry == 0) - intf->session->retry = IPMI_SERIAL_RETRY; + if (intf->ssn_params.timeout == 0) + intf->ssn_params.timeout = IPMI_SERIAL_TIMEOUT; + if (intf->ssn_params.retry == 0) + intf->ssn_params.retry = IPMI_SERIAL_RETRY; intf->opened = 1; @@ -259,7 +261,7 @@ serial_wait_for_data(struct ipmi_intf * intf) pfd.events = POLLIN; pfd.revents = 0; - n = poll(&pfd, 1, intf->session->timeout*1000); + n = poll(&pfd, 1, intf->ssn_params.timeout*1000); if (n < 0) { lperror(LOG_ERR, "Poll for serial data failed"); return -1; @@ -357,7 +359,7 @@ recv_response(struct ipmi_intf * intf, unsigned char *data, int len) { char hex_rs[IPMI_SERIAL_MAX_RESPONSE * 3]; int i, j, resp_len = 0; - unsigned long rv; + long rv; char *p, *pp; char ch, str_hex[3]; @@ -769,7 +771,7 @@ serial_term_get_message(struct ipmi_intf * intf, tm = clock() - start; tm /= CLOCKS_PER_SEC; - } while (tm < intf->session->timeout); + } while (tm < intf->ssn_params.timeout); return 0; } @@ -787,7 +789,7 @@ ipmi_serial_term_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req) } /* Send the message and receive the answer */ - for (retry = 0; retry < intf->session->retry; retry++) { + for (retry = 0; retry < intf->ssn_params.retry; retry++) { /* build output message */ bridging_level = serial_term_build_msg(intf, req, msg, sizeof (msg), req_ctx, &msg_len); @@ -882,33 +884,18 @@ ipmi_serial_term_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req) static int ipmi_serial_term_setup(struct ipmi_intf * intf) { - intf->session = malloc(sizeof(struct ipmi_session)); - if (intf->session == NULL) { - lprintf(LOG_ERR, "ipmitool: malloc failure"); - return -1; - } - - memset(intf->session, 0, sizeof(struct ipmi_session)); - /* setup default LAN maximum request and response sizes */ intf->max_request_data_size = IPMI_SERIAL_MAX_RQ_SIZE; intf->max_response_data_size = IPMI_SERIAL_MAX_RS_SIZE; - return 0; -} -int -ipmi_serial_term_set_my_addr(struct ipmi_intf * intf, uint8_t addr) -{ - intf->my_addr = addr; return 0; } struct ipmi_intf ipmi_serial_term_intf = { - name: "serial-terminal", - desc: "Serial Interface, Terminal Mode", - setup: ipmi_serial_term_setup, - open: ipmi_serial_term_open, - close: ipmi_serial_term_close, - sendrecv: ipmi_serial_term_send_cmd, - set_my_addr:ipmi_serial_term_set_my_addr + .name = "serial-terminal", + .desc = "Serial Interface, Terminal Mode", + .setup = ipmi_serial_term_setup, + .open = ipmi_serial_term_open, + .close = ipmi_serial_term_close, + .sendrecv = ipmi_serial_term_send_cmd, }; |