gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r15786 - gnunet/src/transport
Date: Wed, 29 Jun 2011 10:24:25 +0200

Author: wachs
Date: 2011-06-29 10:24:25 +0200 (Wed, 29 Jun 2011)
New Revision: 15786

Modified:
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/plugin_transport_unix.c
Log:
fixing "minor changes" and repair things that obviously never worked


Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2011-06-28 15:58:37 UTC 
(rev 15785)
+++ gnunet/src/transport/gnunet-service-transport.c     2011-06-29 08:24:25 UTC 
(rev 15786)
@@ -1681,9 +1681,11 @@
   p = find_transport (plugin);
   if ((p == NULL) || (addr_len == 0) || (addr == NULL))
     return NULL;
-  return p->api->address_to_string (p->api->cls,
+
+  return p->api->address_to_string (NULL,
                                    addr,
                                    addr_len);
+  return NULL;
 }
 
 
@@ -2773,7 +2775,7 @@
  * provided by the plugin can be reached.
  *
  * @param cls closure
- * @param add_remove YES to add, NO to remove the address
+ * @param add_remove GNUNET_YES to add, GNUNET_NO to remove the address
  * @param addr one of the addresses of the host, NULL for the last address
  *        the specific address format depends on the transport
  * @param addrlen length of the address
@@ -2788,6 +2790,8 @@
   struct OwnAddressList *al;
   struct OwnAddressList *prev;
 
+  GNUNET_assert (p->api != NULL);
+
   GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
              (add_remove == GNUNET_YES)
              ? "Adding `%s':%s to the set of our addresses\n"

Modified: gnunet/src/transport/plugin_transport_unix.c
===================================================================
--- gnunet/src/transport/plugin_transport_unix.c        2011-06-28 15:58:37 UTC 
(rev 15785)
+++ gnunet/src/transport/plugin_transport_unix.c        2011-06-29 08:24:25 UTC 
(rev 15786)
@@ -1070,44 +1070,30 @@
                        const void *addr,
                        size_t addrlen)
 {
-  static char rbuf[INET6_ADDRSTRLEN + 10];
-  char buf[INET6_ADDRSTRLEN];
-  const void *sb;
-  struct in_addr a4;
-  struct in6_addr a6;
-  const struct IPv4UdpAddress *t4;
-  const struct IPv6UdpAddress *t6;
-  int af;
-  uint16_t port;
-
-  if (addrlen == sizeof (struct IPv6UdpAddress))
-    {
-      t6 = addr;
-      af = AF_INET6;
-      port = ntohs (t6->u6_port);
-      memcpy (&a6, &t6->ipv6_addr, sizeof (a6));
-      sb = &a6;
-    }
-  else if (addrlen == sizeof (struct IPv4UdpAddress))
-    {
-      t4 = addr;
-      af = AF_INET;
-      port = ntohs (t4->u_port);
-      memcpy (&a4, &t4->ipv4_addr, sizeof (a4));
-      sb = &a4;
-    }
+  if ((addr != NULL) && (addrlen > 0))
+    return (const char *) addr;
   else
     return NULL;
-  inet_ntop (af, sb, buf, INET6_ADDRSTRLEN);
-  GNUNET_snprintf (rbuf,
-                   sizeof (rbuf),
-                   "%s:%u",
-                   buf,
-                   port);
-  return rbuf;
 }
 
 /**
+ * Notify transport service about address
+ *
+ * @param cls the plugin
+ * @param tc unused
+ */
+static void
+address_notification (void *cls,
+                    const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct Plugin *plugin = cls;
+  plugin->env->notify_address(plugin->env->cls,
+                              GNUNET_YES,
+                              plugin->unix_socket_path,
+                              strlen(plugin->unix_socket_path) + 1);
+}
+
+/**
  * The exported method. Makes the core api available via a global and
  * returns the unix transport API.
  */
@@ -1157,10 +1143,7 @@
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                _("Failed to open UNIX sockets\n"));
 
-  plugin->env->notify_address(plugin->env->cls,
-                             GNUNET_YES,
-                              plugin->unix_socket_path,
-                              strlen(plugin->unix_socket_path) + 1);
+  GNUNET_SCHEDULER_add_now(address_notification, plugin);
   return api;
 }
 




reply via email to

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