Extending the testcases to use bluetooth
[oweals/gnunet.git] / src / transport / gnunet-service-transport_validation.c
index bd4476082584cec89b2560a993969b0fe57e22bd..4ea0f07a6557c3b4b9e49e3e42df17a7f0abbd8f 100644 (file)
@@ -907,6 +907,8 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
   struct GNUNET_TIME_Absolute *sig_cache_exp;
   const char *addr;
   const char *addrend;
+  char *plugin_name;
+  char *pos;
   size_t alen;
   size_t slen;
   ssize_t ret;
@@ -939,7 +941,7 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
 
   sig_cache = NULL;
   sig_cache_exp = NULL;
-
+  papi = NULL;
   if (alen > 0)
   {
     addrend = memchr (addr, '\0', alen);
@@ -960,22 +962,45 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
     {
        GNUNET_break (0);
     }
-    if (NULL == (papi = GST_plugins_find (address.transport_name)))
+
+    if (0 != strstr (address.transport_name, "_client"))
+               {
+       plugin_name = GNUNET_strdup (address.transport_name);
+       pos = strstr (plugin_name, "_client");
+       GNUNET_assert (NULL != pos);
+       GNUNET_snprintf (pos, strlen ("_server") + 1, "%s", "_server");
+               }
+    else
+       plugin_name = GNUNET_strdup (address.transport_name);
+
+    if (NULL == (papi = GST_plugins_find (plugin_name)))
     {
       /* we don't have the plugin for this address */
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Plugin `%s' not available, cannot confirm having this address \n",
-               address.transport_name) ;
+               plugin_name);
+      GNUNET_free (plugin_name);
       return;
     }
+    GNUNET_free (plugin_name);
     if (GNUNET_OK != papi->check_address (papi->cls, addrend, alen))
                {
+      GNUNET_STATISTICS_update (GST_stats,
+                                gettext_noop
+                                ("# failed address checks during validation"), 1,
+                                GNUNET_NO);
        GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Address `%s' is not one of my addresses, not confirming PING\n",
                GST_plugins_a2s (&address));
        return;
                }
     else
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Address `%s' is one of my addresses, confirming PING\n",
-                       GST_plugins_a2s (&address)); /* DEBUGGING*/
+    {
+      GNUNET_STATISTICS_update (GST_stats,
+                                gettext_noop
+                                ("# successful address checks during validation"), 1,
+                                GNUNET_NO);
+       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Address `%s' is one of my addresses, confirming PING\n",
+                       GST_plugins_a2s (&address));
+    }
 
     if (GNUNET_YES != GST_hello_test_address (&address, &sig_cache, &sig_cache_exp))
     {