summaryrefslogtreecommitdiff
path: root/lib/lanplus/lanplus.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2019-08-11 12:11:26 +0200
committerJörg Frings-Fürst <debian@jff.email>2019-08-11 12:11:26 +0200
commit3d8ccff2a698e62e112f58f8c329b77ae71b8cbd (patch)
tree67892ebc654ed9860eb3517c8913b23670aa211e /lib/lanplus/lanplus.c
parentcb4c53adfa077477b1dd784b200e0a8f9fff2afc (diff)
parent148652fc7e5cdf14c30dd11be98e0d2e4c39d7bb (diff)
Merge branch 'release/debian/3.1.4-1'debian/3.1.4-1
Diffstat (limited to 'lib/lanplus/lanplus.c')
-rw-r--r--lib/lanplus/lanplus.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/lib/lanplus/lanplus.c b/lib/lanplus/lanplus.c
index e423ede..c910b85 100644
--- a/lib/lanplus/lanplus.c
+++ b/lib/lanplus/lanplus.c
@@ -32,19 +32,18 @@
/* ARCress, TODO: improve error handling and remove all assert() calls here. */
#ifdef WIN32
-#include <windows.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <inttypes-win.h>
-#include <io.h>
-#include <signal.h>
-//#define HAVE_IPV6 1
#ifdef HAVE_IPV6
#include <winsock2.h>
//#include <ws2tcpip.h>
#else
#include <winsock.h>
#endif
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <inttypes-win.h>
+#include <io.h>
+#include <signal.h>
#include <time.h>
#else
#include <stdlib.h>
@@ -103,7 +102,11 @@ static int my_ai_flags = AI_NUMERICSERV; /*0x0400 Dont use name resolution NEW*/
#undef HAVE_IPV6
#endif
#ifdef HAVE_IPV6
+#ifdef WIN32
+#define SOCKADDR_T SOCKADDR_STORAGE
+#else
#define SOCKADDR_T struct sockaddr_storage
+#endif
#else
#define SOCKADDR_T struct sockaddr_in
#endif
@@ -3703,7 +3706,7 @@ ipmi_lanplus_open(struct ipmi_intf * intf)
#endif
#ifdef HAVE_IPV6
- session->addrlen = 0;
+ session->addrlen = 0;
memset(&session->addr, 0, sizeof(session->addr));
memset(&addr, 0, sizeof(addr));
sprintf(service, "%d", session->port);
@@ -3714,10 +3717,10 @@ ipmi_lanplus_open(struct ipmi_intf * intf)
hints.ai_flags = my_ai_flags;
hints.ai_protocol = IPPROTO_UDP; /* */
- rc = getaddrinfo((char *)session->hostname, service, &hints, &result);
+ rc = getaddrinfo((char *)session->hostname, service, &hints, &result);
if (rc != 0) {
- lprintf(LOG_ERR, "Address lookup for %s failed with %d",
- session->hostname,rc);
+ lprintf(LOG_ERR, "Address lookup for %s failed with %d, %s",
+ session->hostname,rc,gai_strerror(rc));
return -1;
}
@@ -3725,24 +3728,24 @@ ipmi_lanplus_open(struct ipmi_intf * intf)
* Try each address until we successfully connect(2).
*/
for (rp = result; rp != NULL; rp = rp->ai_next) {
- intf->fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
- if (intf->fd == -1) continue;
+ intf->fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
+ if (intf->fd == -1) continue;
/* valid protocols are IPPROTO_UDP, IPPROTO_IPV6 */
if (rp->ai_protocol == IPPROTO_TCP) continue; /*IPMI != TCP*/
lprintf(LOG_DEBUG, "lanplus socket(%d,%d,%d), connect(%d)",
rp->ai_family, rp->ai_socktype, rp->ai_protocol,
intf->fd );
- if (connect(intf->fd, rp->ai_addr, rp->ai_addrlen) != -1) {
+ if (connect(intf->fd, rp->ai_addr, rp->ai_addrlen) != -1) {
lprintf(LOG_DEBUG, "lanplus connect ok, addrlen=%d size=%d",
rp->ai_addrlen,sizeof(addr));
- addrlen = rp->ai_addrlen;
- memcpy(&addr, rp->ai_addr, addrlen);
- // memcpy(&session->addr, rp->ai_addr, rp->ai_addrlen);
- session->addrlen = rp->ai_addrlen;
- break; /* Success */
- }
- close(intf->fd);
- intf->fd = -1;
+ addrlen = rp->ai_addrlen;
+ memcpy(&addr, rp->ai_addr, addrlen);
+ // memcpy(&session->addr, rp->ai_addr, rp->ai_addrlen);
+ session->addrlen = rp->ai_addrlen;
+ break; /* Success */
+ }
+ close(intf->fd);
+ intf->fd = -1;
}
freeaddrinfo(result); /* Done with addrinfo */
if (intf->fd < 0) {