aboutsummaryrefslogtreecommitdiffstats
path: root/erts/epmd/src/epmd_cli.c
diff options
context:
space:
mode:
authorMichael Santos <[email protected]>2015-10-18 16:20:37 -0400
committerMichael Santos <[email protected]>2016-02-10 16:57:13 -0500
commit40695d080b0dc0665b01803768ffc74ed2eca207 (patch)
tree3255088e5dd5e6cac2dd710a7bb996a98a2e1483 /erts/epmd/src/epmd_cli.c
parent439292ad4afe73243852fe79d5d467c325f382bf (diff)
downloadotp-40695d080b0dc0665b01803768ffc74ed2eca207.tar.gz
otp-40695d080b0dc0665b01803768ffc74ed2eca207.tar.bz2
otp-40695d080b0dc0665b01803768ffc74ed2eca207.zip
epmd: support IPv6 node registration
Allow IPv6 nodes to register with and query epmd. On systems with IPv6 support: * epmd listens on both the IPv4 and IPv6 ANY or loopback sockets * the epmd cli client connects to epmd over the IPv6 loopback * distributed nodes started with "-proto_dist inet6_tcp" will register with epmd over IPv6 To work on IPv6 capable systems that have IPv6 support disabled, epmd ignores errors opening the socket if the protocol is not supported. Similarly, the epmd client will fall back to IPv4 if the IPv6 socket is not available. Update the minimum supported version of Windows to Windows Vista to support IPv6.
Diffstat (limited to 'erts/epmd/src/epmd_cli.c')
-rw-r--r--erts/epmd/src/epmd_cli.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/erts/epmd/src/epmd_cli.c b/erts/epmd/src/epmd_cli.c
index a8fe865d9a..6fc05e153e 100644
--- a/erts/epmd/src/epmd_cli.c
+++ b/erts/epmd/src/epmd_cli.c
@@ -136,19 +136,33 @@ void epmd_call(EpmdVars *g,int what)
static int conn_to_epmd(EpmdVars *g)
{
struct EPMD_SOCKADDR_IN address;
+ size_t salen = 0;
int connect_sock;
-
- connect_sock = socket(FAMILY, SOCK_STREAM, 0);
- if (connect_sock<0)
- goto error;
+ unsigned short sport = g->port;
+
+#if defined(EPMD6)
+ SET_ADDR6(address, in6addr_loopback, sport);
+ salen = sizeof(struct sockaddr_in6);
+
+ connect_sock = socket(AF_INET6, SOCK_STREAM, 0);
+ if (connect_sock>=0) {
+
+ if (connect(connect_sock, (struct sockaddr*)&address, salen) == 0)
+ return connect_sock;
- { /* store port number in unsigned short */
- unsigned short sport = g->port;
- SET_ADDR(address, EPMD_ADDR_LOOPBACK, sport);
+ close(connect_sock);
}
+#endif
+ SET_ADDR(address, htonl(INADDR_LOOPBACK), sport);
+ salen = sizeof(struct sockaddr_in);
- if (connect(connect_sock, (struct sockaddr*)&address, sizeof address) < 0)
+ connect_sock = socket(AF_INET, SOCK_STREAM, 0);
+ if (connect_sock<0)
goto error;
+
+ if (connect(connect_sock, (struct sockaddr*)&address, salen) < 0)
+ goto error;
+
return connect_sock;
error: