summaryrefslogtreecommitdiff
path: root/lib/lanplus
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2019-08-10 12:01:51 +0200
committerJörg Frings-Fürst <debian@jff.email>2019-08-10 12:01:51 +0200
commitccfc550b12b142c11dcf4d249d086925af0443c4 (patch)
treeef39de54973053dad5d130cfeb1feb3f55b7c1cc /lib/lanplus
parent499ce7f7eb7c228d72e646527ce9a5c2950ad58f (diff)
New upstream version 3.1.4upstream/3.1.4
Diffstat (limited to 'lib/lanplus')
-rw-r--r--lib/lanplus/ipmiplus.mak3
-rw-r--r--lib/lanplus/lanplus.c47
2 files changed, 27 insertions, 23 deletions
diff --git a/lib/lanplus/ipmiplus.mak b/lib/lanplus/ipmiplus.mak
index 9a1435a..5c851c2 100644
--- a/lib/lanplus/ipmiplus.mak
+++ b/lib/lanplus/ipmiplus.mak
@@ -16,7 +16,8 @@ CF_EX=/DWIN32 $(INC) /D_CONSOLE /DNDEBUG /D_CRT_SECURE_NO_DEPRECATE
# CFLAGS= /W3 /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo $(CF_EX)
# CFLAGS= /W3 /O2 /Zi /MD /GF /Gy /nologo $(CF_EX)
# CFLAGS= /W3 /O2 /Zi /MD /nologo $(CF_EX)
-CFLAGS= /W3 /O2 /Zi /MT /nologo $(CF_EX)
+#CFLAGS= /W3 /O2 /Zi /MT /nologo $(CF_EX) /DHAVE_IPV6
+CFLAGS= /W3 /O2 /Zi /MT /nologo $(CF_EX)
MKLIB=lib
RM=del
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) {