-fixing #2302
authorChristian Grothoff <christian@grothoff.org>
Sun, 6 May 2012 11:53:15 +0000 (11:53 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sun, 6 May 2012 11:53:15 +0000 (11:53 +0000)
src/transport/gnunet-service-transport_clients.c
src/transport/gnunet-transport.c
src/transport/plugin_transport_http.c
src/transport/plugin_transport_tcp.c
src/transport/plugin_transport_udp.c
src/transport/plugin_transport_unix.c
src/transport/transport_api_address_to_string.c

index cadb4d6c67a9378faf571a48ca2c0fec70d4693b..98844f830a3cb92413ba3840c155f472adfa8e78 100644 (file)
@@ -775,10 +775,6 @@ clients_handle_address_to_string (void *cls,
     return;
   }
   GNUNET_SERVER_disable_receive_done_warning (client);
-  if ((NULL == address) || (0 == address_len))
-  {
-    GNUNET_break_op (0);
-  }
   papi->address_pretty_printer (papi->cls, plugin_name, address, address_len,
                                 numeric, rtimeout, &transmit_address_to_client,
                                 tc);
index 6ef273c45456a87cad06db055c7b42e40ca79d43..ee23189a8ef1badc9e0498732172eaf9cdf2a47c 100644 (file)
@@ -454,7 +454,8 @@ struct ResolutionContext
   int printed;
 };
 
-void
+
+static void
 process_string (void *cls, const char *address)
 {
   struct ResolutionContext *rc = cls;
index 4f927949505741254a139853753022ea21dc6fa7..de616173e7fd1fffeb759f71d0e31cb4caf33e75 100644 (file)
@@ -212,6 +212,12 @@ http_plugin_address_pretty_printer (void *cls, const char *type,
     sbs = sizeof (struct sockaddr_in);
     port = ntohs (a4->u4_port);
   }
+  else if (0 == addrlen)
+  {
+    asc (asc_cls, "<inbound connection>");
+    asc (asc_cls, NULL);
+    return;
+  }
   else
   {
     /* invalid address */
index ec4bbfc5e88f660cdd1a88a42d9800f093431f9e..0c1b8a0562f83b9cf6fd75277bc949a055499a97 100644 (file)
@@ -1507,11 +1507,15 @@ tcp_plugin_address_pretty_printer (void *cls, const char *type,
     sb = &a4;
     sbs = sizeof (a4);
   }
+  else if (0 == addrlen)
+  {
+    asc (asc_cls, "<inbound connection>");
+    asc (asc_cls, NULL);
+    return;
+  }
   else
   {
     /* invalid address */
-    GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "tcp",
-        "Invalid address to string request: plugin `%s', address length: %u bytes\n");
     GNUNET_break_op (0);
     asc (asc_cls, NULL);
     return;
index 9e28f00d47216a895ea4a06079e6bdd71fa8c4a4..ec6e522364a54f7da68ee7c8c468e0e24a60a2a7 100644 (file)
@@ -514,6 +514,12 @@ udp_plugin_address_pretty_printer (void *cls, const char *type,
     sb = &a4;
     sbs = sizeof (a4);
   }
+  else if (0 == addrlen)
+  {
+    asc (asc_cls, "<inbound connection>");
+    asc (asc_cls, NULL);
+    return;
+  }
   else
   {
     /* invalid address */
index 1f39f1d406d189863981d00f193dc79465de8c65..a858b9a2dcbb1f4c8da955628974aa0043d7e227 100644 (file)
@@ -185,12 +185,7 @@ struct Plugin
    */
   struct GNUNET_TRANSPORT_PluginEnvironment *env;
 
-  /*
-   * Session of peers with whom we are currently connected
-   */
-  struct PeerSession *sessions;
-
-  /*
+  /**
    * Sessions
    */
   struct GNUNET_CONTAINER_MultiHashMap *session_map;
@@ -243,9 +238,11 @@ struct Plugin
   unsigned int bytes_in_queue;
 };
 
+
 static void
 unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
 
+
 static void
 reschedule_select (struct Plugin * plugin)
 {
@@ -320,6 +317,7 @@ get_session_delete_it (void *cls, const GNUNET_HashCode * key, void *value)
   return GNUNET_YES;
 }
 
+
 /**
  * Disconnect from a remote node.  Clean up session if we have one for this peer
  *
@@ -327,7 +325,7 @@ get_session_delete_it (void *cls, const GNUNET_HashCode * key, void *value)
  * @param target the peeridentity of the peer to disconnect
  * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
-void
+static void
 unix_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
 {
   struct Plugin *plugin = cls;
@@ -379,23 +377,6 @@ unix_transport_server_stop (void *cls)
 }
 
 
-struct PeerSession *
-find_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *peer)
-{
-  struct PeerSession *pos;
-
-  pos = plugin->sessions;
-  while (pos != NULL)
-  {
-    if (memcmp (&pos->target, peer, sizeof (struct GNUNET_PeerIdentity)) == 0)
-      return pos;
-    pos = pos->next;
-  }
-
-  return pos;
-}
-
-
 /**
  * Actually send out the message, assume we've got the address and
  * send_handle squared away!
@@ -563,6 +544,7 @@ struct gsi_ctx
   struct Session *res;
 };
 
+
 static int
 get_session_it (void *cls, const GNUNET_HashCode * key, void *value)
 {
@@ -824,6 +806,7 @@ unix_plugin_select_read (struct Plugin * plugin)
   }
 }
 
+
 static void
 unix_plugin_select_write (struct Plugin * plugin)
 {
@@ -891,14 +874,14 @@ unix_plugin_select_write (struct Plugin * plugin)
 
 }
 
-/*
- * @param cls the plugin handle
- * @param tc the scheduling context (for rescheduling this function again)
- *
+
+/**
  * We have been notified that our writeset has something to read.  We don't
  * know which socket needs to be read, so we have to check each one
  * Then reschedule this function to be called again once more is available.
  *
+ * @param cls the plugin handle
+ * @param tc the scheduling context (for rescheduling this function again)
  */
 static void
 unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -929,12 +912,13 @@ unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   reschedule_select (plugin);
 }
 
+
 /**
  * Create a slew of UNIX sockets.  If possible, use IPv6 and IPv4.
  *
  * @param cls closure for server start, should be a struct Plugin *
  * @return number of sockets created or GNUNET_SYSERR on error
-*/
+ */
 static int
 unix_transport_server_start (void *cls)
 {
@@ -1041,16 +1025,19 @@ unix_plugin_address_pretty_printer (void *cls, const char *type,
                                     GNUNET_TRANSPORT_AddressStringCallback asc,
                                     void *asc_cls)
 {
-  if ((addr != NULL) && (addrlen > 0))
+  if ((NULL != addr) && (addrlen > 0))
+  {
     asc (asc_cls, (const char *) addr);
+  }
   else
   {
     GNUNET_break (0);
-    asc (asc_cls, "Invalid UNIX address");
+    asc (asc_cls, "<invalid UNIX address>");
   }
-
+  asc (asc_cls, NULL);
 }
 
+
 /**
  * Function called to convert a string address to
  * a binary address.
@@ -1063,11 +1050,11 @@ unix_plugin_address_pretty_printer (void *cls, const char *type,
  * @param added length of created address
  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
  */
-int
+static int
 unix_string_to_address (void *cls, const char *addr, uint16_t addrlen,
     void **buf, size_t *added)
 {
-  if ((NULL == addr) || (addrlen == 0))
+  if ((NULL == addr) || (0 == addrlen))
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
@@ -1091,8 +1078,6 @@ unix_string_to_address (void *cls, const char *addr, uint16_t addrlen,
 }
 
 
-
-
 /**
  * Function called for a quick conversion of the binary address to
  * a numeric address.  Note that the caller must not free the
@@ -1109,10 +1094,10 @@ unix_address_to_string (void *cls, const void *addr, size_t addrlen)
 {
   if ((addr != NULL) && (addrlen > 0))
     return (const char *) addr;
-  else
-    return NULL;
+  return NULL;
 }
 
+
 /**
  * Notify transport service about address
  *
index 237c0b657cd1496fbb22f5820185e96e72b8d6d6..152e573cd78e17038f8e9aa6ce37ecd0591dacd4 100644 (file)
@@ -141,9 +141,8 @@ GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle
     GNUNET_break (0);
     return NULL;
   }
-
   client = GNUNET_CLIENT_connect ("transport", cfg);
-  if (client == NULL)
+  if (NULL == client)
     return NULL;
   msg = GNUNET_malloc (len);
   msg->header.size = htons (len);