summaryrefslogtreecommitdiffstats
path: root/transport
diff options
context:
space:
mode:
Diffstat (limited to 'transport')
-rw-r--r--transport/ib-verbs/src/name.c20
-rw-r--r--transport/socket/src/name.c21
2 files changed, 35 insertions, 6 deletions
diff --git a/transport/ib-verbs/src/name.c b/transport/ib-verbs/src/name.c
index 6c7ea33092a..a3e18481458 100644
--- a/transport/ib-verbs/src/name.c
+++ b/transport/ib-verbs/src/name.c
@@ -360,7 +360,21 @@ af_inet_server_get_local_sockaddr (transport_t *this,
if (listen_port_data)
{
listen_port = data_to_uint16 (listen_port_data);
- }
+ } else {
+ if (addr->sa_family == AF_INET6) {
+ struct sockaddr_in6 *in = (struct sockaddr_in6 *) addr;
+ in->sin6_addr = in6addr_any;
+ in->sin6_port = htons(listen_port);
+ *addr_len = sizeof(struct sockaddr_in6);
+ goto out;
+ } else if (addr->sa_family == AF_INET) {
+ struct sockaddr_in *in = (struct sockaddr_in *) addr;
+ in->sin_addr.s_addr = htonl(INADDR_ANY);
+ in->sin_port = htons(listen_port);
+ *addr_len = sizeof(struct sockaddr_in);
+ goto out;
+ }
+ }
if (listen_port == (uint16_t) -1)
listen_port = GF_DEFAULT_IBVERBS_LISTEN_PORT;
@@ -386,7 +400,7 @@ af_inet_server_get_local_sockaddr (transport_t *this,
"getaddrinfo failed for host %s, service %s (%s)",
listen_host, service, gai_strerror (ret));
ret = -1;
- goto err;
+ goto out;
}
memcpy (addr, res->ai_addr, res->ai_addrlen);
@@ -394,7 +408,7 @@ af_inet_server_get_local_sockaddr (transport_t *this,
freeaddrinfo (res);
-err:
+out:
return ret;
}
diff --git a/transport/socket/src/name.c b/transport/socket/src/name.c
index db7878830f1..712f5a3ffe3 100644
--- a/transport/socket/src/name.c
+++ b/transport/socket/src/name.c
@@ -19,6 +19,7 @@
#include <sys/types.h>
#include <sys/socket.h>
+#include <netinet/in.h>
#include <errno.h>
#include <netdb.h>
#include <string.h>
@@ -368,7 +369,21 @@ af_inet_server_get_local_sockaddr (transport_t *this,
if (listen_host_data)
{
listen_host = data_to_str (listen_host_data);
- }
+ } else {
+ if (addr->sa_family == AF_INET6) {
+ struct sockaddr_in6 *in = (struct sockaddr_in6 *) addr;
+ in->sin6_addr = in6addr_any;
+ in->sin6_port = htons(listen_port);
+ *addr_len = sizeof(struct sockaddr_in6);
+ goto out;
+ } else if (addr->sa_family == AF_INET) {
+ struct sockaddr_in *in = (struct sockaddr_in *) addr;
+ in->sin_addr.s_addr = htonl(INADDR_ANY);
+ in->sin_port = htons(listen_port);
+ *addr_len = sizeof(struct sockaddr_in);
+ goto out;
+ }
+ }
memset (service, 0, sizeof (service));
sprintf (service, "%d", listen_port);
@@ -384,7 +399,7 @@ af_inet_server_get_local_sockaddr (transport_t *this,
"getaddrinfo failed for host %s, service %s (%s)",
listen_host, service, gai_strerror (ret));
ret = -1;
- goto err;
+ goto out;
}
memcpy (addr, res->ai_addr, res->ai_addrlen);
@@ -392,7 +407,7 @@ af_inet_server_get_local_sockaddr (transport_t *this,
freeaddrinfo (res);
-err:
+out:
return ret;
}