@@ -516,15 +516,15 @@ static int get_addr(char *dst, struct sockaddr_in *addr)
return ret;
}
- if (res->ai_family != PF_INET) {
+ if (res->ai_family == PF_INET)
+ memcpy(addr, res->ai_addr, sizeof(struct sockaddr_in));
+ else if (res->ai_family == PF_INET6)
+ memcpy(addr, res->ai_addr, sizeof(struct sockaddr_in6));
+ else
ret = -1;
- goto out;
- }
- *addr = *(struct sockaddr_in *) res->ai_addr;
-out:
- freeaddrinfo(res);
- return ret;
+ freeaddrinfo(res);
+ return ret;
}
static int run_server(void)
@@ -543,11 +543,18 @@ static int run_server(void)
ret = get_addr(src_addr, &test.src_in);
if (ret)
goto out;
- } else
+ if(test.src_in.sin_family == AF_INET)
+ ((struct sockaddr_in *) &test.src_in)->sin_port = port;
+ else
+ ((struct sockaddr_in6 *) &test.src_in)->sin6_port=port;
+
+ } else {
test.src_in.sin_family = PF_INET;
+ test.src_in.sin_port = port;
+ }
+
+ ret = rdma_bind_addr(listen_id, (struct sockaddr *)&test.src_in);
- test.src_in.sin_port = port;
- ret = rdma_bind_addr(listen_id, test.src_addr);
if (ret) {
perror("cmatose: bind address failed");
goto out;
@@ -628,8 +635,8 @@ static int run_client(void)
printf("cmatose: connecting\n");
for (i = 0; i < connections; i++) {
ret = rdma_resolve_addr(test.nodes[i].cma_id,
- src_addr ? test.src_addr : NULL,
- test.dst_addr, 2000);
+ src_addr ? (struct sockaddr *)&test.src_in : NULL,
+ (struct sockaddr *)&test.dst_in, 2000);
if (ret) {
perror("cmatose: failure getting addr");
connect_error();