summaryrefslogtreecommitdiff
path: root/source4/lib/socket
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-09-28 18:54:55 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:07:29 -0500
commitcabc0955d96808eadf7b2573ece6f21df05129eb (patch)
treedaae8fff39c6b02bd4dd42447d65766602947c9f /source4/lib/socket
parent95157091e342afabf75dbe08886cfc9f0a51a007 (diff)
downloadsamba-cabc0955d96808eadf7b2573ece6f21df05129eb.tar.gz
samba-cabc0955d96808eadf7b2573ece6f21df05129eb.tar.bz2
samba-cabc0955d96808eadf7b2573ece6f21df05129eb.zip
r25411: Fix IPv6 socket backend.
(This used to be commit 02b4621181c35ebf3e7c2531302b44863b94f8bf)
Diffstat (limited to 'source4/lib/socket')
-rw-r--r--source4/lib/socket/socket_ip.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/source4/lib/socket/socket_ip.c b/source4/lib/socket/socket_ip.c
index 0b4b9223a8..8d561be55f 100644
--- a/source4/lib/socket/socket_ip.c
+++ b/source4/lib/socket/socket_ip.c
@@ -741,7 +741,7 @@ static NTSTATUS ipv6_recvfrom(struct socket_context *sock, void *buf,
struct sockaddr_in6 *from_addr;
socklen_t from_len = sizeof(*from_addr);
struct socket_address *src;
- struct hostent *he;
+ char addrstring[INET6_ADDRSTRLEN];
src = talloc(addr_ctx, struct socket_address);
if (!src) {
@@ -772,12 +772,13 @@ static NTSTATUS ipv6_recvfrom(struct socket_context *sock, void *buf,
src->sockaddrlen = from_len;
- he = gethostbyaddr((void *)&from_addr->sin6_addr, sizeof(from_addr->sin6_addr), AF_INET6);
- if (he == NULL) {
+ if (inet_ntop(AF_INET6, &from_addr->sin6_addr, addrstring, sizeof(addrstring)) == NULL) {
+ DEBUG(0, ("Unable to convert address to string: %s\n", strerror(errno)));
talloc_free(src);
- return NT_STATUS_INTERNAL_ERROR;
+ return NT_STATUS_INTERNAL_ERROR;
}
- src->addr = talloc_strdup(src, he->h_name);
+
+ src->addr = talloc_strdup(src, addrstring);
if (src->addr == NULL) {
talloc_free(src);
return NT_STATUS_NO_MEMORY;
@@ -905,7 +906,7 @@ static struct socket_address *ipv6_tcp_get_my_addr(struct socket_context *sock,
socklen_t len = sizeof(*local_addr);
struct socket_address *local;
int ret;
- struct hostent *he;
+ char addrstring[INET6_ADDRSTRLEN];
local = talloc(mem_ctx, struct socket_address);
if (!local) {
@@ -929,14 +930,15 @@ static struct socket_address *ipv6_tcp_get_my_addr(struct socket_context *sock,
local->sockaddrlen = len;
- he = gethostbyaddr((char *)&local_addr->sin6_addr, len, AF_INET6);
-
- if (!he || !he->h_name) {
+ if (inet_ntop(AF_INET6, &local_addr->sin6_addr, addrstring,
+ sizeof(addrstring)) == NULL) {
+ DEBUG(0, ("Unable to convert address to string: %s\n",
+ strerror(errno)));
talloc_free(local);
return NULL;
}
- local->addr = talloc_strdup(mem_ctx, he->h_name);
+ local->addr = talloc_strdup(mem_ctx, addrstring);
if (!local->addr) {
talloc_free(local);
return NULL;