aboutsummaryrefslogtreecommitdiffstats
path: root/erts/epmd/src/epmd_cli.c
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2016-03-01 14:06:20 +0100
committerIngela Anderton Andin <[email protected]>2016-03-01 14:06:20 +0100
commit75bc5bebc070a59535b8f6b7b9085c210b4723b5 (patch)
tree8868096be6ad2eadce99475293f370008df1aa9f /erts/epmd/src/epmd_cli.c
parent6f8997c001a17b9d9322e26757690489d6111dac (diff)
parent40695d080b0dc0665b01803768ffc74ed2eca207 (diff)
downloadotp-75bc5bebc070a59535b8f6b7b9085c210b4723b5.tar.gz
otp-75bc5bebc070a59535b8f6b7b9085c210b4723b5.tar.bz2
otp-75bc5bebc070a59535b8f6b7b9085c210b4723b5.zip
Merge branch 'msantos/epmd-IPv6-node-reg2/PR-864/OTP-13364' into maint
* msantos/epmd-IPv6-node-reg2/PR-864/OTP-13364: epmd: support IPv6 node registration
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: