gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r6475 - in GNUnet: . contrib libltdl src/applications/trans


From: gnunet
Subject: [GNUnet-SVN] r6475 - in GNUnet: . contrib libltdl src/applications/transport src/include src/server src/setup src/transports src/transports/upnp src/util/network src/util/network_client
Date: Tue, 26 Feb 2008 23:50:36 -0700 (MST)

Author: grothoff
Date: 2008-02-26 23:50:36 -0700 (Tue, 26 Feb 2008)
New Revision: 6475

Modified:
   GNUnet/ChangeLog
   GNUnet/contrib/config-daemon.scm
   GNUnet/libltdl/config.guess
   GNUnet/libltdl/config.sub
   GNUnet/src/applications/transport/transport.c
   GNUnet/src/include/gnunet_upnp_service.h
   GNUnet/src/include/gnunet_util.h
   GNUnet/src/include/gnunet_util_network.h
   GNUnet/src/server/tcpserver.c
   GNUnet/src/setup/gnunet-win-tool.c
   GNUnet/src/transports/common.c
   GNUnet/src/transports/common.h
   GNUnet/src/transports/http.c
   GNUnet/src/transports/ip.c
   GNUnet/src/transports/ip.h
   GNUnet/src/transports/nat.c
   GNUnet/src/transports/tcp.c
   GNUnet/src/transports/udp.c
   GNUnet/src/transports/upnp/init.c
   GNUnet/src/transports/upnp/ip.c
   GNUnet/src/transports/upnp/ip.h
   GNUnet/src/transports/upnp/upnp.c
   GNUnet/src/transports/upnp/upnptest.c
   GNUnet/src/util/network/dns.c
   GNUnet/src/util/network/io.c
   GNUnet/src/util/network/ip.c
   GNUnet/src/util/network/ipcheck.c
   GNUnet/src/util/network/selecttest.c
   GNUnet/src/util/network_client/tcpio.c
   GNUnet/todo
Log:
DNS code clean up

Modified: GNUnet/ChangeLog
===================================================================
--- GNUnet/ChangeLog    2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/ChangeLog    2008-02-27 06:50:36 UTC (rev 6475)
@@ -1,3 +1,9 @@
+Mon Feb 25 23:25:48 MST 2008
+       Cleanup of the DNS code: removed GNUNET_IPvXAddress
+       and GNUNET_PRIP; centralized all DNS lookup code in 
+       util/network/dns.c; improved IPv6 support for 
+        network-client code.
+
 Mon Feb 25 00:01:27 MST 2008
        Added asynchronous search and download methods for 
        ECRS library.  FSUI now can do with only one thread

Modified: GNUnet/contrib/config-daemon.scm
===================================================================
--- GNUnet/contrib/config-daemon.scm    2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/contrib/config-daemon.scm    2008-02-27 06:50:36 UTC (rev 6475)
@@ -479,7 +479,7 @@
  (builder
  "NETWORK"
  "TRUSTED"
- (_ "IPs allowed to use gnunetd server")
+ (_ "IPv4 networks allowed to use gnunetd server")
  (_ "This option specifies which hosts are trusted enough to connect as 
clients (to the TCP port).  This is useful if you run gnunetd on one host of 
your network and want to allow all other hosts to use this node as their 
server.  By default, this is set to 'loopback only'.  The format is IP/NETMASK 
where the IP is specified in dotted-decimal and the netmask either in CIDR 
notation (/16) or in dotted decimal (255.255.0.0). Several entries must be 
separated by a semicolon, spaces are not allowed.")
  '()
  #t
@@ -487,7 +487,19 @@
  '()
  'advanced) )
 
+(define (network-trusted6 builder)
+ (builder
+ "NETWORK"
+ "TRUSTED6"
+ (_ "IPv6 networks allowed to use gnunetd server")
+ (_ "This option specifies which hosts are trusted enough to connect as 
clients (to the TCP port).  This is useful if you run gnunetd on one host of 
your network and want to allow all other hosts to use this node as their 
server.  By default, this is set to 'loopback only'.  The format is IP/NETMASK 
where the IP is specified in dotted-decimal and the netmask either in CIDR 
notation (/16) or in dotted decimal (255.255.0.0). Several entries must be 
separated by a semicolon, spaces are not allowed.")
+ '()
+ #t
+ "::1;"
+ '()
+ 'advanced) )
 
+
 (define (limit-allow builder)
  (builder
  "GNUNETD"

Modified: GNUnet/libltdl/config.guess
===================================================================
--- GNUnet/libltdl/config.guess 2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/libltdl/config.guess 2008-02-27 06:50:36 UTC (rev 6475)
@@ -1,10 +1,10 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
-#   Free Software Foundation, Inc.
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+#   Inc.
 
-timestamp='2008-01-23'
+timestamp='2007-07-22'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -56,8 +56,8 @@
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 
2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -532,7 +532,7 @@
                echo rs6000-ibm-aix3.2
        fi
        exit ;;
-    *:AIX:*:[456])
+    *:AIX:*:[45])
        IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk 
'{ print $1 }'`
        if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; 
then
                IBM_ARCH=rs6000
@@ -799,9 +799,6 @@
            EM64T | authenticamd)
                echo x86_64-unknown-interix${UNAME_RELEASE}
                exit ;;
-           IA64)
-               echo ia64-unknown-interix${UNAME_RELEASE}
-               exit ;;
        esac ;;
     [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
        echo i${UNAME_MACHINE}-pc-mks
@@ -836,14 +833,7 @@
        echo ${UNAME_MACHINE}-pc-minix
        exit ;;
     arm*:Linux:*:*)
-       eval $set_cc_for_build
-       if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
-           | grep -q __ARM_EABI__
-       then
-           echo ${UNAME_MACHINE}-unknown-linux-gnu
-       else
-           echo ${UNAME_MACHINE}-unknown-linux-gnueabi
-       fi
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
        exit ;;
     avr32*:Linux:*:*)
        echo ${UNAME_MACHINE}-unknown-linux-gnu
@@ -964,8 +954,8 @@
     x86_64:Linux:*:*)
        echo x86_64-unknown-linux-gnu
        exit ;;
-    xtensa*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
+    xtensa:Linux:*:*)
+       echo xtensa-unknown-linux-gnu
        exit ;;
     i*86:Linux:*:*)
        # The BFD linker knows what the default object file format is, so
@@ -1484,9 +1474,9 @@
 the operating system you are using. It is advised that you
 download the most up to date version of the config scripts from
 
-  
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
 and
-  
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
 
 If the version you run ($0) is already up to date, please
 send the following data and any information you think might be

Modified: GNUnet/libltdl/config.sub
===================================================================
--- GNUnet/libltdl/config.sub   2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/libltdl/config.sub   2008-02-27 06:50:36 UTC (rev 6475)
@@ -1,10 +1,10 @@
 #! /bin/sh
 # Configuration validation subroutine script.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
-#   Free Software Foundation, Inc.
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+#   Inc.
 
-timestamp='2008-01-16'
+timestamp='2007-06-28'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -72,8 +72,8 @@
 version="\
 GNU config.sub ($timestamp)
 
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 
2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -369,14 +369,10 @@
        | v850-* | v850e-* | vax-* \
        | we32k-* \
        | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
-       | xstormy16-* | xtensa*-* \
+       | xstormy16-* | xtensa-* \
        | ymp-* \
        | z8k-*)
                ;;
-       # Recognize the basic CPU types without company name, with glob match.
-       xtensa*)
-               basic_machine=$basic_machine-unknown
-               ;;
        # Recognize the various machine names and aliases which stand
        # for a CPU type and a company and sometimes even an OS.
        386bsd)
@@ -447,14 +443,6 @@
                basic_machine=ns32k-sequent
                os=-dynix
                ;;
-       blackfin)
-               basic_machine=bfin-unknown
-               os=-linux
-               ;;
-       blackfin-*)
-               basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
-               os=-linux
-               ;;
        c90)
                basic_machine=c90-cray
                os=-unicos
@@ -680,14 +668,6 @@
                basic_machine=m68k-isi
                os=-sysv
                ;;
-       m68knommu)
-               basic_machine=m68k-unknown
-               os=-linux
-               ;;
-       m68knommu-*)
-               basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
-               os=-linux
-               ;;
        m88k-omron*)
                basic_machine=m88k-omron
                ;;
@@ -833,14 +813,6 @@
                basic_machine=i860-intel
                os=-osf
                ;;
-       parisc)
-               basic_machine=hppa-unknown
-               os=-linux
-               ;;
-       parisc-*)
-               basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
-               os=-linux
-               ;;
        pbd)
                basic_machine=sparc-tti
                ;;
@@ -1049,10 +1021,6 @@
                basic_machine=tic6x-unknown
                os=-coff
                ;;
-       tile*)
-               basic_machine=tile-unknown
-               os=-linux-gnu
-               ;;
        tx39)
                basic_machine=mipstx39-unknown
                ;;

Modified: GNUnet/src/applications/transport/transport.c
===================================================================
--- GNUnet/src/applications/transport/transport.c       2008-02-27 04:14:13 UTC 
(rev 6474)
+++ GNUnet/src/applications/transport/transport.c       2008-02-27 06:50:36 UTC 
(rev 6475)
@@ -667,7 +667,7 @@
   /* Creation of HELLOs takes longer if a locally
      unresolvable hostname ((Dyn)DNS) was specified
      as this host's address and we have no network
-     connection at the moment. gethostbyname()
+     connection at the moment.  Use of gethostbyname()
      blocks the startup process in this case.
      This is why we create the HELLOs in another
      thread. */

Modified: GNUnet/src/include/gnunet_upnp_service.h
===================================================================
--- GNUnet/src/include/gnunet_upnp_service.h    2008-02-27 04:14:13 UTC (rev 
6474)
+++ GNUnet/src/include/gnunet_upnp_service.h    2008-02-27 06:50:36 UTC (rev 
6475)
@@ -50,7 +50,7 @@
    * @return GNUNET_SYSERR on error, GNUNET_OK on success
    */
   int (*get_ip) (unsigned short port, const char *protocol,
-                 GNUNET_IPv4Address * address);
+                 struct in_addr * address);
 
 } GNUNET_UPnP_ServiceAPI;
 

Modified: GNUnet/src/include/gnunet_util.h
===================================================================
--- GNUnet/src/include/gnunet_util.h    2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/include/gnunet_util.h    2008-02-27 06:50:36 UTC (rev 6475)
@@ -85,7 +85,7 @@
  * especially the least significant bits may change
  * frequently, even between different SVN versions.
  */
-#define GNUNET_UTIL_VERSION 0x00070300
+#define GNUNET_UTIL_VERSION 0x00080000
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {

Modified: GNUnet/src/include/gnunet_util_network.h
===================================================================
--- GNUnet/src/include/gnunet_util_network.h    2008-02-27 04:14:13 UTC (rev 
6474)
+++ GNUnet/src/include/gnunet_util_network.h    2008-02-27 06:50:36 UTC (rev 
6475)
@@ -32,6 +32,14 @@
 #ifndef GNUNET_UTIL_NETWORK_H
 #define GNUNET_UTIL_NETWORK_H
 
+#ifndef MINGW
+/* for struct addr_in, etc. */
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#endif
+
 #include "gnunet_util_config.h"
 #include "gnunet_util_string.h"
 #include "gnunet_util_os.h"
@@ -153,35 +161,12 @@
 
 } GNUNET_MessageReturnErrorMessage;
 
-
 /**
- * @brief an IPv4 address
- */
-typedef struct
-{
-  /**
-   * struct in_addr
-   */
-  unsigned int addr;
-} GNUNET_IPv4Address;
-
-/**
  * @brief IPV4 network in CIDR notation.
  */
 struct GNUNET_IPv4NetworkSet;
 
 /**
- * @brief an IPV6 address.
- */
-typedef struct
-{
-  /**
-   * struct in6_addr addr;
-   */
-  unsigned int addr[4];
-} GNUNET_IPv6Address;
-
-/**
  * @brief IPV6 network in CIDR notation.
  */
 struct GNUNET_IPv6NetworkSet;
@@ -298,7 +283,7 @@
  * @return GNUNET_NO if the IP is not in the list, GNUNET_YES if it it is
  */
 int GNUNET_check_ipv4_listed (const struct GNUNET_IPv4NetworkSet *list,
-                              GNUNET_IPv4Address ip);
+                              const struct in_addr * ip);
 
 /**
  * Check if the given IP address is in the list of
@@ -308,21 +293,9 @@
  * @return GNUNET_NO if the IP is not in the list, GNUNET_YES if it it is
  */
 int GNUNET_check_ipv6_listed (const struct GNUNET_IPv6NetworkSet *list,
-                              GNUNET_IPv6Address ip);
+                              const struct in6_addr * ip);
 
-#define GNUNET_PRIP(ip) (unsigned int)(((unsigned int)(ip))>>24), \
-                 (unsigned int)((((unsigned)(ip)))>>16 & 255), \
-                 (unsigned int)((((unsigned int)(ip)))>>8 & 255), \
-                 (unsigned int)((((unsigned int)(ip))) & 255)
 
-/**
- * Get the IP address of the given host.
- *
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
- */
-int GNUNET_get_host_by_name (struct GNUNET_GE_Context *ectx,
-                             const char *hostname, GNUNET_IPv4Address * ip);
-
 /* ********************* low-level socket operations **************** */
 
 /**
@@ -525,6 +498,28 @@
 int GNUNET_select_disconnect (struct GNUNET_SelectHandle *sh,
                               struct GNUNET_SocketHandle *sock);
 
+/**
+ * Convert a string to an IP address. May block!
+ *
+ * @param hostname the hostname to resolve
+ * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any"
+ * @param *sa should be of type "struct sockaddr*" and
+ *        will be set to the IP address on success;
+ *        if *sa is NULL, sufficient space will be
+ *        allocated.        
+ * @param socklen will be set to the length of *sa.
+ *        If *sa is not NULL, socklen will be checked
+ *        to see if sufficient space is provided and
+ *        updated to the amount of space actually
+ *        required/used.
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ */
+int
+GNUNET_get_ip_from_hostname (struct GNUNET_GE_Context *ectx,
+                            const char * hostname,     
+                            int domain,
+                            struct sockaddr ** sa,
+                            socklen_t * socklen);
 
 /**
  * Get an IP address as a string (works for both IPv4 and IPv6).  Note
@@ -543,7 +538,7 @@
  */
 char *GNUNET_get_local_ip (struct GNUNET_GC_Configuration *cfg,
                            struct GNUNET_GE_Context *ectx,
-                           GNUNET_IPv4Address * addr);
+                           struct in_addr * addr);
 
 
 /**

Modified: GNUnet/src/server/tcpserver.c
===================================================================
--- GNUnet/src/server/tcpserver.c       2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/server/tcpserver.c       2008-02-27 06:50:36 UTC (rev 6475)
@@ -93,7 +93,7 @@
  * Is this IP labeled as trusted for CS connections?
  */
 static int
-isWhitelisted4 (GNUNET_IPv4Address ip)
+isWhitelisted4 (const struct in_addr * ip)
 {
   return GNUNET_check_ipv4_listed (trustedNetworksV4, ip);
 }
@@ -102,7 +102,7 @@
  * Is this IP labeled as trusted for CS connections?
  */
 static int
-isWhitelisted6 (GNUNET_IPv6Address ip)
+isWhitelisted6 (const struct in6_addr * ip)
 {
   return GNUNET_check_ipv6_listed (trustedNetworksV6, ip);
 }
@@ -168,8 +168,8 @@
                        const void *addr, unsigned int addr_len)
 {
   struct GNUNET_ClientHandle *session;
-  GNUNET_IPv4Address ip4;
-  GNUNET_IPv6Address ip6;
+  struct in_addr ip4;
+  struct in6_addr ip6;
   struct sockaddr_in *a4;
   struct sockaddr_in6 *a6;
   
@@ -177,22 +177,22 @@
     {
       a6 = (struct sockaddr_in6 *) addr;
       
-      memcpy (&ip6, &a6->sin6_addr, sizeof (GNUNET_IPv6Address));
+      memcpy (&ip6, &a6->sin6_addr, sizeof (struct in6_addr));
       /* get embedded ipv4 address in case address embedding is used */
       memcpy (&ip4,
-             &((char*) &ip6)[sizeof(GNUNET_IPv6Address) - 
sizeof(GNUNET_IPv4Address)], 
-             sizeof (GNUNET_IPv4Address));
-      if ( (!isWhitelisted6 (ip6)) &&
+             &((char*) &ip6)[sizeof(struct in6_addr) - sizeof(struct 
in_addr)], 
+             sizeof (struct in_addr));
+      if ( (!isWhitelisted6 (&ip6)) &&
           (! ( ( (IN6_IS_ADDR_V4COMPAT(&a6->sin6_addr)) ||
                  (IN6_IS_ADDR_V4MAPPED(&a6->sin6_addr)) ) &&
-               (isWhitelisted4(ip4) ) ) ) )      
+               (isWhitelisted4(&ip4) ) ) ) )      
        return NULL;    
     }
   else if (addr_len == sizeof (struct sockaddr_in))
     {
       a4 = (struct sockaddr_in *) addr;
-      memcpy (&ip4, &a4->sin_addr, sizeof (GNUNET_IPv4Address));
-      if (!isWhitelisted4 (ip4))
+      memcpy (&ip4, &a4->sin_addr, sizeof (struct in_addr));
+      if (!isWhitelisted4 (&ip4))
        return NULL;
     }
   else

Modified: GNUnet/src/setup/gnunet-win-tool.c
===================================================================
--- GNUnet/src/setup/gnunet-win-tool.c  2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/setup/gnunet-win-tool.c  2008-02-27 06:50:36 UTC (rev 6475)
@@ -76,6 +76,7 @@
   PMIB_IFTABLE pTable;
   PMIB_IPADDRTABLE pAddrTable;
   DWORD dwIfIdx;
+  char ntop_buf[INET_ADDRSTRLEN];
 
   EnumNICs (&pTable, &pAddrTable);
 
@@ -101,8 +102,8 @@
             {
               if (pAddrTable->table[i].dwIndex ==
                   pTable->table[dwIfIdx].dwIndex)
-                printf ("Address: %u.%u.%u.%u\n",
-                        GNUNET_PRIP (ntohl (pAddrTable->table[i].dwAddr)));
+                printf ("Address: %s\n",
+                       inet_ntop(AF_INET, &pAddrTable->table[i].dwAddr, 
ntop_buf, INET_ADDRSTRLEN));
             }
           printf ("\n");
         }

Modified: GNUnet/src/transports/common.c
===================================================================
--- GNUnet/src/transports/common.c      2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/transports/common.c      2008-02-27 06:50:36 UTC (rev 6475)
@@ -54,25 +54,10 @@
  * Check if we are allowed to connect to the given IP.
  */
 static int
-is_blacklisted_ipv6 (const void *addr, unsigned int addr_len)
+is_blacklisted_ipv6 (const struct in6_addr * ip)
 {
-  GNUNET_IPv6Address ip;
   int ret;
 
-  if (addr_len == sizeof (GNUNET_IPv6Address))
-    {
-      memcpy (&ip, addr, sizeof (GNUNET_IPv6Address));
-    }
-  else if (addr_len == sizeof (struct sockaddr_in6))
-    {
-      memcpy (&ip,
-              &((struct sockaddr_in6 *) addr)->sin6_addr,
-              sizeof (GNUNET_IPv6Address));
-    }
-  else
-    {
-      return GNUNET_SYSERR;
-    }
   GNUNET_mutex_lock (lock);
   ret = GNUNET_check_ipv6_listed (filteredNetworksIPv6, ip);
   GNUNET_mutex_unlock (lock);
@@ -83,25 +68,10 @@
  * Check if we are allowed to connect to the given IP.
  */
 static int
-is_whitelisted_ipv6 (const void *addr, unsigned int addr_len)
+is_whitelisted_ipv6 (const struct in6_addr *ip)
 {
-  GNUNET_IPv6Address ip;
   int ret;
 
-  if (addr_len == sizeof (GNUNET_IPv6Address))
-    {
-      memcpy (&ip, addr, sizeof (GNUNET_IPv6Address));
-    }
-  else if (addr_len == sizeof (struct sockaddr_in6))
-    {
-      memcpy (&ip,
-              &((struct sockaddr_in6 *) addr)->sin6_addr,
-              sizeof (GNUNET_IPv6Address));
-    }
-  else
-    {
-      return GNUNET_SYSERR;
-    }
   ret = GNUNET_OK;
   GNUNET_mutex_lock (lock);
   if (allowedNetworksIPv6 != NULL)
@@ -113,10 +83,28 @@
 static int
 is_rejected_ipv6 (const void *addr, unsigned int addr_len)
 {
-  if ((GNUNET_YES == is_blacklisted_ipv6 (addr,
-                                          addr_len)) ||
-      (GNUNET_YES != is_whitelisted_ipv6 (addr, addr_len)))
-    return GNUNET_YES;
+  const struct sockaddr_in6 * saddr;
+  const struct in6_addr * inaddr;
+
+  if (addr_len == sizeof(struct in6_addr))
+    {
+      inaddr = addr;
+    }
+  else if (addr_len == sizeof(struct sockaddr_in6))
+    {
+      saddr = addr;
+      inaddr = &saddr->sin6_addr;
+    }
+  else
+    {
+      GNUNET_GE_BREAK(NULL, 0);
+      return GNUNET_SYSERR;
+    }
+  if ((GNUNET_YES == is_blacklisted_ipv6 (inaddr)) ||
+      (GNUNET_YES != is_whitelisted_ipv6 (inaddr)))
+    {
+      return GNUNET_YES;
+    }
   return GNUNET_NO;
 }
 
@@ -124,25 +112,11 @@
  * Check if we are allowed to connect to the given IP.
  */
 static int
-is_blacklisted_ipv4 (const void *addr, unsigned int addr_len)
+is_blacklisted_ipv4 (const struct in_addr *ip)
 {
-  GNUNET_IPv4Address ip;
   int ret;
 
-  if (addr_len == sizeof (struct sockaddr_in))
-    {
-      memcpy (&ip, &((struct sockaddr_in *) addr)->sin_addr,
-              sizeof (GNUNET_IPv4Address));
-    }
-  else if (addr_len == sizeof (GNUNET_IPv4Address))
-    {
-      memcpy (&ip, addr, addr_len);
-    }
-  else
-    {
-      return GNUNET_SYSERR;
-    }
-  if (ip.addr == 0)
+  if (ip->s_addr == 0)
     return GNUNET_SYSERR;
   GNUNET_mutex_lock (lock);
   ret = GNUNET_check_ipv4_listed (filteredNetworksIPv4, ip);
@@ -154,24 +128,10 @@
  * Check if we are allowed to connect to the given IP.
  */
 static int
-is_whitelisted_ipv4 (const void *addr, unsigned int addr_len)
+is_whitelisted_ipv4 (const struct in_addr *ip)
 {
-  GNUNET_IPv4Address ip;
   int ret;
 
-  if (addr_len == sizeof (struct sockaddr_in))
-    {
-      memcpy (&ip, &((struct sockaddr_in *) addr)->sin_addr,
-              sizeof (GNUNET_IPv4Address));
-    }
-  else if (addr_len == sizeof (GNUNET_IPv4Address))
-    {
-      memcpy (&ip, addr, addr_len);
-    }
-  else
-    {
-      return GNUNET_SYSERR;
-    }
   ret = GNUNET_YES;
   GNUNET_mutex_lock (lock);
   if (allowedNetworksIPv4 != NULL)
@@ -183,17 +143,49 @@
 static int
 is_rejected_ipv4 (const void *addr, unsigned int addr_len)
 {
-  if ((GNUNET_NO != is_blacklisted_ipv4 (addr,
-                                         addr_len)) ||
-      (GNUNET_YES != is_whitelisted_ipv4 (addr, addr_len)))
-    return GNUNET_YES;
+  const struct sockaddr_in * saddr;
+  const struct in_addr * inaddr;
+
+  if (addr_len == sizeof(struct in_addr))
+    {
+      inaddr = addr;
+    }
+  else if (addr_len == sizeof(struct sockaddr_in))
+    {
+      saddr = addr;
+      inaddr = &saddr->sin_addr;
+    }
+  else
+    {
+      GNUNET_GE_BREAK(NULL, 0);
+      return GNUNET_SYSERR;
+    }
+  if ((GNUNET_NO != is_blacklisted_ipv4 (inaddr)) ||
+      (GNUNET_YES != is_whitelisted_ipv4 (inaddr)))
+    {
+      return GNUNET_YES;
+    }
   return GNUNET_NO;
 }
 
+/**
+ * Test if connections from the given "addr" are
+ * allowed.  "addr" can be a struct in_addr,
+ * struct sockaddr_in, struct in6_addr or
+ * struct sockaddr_in6.  addr_len will be used to
+ * distinguish between the four cases and to pick
+ * the right method.
+ * @return GNUNET_SYSERR if addr_len is not 
+ *         a valid value or if there is any other
+ *         problem with the address; GNUNET_NO if
+ *         connections are allowed, GNUNET_YES if
+ *         connections are not allowed by policy.
+ */
 static int
 is_rejected_tester (const void *addr, unsigned int addr_len)
 {
-  if (addr_len == sizeof (struct sockaddr_in))
+  if ( (addr_len == sizeof (struct in_addr)) ||
+       (addr_len == sizeof (struct sockaddr_in)) )
     return is_rejected_ipv4 (addr, addr_len);
   return is_rejected_ipv6 (addr, addr_len);
 }
@@ -223,18 +215,19 @@
       || ((0 != (ntohs (haddr->availability) & VERSION_AVAILABLE_IPV4))
           &&
           ((GNUNET_YES ==
-            is_blacklisted_ipv4 (&haddr->ipv4, sizeof (GNUNET_IPv4Address)))
+            is_blacklisted_ipv4 (&haddr->ipv4))
            || (GNUNET_YES !=
-               is_whitelisted_ipv4 (&haddr->ipv4,
-                                    sizeof (GNUNET_IPv4Address)))))
+               is_whitelisted_ipv4 (&haddr->ipv4))))
       || ((0 != (ntohs (haddr->availability) & VERSION_AVAILABLE_IPV6))
           &&
           ((GNUNET_YES ==
-            is_blacklisted_ipv6 (&haddr->ipv6, sizeof (GNUNET_IPv6Address)))
+            is_blacklisted_ipv6 (&haddr->ipv6))
            || (GNUNET_YES !=
-               is_whitelisted_ipv6 (&haddr->ipv6,
-                                    sizeof (GNUNET_IPv6Address))))))
-    return GNUNET_SYSERR;       /* invalid */
+               is_whitelisted_ipv6 (&haddr->ipv6)))))
+    {
+      GNUNET_GE_BREAK_OP(NULL, 0);
+      return GNUNET_SYSERR;       /* invalid */
+    }
   return GNUNET_OK;
 }
 
@@ -344,8 +337,8 @@
 static GNUNET_MessageHello *
 create_hello ()
 {
-  static GNUNET_IPv4Address last_addrv4;
-  static GNUNET_IPv6Address last_addrv6;
+  static struct in_addr last_addrv4;
+  static struct in6_addr last_addrv6;
   GNUNET_MessageHello *msg;
   HostAddress *haddr;
   unsigned short port;
@@ -380,7 +373,7 @@
                                            &haddr->ipv4))))
     {
       if (0 != memcmp (&haddr->ipv4,
-                       &last_addrv4, sizeof (GNUNET_IPv4Address)))
+                       &last_addrv4, sizeof (struct in_addr)))
         {
           struct in_addr in4;
           char dst[INET_ADDRSTRLEN];
@@ -401,7 +394,7 @@
       GNUNET_IP_get_public_ipv6_address (cfg, coreAPI->ectx, &haddr->ipv6))
     {
       if (0 != memcmp (&haddr->ipv6,
-                       &last_addrv6, sizeof (GNUNET_IPv6Address)))
+                       &last_addrv6, sizeof (struct in6_addr)))
         {
           struct in6_addr in6;
           char dst[INET6_ADDRSTRLEN];
@@ -451,7 +444,7 @@
       memset (serverAddr4, 0, sizeof (struct sockaddr_in));
       serverAddr4->sin_family = AF_INET;
       memcpy (&serverAddr4->sin_addr, &haddr->ipv4,
-              sizeof (GNUNET_IPv4Address));
+              sizeof (struct in_addr));
       serverAddr4->sin_port = haddr->port;
     }
   else if (0 != (available & VERSION_AVAILABLE_IPV6))
@@ -462,7 +455,7 @@
       memset (serverAddr6, 0, sizeof (struct sockaddr_in6));
       serverAddr6->sin6_family = AF_INET6;
       memcpy (&serverAddr6->sin6_addr, &haddr->ipv6,
-              sizeof (GNUNET_IPv6Address));
+              sizeof (struct in6_addr));
       serverAddr6->sin6_port = haddr->port;
     }
   else

Modified: GNUnet/src/transports/common.h
===================================================================
--- GNUnet/src/transports/common.h      2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/transports/common.h      2008-02-27 06:50:36 UTC (rev 6475)
@@ -42,12 +42,12 @@
   /**
    * IPv6 address of the sender, network byte order
    */
-  GNUNET_IPv6Address ipv6;
+  struct in6_addr ipv6;
 
   /**
    * claimed IP of the sender, network byte order
    */
-  GNUNET_IPv4Address ipv4;
+  struct in_addr ipv4;
 
   /**
    * claimed port of the sender, network byte order

Modified: GNUnet/src/transports/http.c
===================================================================
--- GNUnet/src/transports/http.c        2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/transports/http.c        2008-02-27 06:50:36 UTC (rev 6475)
@@ -1836,6 +1836,7 @@
   long ms;
   int have_tv;
   char buf[128];                /* for reading from pipe */
+  int ret;
 
   ENTER ();
 #if DEBUG_HTTP
@@ -1890,7 +1891,13 @@
       STEP ();
       if (stats != NULL)
         stats->change (stat_select_calls, 1);
-      SELECT (max + 1, &rs, &ws, &es, (have_tv == MHD_YES) ? &tv : NULL);
+      ret = SELECT (max + 1, &rs, &ws, &es, (have_tv == MHD_YES) ? &tv : NULL);
+      if (ret == -1)
+       {
+         GNUNET_GE_LOG_STRERROR(coreAPI->ectx,
+                                GNUNET_GE_ERROR | GNUNET_GE_ADMIN | 
GNUNET_GE_DEVELOPER,
+                                "select");
+       }
       STEP ();
       if (GNUNET_YES != http_running)
         break;

Modified: GNUnet/src/transports/ip.c
===================================================================
--- GNUnet/src/transports/ip.c  2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/transports/ip.c  2008-02-27 06:50:36 UTC (rev 6475)
@@ -49,9 +49,9 @@
 int
 GNUNET_IP_get_public_ipv4_address (struct GNUNET_GC_Configuration *cfg,
                                    struct GNUNET_GE_Context *ectx,
-                                   GNUNET_IPv4Address * address)
+                                   struct in_addr * address)
 {
-  static GNUNET_IPv4Address myAddress;
+  static struct in_addr myAddress;
   static GNUNET_CronTime last;
   static GNUNET_CronTime lastError;
   GNUNET_CronTime now;
@@ -75,7 +75,7 @@
       GNUNET_free (ips);
       last = now;
     }
-  memcpy (address, &myAddress, sizeof (GNUNET_IPv4Address));
+  memcpy (address, &myAddress, sizeof (struct in_addr));
   return GNUNET_OK;
 }
 
@@ -213,10 +213,12 @@
  */
 static int
 getAddress6FromHostname (struct GNUNET_GE_Context *ectx,
-                         GNUNET_IPv6Address * identity)
+                         struct in6_addr * identity)
 {
   char hostname[MAX_HOSTNAME];
-  struct hostent *ip;
+  struct sockaddr_in6 addr;
+  struct sockaddr * sa;
+  socklen_t salen;
 
   if (0 != gethostname (hostname, MAX_HOSTNAME))
     {
@@ -228,25 +230,16 @@
   /* GNUNET_GE_LOG(ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
      " looking up $HOSTNAME (%s) to obtain local IP\n",
      hostname); */
-
-  ip = gethostbyname2 (hostname, AF_INET6);
-  if (ip == NULL)
-    {
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_INFO | GNUNET_GE_ADMIN | GNUNET_GE_USER |
-                     GNUNET_GE_BULK,
-                     _("Could not find IPv6 address of host `%s': %s\n"),
-                     hostname, hstrerror (h_errno));
-      return GNUNET_SYSERR;
-    }
-  if (ip->h_addrtype != AF_INET6)
-    {
-      GNUNET_GE_BREAK (ectx, 0);
-      return GNUNET_SYSERR;
-    }
-  GNUNET_GE_ASSERT (ectx,
-                    sizeof (struct in6_addr) == sizeof (identity->addr));
-  memcpy (&identity->addr[0], ip->h_addr_list[0], sizeof (struct in6_addr));
+  salen = sizeof(struct sockaddr_in);
+  sa = (struct sockaddr*) &addr;
+  if (GNUNET_OK !=
+      GNUNET_get_ip_from_hostname(ectx,
+                                 hostname,
+                                 AF_INET6,
+                                 &sa,
+                                 &salen))
+    return GNUNET_SYSERR;
+  *identity = addr.sin6_addr;
   return GNUNET_OK;
 }
 
@@ -254,7 +247,7 @@
 static int
 getAddress6FromGetIfAddrs (struct GNUNET_GC_Configuration *cfg,
                            struct GNUNET_GE_Context *ectx,
-                           GNUNET_IPv6Address * identity)
+                           struct in6_addr * identity)
 {
   char *interfaces;
   struct ifaddrs *ifa_first;
@@ -312,10 +305,14 @@
  */
 static int
 getAddress6 (struct GNUNET_GC_Configuration *cfg,
-             struct GNUNET_GE_Context *ectx, GNUNET_IPv6Address * address)
+             struct GNUNET_GE_Context *ectx, 
+            struct in6_addr * address)
 {
   char *ipString;
   int retval;
+  socklen_t sa_len;
+  struct sockaddr * sa;
+  struct sockaddr_in6 sa6;
 
   retval = GNUNET_SYSERR;
   if (GNUNET_GC_have_configuration_value (cfg, "NETWORK", "IP6"))
@@ -324,73 +321,19 @@
       GNUNET_GC_get_configuration_value_string (cfg,
                                                 "NETWORK", "IP6", "",
                                                 &ipString);
-      if (strlen (ipString) > 0)
-        {
-#if HAVE_GETADDRINFO
-          int s;
-          struct addrinfo hints;
-          struct addrinfo *result;
-
-          memset (&hints, 0, sizeof (struct addrinfo));
-          hints.ai_family = AF_INET6;   /* Allow only IPv6 */
-          hints.ai_socktype = SOCK_STREAM;      /* fixme? */
-          hints.ai_protocol = 0;        /* Any protocol */
-          hints.ai_canonname = NULL;
-          hints.ai_addr = NULL;
-          hints.ai_next = NULL;
-
-          if (0 != (s = getaddrinfo (ipString, NULL, &hints, &result)))
-            {
-              GNUNET_GE_LOG (ectx,
-                             GNUNET_GE_ERROR | GNUNET_GE_USER |
-                             GNUNET_GE_BULK,
-                             _("Could not resolve `%s': %s\n"), ipString,
-                             gai_strerror (s));
-            }
-          else
-            {
-              if ((result != NULL) &&
-                  (result->ai_addrlen == sizeof (struct sockaddr_in6)))
-                {
-                  GNUNET_GE_ASSERT (ectx,
-                                    sizeof (struct in6_addr) ==
-                                    sizeof (GNUNET_IPv6Address));
-                  memcpy (address,
-                          &((struct sockaddr_in6 *) result->ai_addr)->
-                          sin6_addr, sizeof (struct in6_addr));
-                  retval = GNUNET_OK;
-                }
-              freeaddrinfo (result);
-            }
-#else
-          struct hostent *ip;
-
-          ip = gethostbyname2 (ipString, AF_INET6);
-          if (ip == NULL)
-            {
-              GNUNET_GE_LOG (ectx,
-                             GNUNET_GE_ERROR | GNUNET_GE_USER |
-                             GNUNET_GE_BULK,
-                             _("Could not resolve `%s': %s\n"), ipString,
-                             hstrerror (h_errno));
-            }
-          else if (ip->h_addrtype != AF_INET6)
-            {
-              GNUNET_GE_ASSERT (ectx, 0);
-            }
-          else
-            {
-              GNUNET_GE_ASSERT (ectx,
-                                sizeof (struct in6_addr) ==
-                                sizeof (address->addr));
-              GNUNET_GE_ASSERT (ectx,
-                                sizeof (struct in6_addr) ==
-                                sizeof (GNUNET_IPv6Address));
-              memcpy (address, ip->h_addr_list[0], sizeof (struct in6_addr));
-              retval = GNUNET_OK;
-            }
-#endif
-        }
+      sa_len = sizeof(struct sockaddr_in6);
+      sa = (struct sockaddr*) &sa6;      
+      if ( (strlen (ipString) > 0) &&
+          (GNUNET_OK ==
+           GNUNET_get_ip_from_hostname(ectx,
+                                       ipString,
+                                       AF_INET6,
+                                       &sa,
+                                       &sa_len)) )
+       {
+         *address = sa6.sin6_addr;
+         retval = GNUNET_OK;
+       }
       GNUNET_free (ipString);
     }
 #if HAVE_GETIFADDRS && HAVE_FREEIFADDRS
@@ -410,9 +353,9 @@
 int
 GNUNET_IP_get_public_ipv6_address (struct GNUNET_GC_Configuration *cfg,
                                    struct GNUNET_GE_Context *ectx,
-                                   GNUNET_IPv6Address * address)
+                                   struct in6_addr * address)
 {
-  static GNUNET_IPv6Address myAddress;
+  static struct in6_addr myAddress;
   static GNUNET_CronTime last;
   static GNUNET_CronTime lastError;
   GNUNET_CronTime now;
@@ -433,7 +376,7 @@
         }
       last = now;
     }
-  memcpy (address, &myAddress, sizeof (GNUNET_IPv6Address));
+  memcpy (address, &myAddress, sizeof (struct in6_addr));
   return GNUNET_OK;
 }
 

Modified: GNUnet/src/transports/ip.h
===================================================================
--- GNUnet/src/transports/ip.h  2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/transports/ip.h  2008-02-27 06:50:36 UTC (rev 6475)
@@ -47,7 +47,7 @@
  */
 int GNUNET_IP_get_public_ipv4_address (struct GNUNET_GC_Configuration *cfg,
                                        struct GNUNET_GE_Context *ectx,
-                                       GNUNET_IPv4Address * address);
+                                       struct in_addr * address);
 
 /**
  * @brief Get the IPv6 address for the local machine.
@@ -56,7 +56,7 @@
  */
 int GNUNET_IP_get_public_ipv6_address (struct GNUNET_GC_Configuration *cfg,
                                        struct GNUNET_GE_Context *ectx,
-                                       GNUNET_IPv6Address * address);
+                                       struct in6_addr * address);
 
 
 /**

Modified: GNUnet/src/transports/nat.c
===================================================================
--- GNUnet/src/transports/nat.c 2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/transports/nat.c 2008-02-27 06:50:36 UTC (rev 6475)
@@ -47,14 +47,14 @@
 static int
 lan_ip_detected ()
 {
-  GNUNET_IPv4Address addr;
+  struct in_addr addr;
   unsigned int anum;
 
   if (GNUNET_SYSERR == GNUNET_IP_get_public_ipv4_address (coreAPI->cfg,
                                                           coreAPI->ectx,
                                                           &addr))
     return GNUNET_YES;          /* kind-of */
-  anum = ntohl (addr.addr);
+  anum = ntohl (addr.s_addr);
   if (((anum >= 0x0a000000) && (anum <= 0x0affffff)) || /* 10.x.x.x */
       ((anum >= 0xac100000) && (anum <= 0xac10ffff)) || /* 
172.16.0.0-172.31.0.0 */
       ((anum >= 0xc0a80000) && (anum <= 0xc0a8ffff)) || /* 192.168.x.x */

Modified: GNUnet/src/transports/tcp.c
===================================================================
--- GNUnet/src/transports/tcp.c 2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/transports/tcp.c 2008-02-27 06:50:36 UTC (rev 6475)
@@ -602,7 +602,7 @@
   if ((available & VERSION_AVAILABLE_IPV4) > 0)
     {
       soaddr4.sin_family = AF_INET;
-      memcpy (&soaddr4.sin_addr, &haddr->ipv4, sizeof (GNUNET_IPv4Address));
+      memcpy (&soaddr4.sin_addr, &haddr->ipv4, sizeof (struct in_addr));
       soaddr4.sin_port = haddr->port;
       soaddr = (struct sockaddr *) &soaddr4;
       soaddrlen = sizeof (soaddr4);
@@ -610,7 +610,7 @@
   else
     {
       soaddr6.sin6_family = AF_INET6;
-      memcpy (&soaddr6.sin6_addr, &haddr->ipv6, sizeof (GNUNET_IPv6Address));
+      memcpy (&soaddr6.sin6_addr, &haddr->ipv6, sizeof (struct in6_addr));
       soaddr6.sin6_port = haddr->port;
       soaddr = (struct sockaddr *) &soaddr6;
       soaddrlen = sizeof (soaddr6);

Modified: GNUnet/src/transports/udp.c
===================================================================
--- GNUnet/src/transports/udp.c 2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/transports/udp.c 2008-02-27 06:50:36 UTC (rev 6475)
@@ -360,7 +360,7 @@
       serverAddrv4.sin_family = AF_INET;
       serverAddrv4.sin_port = haddr->port;
       memcpy (&serverAddrv4.sin_addr, &haddr->ipv4,
-              sizeof (GNUNET_IPv4Address));
+              sizeof (struct in_addr));
       addrlen = sizeof (serverAddrv4);
       serverAddr = (struct sockaddr *) &serverAddrv4;
     }
@@ -370,7 +370,7 @@
       serverAddrv6.sin6_family = AF_INET;
       serverAddrv6.sin6_port = haddr->port;
       memcpy (&serverAddrv6.sin6_addr, &haddr->ipv6,
-              sizeof (GNUNET_IPv6Address));
+              sizeof (struct in6_addr));
       addrlen = sizeof (serverAddrv6);
       serverAddr = (struct sockaddr *) &serverAddrv6;
     }

Modified: GNUnet/src/transports/upnp/init.c
===================================================================
--- GNUnet/src/transports/upnp/init.c   2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/transports/upnp/init.c   2008-02-27 06:50:36 UTC (rev 6475)
@@ -58,14 +58,27 @@
  * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 static int
-gnunet_upnp_get_public_ip (GNUNET_IPv4Address * address)
+gnunet_upnp_get_public_ip (struct in_addr * address)
 {
   const char *ip;
+  socklen_t socklen;
+  struct sockaddr * sa;
+  struct sockaddr_in s4;
+  int ret;
 
   ip = gaim_upnp_get_public_ip ();
   if (ip == NULL)
     return GNUNET_SYSERR;
-  return GNUNET_get_host_by_name (ectx, ip, address);
+  socklen = sizeof(struct sockaddr_in);
+  sa = (struct sockaddr*) &s4;  
+  ret = GNUNET_get_ip_from_hostname (NULL,
+                                    ip,
+                                    AF_INET,
+                                    &sa,
+                                    &socklen);
+  if (ret == GNUNET_OK)
+    *address = s4.sin_addr;
+  return ret;
 }
 
 static void
@@ -126,7 +139,7 @@
  */
 static int
 gnunet_upnp_get_ip (unsigned short port,
-                    const char *protocol, GNUNET_IPv4Address * address)
+                    const char *protocol, struct in_addr * address)
 {
   unsigned int i;
 

Modified: GNUnet/src/transports/upnp/ip.c
===================================================================
--- GNUnet/src/transports/upnp/ip.c     2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/transports/upnp/ip.c     2008-02-27 06:50:36 UTC (rev 6475)
@@ -35,10 +35,10 @@
  * @return NULL on error
  */
 char *
-gaim_upnp_get_internal_ip (struct GNUNET_GC_Configuration *cfg,
-                           struct GNUNET_GE_Context *ectx)
+GNUNET_upnp_get_internal_ip (struct GNUNET_GC_Configuration *cfg,
+                            struct GNUNET_GE_Context *ectx)
 {
-  GNUNET_IPv4Address address;
+  struct in_addr address;
 
   return GNUNET_get_local_ip (cfg, ectx, &address);
 }

Modified: GNUnet/src/transports/upnp/ip.h
===================================================================
--- GNUnet/src/transports/upnp/ip.h     2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/transports/upnp/ip.h     2008-02-27 06:50:36 UTC (rev 6475)
@@ -33,8 +33,8 @@
  * Get the IP address for the local machine.
  * @return NULL on error
  */
-char *gaim_upnp_get_internal_ip (struct GNUNET_GC_Configuration *cfg,
-                                 struct GNUNET_GE_Context *ectx);
+char *GNUNET_upnp_get_internal_ip (struct GNUNET_GC_Configuration *cfg,
+                                  struct GNUNET_GE_Context *ectx);
 
 
 #endif

Modified: GNUnet/src/transports/upnp/upnp.c
===================================================================
--- GNUnet/src/transports/upnp/upnp.c   2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/transports/upnp/upnp.c   2008-02-27 06:50:36 UTC (rev 6475)
@@ -553,7 +553,7 @@
                     struct GNUNET_GC_Configuration *cfg, int sock)
 {
   char *proxy;
-  struct hostent *hp;
+  socklen_t avail;
   struct sockaddr_in server;
   int retry_count;
   char *sendMessage;
@@ -565,20 +565,26 @@
   const char *endDescURL;
   int ret;
   UPnPDiscoveryData dd;
+  struct sockaddr * sa;
 
   memset (&dd, 0, sizeof (UPnPDiscoveryData));
   if (control_info.status == GAIM_UPNP_STATUS_DISCOVERING)
     return GNUNET_NO;
   dd.sock = sock;
-  hp = gethostbyname (HTTPMU_HOST_ADDRESS);
-  if (hp == NULL)
+  memset (&server, 0, sizeof (struct sockaddr_in));
+  server.sin_family = AF_INET;
+  avail = sizeof(struct sockaddr_in);
+  sa = (struct sockaddr*) &server;
+  if (GNUNET_OK !=
+      GNUNET_get_ip_from_hostname(ectx,
+                                 HTTPMU_HOST_ADDRESS,
+                                 AF_INET,
+                                 &sa,
+                                 &avail))
     {
       CLOSE (dd.sock);
       return GNUNET_SYSERR;
     }
-  memset (&server, 0, sizeof (struct sockaddr));
-  server.sin_family = AF_INET;
-  memcpy (&server.sin_addr, hp->h_addr_list[0], hp->h_length);
   server.sin_port = htons (HTTPMU_HOST_PORT);
   control_info.status = GAIM_UPNP_STATUS_DISCOVERING;
 
@@ -694,7 +700,7 @@
     return GNUNET_NO;
   if (do_add)
     {
-      internal_ip = gaim_upnp_get_internal_ip (cfg, ectx);
+      internal_ip = GNUNET_upnp_get_internal_ip (cfg, ectx);
       if (internal_ip == NULL)
         {
           gaim_debug_error ("upnp",

Modified: GNUnet/src/transports/upnp/upnptest.c
===================================================================
--- GNUnet/src/transports/upnp/upnptest.c       2008-02-27 04:14:13 UTC (rev 
6474)
+++ GNUnet/src/transports/upnp/upnptest.c       2008-02-27 06:50:36 UTC (rev 
6475)
@@ -36,12 +36,13 @@
   static GNUNET_CoreAPIForPlugins capi;
   struct GNUNET_GE_Context *ectx;
   struct GNUNET_GC_Configuration *cfg;
-  GNUNET_IPv4Address addr;
+  struct in_addr addr;
   int i;
   GNUNET_UPnP_ServiceAPI *upnp;
   struct GNUNET_PluginHandle *plug;
   GNUNET_ServicePluginInitializationMethod init;
   GNUNET_ServicePluginShutdownMethod done;
+  char ntop_buf[INET_ADDRSTRLEN];
 
   ectx = GNUNET_GE_create_context_stderr (GNUNET_NO,
                                           GNUNET_GE_WARNING | GNUNET_GE_ERROR
@@ -85,8 +86,8 @@
         break;
       if (GNUNET_OK == upnp->get_ip (2086, "TCP", &addr))
         {
-          printf ("UPnP returned external IP %u.%u.%u.%u\n",
-                  GNUNET_PRIP (ntohl (*(int *) &addr)));
+          printf ("UPnP returned external IP %s\n",
+                 inet_ntop(AF_INET, &addr, ntop_buf, INET_ADDRSTRLEN));
         }
       else
         {

Modified: GNUnet/src/util/network/dns.c
===================================================================
--- GNUnet/src/util/network/dns.c       2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/util/network/dns.c       2008-02-27 06:50:36 UTC (rev 6475)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2007 Christian Grothoff (and other contributing authors)
+     (C) 2007, 2008 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -21,7 +21,6 @@
 /**
  * @file util/network/dns.c
  * @brief code to do DNS resolution
- *
  * @author Christian Grothoff
  */
 
@@ -58,10 +57,9 @@
 static adns_state a_state;
 #endif
 
-static void
-cache_resolve (struct IPCache *cache)
+#if HAVE_ADNS
+static void adns_resolve(struct IPCache * cache)
 {
-#if HAVE_ADNS
   adns_answer *answer;
   adns_status ret;
   struct IPCache *rec;
@@ -97,34 +95,60 @@
         }
       cache->posted = GNUNET_NO;
     }
-#else
+}
+#endif
+
 #if HAVE_GETNAMEINFO
+static void getnameinfo_resolve(struct IPCache * cache)
+{
   char hostname[256];
 
   if (0 == getnameinfo (cache->sa, cache->salen, hostname, 255, NULL, 0, 0))
     cache->addr = GNUNET_strdup (hostname);
-#else
+}
+#endif
+
 #if HAVE_GETHOSTBYADDR
+static void gethostbyaddr_resolve(struct IPCache * cache)
+{
   struct hostent *ent;
 
   switch (cache->sa->sa_family)
     {
     case AF_INET:
       ent = gethostbyaddr (&((struct sockaddr_in *) cache->sa)->sin_addr,
-                           sizeof (GNUNET_IPv4Address), AF_INET);
+                           sizeof (struct in_addr), AF_INET);
       break;
     case AF_INET6:
       ent = gethostbyaddr (&((struct sockaddr_in6 *) cache->sa)->sin6_addr,
-                           sizeof (IPaddr6), AF_INET6);
+                           sizeof (struct in6_addr), AF_INET6);
       break;
     default:
       ent = NULL;
     }
   if (ent != NULL)
     cache->addr = GNUNET_strdup (ent->h_name);
+}
 #endif
+
+static void
+cache_resolve (struct IPCache *cache)
+{
+#if HAVE_ADNS
+  if (cache->sa->sa_family == AF_INET)
+    {
+      adns_resolve(cache);
+      return;
+    }
 #endif
+#if HAVE_GETNAMEINFO
+  if (cache->addr == NULL)
+    getnameinfo_resolve(cache);
 #endif
+#if HAVE_GETHOSTBYADDR
+  if (cache->addr == NULL)
+    gethostbyaddr_resolve(cache);
+#endif
 }
 
 static struct IPCache *
@@ -152,6 +176,7 @@
 no_resolve (const struct sockaddr *sa, unsigned int salen)
 {
   char *ret;
+  char inet4[INET_ADDRSTRLEN];
   char inet6[INET6_ADDRSTRLEN];
 
   if (salen < sizeof (struct sockaddr))
@@ -161,13 +186,10 @@
     case AF_INET:
       if (salen != sizeof (struct sockaddr_in))
         return NULL;
-      ret = GNUNET_strdup ("255.255.255.255");
-      GNUNET_snprintf (ret,
-                       strlen ("255.255.255.255") + 1,
-                       "%u.%u.%u.%u",
-                       GNUNET_PRIP (ntohl
-                                    (*(int *) &((struct sockaddr_in *) sa)->
-                                     sin_addr)));
+      inet_ntop (AF_INET,
+                 &((struct sockaddr_in *) sa)->sin_addr,
+                 inet4, INET_ADDRSTRLEN);
+      ret = GNUNET_strdup (inet4);
       break;
     case AF_INET6:
       if (salen != sizeof (struct sockaddr_in6))
@@ -271,9 +293,248 @@
   return ret;
 }
 
+#if HAVE_GETHOSTBYNAME
+static int
+gethostbyname_resolve(struct GNUNET_GE_Context *ectx,
+                     const char * hostname,    
+                     struct sockaddr ** sa,
+                     socklen_t * socklen) 
+{
+  struct hostent *hp;
+  struct sockaddr_in * addr;
+   
+  hp = GETHOSTBYNAME (hostname);
+  if (hp == NULL)
+    {
+      GNUNET_GE_LOG (ectx,
+                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_BULK,
+                     _("Could not find IP of host `%s': %s\n"),
+                     hostname, hstrerror (h_errno));
+      return GNUNET_SYSERR;    
+    }
+  if (hp->h_addrtype != AF_INET)
+    {
+      GNUNET_GE_BREAK (ectx, 0);
+      return GNUNET_SYSERR;
+    }
+  GNUNET_GE_ASSERT(NULL, hp->h_length == sizeof(struct in_addr));
+  if (NULL == *sa)
+    {
+      *sa = GNUNET_malloc(sizeof(struct sockaddr_in));
+      memset(*sa, 0, sizeof(struct sockaddr_in));
+      *socklen = sizeof(struct sockaddr_in);
+    }
+  else
+    {
+      if (sizeof(struct sockaddr_in) > *socklen)
+       return GNUNET_SYSERR;
+      *socklen = sizeof(struct sockaddr_in);
+    }
+  addr = (struct sockaddr_in*) *sa;
+  memset (addr, 0, sizeof (struct sockaddr_in));
+  addr->sin_family = AF_INET;
+  memcpy(&addr->sin_addr,
+        hp->h_addr_list[0], 
+        hp->h_length);
+  return GNUNET_OK;
+}
+#endif
 
+#if HAVE_GETHOSTBYNAME2
+static int
+gethostbyname2_resolve(struct GNUNET_GE_Context *ectx,
+                      const char * hostname,   
+                      int domain,
+                      struct sockaddr ** sa,
+                      socklen_t * socklen) 
+{
+  struct hostent *hp;
+   
+  if (domain == AF_UNSPEC)
+    {
+      hp = gethostbyname2 (hostname, AF_INET);
+      if (hp == NULL)
+       hp = gethostbyname2 (hostname, AF_INET6);
+    }
+  else
+    {
+      hp = gethostbyname2 (hostname, domain);
+    }
+  if (hp == NULL)
+    {
+      GNUNET_GE_LOG (ectx,
+                     GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_BULK,
+                     _("Could not find IP of host `%s': %s\n"),
+                     hostname, hstrerror (h_errno));
+      return GNUNET_SYSERR;    
+    }
+  if ( (hp->h_addrtype != domain) &&
+       (domain != 0) )
+    {
+      GNUNET_GE_BREAK (ectx, 0);
+      return GNUNET_SYSERR;
+    }
+  domain = hp->haddrtype;
+  if (domain == AF_INET)
+    {
+      GNUNET_GE_ASSERT(NULL, hp->h_length == sizeof(struct in_addr));
+      if (NULL == *sa)
+       {
+         *sa = GNUNET_malloc(sizeof(struct sockaddr_in));
+         memset(*sa, 0, sizeof(struct sockaddr_in));
+         *socklen = sizeof(struct sockaddr_in);
+       }
+      else
+       {
+         if (sizeof(struct sockaddr_in) > *socklen)
+           return GNUNET_SYSERR;
+         *socklen = sizeof(struct sockaddr_in);
+       }
+      memset (*sa, 0, sizeof (struct sockaddr_in));
+      (*sa)->sa_family = AF_INET;
+      memcpy(&((struct sockaddr_in*)(*sa))->sin_addr,
+            hp->h_addr_list[0], 
+            hp->h_length);
+    }
+  else
+    {
+      GNUNET_GE_ASSERT(NULL, hp->h_length == sizeof(struct in_addr6));
+      if (NULL == *sa)
+       {
+         *sa = GNUNET_malloc(sizeof(struct sockaddr_in6));
+         memset(*sa, 0, sizeof(struct sockaddr_in6));      
+         *socklen = sizeof(struct sockaddr_in6);
+       }
+      else
+       {
+         if (sizeof(struct sockaddr_in6) > *socklen)
+           return GNUNET_SYSERR;
+         *socklen = sizeof(struct sockaddr_in6);
+       }
+      memset (*sa, 0, sizeof (struct sockaddr_in6));
+      (*sa)->sa_family = AF_INET6;
+      memcpy(&((struct sockaddr_in6*)(*sa))->sin6_addr,
+            hp->h_addr_list[0], 
+            hp->h_length);
+    }
+  return GNUNET_OK;
+}
+#endif
 
+#if HAVE_GETADDRINFO
+int
+getaddrinfo_resolve (struct GNUNET_GE_Context *ectx,
+                     const char * hostname,    
+                    int domain,
+                    struct sockaddr ** sa,
+                    socklen_t * socklen) 
+{
+  int s;
+  struct addrinfo hints;
+  struct addrinfo *result;
+  
+  memset (&hints, 0, sizeof (struct addrinfo));
+  hints.ai_family = domain;
+  hints.ai_socktype = 0;
+  hints.ai_protocol = 0;   /* Any protocol */
+  hints.ai_canonname = NULL;
+  hints.ai_addr = NULL;
+  hints.ai_next = NULL;
+  
+  if (0 != (s = getaddrinfo (hostname, NULL, &hints, &result)))
+    {
+      GNUNET_GE_LOG (ectx,
+                    GNUNET_GE_ERROR | GNUNET_GE_USER |
+                    GNUNET_GE_BULK,
+                    _("Could not resolve `%s': %s\n"), hostname,
+                    gai_strerror (s));
+      return GNUNET_SYSERR;
+    }
+  if (result == NULL)
+    return GNUNET_SYSERR;
+  if (NULL == *sa)
+    {
+      *sa = GNUNET_malloc(result->ai_addrlen);
+      *socklen = result->ai_addrlen;
+      memcpy(*sa,
+            result->ai_addr,
+            result->ai_addrlen);
+      freeaddrinfo (result);
+      return GNUNET_OK;
+    }
+  if (result->ai_addrlen > *socklen)
+    {
+      freeaddrinfo (result);
+      return GNUNET_SYSERR;
+    }
+  *socklen = result->ai_addrlen;
+  memcpy (*sa,
+         result->ai_addr,
+         result->ai_addrlen);
+  freeaddrinfo (result);
+  return GNUNET_OK;
+}
+#endif
 
+
+/**
+ * Convert a string to an IP address.
+ *
+ * @param hostname the hostname to resolve
+ * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any"
+ * @param *sa should be of type "struct sockaddr*" and
+ *        will be set to the IP address on success;
+ *        if *sa is NULL, sufficient space will be
+ *        allocated.        
+ * @param socklen will be set to the length of *sa.
+ *        If *sa is not NULL, socklen will be checked
+ *        to see if sufficient space is provided and
+ *        updated to the amount of space actually
+ *        required/used.
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ */
+int
+GNUNET_get_ip_from_hostname (struct GNUNET_GE_Context *ectx,
+                            const char * hostname,     
+                            int domain,
+                            struct sockaddr ** sa,
+                            socklen_t * socklen) 
+{
+  int ret;
+
+  ret = GNUNET_NO; /* NO: continue trying, OK: success, SYSERR: failure */
+  GNUNET_mutex_lock(lock);
+#if HAVE_GETADDRINFO
+  if (ret == GNUNET_NO)
+    ret = getaddrinfo_resolve(ectx,
+                             hostname,
+                             domain,
+                             sa,
+                             socklen);        
+#endif
+#if HAVE_GETHOSTBYNAME2
+  if (ret == GNUNET_NO) 
+    ret = gethostbyname2_resolve(ectx,
+                                hostname,
+                                domain,
+                                sa,
+                                socklen);    
+#endif
+#if HAVE_GETHOSTBYNAME
+  if ( (ret == GNUNET_NO) &&
+       ( (domain == AF_UNSPEC) ||
+        (domain == PF_INET) ) ) 
+    ret = gethostbyname_resolve(ectx,
+                               hostname,
+                               sa,
+                               socklen);    
+#endif
+  GNUNET_mutex_unlock(lock);
+  if (ret == GNUNET_NO)
+    ret = GNUNET_SYSERR; /* no further options */
+  return ret;
+}
+
 void __attribute__ ((constructor)) GNUNET_dns_ltdl_init ()
 {
   lock = GNUNET_mutex_create (GNUNET_YES);

Modified: GNUnet/src/util/network/io.c
===================================================================
--- GNUnet/src/util/network/io.c        2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/util/network/io.c        2008-02-27 06:50:36 UTC (rev 6475)
@@ -30,11 +30,6 @@
 
 #define DEBUG_IO GNUNET_NO
 
-/**
- * Global lock for gethostbyname.
- */
-static struct GNUNET_Mutex *lock;
-
 #ifndef MINGW
 static struct GNUNET_SignalHandlerContext *sctx;
 
@@ -46,7 +41,6 @@
 
 void __attribute__ ((constructor)) GNUNET_network_io_init ()
 {
-  lock = GNUNET_mutex_create (GNUNET_NO);
 #ifndef MINGW
   sctx = GNUNET_signal_handler_install (SIGPIPE, &catcher);
 #else
@@ -56,8 +50,6 @@
 
 void __attribute__ ((destructor)) GNUNET_network_io_fini ()
 {
-  GNUNET_mutex_destroy (lock);
-  lock = NULL;
 #ifndef MINGW
   GNUNET_signal_handler_uninstall (SIGPIPE, &catcher, sctx);
   sctx = NULL;
@@ -66,43 +58,7 @@
 #endif
 }
 
-/**
- * Get the IP address of the given host.
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
- */
-int
-GNUNET_get_host_by_name (struct GNUNET_GE_Context *ectx, const char *hostname,
-                         GNUNET_IPv4Address * ip)
-{
-  struct hostent *he;
 
-  /* slight hack: re-use config lock */
-  GNUNET_mutex_lock (lock);
-  he = GETHOSTBYNAME (hostname);
-  if (he == NULL)
-    {
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_BULK,
-                     _("Could not find IP of host `%s': %s\n"),
-                     hostname, hstrerror (h_errno));
-      GNUNET_mutex_unlock (lock);
-      return GNUNET_SYSERR;
-    }
-  if (he->h_addrtype != AF_INET)
-    {
-      GNUNET_GE_BREAK (ectx, 0);
-      GNUNET_mutex_unlock (lock);
-      return GNUNET_SYSERR;
-    }
-  memcpy (ip,
-          &((struct in_addr *) he->h_addr_list[0])->s_addr,
-          sizeof (struct in_addr));
-  GNUNET_mutex_unlock (lock);
-  return GNUNET_OK;
-}
-
-
-
 struct GNUNET_SocketHandle *
 GNUNET_socket_create (struct GNUNET_GE_Context *ectx,
                       struct GNUNET_LoadMonitor *mon, int osSocket)

Modified: GNUnet/src/util/network/ip.c
===================================================================
--- GNUnet/src/util/network/ip.c        2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/util/network/ip.c        2008-02-27 06:50:36 UTC (rev 6475)
@@ -51,10 +51,13 @@
  */
 static int
 getAddressFromHostname (struct GNUNET_GE_Context *ectx,
-                        GNUNET_IPv4Address * identity)
+                        struct in_addr * identity)
 {
   char hostname[MAX_HOSTNAME];
   int ret;
+  struct sockaddr * my_addr;
+  struct sockaddr_in a4;
+  socklen_t socklen;
 
   if (0 != gethostname (hostname, MAX_HOSTNAME))
     {
@@ -63,7 +66,11 @@
                               GNUNET_GE_USER | GNUNET_GE_BULK, "gethostname");
       return GNUNET_SYSERR;
     }
-  ret = GNUNET_get_host_by_name (ectx, hostname, identity);
+  socklen = sizeof(struct sockaddr_in);          
+  my_addr = (struct sockaddr*) &a4;
+  ret = GNUNET_get_ip_from_hostname (ectx, hostname, AF_INET, &my_addr, 
&socklen);
+  if (ret == GNUNET_OK)
+    *identity = a4.sin_addr;
   return ret;
 }
 
@@ -71,7 +78,7 @@
 static int
 getAddressFromGetIfAddrs (struct GNUNET_GC_Configuration *cfg,
                           struct GNUNET_GE_Context *ectx,
-                          GNUNET_IPv4Address * identity)
+                          struct in_addr * identity)
 {
   char *interfaces;
   struct ifaddrs *ifa_first;
@@ -129,7 +136,7 @@
 static int
 getAddressFromIOCTL (struct GNUNET_GC_Configuration *cfg,
                      struct GNUNET_GE_Context *ectx,
-                     GNUNET_IPv4Address * identity)
+                     struct in_addr * identity)
 {
   char *interfaces;
 #ifndef MINGW
@@ -241,6 +248,7 @@
   GNUNET_free (interfaces);
   return GNUNET_SYSERR;
 #else /* MinGW */
+  char ntop_buf[INET_ADDRSTRLEN];
 
   /* Win 98 or Win NT SP 4 */
   if (GNGetIpAddrTable)
@@ -292,12 +300,14 @@
           return GNUNET_SYSERR;
         }
       else if (iAddrCount > 1)
-        GNUNET_GE_LOG (ectx,
-                       GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
-                       _("There is more than one IP address specified"
-                         " for interface `%s'.\nGNUnet will "
-                         "use %u.%u.%u.%u.\n"), interfaces,
-                       GNUNET_PRIP (ntohl (dwIP)));
+       {
+         GNUNET_GE_LOG (ectx,
+                        GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
+                        _("There is more than one IP address specified"
+                          " for interface `%s'.\nGNUnet will "
+                          "use %s.\n"), interfaces,
+                        inet_ntop(AF_INET, &dwIP, ntop_buf, INET_ADDRSTRLEN));
+       }
 
       identity->addr = dwIP;
 
@@ -349,9 +359,8 @@
     }
 
   GNUNET_GE_LOG (ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
-                 _("GNUnet now uses the IP address %u.%u.%u.%u.\n"),
-                 GNUNET_PRIP (ntohl (identity->addr)));
-
+                 _("GNUnet now uses the IP address %s.\n"),
+                inet_ntop(AF_INET, &identity->addr, ntop_buf, 
INET_ADDRSTRLEN));
   return GNUNET_OK;
 #endif
 }
@@ -365,12 +374,15 @@
 char *
 GNUNET_get_local_ip (struct GNUNET_GC_Configuration *cfg,
                      struct GNUNET_GE_Context *ectx,
-                     GNUNET_IPv4Address * addr)
+                     struct in_addr * addr)
 {
-  GNUNET_IPv4Address address;
+  struct in_addr address;
+  struct sockaddr * my_addr;
+  struct sockaddr_in a4;
   char *ipString;
   int retval;
-  char buf[65];
+  char buf[INET_ADDRSTRLEN];
+  socklen_t socklen;
 
   retval = GNUNET_SYSERR;
   if (GNUNET_GC_have_configuration_value (cfg, "NETWORK", "IP"))
@@ -380,7 +392,11 @@
                                                 &ipString);
       if (strlen (ipString) > 0)
         {
-          retval = GNUNET_get_host_by_name (ectx, ipString, &address);
+         socklen = sizeof(struct sockaddr_in);   
+         my_addr = (struct sockaddr*) &a4;
+          retval = GNUNET_get_ip_from_hostname (ectx, ipString, AF_INET, 
&my_addr, &socklen);
+         if (retval == GNUNET_OK)
+           address = a4.sin_addr;
         }
       GNUNET_free (ipString);
     }
@@ -398,8 +414,12 @@
     retval = getAddressFromHostname (ectx, &address);
   if (retval == GNUNET_SYSERR)
     return NULL;
-  GNUNET_snprintf (buf, 64, "%u.%u.%u.%u",
-                   GNUNET_PRIP (ntohl (*(int *) &address)));
+  if (NULL == 
+      inet_ntop(AF_INET,
+               &address,
+               buf,
+               INET_ADDRSTRLEN))
+    return NULL;
   if (addr != NULL)
     *addr = address;
   return GNUNET_strdup (buf);

Modified: GNUnet/src/util/network/ipcheck.c
===================================================================
--- GNUnet/src/util/network/ipcheck.c   2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/src/util/network/ipcheck.c   2008-02-27 06:50:36 UTC (rev 6475)
@@ -34,8 +34,8 @@
  */
 typedef struct GNUNET_IPv4NetworkSet
 {
-  GNUNET_IPv4Address network;
-  GNUNET_IPv4Address netmask;
+  struct in_addr network;
+  struct in_addr netmask;
 } CIDRNetwork;
 
 /**
@@ -43,8 +43,8 @@
  */
 typedef struct GNUNET_IPv6NetworkSet
 {
-  GNUNET_IPv6Address network;
-  GNUNET_IPv6Address netmask;
+  struct in6_addr network;
+  struct in6_addr netmask;
 } CIDR6Network;
 
 
@@ -108,11 +108,11 @@
                 GNUNET_free (result);
                 return NULL;
               }
-          result[i].network.addr
+          result[i].network.s_addr
             =
             htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) +
                    temps[3]);
-          result[i].netmask.addr =
+          result[i].netmask.s_addr =
             htonl ((temps[4] << 24) + (temps[5] << 16) + (temps[6] << 8) +
                    temps[7]);
           while (routeList[pos] != ';')
@@ -138,20 +138,20 @@
                 GNUNET_free (result);
                 return NULL;
               }
-          result[i].network.addr
+          result[i].network.s_addr
             =
             htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) +
                    temps[3]);
           if ((slash <= 32) && (slash >= 0))
             {
-              result[i].netmask.addr = 0;
+              result[i].netmask.s_addr = 0;
               while (slash > 0)
                 {
-                  result[i].netmask.addr
-                    = (result[i].netmask.addr >> 1) + 0x80000000;
+                  result[i].netmask.s_addr
+                    = (result[i].netmask.s_addr >> 1) + 0x80000000;
                   slash--;
                 }
-              result[i].netmask.addr = htonl (result[i].netmask.addr);
+              result[i].netmask.s_addr = htonl (result[i].netmask.s_addr);
               while (routeList[pos] != ';')
                 pos++;
               pos++;
@@ -188,18 +188,18 @@
                 GNUNET_free (result);
                 return NULL;
               }
-          result[i].network.addr
+          result[i].network.s_addr
             =
             htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) +
                    temps[3]);
-          result[i].netmask.addr = 0;
+          result[i].netmask.s_addr = 0;
           while (slash > 0)
             {
-              result[i].netmask.addr
-                = (result[i].netmask.addr >> 1) + 0x80000000;
+              result[i].netmask.s_addr
+                = (result[i].netmask.s_addr >> 1) + 0x80000000;
               slash--;
             }
-          result[i].netmask.addr = htonl (result[i].netmask.addr);
+          result[i].netmask.s_addr = htonl (result[i].netmask.s_addr);
           while (routeList[pos] != ';')
             pos++;
           pos++;
@@ -284,7 +284,7 @@
         slash--;
       if (slash < start)
         {
-          memset (&result[i].netmask, 0xFF, sizeof (GNUNET_IPv6Address));
+          memset (&result[i].netmask, 0xFF, sizeof (struct in6_addr));
           slash = pos;
         }
       else
@@ -333,20 +333,21 @@
  * @return GNUNET_NO if the IP is not in the list, GNUNET_YES if it it is
  */
 int
-GNUNET_check_ipv4_listed (const CIDRNetwork * list, GNUNET_IPv4Address ip)
+GNUNET_check_ipv4_listed (const CIDRNetwork * list, 
+                         const struct in_addr * ip)
 {
   int i;
-  GNUNET_IPv4Address add;
+  const struct in_addr * add;
 
   add = ip;
   i = 0;
   if (list == NULL)
     return GNUNET_NO;
 
-  while ((list[i].network.addr != 0) || (list[i].netmask.addr != 0))
+  while ((list[i].network.s_addr != 0) || (list[i].netmask.s_addr != 0))
     {
-      if ((add.addr & list[i].netmask.addr) ==
-          (list[i].network.addr & list[i].netmask.addr))
+      if ((add->s_addr & list[i].netmask.s_addr) ==
+          (list[i].network.s_addr & list[i].netmask.s_addr))
         return GNUNET_YES;
       i++;
     }
@@ -361,7 +362,8 @@
  * @return GNUNET_NO if the IP is not in the list, GNUNET_YES if it it is
  */
 int
-GNUNET_check_ipv6_listed (const CIDR6Network * list, GNUNET_IPv6Address ip)
+GNUNET_check_ipv6_listed (const CIDR6Network * list, 
+                         const struct in6_addr * ip)
 {
   unsigned int i;
   unsigned int j;
@@ -376,7 +378,7 @@
          (memcmp (&zero, &list[i].netmask, sizeof (struct in6_addr)) != 0))
     {
       for (j = 0; j < sizeof (struct in6_addr) / sizeof (int); j++)
-        if (((((int *) &ip)[j] & ((int *) &list[i].netmask)[j])) !=
+        if (((((int *) ip)[j] & ((int *) &list[i].netmask)[j])) !=
             (((int *) &list[i].network)[j] & ((int *) &list[i].netmask)[j]))
           {
             i++;

Modified: GNUnet/src/util/network/selecttest.c
===================================================================
--- GNUnet/src/util/network/selecttest.c        2008-02-27 04:14:13 UTC (rev 
6474)
+++ GNUnet/src/util/network/selecttest.c        2008-02-27 06:50:36 UTC (rev 
6475)
@@ -197,7 +197,7 @@
   sh = GNUNET_select_create ("Select Tester", GNUNET_NO,        /* tcp */
                              NULL,      /* ectx */
                              NULL,      /* no load monitoring */
-                             listen_sock, sizeof (GNUNET_IPv4Address), 15 * 
GNUNET_CRON_SECONDS,        /* inactive timeout */
+                             listen_sock, sizeof (struct in_addr), 15 * 
GNUNET_CRON_SECONDS,        /* inactive timeout */
                              test_smh, NULL, test_sah, NULL, test_sch, NULL, 
128 * 1024,        /* memory quota */
                              128 /* socket quota */ );
 

Modified: GNUnet/src/util/network_client/tcpio.c
===================================================================
--- GNUnet/src/util/network_client/tcpio.c      2008-02-27 04:14:13 UTC (rev 
6474)
+++ GNUnet/src/util/network_client/tcpio.c      2008-02-27 06:50:36 UTC (rev 
6475)
@@ -236,7 +236,8 @@
                                            GNUNET_ClientServerConnection
                                            *sock)
 {
-  struct sockaddr_in soaddr;
+  struct sockaddr * soaddr;
+  socklen_t socklen;
   fd_set rset;
   fd_set wset;
   fd_set eset;
@@ -245,7 +246,6 @@
   int osock;
   unsigned short port;
   char *host;
-  GNUNET_IPv4Address ip;
 
   GNUNET_GE_ASSERT (NULL, sock != NULL);
   if (sock->sock != NULL)
@@ -258,7 +258,9 @@
   host = getGNUnetdHost (sock->ectx, sock->cfg);
   if (host == NULL)
     return GNUNET_SYSERR;
-  if (GNUNET_SYSERR == GNUNET_get_host_by_name (sock->ectx, host, &ip))
+  soaddr = NULL;
+  socklen = 0;
+  if (GNUNET_SYSERR == GNUNET_get_ip_from_hostname (sock->ectx, host, 
AF_UNSPEC, &soaddr, &socklen))
     {
       GNUNET_free (host);
       return GNUNET_SYSERR;
@@ -268,15 +270,26 @@
     {
       GNUNET_free (host);
       GNUNET_mutex_unlock (sock->destroylock);
+      GNUNET_free(soaddr);
       return GNUNET_OK;
     }
   if (sock->dead == GNUNET_YES)
     {
       GNUNET_free (host);
       GNUNET_mutex_unlock (sock->destroylock);
+      GNUNET_free(soaddr);
       return GNUNET_SYSERR;
     }
-  osock = SOCKET (PF_INET, SOCK_STREAM, 6);     /* 6: TCP */
+  if (soaddr->sa_family == AF_INET)
+    {
+      ((struct sockaddr_in*) soaddr)->sin_port = htons (port);
+      osock = SOCKET (PF_INET, SOCK_STREAM, 0);
+    } 
+  else
+    {
+      ((struct sockaddr_in6*) soaddr)->sin6_port = htons (port);
+      osock = SOCKET (PF_INET6, SOCK_STREAM, 0);
+    }
   if (osock == -1)
     {
       GNUNET_GE_LOG_STRERROR (sock->ectx,
@@ -284,17 +297,13 @@
                               GNUNET_GE_ADMIN | GNUNET_GE_BULK, "socket");
       GNUNET_free (host);
       GNUNET_mutex_unlock (sock->destroylock);
+      GNUNET_free(soaddr);
       return GNUNET_SYSERR;
     }
   sock->sock = GNUNET_socket_create (sock->ectx, NULL, osock);
   GNUNET_socket_set_blocking (sock->sock, GNUNET_NO);
-  memset (&soaddr, 0, sizeof (soaddr));
-  soaddr.sin_family = AF_INET;
-  GNUNET_GE_ASSERT (sock->ectx,
-                    sizeof (struct in_addr) == sizeof (GNUNET_IPv4Address));
-  memcpy (&soaddr.sin_addr, &ip, sizeof (struct in_addr));
-  soaddr.sin_port = htons (port);
-  ret = CONNECT (osock, (struct sockaddr *) &soaddr, sizeof (soaddr));
+  ret = CONNECT (osock, soaddr, socklen);
+  GNUNET_free(soaddr);
   if ((ret != 0) && (errno != EINPROGRESS) && (errno != EWOULDBLOCK))
     {
       GNUNET_GE_LOG (sock->ectx,

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2008-02-27 04:14:13 UTC (rev 6474)
+++ GNUnet/todo 2008-02-27 06:50:36 UTC (rev 6475)
@@ -5,10 +5,6 @@
   PRE == to be done before a pre-release
 
 0.8.0pre0 [2'08]:
-- make sure "make check" passes
-- make tcpserver & network_client IPv6 compatible
-  => clean up gethostbyname mess!
-  => fix gnunet_util_network API for that stuff!
 - gnunet-gtk ready?
 - more IPv6 testing
 
@@ -19,7 +15,7 @@
 - test new asynchronous ECRS API (and resulting FSUI changes);
   make sure error handling & reporting are nice [RC]
 - test RPC code (write a small demo)
-- test GAP code in general; still have one unexplained crazy crash:
+- test GAP code in general; still have one unexplained crazy crash (not seen 
in a while):
   Program terminated with signal 11, Segmentation fault.
  #0  0xb4e8e73a in GNUNET_FS_SHARED_test_valid_new_response (rl=0x8060,
      primary_key=0xb343f1c8, size=820, data=0xb0b8f0e8, hc=0xb343f134) at 
shared.c:94





reply via email to

[Prev in Thread] Current Thread [Next in Thread]