gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r25830 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r25830 - gnunet/src/transport
Date: Fri, 18 Jan 2013 14:49:00 +0100

Author: wachs
Date: 2013-01-18 14:49:00 +0100 (Fri, 18 Jan 2013)
New Revision: 25830

Modified:
   gnunet/src/transport/plugin_transport_http_client.c
   gnunet/src/transport/plugin_transport_http_common.c
Log:
changes


Modified: gnunet/src/transport/plugin_transport_http_client.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_client.c 2013-01-18 12:23:11 UTC 
(rev 25829)
+++ gnunet/src/transport/plugin_transport_http_client.c 2013-01-18 13:49:00 UTC 
(rev 25830)
@@ -1450,11 +1450,12 @@
       {
           salen = sizeof (struct sockaddr_in);
       }
-      else if (AF_INET == sa->sa_family)
+      else if (AF_INET6 == sa->sa_family)
       {
           salen = sizeof (struct sockaddr_in6);
       }
       ats = plugin->env->get_address_type (plugin->env->cls, sa, salen);
+      //fprintf (stderr, "Address %s is in %s\n", GNUNET_a2s (sa,salen), 
GNUNET_ATS_print_network_type(ntohl(ats.value)));
       GNUNET_free (sa);
   }
   else if (GNUNET_NO == res)

Modified: gnunet/src/transport/plugin_transport_http_common.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_common.c 2013-01-18 12:23:11 UTC 
(rev 25829)
+++ gnunet/src/transport/plugin_transport_http_common.c 2013-01-18 13:49:00 UTC 
(rev 25830)
@@ -37,6 +37,18 @@
        int port;
 };
 
+static void
+http_clean_splitted (struct SplittedHTTPAddress *spa)
+{
+       if (NULL != spa)
+       {
+                       GNUNET_free_non_null (spa->protocol);
+                       GNUNET_free_non_null (spa->host);
+                       GNUNET_free_non_null (spa->path);
+                       GNUNET_free_non_null (spa);
+       }
+}
+
 struct SplittedHTTPAddress *
 http_split_address (const char * addr)
 {
@@ -289,11 +301,10 @@
 struct sockaddr *
 http_common_socket_from_address (const void *addr, size_t addrlen, int *res)
 {
+       struct SplittedHTTPAddress * spa;
   struct sockaddr_storage *s;
-  char *addrs;
-  char *addrs_org;
-  char *addrs_end;
   (*res) = GNUNET_SYSERR;
+  char * to_conv;
 
   if (NULL == addr)
     {
@@ -311,50 +322,35 @@
       return NULL;
     }
 
-  addrs_org = strdup ((char *) addr);
-  addrs = strstr (addrs_org , "://");
-  if (NULL == addrs)
+  spa = http_split_address (addr);
+  if (NULL == spa)
   {
-    GNUNET_break (0);
-    GNUNET_free (addrs_org);
-    return NULL;
+      (*res) = GNUNET_SYSERR;
+      return NULL;
   }
 
-  if (strlen (addrs) < 3)
-  {
-    GNUNET_break (0);
-    GNUNET_free (addrs_org);
-    return NULL;
-  }
-
-  addrs += 3;
-
-  addrs_end = strchr (addrs, '/');
-  if (NULL != addrs_end)
-    addrs[strlen (addrs) - strlen(addrs_end)] = '\0';
-
   s = GNUNET_malloc (sizeof (struct sockaddr_storage));
-  if (GNUNET_SYSERR == GNUNET_STRINGS_to_address_ip (addrs, strlen(addrs), s))
+  GNUNET_asprintf (&to_conv, "%s:%u", spa->host, spa->port);
+  if (GNUNET_SYSERR == GNUNET_STRINGS_to_address_ip (to_conv, strlen(to_conv), 
s))
   {
     /* could be a hostname */
-    GNUNET_free (s);
-    GNUNET_free (addrs_org);
+       GNUNET_free (s);
     (*res) = GNUNET_NO;
-    return NULL;
+    s = NULL;
   }
+  else if ((AF_INET != s->ss_family) && (AF_INET6 != s->ss_family))
+  {
+
+               GNUNET_free (s);
+               (*res) = GNUNET_SYSERR;
+               s = NULL;
+  }
   else
   {
-    if ((AF_INET != s->ss_family) && (AF_INET6 != s->ss_family))
-    {
-      GNUNET_break (0);
-      GNUNET_free (s);
-      GNUNET_free (addrs_org);
-      (*res) = GNUNET_SYSERR;
-      return NULL;
-    }
+               (*res) = GNUNET_YES;
   }
-  (*res) = GNUNET_YES;
-  GNUNET_free (addrs_org);
+       http_clean_splitted (spa);
+  GNUNET_free (to_conv);
   return (struct sockaddr *) s;
 }
 




reply via email to

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