gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r6421 - GNUnet/src/transports


From: gnunet
Subject: [GNUnet-SVN] r6421 - GNUnet/src/transports
Date: Sat, 23 Feb 2008 21:47:38 -0700 (MST)

Author: grothoff
Date: 2008-02-23 21:47:37 -0700 (Sat, 23 Feb 2008)
New Revision: 6421

Modified:
   GNUnet/src/transports/common.c
   GNUnet/src/transports/http.c
   GNUnet/src/transports/ip.c
   GNUnet/src/transports/test.c
   GNUnet/src/transports/test.conf
   GNUnet/src/transports/test_repeat.c
Log:
http ipv6 fixes

Modified: GNUnet/src/transports/common.c
===================================================================
--- GNUnet/src/transports/common.c      2008-02-23 06:17:27 UTC (rev 6420)
+++ GNUnet/src/transports/common.c      2008-02-24 04:47:37 UTC (rev 6421)
@@ -366,6 +366,7 @@
       return NULL;              /* TCP transport is configured SEND-only! */
     }
   msg = GNUNET_malloc (sizeof (GNUNET_MessageHello) + sizeof (HostAddress));
+  msg->header.size = htons(sizeof (GNUNET_MessageHello) + sizeof 
(HostAddress));
   haddr = (HostAddress *) & msg[1];
 
   available = VERSION_AVAILABLE_NONE;

Modified: GNUnet/src/transports/http.c
===================================================================
--- GNUnet/src/transports/http.c        2008-02-23 06:17:27 UTC (rev 6420)
+++ GNUnet/src/transports/http.c        2008-02-24 04:47:37 UTC (rev 6421)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet
-     (C) 2003, 2004, 2005, 2006, 2007 Christian Grothoff (and other 
contributing authors)
+     (C) 2003, 2004, 2005, 2006, 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
@@ -191,11 +191,6 @@
   struct MHDGetData *next;
 
   /**
-   * mutex for synchronized access to struct
-   */
-  struct GNUNET_Mutex *lock;
-
-  /**
    * MHD connection handle for this request.
    */
   struct MHD_Connection *session;
@@ -250,11 +245,6 @@
   GNUNET_TSession *tsession;
 
   /**
-   * mutex for synchronized access to struct
-   */
-  struct GNUNET_Mutex *lock;
-
-  /**
    * To whom are we talking to.
    */
   GNUNET_PeerIdentity sender;
@@ -434,10 +424,10 @@
 static unsigned int tsessionArrayLength;
 
 /**
- * CURL requires that only one thread manipulates each
- * handle.  This lock is used to ensure that.
+ * Lock for concurrent access to all structures used
+ * by http, including CURL.
  */
-static struct GNUNET_Mutex *curllock;
+static struct GNUNET_Mutex * lock;
 
 
 /**
@@ -488,9 +478,9 @@
       GNUNET_free (tsession);
       return GNUNET_OK;
     }
-  GNUNET_mutex_lock (httpsession->lock);
+  GNUNET_mutex_lock (lock);
   httpsession->users--;
-  GNUNET_mutex_unlock (httpsession->lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
   return GNUNET_OK;
 }
@@ -518,10 +508,8 @@
           break;
         }
     }
-  GNUNET_mutex_unlock (lock);
   if (httpsession->is_client)
     {
-      GNUNET_mutex_lock (curllock);
 #if DO_GET
       STEP ();
       curl_multi_remove_handle (curl_multi, httpsession->cs.client.get);
@@ -550,8 +538,6 @@
           GNUNET_free (pos);
           pos = next;
         }
-      GNUNET_mutex_unlock (curllock);
-      GNUNET_mutex_destroy (httpsession->lock);
       GNUNET_free (httpsession);
       GNUNET_free (tsession);
     }
@@ -563,23 +549,19 @@
       gpos = httpsession->cs.server.gets;
       while (gpos != NULL)
         {
-          GNUNET_mutex_lock (gpos->lock);
           GNUNET_array_grow (gpos->wbuff, gpos->wsize, 0);
           r = gpos->get;
           gpos->get = NULL;
-          /* contentReaderFreeCallback WILL
-             destroy gpos->lock/gpos */
           gnext = gpos->next;
-          GNUNET_mutex_unlock (gpos->lock);
           MHD_destroy_response (r);
           gpos = gnext;
         }
       httpsession->cs.server.gets = NULL;
 #endif
-      GNUNET_mutex_destroy (httpsession->lock);
       GNUNET_free (httpsession->tsession);
       GNUNET_free (httpsession);
     }
+  GNUNET_mutex_unlock (lock);
   EXIT ();
 }
 
@@ -668,15 +650,15 @@
       return GNUNET_SYSERR;
     }
   httpSession = tsession->internal;
-  GNUNET_mutex_lock (httpSession->lock);
+  GNUNET_mutex_lock (lock);
   if (httpSession->destroyed == GNUNET_YES)
     {
-      GNUNET_mutex_unlock (httpSession->lock);
+      GNUNET_mutex_unlock (lock);
       EXIT ();
       return GNUNET_SYSERR;
     }
   httpSession->users++;
-  GNUNET_mutex_unlock (httpSession->lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
   return GNUNET_OK;
 }
@@ -684,8 +666,8 @@
 /**
  * Add a new session to the array watched by the select thread.  Grows
  * the array if needed.  If the caller wants to do anything useful
- * with the return value, it must have the lock on httplock before
- * calling.  It is ok to call this function without holding httplock if
+ * with the return value, it must have the lock before
+ * calling.  It is ok to call this function without holding lock if
  * the return value is ignored.
  */
 static unsigned int
@@ -723,7 +705,7 @@
   GNUNET_CronTime now;
 
   ENTER ();
-  GNUNET_mutex_lock (mgd->lock);
+  GNUNET_mutex_lock (lock);
   if (mgd->wpos < max)
     max = mgd->wpos;
   memcpy (buf, &mgd->wbuff[mgd->woff], max);
@@ -734,11 +716,11 @@
     mgd->last_get_activity = now;
   if (mgd->wpos == 0)
     mgd->woff = 0;
-  GNUNET_mutex_unlock (mgd->lock);
+  GNUNET_mutex_unlock (lock);
 #if DEBUG_HTTP
   GNUNET_GE_LOG (coreAPI->ectx,
                  GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
-                 "HTTP returns %u bytes in MHD GET handler.\n", max);
+                 "HTTP returns %u bytes in MHD's GET handler.\n", max);
 #endif
   if (stats != NULL)
     stats->change (stat_bytesSent, max);
@@ -764,7 +746,6 @@
 
   ENTER ();
   GNUNET_GE_ASSERT (NULL, mgd->get == NULL);
-  GNUNET_mutex_destroy (mgd->lock);
   GNUNET_array_grow (mgd->wbuff, mgd->wsize, 0);
   GNUNET_free (mgd);
   EXIT ();
@@ -856,7 +837,6 @@
       httpSession = GNUNET_malloc (sizeof (HTTPSession));
       memset (httpSession, 0, sizeof (HTTPSession));
       httpSession->sender.hashPubKey = client;
-      httpSession->lock = GNUNET_mutex_create (GNUNET_YES);
       httpSession->users = 0;   /* MHD */
       tsession = GNUNET_malloc (sizeof (GNUNET_TSession));
       memset (tsession, 0, sizeof (GNUNET_TSession));
@@ -871,7 +851,7 @@
       httpSession->is_mhd_active++;
       *httpSessionCache = httpSession;
     }
-  GNUNET_mutex_lock (httpSession->lock);
+  GNUNET_mutex_lock (lock);
 #if DO_GET
   if (0 == strcasecmp (MHD_HTTP_METHOD_GET, method))
     {
@@ -885,7 +865,6 @@
          have one already */
       get = GNUNET_malloc (sizeof (struct MHDGetData));
       memset (get, 0, sizeof (struct MHDGetData));
-      get->lock = GNUNET_mutex_create (GNUNET_NO);
       get->next = httpSession->cs.server.gets;
       httpSession->cs.server.gets = get;
       get->session = session;
@@ -900,7 +879,7 @@
       STEP ();
       MHD_queue_response (session, MHD_HTTP_OK, get->get);
       STEP ();
-      GNUNET_mutex_unlock (httpSession->lock);
+      GNUNET_mutex_unlock (lock);
       EXIT ();
       return MHD_YES;
     }
@@ -951,7 +930,7 @@
           STEP ();
           MHD_destroy_response (response);
           STEP ();
-          GNUNET_mutex_unlock (httpSession->lock);
+          GNUNET_mutex_unlock (lock);
           return MHD_YES;
         }
       while (have > 0)
@@ -1007,10 +986,10 @@
           put->rpos1 = 0;
           put->ready = GNUNET_YES;
         }
-      GNUNET_mutex_unlock (httpSession->lock);
+      GNUNET_mutex_unlock (lock);
       return MHD_YES;
     }
-  GNUNET_mutex_unlock (httpSession->lock);
+  GNUNET_mutex_unlock (lock);
   GNUNET_GE_BREAK_OP (NULL, 0); /* invalid request */
   EXIT ();
   return MHD_NO;
@@ -1131,6 +1110,8 @@
   char *url;
   GNUNET_EncName enc;
   unsigned short available;
+  const char * obr;
+  const char * cbr;
   const HostAddress *haddr =
     (const HostAddress *) &httpSession->cs.client.address;
 
@@ -1147,9 +1128,11 @@
           if (NULL == inet_ntop (AF_INET6, &haddr->ipv6, buf, IP_BUF_LEN))
             {
               /* log? */
-              return;
               EXIT ();
+              return;
             }
+         obr = "[";
+         cbr = "]";
         }
       else
         {
@@ -1159,11 +1142,13 @@
               EXIT ();
               return;
             }
+         obr = "";
+         cbr = "";
         }
       url = GNUNET_malloc (64 + sizeof (GNUNET_EncName) + strlen (buf));
       GNUNET_snprintf (url,
                        64 + sizeof (GNUNET_EncName),
-                       "http://%s:%u/%s";, buf, ntohs (haddr->port), &enc);
+                       "http://%s%s%s/%s";, obr, buf, cbr, &enc);
       httpSession->cs.client.url = url;
     }
   EXIT ();
@@ -1183,6 +1168,7 @@
   CURLcode ret;
   CURLMcode mret;
   GNUNET_CronTime now;
+  const HostAddress *haddr;
 
   ENTER ();
   if (httpSession->cs.client.url == NULL)
@@ -1191,13 +1177,13 @@
   if (curl_get != NULL)
     {
       STEP ();
-      GNUNET_mutex_lock (curllock);
+      GNUNET_mutex_lock (lock);
       curl_multi_remove_handle (curl_multi, curl_get);
       http_requests_pending--;
       signal_select ();
       STEP ();
       curl_easy_cleanup (curl_get);
-      GNUNET_mutex_unlock (curllock);
+      GNUNET_mutex_unlock (lock);
       STEP ();
       httpSession->cs.client.get = NULL;
     }
@@ -1206,8 +1192,11 @@
   if (curl_get == NULL)
     return GNUNET_SYSERR;
   /* create GET */
+  haddr =
+    (const HostAddress *) &httpSession->cs.client.address;
   CURL_EASY_SETOPT (curl_get, CURLOPT_FAILONERROR, 1);
   CURL_EASY_SETOPT (curl_get, CURLOPT_URL, httpSession->cs.client.url);
+  CURL_EASY_SETOPT (curl_get, CURLOPT_PORT, (long) ntohs (haddr->port));
   if (strlen (proxy) > 0)
     CURL_EASY_SETOPT (curl_get, CURLOPT_PROXY, proxy);
   CURL_EASY_SETOPT (curl_get, CURLOPT_BUFFERSIZE, 32 * 1024);
@@ -1232,10 +1221,10 @@
       return GNUNET_SYSERR;
     }
   STEP ();
-  GNUNET_mutex_lock (curllock);
+  GNUNET_mutex_lock (lock);
   mret = curl_multi_add_handle (curl_multi, curl_get);
   http_requests_pending++;
-  GNUNET_mutex_unlock (curllock);
+  GNUNET_mutex_unlock (lock);
   if (stats != NULL)
     stats->change (stat_get_issued, 1);
   STEP ();
@@ -1309,7 +1298,6 @@
   httpSession = GNUNET_malloc (sizeof (HTTPSession));
   memset (httpSession, 0, sizeof (HTTPSession));
   httpSession->sender = hello->senderIdentity;
-  httpSession->lock = GNUNET_mutex_create (GNUNET_YES);
   httpSession->users = 1;       /* us only, core has not seen this tsession! */
   httpSession->is_client = GNUNET_YES;
   httpSession->cs.client.address = *haddr;
@@ -1371,6 +1359,7 @@
   CURLcode ret;
   CURLMcode mret;
   long size;
+  const HostAddress *haddr;
 
   ENTER ();
   /* we should have initiated a GET earlier,
@@ -1382,8 +1371,11 @@
   STEP ();
   if (curl_put == NULL)
     return GNUNET_SYSERR;
+  haddr =
+    (const HostAddress *) &httpSession->cs.client.address;
   CURL_EASY_SETOPT (curl_put, CURLOPT_FAILONERROR, 1);
   CURL_EASY_SETOPT (curl_put, CURLOPT_URL, httpSession->cs.client.url);
+  CURL_EASY_SETOPT (curl_put, CURLOPT_PORT, (long) ntohs (haddr->port));
   if (strlen (proxy) > 0)
     CURL_EASY_SETOPT (curl_put, CURLOPT_PROXY, proxy);
   CURL_EASY_SETOPT (curl_put, CURLOPT_BUFFERSIZE, put->size);
@@ -1413,10 +1405,10 @@
       return GNUNET_SYSERR;
     }
   STEP ();
-  GNUNET_mutex_lock (curllock);
+  GNUNET_mutex_lock (lock);
   mret = curl_multi_add_handle (curl_multi, curl_put);
   http_requests_pending++;
-  GNUNET_mutex_unlock (curllock);
+  GNUNET_mutex_unlock (lock);
   if (stats != NULL)
     stats->change (stat_put_issued, 1);
   STEP ();
@@ -1427,7 +1419,6 @@
                      GNUNET_GE_BULK, _("%s failed at %s:%d: `%s'\n"),
                      "curl_multi_add_handle", __FILE__, __LINE__,
                      curl_multi_strerror (mret));
-      GNUNET_mutex_unlock (lock);
       EXIT ();
       return GNUNET_SYSERR;
     }
@@ -1487,7 +1478,7 @@
   else
     {
       /* server */
-      GNUNET_mutex_lock (httpSession->lock);
+      GNUNET_mutex_lock (lock);
       get = httpSession->cs.server.gets;
       if (get == NULL)
         ret = GNUNET_NO;
@@ -1501,7 +1492,7 @@
           else
             ret = GNUNET_YES;
         }
-      GNUNET_mutex_unlock (httpSession->lock);
+      GNUNET_mutex_unlock (lock);
       EXIT ();
       return ret;
     }
@@ -1542,19 +1533,19 @@
         }
       if (important != GNUNET_YES)
         {
-          GNUNET_mutex_lock (httpSession->lock);
+          GNUNET_mutex_lock (lock);
           if (httpSession->cs.client.puts != NULL)
             {
               /* do not queue more than one unimportant PUT at a time */
              signal_select ();       /* do clean up now! */
-              GNUNET_mutex_unlock (httpSession->lock);
+              GNUNET_mutex_unlock (lock);
               if (stats != NULL)
                 stats->change (stat_bytesDropped, size);
 
               EXIT ();
               return GNUNET_NO;
             }
-          GNUNET_mutex_unlock (httpSession->lock);
+          GNUNET_mutex_unlock (lock);
         }
       putData = GNUNET_malloc (sizeof (struct HTTPPutData));
       memset (putData, 0, sizeof (struct HTTPPutData));
@@ -1572,10 +1563,10 @@
           EXIT ();
           return GNUNET_SYSERR;
         }
-      GNUNET_mutex_lock (httpSession->lock);
+      GNUNET_mutex_lock (lock);
       putData->next = httpSession->cs.client.puts;
       httpSession->cs.client.puts = putData;
-      GNUNET_mutex_unlock (httpSession->lock);
+      GNUNET_mutex_unlock (lock);
       EXIT ();
       return GNUNET_OK;
     }
@@ -1589,15 +1580,14 @@
                  size);
 #endif
 #if DO_GET
-  GNUNET_mutex_lock (httpSession->lock);
+  GNUNET_mutex_lock (lock);
   getData = httpSession->cs.server.gets;
   if (getData == NULL)
     {
-      GNUNET_mutex_unlock (httpSession->lock);
+      GNUNET_mutex_unlock (lock);
       EXIT ();
       return GNUNET_SYSERR;
     }
-  GNUNET_mutex_lock (getData->lock);
   if (getData->wsize == 0)
     GNUNET_array_grow (getData->wbuff, getData->wsize, HTTP_BUF_SIZE);
   size += sizeof (GNUNET_MessageHeader);
@@ -1606,8 +1596,7 @@
       /* need to grow or discard */
       if (!important)
         {
-          GNUNET_mutex_unlock (getData->lock);
-          GNUNET_mutex_unlock (httpSession->lock);
+         GNUNET_mutex_unlock (lock);
           EXIT ();
           return GNUNET_NO;
         }
@@ -1641,8 +1630,7 @@
       memcpy (&hdr[1], msg, size - sizeof (GNUNET_MessageHeader));
       getData->wpos += size;
     }
-  GNUNET_mutex_unlock (getData->lock);
-  GNUNET_mutex_unlock (httpSession->lock);
+  GNUNET_mutex_unlock (lock);
 #endif
   EXIT ();
   return GNUNET_OK;
@@ -1676,7 +1664,6 @@
   for (i = 0; i < tsessionCount; i++)
     {
       s = tsessions[i]->internal;
-      GNUNET_mutex_lock (s->lock);
       if (s->is_client)
         {
           if ((s->cs.client.puts == NULL) && (s->users == 0)
@@ -1685,7 +1672,6 @@
 #endif
             )
             {
-              GNUNET_mutex_unlock (s->lock);
 #if DO_GET
 #if DEBUG_HTTP
               GNUNET_GE_LOG (coreAPI->ectx,
@@ -1714,10 +1700,8 @@
                     prev->next = pos->next;
                   GNUNET_free (pos->msg);
                   STEP ();
-                  GNUNET_mutex_lock (curllock);
                   curl_multi_remove_handle (curl_multi, pos->curl_put);
                   http_requests_pending--;
-                  GNUNET_mutex_unlock (curllock);
                   STEP ();
                   signal_select ();
                   STEP ();
@@ -1794,7 +1778,6 @@
 #endif
                (s->is_mhd_active == 0) && (s->users == 0))
             {
-              GNUNET_mutex_unlock (s->lock);
 #if DO_GET
 #if DEBUG_HTTP
               GNUNET_GE_LOG (coreAPI->ectx,
@@ -1808,7 +1791,6 @@
               continue;
             }
         }
-      GNUNET_mutex_unlock (s->lock);
     }
   GNUNET_mutex_unlock (lock);
   EXIT ();
@@ -1845,9 +1827,9 @@
       FD_ZERO (&ws);
       FD_ZERO (&es);
       STEP ();
-      GNUNET_mutex_lock (curllock);
+      GNUNET_mutex_lock (lock);
       mret = curl_multi_fdset (curl_multi, &rs, &ws, &es, &max);
-      GNUNET_mutex_unlock (curllock);
+      GNUNET_mutex_unlock (lock);
       STEP ();
       if (mret != CURLM_OK)
         {
@@ -1868,14 +1850,14 @@
         have_tv = MHD_get_timeout (mhd_daemon, &timeout);
       STEP ();
 
-      GNUNET_mutex_lock (curllock);
+      GNUNET_mutex_lock (lock);
       if ((CURLM_OK == curl_multi_timeout (curl_multi, &ms)) &&
           (ms != -1) && ((ms < timeout) || (have_tv == MHD_NO)))
         {
           timeout = ms;
           have_tv = MHD_YES;
         }
-      GNUNET_mutex_unlock (curllock);
+      GNUNET_mutex_unlock (lock);
       STEP ();
       FD_SET (signal_pipe[0], &rs);
       if (max < signal_pipe[0])
@@ -1891,15 +1873,15 @@
       do
         {
           STEP ();
-          GNUNET_mutex_lock (curllock);
+          GNUNET_mutex_lock (lock);
           mret = curl_multi_perform (curl_multi, &running);
-          GNUNET_mutex_unlock (curllock);
+          GNUNET_mutex_unlock (lock);
           STEP ();
         }
       while ((mret == CURLM_CALL_MULTI_PERFORM)
              && (http_running == GNUNET_YES));
       if (FD_ISSET (signal_pipe[0], &rs))
-        read (signal_pipe[0], buf, 1);
+       read (signal_pipe[0], buf, sizeof(buf));
       if ((mret != CURLM_OK) && (mret != CURLM_CALL_MULTI_PERFORM))
         GNUNET_GE_LOG (coreAPI->ectx,
                        GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER |
@@ -2003,6 +1985,7 @@
       return GNUNET_SYSERR;
     }
   GNUNET_pipe_make_nonblocking (coreAPI->ectx, signal_pipe[0]);
+  GNUNET_pipe_make_nonblocking (coreAPI->ectx, signal_pipe[1]);
   http_running = GNUNET_YES;
   curl_thread = GNUNET_thread_create (&curl_runner, NULL, 32 * 1024);
   if (curl_thread == NULL)
@@ -2071,11 +2054,11 @@
   coreAPI = core;
   cfg = coreAPI->cfg;
   lock = GNUNET_mutex_create (GNUNET_YES);
-  curllock = GNUNET_mutex_create (GNUNET_YES);
   if (0 != GNUNET_GC_attach_change_listener (coreAPI->cfg,
                                              &reload_configuration, NULL))
     {
       GNUNET_mutex_destroy (lock);
+      lock = NULL;
       return NULL;
     }
   if (0 != curl_global_init (CURL_GLOBAL_WIN32))
@@ -2084,6 +2067,7 @@
       GNUNET_GC_detach_change_listener (coreAPI->cfg, &reload_configuration,
                                         NULL);
       GNUNET_mutex_destroy (lock);
+      lock = NULL;
       return NULL;
     }
   tsessionCount = 0;
@@ -2147,7 +2131,6 @@
 donetransport_http ()
 {
   ENTER ();
-  GNUNET_mutex_destroy (curllock);
   curl_global_cleanup ();
   GNUNET_free_non_null (proxy);
   proxy = NULL;

Modified: GNUnet/src/transports/ip.c
===================================================================
--- GNUnet/src/transports/ip.c  2008-02-23 06:17:27 UTC (rev 6420)
+++ GNUnet/src/transports/ip.c  2008-02-24 04:47:37 UTC (rev 6421)
@@ -316,7 +316,6 @@
 {
   char *ipString;
   int retval;
-  struct hostent *ip;           /* for the lookup of the IP in gnunet.conf */
 
   retval = GNUNET_SYSERR;
   if (GNUNET_GC_have_configuration_value (cfg, "NETWORK", "IP6"))
@@ -327,6 +326,49 @@
                                                 &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)
             {
@@ -339,17 +381,20 @@
           else if (ip->h_addrtype != AF_INET6)
             {
               GNUNET_GE_ASSERT (ectx, 0);
-              retval = GNUNET_SYSERR;
             }
-          else
-            {
-              GNUNET_GE_ASSERT (ectx,
-                                sizeof (struct in6_addr) ==
-                                sizeof (address->addr));
-              memcpy (&address->addr[0], ip->h_addr_list[0],
-                      sizeof (struct in6_addr));
-              retval = GNUNET_OK;
-            }
+         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
         }
       GNUNET_free (ipString);
     }

Modified: GNUnet/src/transports/test.c
===================================================================
--- GNUnet/src/transports/test.c        2008-02-23 06:17:27 UTC (rev 6420)
+++ GNUnet/src/transports/test.c        2008-02-24 04:47:37 UTC (rev 6421)
@@ -32,6 +32,7 @@
 #include "gnunet_directories.h"
 #include "gnunet_protocols.h"
 #include "gnunet_transport.h"
+#include "common.h"
 
 #define ROUNDS 10
 
@@ -115,8 +116,8 @@
         {
           hello = transport->createhello ();
           /* HACK hello -- change port! */
-          ((unsigned short *) &hello[1])[2] =
-            htons (ntohs (((unsigned short *) &hello[1])[2]) - OFFSET);
+          ((HostAddress *) &hello[1])->port =
+            htons (ntohs (((HostAddress *) &hello[1])->port) - OFFSET);
           if (GNUNET_OK != transport->connect (hello, &tsession, GNUNET_NO))
             {
               GNUNET_free (hello);
@@ -175,7 +176,7 @@
   GNUNET_MessageHello *hello;
 
   memset (&api, 0, sizeof (GNUNET_CoreAPIForTransport));
-  pid = fork ();
+  pid = fork();
   res = GNUNET_init (argc,
                      argv,
                      "transport-test",
@@ -202,14 +203,10 @@
                                             "BLACKLIST", "");
   GNUNET_GC_set_configuration_value_string (api.cfg, api.ectx, "TCP", "UPNP",
                                             "NO");
-  GNUNET_GC_set_configuration_value_string (api.cfg, api.ectx, "TCP6",
-                                            "BLACKLIST", "");
   GNUNET_GC_set_configuration_value_string (api.cfg, api.ectx, "UDP",
                                             "BLACKLIST", "");
   GNUNET_GC_set_configuration_value_string (api.cfg, api.ectx, "UDP", "UPNP",
                                             "NO");
-  GNUNET_GC_set_configuration_value_string (api.cfg, api.ectx, "UDP6",
-                                            "BLACKLIST", "");
   GNUNET_GC_set_configuration_value_string (api.cfg, api.ectx, "HTTP",
                                             "BLACKLIST", "");
   GNUNET_GC_set_configuration_value_string (api.cfg, api.ectx, "HTTP", "UPNP",
@@ -221,12 +218,8 @@
     pos = 0;
   GNUNET_GC_set_configuration_value_number (api.cfg, api.ectx, "TCP", "PORT",
                                             4444 + pos);
-  GNUNET_GC_set_configuration_value_number (api.cfg, api.ectx, "TCP6", "PORT",
-                                            4445 + pos);
   GNUNET_GC_set_configuration_value_number (api.cfg, api.ectx, "UDP", "PORT",
                                             4446 + pos);
-  GNUNET_GC_set_configuration_value_number (api.cfg, api.ectx, "UDP6", "PORT",
-                                            4447 + pos);
   GNUNET_GC_set_configuration_value_number (api.cfg, api.ectx, "HTTP", "PORT",
                                             4448 + pos);
   GNUNET_create_random_hash (&me.hashPubKey);
@@ -274,8 +267,8 @@
       /* client - initiate requests */
       hello = transport->createhello ();
       /* HACK hello -- change port! */
-      ((unsigned short *) &hello[1])[2] =
-        htons (ntohs (((unsigned short *) &hello[1])[2]) + OFFSET);
+      ((HostAddress *) &hello[1])->port =
+       htons (ntohs (((HostAddress *) &hello[1])->port) + OFFSET);
       if (GNUNET_OK != transport->connect (hello, &tsession, GNUNET_NO))
         {
           GNUNET_free (hello);
@@ -349,4 +342,4 @@
 }
 
 
-/* end of gnunet-transport-check */
+/* end of test.c */

Modified: GNUnet/src/transports/test.conf
===================================================================
--- GNUnet/src/transports/test.conf     2008-02-23 06:17:27 UTC (rev 6420)
+++ GNUnet/src/transports/test.conf     2008-02-24 04:47:37 UTC (rev 6421)
@@ -6,6 +6,9 @@
 RARE = YES
 EXPERIMENTAL = NO
 
+[MODULES]
+topology = topology_default
+
 [GNUNETD]
 TRANSPORTS = udp tcp nat
 KEEPLOG = 3
@@ -13,10 +16,12 @@
 
 [NETWORK]
 IP = 127.0.0.1
+IP6 = ::1
 
 [LOGGING]
 USER-LEVEL = WARNING
 ADMIN-LEVEL = WARNING
+DEVELOPER = NO
 
 [TCP]
 PORT = 2086
@@ -24,21 +29,24 @@
 [TCP6]
 PORT = 2088
 BLACKLIST = 
+UPNP = NO
 
 [UDP]
 PORT = 2086
 MTU = 1472
 BLACKLIST = 
+UPNP = NO
 
 [UDP6]
 PORT = 2088
 MTU = 1452
 BLACKLIST = 
+UPNP = NO
 
 [HTTP]
 PORT = 1080
+UPNP = NO
 
-
 [TESTING]
 WEAKRANDOM = YES
 

Modified: GNUnet/src/transports/test_repeat.c
===================================================================
--- GNUnet/src/transports/test_repeat.c 2008-02-23 06:17:27 UTC (rev 6420)
+++ GNUnet/src/transports/test_repeat.c 2008-02-24 04:47:37 UTC (rev 6421)
@@ -19,7 +19,7 @@
 */
 
 /**
- * @file transports/test.c
+ * @file transports/test_repeat.c
  * @brief Test for the transports.
  * @author Christian Grothoff
  *
@@ -32,6 +32,7 @@
 #include "gnunet_directories.h"
 #include "gnunet_protocols.h"
 #include "gnunet_transport.h"
+#include "common.h"
 
 #define ROUNDS 10
 
@@ -117,8 +118,8 @@
         {
           hello = transport->createhello ();
           /* HACK hello -- change port! */
-          ((unsigned short *) &hello[1])[2] =
-            htons (ntohs (((unsigned short *) &hello[1])[2]) - OFFSET);
+          ((HostAddress *) &hello[1])->port =
+            htons (ntohs (((HostAddress *) &hello[1])->port) - OFFSET);
           if (GNUNET_OK != transport->connect (hello, &tsession, GNUNET_NO))
             {
               GNUNET_free (hello);
@@ -280,8 +281,8 @@
           /* client - initiate requests */
           hello = transport->createhello ();
           /* HACK hello -- change port! */
-          ((unsigned short *) &hello[1])[2] =
-            htons (ntohs (((unsigned short *) &hello[1])[2]) + OFFSET);
+          ((HostAddress *) &hello[1])->port =
+            htons (ntohs (((HostAddress *) &hello[1])->port) + OFFSET);
           if (GNUNET_OK != transport->connect (hello, &tsession, GNUNET_NO))
             {
               GNUNET_free (hello);
@@ -363,4 +364,4 @@
 }
 
 
-/* end of gnunet-transport-check */
+/* end of test_repeat.c */





reply via email to

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