r15329: I'm sick of this patch being in my local tree...
authorAndrew Bartlett <abartlet@samba.org>
Sat, 29 Apr 2006 20:01:07 +0000 (20:01 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:05:17 +0000 (14:05 -0500)
Use inet_ntop to convert IPv6 names to strings.  Don't do a reverse
lookup.

Andrew Bartlett

source/lib/socket/socket_ipv6.c

index 90eb27b8117e3b496b29ca86c50543b3d252d479..9b6dcbf9850ee7d0ce25200897ba887bc023a851 100644 (file)
@@ -302,7 +302,8 @@ static struct socket_address *ipv6_tcp_get_peer_addr(struct socket_context *sock
        socklen_t len = sizeof(*peer_addr);
        struct socket_address *peer;
        int ret;
-       struct hostent *he;
+       char addr[128];
+       const char *addr_ret;
        
        peer = talloc(mem_ctx, struct socket_address);
        if (!peer) {
@@ -326,18 +327,18 @@ static struct socket_address *ipv6_tcp_get_peer_addr(struct socket_context *sock
 
        peer->sockaddrlen = len;
 
-       he = gethostbyaddr((char *)&peer_addr->sin6_addr, len, AF_INET6);
-
-       if (!he || !he->h_name) {
+       addr_ret = inet_ntop(AF_INET6, &peer_addr->sin6_addr, addr, sizeof(addr));
+       if (addr_ret == NULL) {
                talloc_free(peer);
                return NULL;
        }
-       
-       peer->addr = talloc_strdup(mem_ctx, he->h_name);
-       if (!peer->addr) {
+
+       peer->addr = talloc_strdup(peer, addr_ret);
+       if (peer->addr == NULL) {
                talloc_free(peer);
                return NULL;
        }
+
        peer->port = ntohs(peer_addr->sin6_port);
 
        return peer;