diff options
Diffstat (limited to 'src/plugins/serial')
-rw-r--r-- | src/plugins/serial/Makefile.in | 2 | ||||
-rw-r--r-- | src/plugins/serial/serial_basic.c | 46 | ||||
-rw-r--r-- | src/plugins/serial/serial_terminal.c | 45 |
3 files changed, 35 insertions, 58 deletions
diff --git a/src/plugins/serial/Makefile.in b/src/plugins/serial/Makefile.in index 9826ebf..cae1857 100644 --- a/src/plugins/serial/Makefile.in +++ b/src/plugins/serial/Makefile.in @@ -241,6 +241,8 @@ INTF_OPEN = @INTF_OPEN@ INTF_OPEN_LIB = @INTF_OPEN_LIB@ INTF_SERIAL = @INTF_SERIAL@ INTF_SERIAL_LIB = @INTF_SERIAL_LIB@ +INTF_USB = @INTF_USB@ +INTF_USB_LIB = @INTF_USB_LIB@ IPMITOOL_INTF_LIB = @IPMITOOL_INTF_LIB@ LD = @LD@ LDFLAGS = @LDFLAGS@ diff --git a/src/plugins/serial/serial_basic.c b/src/plugins/serial/serial_basic.c index 871593f..fe2ebff 100644 --- a/src/plugins/serial/serial_basic.c +++ b/src/plugins/serial/serial_basic.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, Basic Mode plugin. */ +#include <alloca.h> #include <stdio.h> #include <fcntl.h> #include <time.h> @@ -183,16 +185,10 @@ static int is_system; static int serial_bm_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 = SERIAL_BM_MAX_RQ_SIZE; intf->max_response_data_size = SERIAL_BM_MAX_RS_SIZE; + return 0; } @@ -285,10 +281,10 @@ serial_bm_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 = SERIAL_BM_TIMEOUT; - if (intf->session->retry == 0) - intf->session->retry = SERIAL_BM_RETRY_COUNT; + if (intf->ssn_params.timeout == 0) + intf->ssn_params.timeout = SERIAL_BM_TIMEOUT; + if (intf->ssn_params.retry == 0) + intf->ssn_params.retry = SERIAL_BM_RETRY_COUNT; intf->opened = 1; @@ -459,7 +455,7 @@ serial_bm_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; @@ -887,7 +883,7 @@ serial_bm_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; } @@ -910,7 +906,7 @@ serial_bm_send_request(struct ipmi_intf * intf, struct ipmi_rq * req) read_ctx.max_buffer_size = SERIAL_BM_MAX_BUFFER_SIZE; /* 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_bm_build_msg(intf, req, msg, sizeof (msg), req_ctx, &msg_len); @@ -956,7 +952,7 @@ serial_bm_send_request(struct ipmi_intf * intf, struct ipmi_rq * req) /* check if response for inner request is not encapsulated */ } else if (rv == 1) { /* wait for response for inner request */ - rv = serial_bm_wait_response(intf, &req_ctx[0], + rv = serial_bm_wait_response(intf, &req_ctx[1], &read_ctx, msg, sizeof (msg)); /* check for IO error */ @@ -1003,22 +999,14 @@ serial_bm_send_request(struct ipmi_intf * intf, struct ipmi_rq * req) return NULL; } -int -serial_bm_set_my_addr(struct ipmi_intf * intf, uint8_t addr) -{ - intf->my_addr = addr; - return 0; -} - /* * Serial BM interface */ struct ipmi_intf ipmi_serial_bm_intf = { - name: "serial-basic", - desc: "Serial Interface, Basic Mode", - setup: serial_bm_setup, - open: serial_bm_open, - close: serial_bm_close, - sendrecv: serial_bm_send_request, - set_my_addr:serial_bm_set_my_addr + .name = "serial-basic", + .desc = "Serial Interface, Basic Mode", + .setup = serial_bm_setup, + .open = serial_bm_open, + .close = serial_bm_close, + .sendrecv = serial_bm_send_request, }; 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, }; |