lan.c (70984dcad503a28baed2a269aa725b4cfb19251e) lan.c (eb54136775f63a6a159f3c55ee4772d7aa363cc4)
1/*
2 * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistribution of source code must retain the above copyright

--- 248 unchanged lines hidden (view full) ---

257 int ret;
258
259 FD_ZERO(&read_set);
260 FD_SET(intf->fd, &read_set);
261
262 FD_ZERO(&err_set);
263 FD_SET(intf->fd, &err_set);
264
1/*
2 * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistribution of source code must retain the above copyright

--- 248 unchanged lines hidden (view full) ---

257 int ret;
258
259 FD_ZERO(&read_set);
260 FD_SET(intf->fd, &read_set);
261
262 FD_ZERO(&err_set);
263 FD_SET(intf->fd, &err_set);
264
265 tmout.tv_sec = intf->session->timeout;
265 tmout.tv_sec = intf->ssn_params.timeout;
266 tmout.tv_usec = 0;
267
268 ret = select(intf->fd + 1, &read_set, NULL, &err_set, &tmout);
269 if (ret < 0 || FD_ISSET(intf->fd, &err_set) || !FD_ISSET(intf->fd, &read_set))
270 return NULL;
271
272 /* the first read may return ECONNREFUSED because the rmcp ping
273 * packet--sent to UDP port 623--will be processed by both the

--- 9 unchanged lines hidden (view full) ---

283
284 if (ret < 0) {
285 FD_ZERO(&read_set);
286 FD_SET(intf->fd, &read_set);
287
288 FD_ZERO(&err_set);
289 FD_SET(intf->fd, &err_set);
290
266 tmout.tv_usec = 0;
267
268 ret = select(intf->fd + 1, &read_set, NULL, &err_set, &tmout);
269 if (ret < 0 || FD_ISSET(intf->fd, &err_set) || !FD_ISSET(intf->fd, &read_set))
270 return NULL;
271
272 /* the first read may return ECONNREFUSED because the rmcp ping
273 * packet--sent to UDP port 623--will be processed by both the

--- 9 unchanged lines hidden (view full) ---

283
284 if (ret < 0) {
285 FD_ZERO(&read_set);
286 FD_SET(intf->fd, &read_set);
287
288 FD_ZERO(&err_set);
289 FD_SET(intf->fd, &err_set);
290
291 tmout.tv_sec = intf->session->timeout;
291 tmout.tv_sec = intf->ssn_params.timeout;
292 tmout.tv_usec = 0;
293
294 ret = select(intf->fd + 1, &read_set, NULL, &err_set, &tmout);
295 if (ret < 0 || FD_ISSET(intf->fd, &err_set) || !FD_ISSET(intf->fd, &read_set))
296 return NULL;
297
298 ret = recv(intf->fd, &rsp.data, IPMI_BUF_SIZE, 0);
299 if (ret < 0)

--- 650 unchanged lines hidden (view full) ---

950 rsp = NULL;
951 rsp = ipmi_lan_poll_recv(intf);
952 }
953
954 if (rsp)
955 break;
956
957 usleep(5000);
292 tmout.tv_usec = 0;
293
294 ret = select(intf->fd + 1, &read_set, NULL, &err_set, &tmout);
295 if (ret < 0 || FD_ISSET(intf->fd, &err_set) || !FD_ISSET(intf->fd, &read_set))
296 return NULL;
297
298 ret = recv(intf->fd, &rsp.data, IPMI_BUF_SIZE, 0);
299 if (ret < 0)

--- 650 unchanged lines hidden (view full) ---

950 rsp = NULL;
951 rsp = ipmi_lan_poll_recv(intf);
952 }
953
954 if (rsp)
955 break;
956
957 usleep(5000);
958 if (++try >= intf->session->retry) {
958 if (++try >= intf->ssn_params.retry) {
959 lprintf(LOG_DEBUG, " No response from remote controller");
960 break;
961 }
962 }
963
964 // We need to cleanup the existing entries from the list. Because if we
965 // keep it and then when we send the new command and if the response is for
966 // old command it still matches it and then returns success.

--- 333 unchanged lines hidden (view full) ---

1300 /*
1301 * We're still waiting for our ACK, but we more data from
1302 * the BMC
1303 */
1304 intf->session->sol_data.sol_input_handler(rsp);
1305 }
1306
1307 usleep(5000);
959 lprintf(LOG_DEBUG, " No response from remote controller");
960 break;
961 }
962 }
963
964 // We need to cleanup the existing entries from the list. Because if we
965 // keep it and then when we send the new command and if the response is for
966 // old command it still matches it and then returns success.

--- 333 unchanged lines hidden (view full) ---

1300 /*
1301 * We're still waiting for our ACK, but we more data from
1302 * the BMC
1303 */
1304 intf->session->sol_data.sol_input_handler(rsp);
1305 }
1306
1307 usleep(5000);
1308 if (++try >= intf->session->retry) {
1308 if (++try >= intf->ssn_params.retry) {
1309 lprintf(LOG_DEBUG, " No response from remote controller");
1310 break;
1311 }
1312 }
1313
1314 if (msg != NULL) {
1315 free(msg);
1316 msg = NULL;

--- 258 unchanged lines hidden (view full) ---

1575 * IPMI Get Channel Authentication Capabilities Command
1576 */
1577static int
1578ipmi_get_auth_capabilities_cmd(struct ipmi_intf * intf)
1579{
1580 struct ipmi_rs * rsp;
1581 struct ipmi_rq req;
1582 struct ipmi_session * s = intf->session;
1309 lprintf(LOG_DEBUG, " No response from remote controller");
1310 break;
1311 }
1312 }
1313
1314 if (msg != NULL) {
1315 free(msg);
1316 msg = NULL;

--- 258 unchanged lines hidden (view full) ---

1575 * IPMI Get Channel Authentication Capabilities Command
1576 */
1577static int
1578ipmi_get_auth_capabilities_cmd(struct ipmi_intf * intf)
1579{
1580 struct ipmi_rs * rsp;
1581 struct ipmi_rq req;
1582 struct ipmi_session * s = intf->session;
1583 struct ipmi_session_params *p = &intf->ssn_params;
1583 uint8_t msg_data[2];
1584
1585 msg_data[0] = IPMI_LAN_CHANNEL_E;
1584 uint8_t msg_data[2];
1585
1586 msg_data[0] = IPMI_LAN_CHANNEL_E;
1586 msg_data[1] = s->privlvl;
1587 msg_data[1] = p->privlvl;
1587
1588 memset(&req, 0, sizeof(req));
1589 req.msg.netfn = IPMI_NETFN_APP;
1590 req.msg.cmd = 0x38;
1591 req.msg.data = msg_data;
1592 req.msg.data_len = 2;
1593
1594 rsp = intf->sendrecv(intf, &req);

--- 34 unchanged lines hidden (view full) ---

1629 "en" : "dis");
1630 lprintf(LOG_DEBUG, " Anonymous login : %sabled",
1631 (rsp->data[2] & IPMI_AUTHSTATUS_ANONYMOUS_USERS_ENABLED) ?
1632 "en" : "dis");
1633 lprintf(LOG_DEBUG, "");
1634
1635 s->authstatus = rsp->data[2];
1636
1588
1589 memset(&req, 0, sizeof(req));
1590 req.msg.netfn = IPMI_NETFN_APP;
1591 req.msg.cmd = 0x38;
1592 req.msg.data = msg_data;
1593 req.msg.data_len = 2;
1594
1595 rsp = intf->sendrecv(intf, &req);

--- 34 unchanged lines hidden (view full) ---

1630 "en" : "dis");
1631 lprintf(LOG_DEBUG, " Anonymous login : %sabled",
1632 (rsp->data[2] & IPMI_AUTHSTATUS_ANONYMOUS_USERS_ENABLED) ?
1633 "en" : "dis");
1634 lprintf(LOG_DEBUG, "");
1635
1636 s->authstatus = rsp->data[2];
1637
1637 if (s->password &&
1638 (s->authtype_set == 0 ||
1639 s->authtype_set == IPMI_SESSION_AUTHTYPE_MD5) &&
1638 if (p->password &&
1639 (p->authtype_set == 0 ||
1640 p->authtype_set == IPMI_SESSION_AUTHTYPE_MD5) &&
1640 (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_MD5))
1641 {
1642 s->authtype = IPMI_SESSION_AUTHTYPE_MD5;
1643 }
1641 (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_MD5))
1642 {
1643 s->authtype = IPMI_SESSION_AUTHTYPE_MD5;
1644 }
1644 else if (s->password &&
1645 (s->authtype_set == 0 ||
1646 s->authtype_set == IPMI_SESSION_AUTHTYPE_MD2) &&
1645 else if (p->password &&
1646 (p->authtype_set == 0 ||
1647 p->authtype_set == IPMI_SESSION_AUTHTYPE_MD2) &&
1647 (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_MD2))
1648 {
1649 s->authtype = IPMI_SESSION_AUTHTYPE_MD2;
1650 }
1648 (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_MD2))
1649 {
1650 s->authtype = IPMI_SESSION_AUTHTYPE_MD2;
1651 }
1651 else if (s->password &&
1652 (s->authtype_set == 0 ||
1653 s->authtype_set == IPMI_SESSION_AUTHTYPE_PASSWORD) &&
1652 else if (p->password &&
1653 (p->authtype_set == 0 ||
1654 p->authtype_set == IPMI_SESSION_AUTHTYPE_PASSWORD) &&
1654 (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_PASSWORD))
1655 {
1656 s->authtype = IPMI_SESSION_AUTHTYPE_PASSWORD;
1657 }
1655 (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_PASSWORD))
1656 {
1657 s->authtype = IPMI_SESSION_AUTHTYPE_PASSWORD;
1658 }
1658 else if (s->password &&
1659 (s->authtype_set == 0 ||
1660 s->authtype_set == IPMI_SESSION_AUTHTYPE_OEM) &&
1659 else if (p->password &&
1660 (p->authtype_set == 0 ||
1661 p->authtype_set == IPMI_SESSION_AUTHTYPE_OEM) &&
1661 (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_OEM))
1662 {
1663 s->authtype = IPMI_SESSION_AUTHTYPE_OEM;
1664 }
1662 (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_OEM))
1663 {
1664 s->authtype = IPMI_SESSION_AUTHTYPE_OEM;
1665 }
1665 else if ((s->authtype_set == 0 ||
1666 s->authtype_set == IPMI_SESSION_AUTHTYPE_NONE) &&
1666 else if ((p->authtype_set == 0 ||
1667 p->authtype_set == IPMI_SESSION_AUTHTYPE_NONE) &&
1667 (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_NONE))
1668 {
1669 s->authtype = IPMI_SESSION_AUTHTYPE_NONE;
1670 }
1671 else {
1668 (rsp->data[1] & 1<<IPMI_SESSION_AUTHTYPE_NONE))
1669 {
1670 s->authtype = IPMI_SESSION_AUTHTYPE_NONE;
1671 }
1672 else {
1672 if (!(rsp->data[1] & 1<<s->authtype_set))
1673 if (!(rsp->data[1] & 1<<p->authtype_set))
1673 lprintf(LOG_ERR, "Authentication type %s not supported",
1674 lprintf(LOG_ERR, "Authentication type %s not supported",
1674 val2str(s->authtype_set, ipmi_authtype_session_vals));
1675 val2str(p->authtype_set, ipmi_authtype_session_vals));
1675 else
1676 lprintf(LOG_ERR, "No supported authtypes found");
1677
1678 return -1;
1679 }
1680
1681 lprintf(LOG_DEBUG, "Proceeding with AuthType %s",
1682 val2str(s->authtype, ipmi_authtype_session_vals));

--- 10 unchanged lines hidden (view full) ---

1693{
1694 struct ipmi_rs * rsp;
1695 struct ipmi_rq req;
1696 struct ipmi_session * s = intf->session;
1697 uint8_t msg_data[17];
1698
1699 memset(msg_data, 0, 17);
1700 msg_data[0] = s->authtype;
1676 else
1677 lprintf(LOG_ERR, "No supported authtypes found");
1678
1679 return -1;
1680 }
1681
1682 lprintf(LOG_DEBUG, "Proceeding with AuthType %s",
1683 val2str(s->authtype, ipmi_authtype_session_vals));

--- 10 unchanged lines hidden (view full) ---

1694{
1695 struct ipmi_rs * rsp;
1696 struct ipmi_rq req;
1697 struct ipmi_session * s = intf->session;
1698 uint8_t msg_data[17];
1699
1700 memset(msg_data, 0, 17);
1701 msg_data[0] = s->authtype;
1701 memcpy(msg_data+1, s->username, 16);
1702 memcpy(msg_data+1, intf->ssn_params.username, 16);
1702
1703 memset(&req, 0, sizeof(req));
1704 req.msg.netfn = IPMI_NETFN_APP;
1705 req.msg.cmd = 0x39;
1706 req.msg.data = msg_data;
1707 req.msg.data_len = 17; /* 1 byte for authtype, 16 for user */
1708
1709 rsp = intf->sendrecv(intf, &req);

--- 40 unchanged lines hidden (view full) ---

1750 struct ipmi_session * s = intf->session;
1751 uint8_t msg_data[22];
1752
1753 memset(&req, 0, sizeof(req));
1754 req.msg.netfn = IPMI_NETFN_APP;
1755 req.msg.cmd = 0x3a;
1756
1757 msg_data[0] = s->authtype;
1703
1704 memset(&req, 0, sizeof(req));
1705 req.msg.netfn = IPMI_NETFN_APP;
1706 req.msg.cmd = 0x39;
1707 req.msg.data = msg_data;
1708 req.msg.data_len = 17; /* 1 byte for authtype, 16 for user */
1709
1710 rsp = intf->sendrecv(intf, &req);

--- 40 unchanged lines hidden (view full) ---

1751 struct ipmi_session * s = intf->session;
1752 uint8_t msg_data[22];
1753
1754 memset(&req, 0, sizeof(req));
1755 req.msg.netfn = IPMI_NETFN_APP;
1756 req.msg.cmd = 0x3a;
1757
1758 msg_data[0] = s->authtype;
1758 msg_data[1] = s->privlvl;
1759 msg_data[1] = intf->ssn_params.privlvl;
1759
1760 /* supermicro oem authentication hack */
1761 if (ipmi_oem_active(intf, "supermicro")) {
1762 uint8_t * special = ipmi_auth_special(s);
1760
1761 /* supermicro oem authentication hack */
1762 if (ipmi_oem_active(intf, "supermicro")) {
1763 uint8_t * special = ipmi_auth_special(s);
1763 memcpy(s->authcode, special, 16);
1764 memcpy(intf->session->authcode, special, 16);
1764 memset(msg_data + 2, 0, 16);
1765 lprintf(LOG_DEBUG, " OEM Auth : %s",
1766 buf2str(special, 16));
1767 } else {
1768 memcpy(msg_data + 2, s->challenge, 16);
1769 }
1770
1771 /* setup initial outbound sequence number */

--- 60 unchanged lines hidden (view full) ---

1832 if (s->authstatus & IPMI_AUTHSTATUS_PER_MSG_DISABLED)
1833 s->authtype = IPMI_SESSION_AUTHTYPE_NONE;
1834 else if (s->authtype != (rsp->data[0] & 0xf)) {
1835 lprintf(LOG_ERR, "Invalid Session AuthType %s in response",
1836 val2str(s->authtype, ipmi_authtype_session_vals));
1837 return -1;
1838 }
1839
1765 memset(msg_data + 2, 0, 16);
1766 lprintf(LOG_DEBUG, " OEM Auth : %s",
1767 buf2str(special, 16));
1768 } else {
1769 memcpy(msg_data + 2, s->challenge, 16);
1770 }
1771
1772 /* setup initial outbound sequence number */

--- 60 unchanged lines hidden (view full) ---

1833 if (s->authstatus & IPMI_AUTHSTATUS_PER_MSG_DISABLED)
1834 s->authtype = IPMI_SESSION_AUTHTYPE_NONE;
1835 else if (s->authtype != (rsp->data[0] & 0xf)) {
1836 lprintf(LOG_ERR, "Invalid Session AuthType %s in response",
1837 val2str(s->authtype, ipmi_authtype_session_vals));
1838 return -1;
1839 }
1840
1840 bridge_possible = 1;
1841
1842 lprintf(LOG_DEBUG, "\nSession Activated");
1843 lprintf(LOG_DEBUG, " Auth Type : %s",
1844 val2str(rsp->data[0], ipmi_authtype_session_vals));
1845 lprintf(LOG_DEBUG, " Max Priv Level : %s",
1846 val2str(rsp->data[9], ipmi_privlvl_vals));
1847 lprintf(LOG_DEBUG, " Session ID : %08lx", (long)s->session_id);
1848 lprintf(LOG_DEBUG, " Inbound Seq : %08lx\n", (long)s->in_seq);
1849

--- 4 unchanged lines hidden (view full) ---

1854/*
1855 * IPMI Set Session Privilege Level Command
1856 */
1857static int
1858ipmi_set_session_privlvl_cmd(struct ipmi_intf * intf)
1859{
1860 struct ipmi_rs * rsp;
1861 struct ipmi_rq req;
1841 lprintf(LOG_DEBUG, "\nSession Activated");
1842 lprintf(LOG_DEBUG, " Auth Type : %s",
1843 val2str(rsp->data[0], ipmi_authtype_session_vals));
1844 lprintf(LOG_DEBUG, " Max Priv Level : %s",
1845 val2str(rsp->data[9], ipmi_privlvl_vals));
1846 lprintf(LOG_DEBUG, " Session ID : %08lx", (long)s->session_id);
1847 lprintf(LOG_DEBUG, " Inbound Seq : %08lx\n", (long)s->in_seq);
1848

--- 4 unchanged lines hidden (view full) ---

1853/*
1854 * IPMI Set Session Privilege Level Command
1855 */
1856static int
1857ipmi_set_session_privlvl_cmd(struct ipmi_intf * intf)
1858{
1859 struct ipmi_rs * rsp;
1860 struct ipmi_rq req;
1862 uint8_t privlvl = intf->session->privlvl;
1861 uint8_t privlvl = intf->ssn_params.privlvl;
1863 uint8_t backup_bridge_possible = bridge_possible;
1864
1865 if (privlvl <= IPMI_SESSION_PRIV_USER)
1866 return 0; /* no need to set higher */
1867
1868 memset(&req, 0, sizeof(req));
1869 req.msg.netfn = IPMI_NETFN_APP;
1870 req.msg.cmd = 0x3b;

--- 116 unchanged lines hidden (view full) ---

1987 rc = ipmi_activate_session_cmd(intf);
1988 if (rc < 0)
1989 goto fail;
1990
1991 intf->abort = 0;
1992
1993 rc = ipmi_set_session_privlvl_cmd(intf);
1994 if (rc < 0)
1862 uint8_t backup_bridge_possible = bridge_possible;
1863
1864 if (privlvl <= IPMI_SESSION_PRIV_USER)
1865 return 0; /* no need to set higher */
1866
1867 memset(&req, 0, sizeof(req));
1868 req.msg.netfn = IPMI_NETFN_APP;
1869 req.msg.cmd = 0x3b;

--- 116 unchanged lines hidden (view full) ---

1986 rc = ipmi_activate_session_cmd(intf);
1987 if (rc < 0)
1988 goto fail;
1989
1990 intf->abort = 0;
1991
1992 rc = ipmi_set_session_privlvl_cmd(intf);
1993 if (rc < 0)
1995 goto fail;
1994 goto close_fail;
1996
1997 return 0;
1998
1995
1996 return 0;
1997
1998 close_fail:
1999 ipmi_close_session_cmd(intf);
1999 fail:
2000 lprintf(LOG_ERR, "Error: Unable to establish LAN session");
2001 return -1;
2002}
2003
2000 fail:
2001 lprintf(LOG_ERR, "Error: Unable to establish LAN session");
2002 return -1;
2003}
2004
2004static void
2005void
2005ipmi_lan_close(struct ipmi_intf * intf)
2006{
2006ipmi_lan_close(struct ipmi_intf * intf)
2007{
2007 if (intf->abort == 0)
2008 if (!intf->abort && intf->session)
2008 ipmi_close_session_cmd(intf);
2009
2009 ipmi_close_session_cmd(intf);
2010
2010 if (intf->fd >= 0)
2011 if (intf->fd >= 0) {
2011 close(intf->fd);
2012 close(intf->fd);
2013 intf->fd = -1;
2014 }
2012
2013 ipmi_req_clear_entries();
2014 ipmi_intf_session_cleanup(intf);
2015 intf->opened = 0;
2016 intf->manufacturer_id = IPMI_OEM_UNKNOWN;
2017 intf = NULL;
2018}
2019
2020static int
2021ipmi_lan_open(struct ipmi_intf * intf)
2022{
2023 int rc;
2024 struct ipmi_session *s;
2015
2016 ipmi_req_clear_entries();
2017 ipmi_intf_session_cleanup(intf);
2018 intf->opened = 0;
2019 intf->manufacturer_id = IPMI_OEM_UNKNOWN;
2020 intf = NULL;
2021}
2022
2023static int
2024ipmi_lan_open(struct ipmi_intf * intf)
2025{
2026 int rc;
2027 struct ipmi_session *s;
2028 struct ipmi_session_params *p;
2029 struct sockaddr_storage addr;
2025
2030
2026 if (intf == NULL || intf->session == NULL)
2031 if (intf == NULL || intf->opened)
2027 return -1;
2032 return -1;
2033
2028 s = intf->session;
2034 s = intf->session;
2035 p = &intf->ssn_params;
2029
2036
2030 if (s->port == 0)
2031 s->port = IPMI_LAN_PORT;
2032 if (s->privlvl == 0)
2033 s->privlvl = IPMI_SESSION_PRIV_ADMIN;
2034 if (s->timeout == 0)
2035 s->timeout = IPMI_LAN_TIMEOUT;
2036 if (s->retry == 0)
2037 s->retry = IPMI_LAN_RETRY;
2037 if (p->port == 0)
2038 p->port = IPMI_LAN_PORT;
2039 if (p->privlvl == 0)
2040 p->privlvl = IPMI_SESSION_PRIV_ADMIN;
2041 if (p->timeout == 0)
2042 p->timeout = IPMI_LAN_TIMEOUT;
2043 if (p->retry == 0)
2044 p->retry = IPMI_LAN_RETRY;
2038
2045
2039 if (s->hostname == NULL || strlen((const char *)s->hostname) == 0) {
2046 if (p->hostname == NULL || strlen((const char *)p->hostname) == 0) {
2040 lprintf(LOG_ERR, "No hostname specified!");
2041 return -1;
2042 }
2043
2047 lprintf(LOG_ERR, "No hostname specified!");
2048 return -1;
2049 }
2050
2044 intf->abort = 1;
2045
2046 intf->session->sol_data.sequence_number = 1;
2047
2048 if (ipmi_intf_socket_connect (intf) == -1) {
2051 if (ipmi_intf_socket_connect(intf) == -1) {
2049 lprintf(LOG_ERR, "Could not open socket!");
2050 return -1;
2051 }
2052
2052 lprintf(LOG_ERR, "Could not open socket!");
2053 return -1;
2054 }
2055
2053 if (intf->fd < 0) {
2054 lperror(LOG_ERR, "Connect to %s failed",
2055 s->hostname);
2056 intf->close(intf);
2057 return -1;
2056 s = (struct ipmi_session *)malloc(sizeof(struct ipmi_session));
2057 if (!s) {
2058 lprintf(LOG_ERR, "ipmitool: malloc failure");
2059 goto fail;
2058 }
2059
2060 intf->opened = 1;
2060 }
2061
2062 intf->opened = 1;
2063 intf->abort = 1;
2061
2064
2065 intf->session = s;
2066
2067 memset(s, 0, sizeof(struct ipmi_session));
2068 s->sol_data.sequence_number = 1;
2069 s->timeout = p->timeout;
2070 memcpy(&s->authcode, &p->authcode_set, sizeof(s->authcode));
2071 s->addrlen = sizeof(s->addr);
2072 if (getsockname(intf->fd, &s->addr, &s->addrlen)) {
2073 goto fail;
2074 }
2075
2062 /* try to open session */
2063 rc = ipmi_lan_activate_session(intf);
2064 if (rc < 0) {
2076 /* try to open session */
2077 rc = ipmi_lan_activate_session(intf);
2078 if (rc < 0) {
2065 intf->close(intf);
2066 intf->opened = 0;
2067 return -1;
2079 goto fail;
2068 }
2069
2080 }
2081
2070 intf->manufacturer_id = ipmi_get_oem(intf);
2071
2072 /* automatically detect interface request and response sizes */
2073 hpm2_detect_max_payload_size(intf);
2074
2082 /* automatically detect interface request and response sizes */
2083 hpm2_detect_max_payload_size(intf);
2084
2085 /* set manufactirer OEM id */
2086 intf->manufacturer_id = ipmi_get_oem(intf);
2087
2088 /* now allow bridging */
2089 bridge_possible = 1;
2075 return intf->fd;
2090 return intf->fd;
2091
2092 fail:
2093 lprintf(LOG_ERR, "Error: Unable to establish IPMI v1.5 / RMCP session");
2094 intf->close(intf);
2095 return -1;
2076}
2077
2078static int
2079ipmi_lan_setup(struct ipmi_intf * intf)
2080{
2096}
2097
2098static int
2099ipmi_lan_setup(struct ipmi_intf * intf)
2100{
2081 intf->session = malloc(sizeof(struct ipmi_session));
2082 if (intf->session == NULL) {
2083 lprintf(LOG_ERR, "ipmitool: malloc failure");
2084 return -1;
2085 }
2086 memset(intf->session, 0, sizeof(struct ipmi_session));
2087
2088 /* setup default LAN maximum request and response sizes */
2089 intf->max_request_data_size = IPMI_LAN_MAX_REQUEST_SIZE;
2090 intf->max_response_data_size = IPMI_LAN_MAX_RESPONSE_SIZE;
2091
2092 return 0;
2093}
2094
2095static void

--- 18 unchanged lines hidden ---
2101 /* setup default LAN maximum request and response sizes */
2102 intf->max_request_data_size = IPMI_LAN_MAX_REQUEST_SIZE;
2103 intf->max_response_data_size = IPMI_LAN_MAX_RESPONSE_SIZE;
2104
2105 return 0;
2106}
2107
2108static void

--- 18 unchanged lines hidden ---