gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r26612 - in gnunet/src: ats ats-tool dht dv fs include


From: gnunet
Subject: [GNUnet-SVN] r26612 - in gnunet/src: ats ats-tool dht dv fs include
Date: Tue, 26 Mar 2013 16:02:37 +0100

Author: wachs
Date: 2013-03-26 16:02:37 +0100 (Tue, 26 Mar 2013)
New Revision: 26612

Removed:
   gnunet/src/ats/test_ats_api_performance_monitor.c
Modified:
   gnunet/src/ats-tool/gnunet-ats.c
   gnunet/src/ats/Makefile.am
   gnunet/src/ats/ats_api_performance.c
   gnunet/src/ats/gnunet-service-ats_addresses.c
   gnunet/src/ats/gnunet-service-ats_performance.c
   gnunet/src/ats/test_ats_api_performance_address_info.c
   gnunet/src/ats/test_ats_api_performance_list_addresses.c
   gnunet/src/ats/test_ats_simplistic_change_preference.c
   gnunet/src/ats/test_ats_simplistic_pref_aging.c
   gnunet/src/dht/gnunet-service-dht_neighbours.c
   gnunet/src/dv/gnunet-service-dv.c
   gnunet/src/fs/gnunet-service-fs.c
   gnunet/src/include/gnunet_ats_service.h
Log:
api change


Modified: gnunet/src/ats/Makefile.am
===================================================================
--- gnunet/src/ats/Makefile.am  2013-03-26 14:35:22 UTC (rev 26611)
+++ gnunet/src/ats/Makefile.am  2013-03-26 15:02:37 UTC (rev 26612)
@@ -75,7 +75,6 @@
  test_ats_simplistic_change_preference \
  test_ats_simplistic_pref_aging \
  test_ats_api_performance_list_addresses \
- test_ats_api_performance_monitor \
  test_ats_api_performance_address_info \
  $(GN_MLP_TEST) $(GN_MLP_PERF) $(GN_MLP_TEST_UPDATE)
 # $(GN_MLP_TEST_AVG)
@@ -166,16 +165,7 @@
   $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/hello/libgnunethello.la \
   $(top_builddir)/src/ats/libgnunetats.la    
-  
-test_ats_api_performance_monitor_SOURCES = \
- test_ats_api_performance_monitor.c
-test_ats_api_performance_monitor_LDADD = \
-  $(top_builddir)/src/util/libgnunetutil.la \
-  $(top_builddir)/src/testing/libgnunettesting.la \
-  $(top_builddir)/src/hello/libgnunethello.la \
-  $(top_builddir)/src/ats/libgnunetats.la     
 
-
 test_ats_api_performance_address_info_SOURCES = \
  test_ats_api_performance_address_info.c
 test_ats_api_performance_address_info_LDADD = \

Modified: gnunet/src/ats/ats_api_performance.c
===================================================================
--- gnunet/src/ats/ats_api_performance.c        2013-03-26 14:35:22 UTC (rev 
26611)
+++ gnunet/src/ats/ats_api_performance.c        2013-03-26 15:02:37 UTC (rev 
26612)
@@ -181,16 +181,6 @@
   void *addr_info_cb_cls;
 
   /**
-   * Callback to invoke when a peer has performance changes.
-   */
-       GNUNET_ATS_PerformanceMonitorCb perf_monitor_cb;
-
-  /**
-   * Closure for 'perf_monitor_cb'.
-   */
-       void *perf_monitor_cb_cls;
-
-  /**
    * Connection to ATS service.
    */
   struct GNUNET_CLIENT_Connection *client;
@@ -396,15 +386,6 @@
                ph->addr_info_cb (ph->addr_info_cb_cls, &address, addr_active, 
pi->bandwidth_out, pi->bandwidth_in,
               atsi, ats_count);
   }
-  if ((NULL != ph->perf_monitor_cb) &&
-               (GNUNET_YES == addr_active))
-  {
-               ph->perf_monitor_cb (ph->perf_monitor_cb_cls,
-                                                                               
                &pi->peer,
-                                                                               
                pi->bandwidth_out,
-                                                                               
                pi->bandwidth_in,
-                                                                               
                atsi, ats_count);
-  }
   return GNUNET_OK;
 }
 
@@ -640,7 +621,7 @@
     init->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_START);
     init->header.size = htons (sizeof (struct ClientStartMessage));
     init->start_flag =
-        htonl (((NULL ==ph->addr_info_cb) && (NULL == ph->perf_monitor_cb)) ?
+        htonl ((NULL ==ph->addr_info_cb) ?
                        START_FLAG_PERFORMANCE_NO_PIC : 
START_FLAG_PERFORMANCE_WITH_PIC);
     GNUNET_CONTAINER_DLL_insert (ph->pending_head, ph->pending_tail, p);
   }
@@ -653,9 +634,6 @@
  * Get handle to access performance API of the ATS subsystem.
  *
  * @param cfg configuration to use
- * @param perf_monitor_cb callback called when performance characteristics for
- *     a peer change
- * @param perf_monitor_cb closure for the perf_monitor_cb
  * @param addr_info_cb callback called when performance characteristics for
  *     an address change
  * @param addr_info_cb_cls closure for infocb
@@ -663,8 +641,6 @@
  */
 struct GNUNET_ATS_PerformanceHandle *
 GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                                                               
                                 GNUNET_ATS_PerformanceMonitorCb 
perf_monitor_cb,
-                                                                               
                                 void *perf_monitor_cb_cls,
                              GNUNET_ATS_AddressInformationCallback 
addr_info_cb,
                              void *addr_info_cb_cls)
 {
@@ -674,8 +650,6 @@
   ph->cfg = cfg;
   ph->addr_info_cb = addr_info_cb;
   ph->addr_info_cb_cls = addr_info_cb_cls;
-  ph->perf_monitor_cb = perf_monitor_cb;
-  ph->perf_monitor_cb_cls = perf_monitor_cb_cls;
   ph->id  = 0;
   reconnect (ph);
   return ph;

Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c       2013-03-26 14:35:22 UTC 
(rev 26611)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c       2013-03-26 15:02:37 UTC 
(rev 26612)
@@ -367,6 +367,13 @@
 };
 
 
+/**
+ * Assemble ATS information from address
+ *
+ * @param src source address
+ * @param dest destination
+ * @return number of elements
+ */
 static unsigned int
 assemble_ats_information (const struct ATS_Address *aa,  struct 
GNUNET_ATS_Information **dest)
 {
@@ -393,6 +400,14 @@
   return ats_count;
 }
 
+/**
+ * Disassemble ATS information and update address
+ *
+ * @param src source ATS information
+ * @param ats_count number of ATS information
+ * @param dest destination address
+ * @return GNUNET_YES if address was address updated, GNUNET_NO otherwise
+ */
 static unsigned int
 disassemble_ats_information (const struct GNUNET_ATS_Information *src,
                              uint32_t ats_count,
@@ -460,17 +475,7 @@
       GNUNET_break (0);
       break;
     }
-  if (GNUNET_YES == change)
-  {
-               struct GNUNET_ATS_Information *destats;
-               int ats_count;
-               ats_count = assemble_ats_information (dest, &destats);
-               GAS_handle_performance_update (&dest->peer, dest->plugin,
-                               dest->addr, dest->addr_len, dest->active,
-                               destats, ats_count, dest->assigned_bw_out, 
dest->assigned_bw_in);
-               GNUNET_free (destats);
-  }
-  return res;
+  return change;
 }
 
 /**
@@ -688,6 +693,8 @@
 {
   struct ATS_Address *aa;
   struct ATS_Address *ea;
+  struct GNUNET_ATS_Information *ats_new;
+  uint32_t ats_count_new;
   unsigned int ats_res;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -702,6 +709,7 @@
 
   aa = create_address (peer, plugin_name, plugin_addr, plugin_addr_len,
                        session_id);
+
   if (atsi_count != (ats_res = disassemble_ats_information(atsi, atsi_count, 
aa)))
   {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -722,6 +730,16 @@
                 GNUNET_i2s (peer), session_id, aa);
     /* Tell solver about new address */
     handle->s_add (handle->solver, handle->addresses, aa);
+    /* Notify performance clients about new address */
+    ats_count_new = assemble_ats_information (aa, &ats_new);
+    GAS_performance_notify_all_clients (&aa->peer,
+        aa->plugin,
+        aa->addr, aa->addr_len,
+        aa->session_id,
+        ats_new, ats_count_new,
+        aa->assigned_bw_out,
+        aa->assigned_bw_in);
+    GNUNET_free (ats_new);
     return;
   }
   GNUNET_free (aa->plugin);
@@ -745,11 +763,17 @@
 
   /* Do the update */
   ea->session_id = session_id;
-  if (atsi_count != (ats_res = disassemble_ats_information(atsi, atsi_count, 
ea)))
+  if (GNUNET_YES == disassemble_ats_information(atsi, atsi_count, ea))
   {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "While updating address: had %u ATS elements to add, could 
only add %u\n",
-                  atsi_count, ats_res);
+               ats_count_new = assemble_ats_information (aa, &ats_new);
+               GAS_performance_notify_all_clients (&aa->peer,
+                               aa->plugin,
+                               aa->addr, aa->addr_len,
+                               aa->session_id,
+                               ats_new, ats_count_new,
+                               aa->assigned_bw_out,
+                               aa->assigned_bw_in);
+               GNUNET_free (ats_new);
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
            "Updated existing address for peer `%s' %p with new session %u\n",
@@ -766,7 +790,8 @@
                       uint32_t atsi_count)
 {
   struct ATS_Address *aa;
-  uint32_t ats_res;
+  struct GNUNET_ATS_Information *ats_new;
+  uint32_t ats_count_new;
 
   if (GNUNET_NO == handle->running)
     return;
@@ -793,15 +818,19 @@
   handle->s_update (handle->solver, handle->addresses, aa, session_id, 
aa->used, atsi, atsi_count);
 
   /* Update address */
-  if (atsi_count != (ats_res = disassemble_ats_information (atsi, atsi_count, 
aa)))
+  if (GNUNET_YES == disassemble_ats_information (atsi, atsi_count, aa))
   {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "While adding address: had %u ATS elements to add, could only 
add %u\n",
-                atsi_count, ats_res);
+               ats_count_new = assemble_ats_information (aa, &ats_new);
+               /* Notify performance clients about updated address */
+               GAS_performance_notify_all_clients (&aa->peer,
+                               aa->plugin,
+                               aa->addr, aa->addr_len,
+                               aa->session_id,
+                               ats_new, ats_count_new,
+                               aa->assigned_bw_out,
+                               aa->assigned_bw_in);
+               GNUNET_free (ats_new);
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-            "Updated %u ATS elements for address %p\n",
-            ats_res, aa);
 }
 
 
@@ -1274,6 +1303,8 @@
 
 
   ats_count = assemble_ats_information (address, &ats);
+
+  /* Notify performance clients about changes to address */
   GAS_performance_notify_all_clients (&address->peer,
       address->plugin,
       address->addr, address->addr_len,
@@ -1281,7 +1312,6 @@
       ats, ats_count,
       address->assigned_bw_out,
       address->assigned_bw_in);
-
   cur = handle->r_head;
   while (NULL != cur)
   {
@@ -1300,7 +1330,7 @@
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Sending bandwidth update for peer `%s'\n",GNUNET_i2s 
(&address->peer));
 
-
+  /* *Notify scheduling clients about suggestion */
   GAS_scheduling_transmit_address_suggestion (&address->peer,
                                               address->plugin,
                                               address->addr, address->addr_len,

Modified: gnunet/src/ats/gnunet-service-ats_performance.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_performance.c     2013-03-26 14:35:22 UTC 
(rev 26611)
+++ gnunet/src/ats/gnunet-service-ats_performance.c     2013-03-26 15:02:37 UTC 
(rev 26612)
@@ -225,7 +225,6 @@
                                 struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_in)
 {
   struct PerformanceClient *pc;
-
   for (pc = pc_head; pc != NULL; pc = pc->next)
     if (pc->flag == START_FLAG_PERFORMANCE_WITH_PIC)
     {

Modified: gnunet/src/ats/test_ats_api_performance_address_info.c
===================================================================
--- gnunet/src/ats/test_ats_api_performance_address_info.c      2013-03-26 
14:35:22 UTC (rev 26611)
+++ gnunet/src/ats/test_ats_api_performance_address_info.c      2013-03-26 
15:02:37 UTC (rev 26612)
@@ -152,7 +152,7 @@
 static void
 addrinfo_cb (void *cls,
                                                const struct 
GNUNET_HELLO_Address *address,
-                                               unsigned int address_active,
+                                               int address_active,
                                                struct 
GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
                                                struct 
GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
                                                const struct 
GNUNET_ATS_Information *ats,
@@ -213,6 +213,7 @@
   setup_addresses ();
 
   /* Get an active address for peer0 and expect callback */
+  return;
   GNUNET_ATS_suggest_address (sh, &addr[0].peer);
 
        atsi[0].type = htonl(GNUNET_ATS_QUALITY_NET_DELAY);
@@ -235,7 +236,7 @@
   cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg;
   die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
 
-  ph = GNUNET_ATS_performance_init (cfg, NULL, NULL, addrinfo_cb, NULL);
+  ph = GNUNET_ATS_performance_init (cfg, addrinfo_cb, NULL);
   GNUNET_assert (NULL != ph);
 
   sh = GNUNET_ATS_scheduling_init (cfg, &ats_suggest_cb, NULL);

Modified: gnunet/src/ats/test_ats_api_performance_list_addresses.c
===================================================================
--- gnunet/src/ats/test_ats_api_performance_list_addresses.c    2013-03-26 
14:35:22 UTC (rev 26611)
+++ gnunet/src/ats/test_ats_api_performance_list_addresses.c    2013-03-26 
15:02:37 UTC (rev 26612)
@@ -130,7 +130,7 @@
 
 void all_active_addresses_peer_cb (void *cls,
                const struct GNUNET_HELLO_Address *address,
-               unsigned int active,
+               int active,
                struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
                struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
                const struct GNUNET_ATS_Information *ats,
@@ -193,7 +193,7 @@
 
 void all_active_addresses_cb (void *cls,
                                                                                
                                        const struct GNUNET_HELLO_Address 
*address,
-                                                                               
                                        unsigned int active,
+                                                                               
                                        int active,
                                                                                
                                        struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_out,
                                                                                
                                        struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_in,
                                                                                
                                        const struct GNUNET_ATS_Information 
*ats,
@@ -268,7 +268,7 @@
 
 void all_addresses_peer_cb (void *cls,
                                                                                
                                const struct GNUNET_HELLO_Address *address,
-                                                                               
                                unsigned int active,
+                                                                               
                                int active,
                                                                                
                                struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_out,
                                                                                
                                struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
                                                                                
                                const struct GNUNET_ATS_Information *ats,
@@ -317,7 +317,7 @@
 
 void all_addresses_cb (void *cls,
                                                                                
        const struct GNUNET_HELLO_Address *address,
-                                                                               
        unsigned int active,
+                                                                               
        int active,
                                                                                
        struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
                                                                                
        struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
                                                                                
        const struct GNUNET_ATS_Information *ats,
@@ -380,7 +380,7 @@
 test_performance_api (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   if (NULL == ph)
-    ph = GNUNET_ATS_performance_init (cfg, NULL, NULL, NULL, NULL);
+    ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
   if (NULL == ph)
   {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize performance 
handle\n");

Deleted: gnunet/src/ats/test_ats_api_performance_monitor.c
===================================================================
--- gnunet/src/ats/test_ats_api_performance_monitor.c   2013-03-26 14:35:22 UTC 
(rev 26611)
+++ gnunet/src/ats/test_ats_api_performance_monitor.c   2013-03-26 15:02:37 UTC 
(rev 26612)
@@ -1,358 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2010,2011 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
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
-*/
-/**
- * @file ats/test_ats_api_performance_monitor.c
- * @brief Test performance API:
- *                             Add an address for a peer and request it. We 
expect an monitor callback
- * @author Christian Grothoff
- * @author Matthias Wachs
- */
-#include "platform.h"
-#include "gnunet_ats_service.h"
-#include "gnunet_testing_lib.h"
-#include "ats.h"
-
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20)
-#define SHUTDOWN_CORRECT GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 5)
-
-#define ATS_COUNT 2
-
-static GNUNET_SCHEDULER_TaskIdentifier die_task;
-static GNUNET_SCHEDULER_TaskIdentifier stage_task;
-
-struct GNUNET_CONFIGURATION_Handle *cfg;
-
-static struct GNUNET_ATS_SchedulingHandle *sh;
-
-static struct GNUNET_ATS_PerformanceHandle *ph;
-
-static struct GNUNET_HELLO_Address addr[2];
-
-static struct GNUNET_ATS_Information atsi[ATS_COUNT];
-
-static int ret;
-
-static int res_suggest_cb_p0;
-static int res_suggest_cb_p1;
-
-static int res_perf_cb_p0;
-static int res_perf_cb_p1;
-
-/**
- * Stage 0: Init, request address and wait for peer0 suggest cb
- * Stage 1: Got peer0 suggest cb, expect monitoring cb
- * Stage 2: Got peer0 monitoring cb, update address and expect monitor cb
- * Stage 3: Got 2nd peer0 monitoring cb, shutdown
- */
-
-static int stage;
-
-
-static void cleanup_addresses ()
-{
-       GNUNET_ATS_address_destroyed (sh, &addr[0], NULL);
-       GNUNET_ATS_address_destroyed (sh, &addr[1], NULL);
-}
-
-static void setup_addresses ()
-{
-       memset (&addr[0].peer,'\0', sizeof (addr[0].peer));
-       addr[0].transport_name = "test0";
-       addr[0].address = "test_addr0";
-       addr[0].address_length = strlen ("test_addr0") + 1;
-
-       atsi[0].type = htonl(GNUNET_ATS_QUALITY_NET_DELAY);
-       atsi[0].value = htonl(100);
-
-       atsi[1].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE);
-       atsi[1].value = htonl(5);
-
-       GNUNET_ATS_address_add (sh, &addr[0], NULL, atsi, ATS_COUNT);
-
-       memset (&addr[1].peer,'\1', sizeof (addr[1].peer));
-       addr[1].transport_name = "test1";
-       addr[1].address = "test_addr1";
-       addr[1].address_length = strlen ("test_addr1") + 1;
-
-       GNUNET_ATS_address_add (sh, &addr[1], NULL, atsi, ATS_COUNT);
-}
-
-
-static void
-end_now (int res)
-{
-       if (GNUNET_SCHEDULER_NO_TASK != stage_task)
-       {
-                       GNUNET_SCHEDULER_cancel (stage_task);
-                       stage_task = GNUNET_SCHEDULER_NO_TASK;
-       }
-       if (GNUNET_SCHEDULER_NO_TASK != die_task)
-       {
-                       GNUNET_SCHEDULER_cancel (die_task);
-                       die_task = GNUNET_SCHEDULER_NO_TASK;
-       }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n");
-
-       cleanup_addresses ();
-
-       if (NULL != ph)
-       {
-               GNUNET_ATS_performance_done (ph);
-               ph = NULL;
-       }
-
-       if (NULL != sh)
-       {
-               GNUNET_ATS_scheduling_done (sh);
-               sh = NULL;
-       }
-       ret = res;
-}
-
-static void
-end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  die_task = GNUNET_SCHEDULER_NO_TASK;
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error!\n");
-  if (GNUNET_NO == res_perf_cb_p0)
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not get performance 
information for requested peer!\n");
-  if (GNUNET_YES == res_perf_cb_p1)
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got suggestion for not requested 
peer!\n");
-  if (GNUNET_NO == res_suggest_cb_p0)
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not get suggestion for not 
peer!\n");
-  if (GNUNET_YES == res_suggest_cb_p1)
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got suggestion for not requested 
peer!\n");
-  end_now (1);
-}
-
-static void end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Success\n");
-  end_now (0);
-}
-
-
-static void
-perf_mon_cb (void *cls,
-                                               const struct 
GNUNET_PeerIdentity *peer,
-                                               const struct 
GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
-                                               const struct 
GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
-                                               const struct 
GNUNET_ATS_Information *ats,
-                                               uint32_t ats_count)
-{
-       int c1;
-       int c2;
-       int c3;
-
-       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                       "ATS notifies about perfomance change for peer `%s'\n", 
GNUNET_i2s (peer));
-
-       if ((1 != stage) && (2 != stage))
-       {
-               GNUNET_break (0);
-               end_now(1);
-               return;
-       }
-
-       if (1 == stage)
-       {
-                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received 1st 
callback for peer `%s' with %u information\n",
-                                       GNUNET_i2s (&addr[0].peer), ats_count);
-                       if (0 != memcmp (peer, &addr[0].peer, sizeof 
(addr[0].peer)))
-                       {
-                                       res_perf_cb_p1 = GNUNET_YES;
-                                       GNUNET_break (0);
-                                       if (GNUNET_SCHEDULER_NO_TASK != 
die_task)
-                                               GNUNET_SCHEDULER_cancel 
(die_task);
-                                       die_task = GNUNET_SCHEDULER_add_now 
(&end_badly, NULL);
-                                       return;
-                       }
-
-                       if (ats_count < ATS_COUNT)
-                       {
-                                       GNUNET_break (0);
-                                       if (GNUNET_SCHEDULER_NO_TASK != 
die_task)
-                                               GNUNET_SCHEDULER_cancel 
(die_task);
-                                       die_task = GNUNET_SCHEDULER_add_now 
(&end_badly, NULL);
-                                       return;
-                       }
-
-                       c3 = 0;
-                       for (c1 = 0; c1 < ats_count; c1++)
-                       {
-                               GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS 
information [%u] %u : %u \n",
-                                               c1, ntohl (ats[c1].type), ntohl 
(ats[c1].value));
-                               for (c2 = 0; c2 < ATS_COUNT; c2++)
-                               {
-                                       if (ats[c1].type == atsi[c2].type)
-                                       {
-                                               if (ats[c1].value == 
atsi[c2].value)
-                                                               c3++;
-                                               else
-                                                               GNUNET_break 
(0);
-                                       }
-                               }
-                       }
-                       if (ATS_COUNT != c3)
-                       {
-                               GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received 
only %u correct ATS information \n", c3);
-                               if (GNUNET_SCHEDULER_NO_TASK != die_task)
-                                       GNUNET_SCHEDULER_cancel (die_task);
-                               die_task = GNUNET_SCHEDULER_add_now 
(&end_badly, NULL);
-                               return;
-                       }
-
-                       /* Everything OK */
-                       stage ++;
-                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %u 
correct ATS information \n", c3);
-
-                       atsi[0].type = htonl(GNUNET_ATS_QUALITY_NET_DELAY);
-                       atsi[0].value = htonl(1000);
-
-                       atsi[1].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE);
-                       atsi[1].value = htonl(50);
-
-                       GNUNET_ATS_address_update (sh, &addr[0], NULL, atsi, 
ATS_COUNT);
-                       return;
-       }
-       if (2 == stage)
-       {
-                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received 2nd 
callback for peer `%s' with %u information\n",
-                                       GNUNET_i2s (&addr[0].peer), ats_count);
-                       if (0 != memcmp (peer, &addr[0].peer, sizeof 
(addr[0].peer)))
-                       {
-                                       res_perf_cb_p1 = GNUNET_YES;
-                                       GNUNET_break (0);
-                                       if (GNUNET_SCHEDULER_NO_TASK != 
die_task)
-                                               GNUNET_SCHEDULER_cancel 
(die_task);
-                                       die_task = GNUNET_SCHEDULER_add_now 
(&end_badly, NULL);
-                                       return;
-                       }
-
-                       if (ats_count < ATS_COUNT)
-                       {
-                                       GNUNET_break (0);
-                                       if (GNUNET_SCHEDULER_NO_TASK != 
die_task)
-                                               GNUNET_SCHEDULER_cancel 
(die_task);
-                                       die_task = GNUNET_SCHEDULER_add_now 
(&end_badly, NULL);
-                                       return;
-                       }
-
-
-                       c3 = 0;
-                       for (c1 = 0; c1 < ats_count; c1++)
-                       {
-                               GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS 
information [%u] %u : %u \n",
-                                               c1, ntohl (ats[c1].type), ntohl 
(ats[c1].value));
-                               for (c2 = 0; c2 < ATS_COUNT; c2++)
-                               {
-                                       if (ats[c1].type == atsi[c2].type)
-                                       {
-                                               if (ats[c1].value == 
atsi[c2].value)
-                                                               c3++;
-                                               else
-                                               {
-                                                       GNUNET_log 
(GNUNET_ERROR_TYPE_DEBUG, "ATS information [%u] should be %u, but is %u \n",
-                                                                       ntohl 
(ats[c1].type), ntohl(atsi[c2].value),  ntohl (ats[c1].value));
-                                                               GNUNET_break 
(0);
-                                               }
-                                       }
-                               }
-                       }
-                       if (ATS_COUNT != c3)
-                       {
-                               GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received 
only %u correct ATS information \n", c3);
-                               if (GNUNET_SCHEDULER_NO_TASK != die_task)
-                                       GNUNET_SCHEDULER_cancel (die_task);
-                               die_task = GNUNET_SCHEDULER_add_now 
(&end_badly, NULL);
-                               return;
-                       }
-
-                       /* Everything OK */
-                       stage ++;
-                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %u 
correct ATS information \n", c3);
-                       GNUNET_SCHEDULER_add_now (&end, NULL);
-                       return;
-       }
-}
-
-void ats_suggest_cb (void *cls,
-                                                                               
const struct GNUNET_HELLO_Address * address,
-                                                                               
struct Session * session,
-                                                                               
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
-                                                                               
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
-                                                                               
const struct GNUNET_ATS_Information *ats,
-                                                                               
uint32_t ats_count)
-{
-       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                       "ATS is suggesting address for peer `%s'\n", GNUNET_i2s 
(&address->peer));
-
-       if (0 != stage)
-       {
-               GNUNET_break (0);
-               end_now(1);
-               return;
-       }
-
-       if (0 == memcmp (&addr[0].peer, &address->peer, sizeof (address->peer)))
-       {
-               res_suggest_cb_p0 = GNUNET_YES;
-               stage = 1;
-       }
-       if (0 == memcmp (&addr[1].peer, &address->peer, sizeof (address->peer)))
-               res_suggest_cb_p1 = GNUNET_YES;
-}
-
-
-static void
-run (void *cls, 
-     const struct GNUNET_CONFIGURATION_Handle *mycfg,
-     struct GNUNET_TESTING_Peer *peer)
-{
-  ret = 1;
-  stage = 0;
-  cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg;
-  die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
-
-  sh = GNUNET_ATS_scheduling_init (cfg, &ats_suggest_cb, NULL);
-  GNUNET_assert (NULL != sh);
-
-  ph = GNUNET_ATS_performance_init (cfg, &perf_mon_cb, &ret, NULL, NULL);
-  GNUNET_assert (NULL != ph);
-
-  /* Add addresses */
-  setup_addresses ();
-
-  /* Get an active address for peer0 and expect callback */
-  GNUNET_ATS_suggest_address (sh, &addr[0].peer);
-}
-
-
-int
-main (int argc, char *argv[])
-{
-  if (0 != GNUNET_TESTING_peer_run ("test_ats_api_performance_monitor",
-                                   "test_ats_api.conf",
-                                   &run, NULL))
-    return 1;
-  return ret;
-}
-
-/* end of file test_ats_api_performance_monitor.c */

Modified: gnunet/src/ats/test_ats_simplistic_change_preference.c
===================================================================
--- gnunet/src/ats/test_ats_simplistic_change_preference.c      2013-03-26 
14:35:22 UTC (rev 26611)
+++ gnunet/src/ats/test_ats_simplistic_change_preference.c      2013-03-26 
15:02:37 UTC (rev 26612)
@@ -318,7 +318,7 @@
     return;
   }
 
-  perf_ats = GNUNET_ATS_performance_init (cfg, NULL, NULL, NULL, NULL);
+  perf_ats = GNUNET_ATS_performance_init (cfg, NULL, NULL);
   if (perf_ats == NULL)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS 
performance!\n");

Modified: gnunet/src/ats/test_ats_simplistic_pref_aging.c
===================================================================
--- gnunet/src/ats/test_ats_simplistic_pref_aging.c     2013-03-26 14:35:22 UTC 
(rev 26611)
+++ gnunet/src/ats/test_ats_simplistic_pref_aging.c     2013-03-26 15:02:37 UTC 
(rev 26612)
@@ -368,7 +368,7 @@
   }
 
   /* Connect to ATS performance */
-  perf_ats = GNUNET_ATS_performance_init(cfg, NULL, NULL, NULL, NULL);
+  perf_ats = GNUNET_ATS_performance_init(cfg, NULL, NULL);
   if (sched_ats == NULL)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS 
scheduling!\n");

Modified: gnunet/src/ats-tool/gnunet-ats.c
===================================================================
--- gnunet/src/ats-tool/gnunet-ats.c    2013-03-26 14:35:22 UTC (rev 26611)
+++ gnunet/src/ats-tool/gnunet-ats.c    2013-03-26 15:02:37 UTC (rev 26612)
@@ -222,7 +222,7 @@
 
 void ats_perf_cb (void *cls,
                                                                        const 
struct GNUNET_HELLO_Address *address,
-                                                                       
unsigned int active,
+                                                                       int 
active,
                                                                        struct 
GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
                                                                        struct 
GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
                                                                        const 
struct GNUNET_ATS_Information *ats,
@@ -367,7 +367,7 @@
     }
     if (op_list_all)
     {
-        ph = GNUNET_ATS_performance_init (cfg, NULL, NULL, NULL, NULL);
+        ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
         if (NULL == ph)
         {
           fprintf (stderr, _("Cannot connect to ATS service, exiting...\n"));
@@ -387,7 +387,7 @@
     }
     else if (op_list_used)
     {
-        ph = GNUNET_ATS_performance_init (cfg, NULL, NULL, NULL, NULL);
+        ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
         if (NULL == ph)
           fprintf (stderr, _("Cannot connect to ATS service, exiting...\n"));
 
@@ -404,7 +404,7 @@
     }
     else if (op_monitor)
     {
-        ph = GNUNET_ATS_performance_init (cfg, NULL, NULL, ats_perf_cb, NULL);
+        ph = GNUNET_ATS_performance_init (cfg, ats_perf_cb, NULL);
         if (NULL == ph)
           fprintf (stderr, _("Cannot connect to ATS service, exiting...\n"));
         end_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 
&end, NULL);
@@ -429,7 +429,7 @@
         }
 
             /* set */
-            ph = GNUNET_ATS_performance_init (cfg, NULL, NULL, NULL, NULL);
+            ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
             if (NULL == ph)
               fprintf (stderr, _("Cannot connect to ATS service, 
exiting...\n"));
 

Modified: gnunet/src/dht/gnunet-service-dht_neighbours.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_neighbours.c      2013-03-26 14:35:22 UTC 
(rev 26611)
+++ gnunet/src/dht/gnunet-service-dht_neighbours.c      2013-03-26 15:02:37 UTC 
(rev 26612)
@@ -2077,7 +2077,7 @@
     bucket_size = (unsigned int) temp_config_num;
   log_route_details_stderr =
     (NULL != getenv("GNUNET_DHT_ROUTE_DEBUG")) ? GNUNET_YES : GNUNET_NO;
-  atsAPI = GNUNET_ATS_performance_init (GDS_cfg, NULL, NULL, NULL, NULL);
+  atsAPI = GNUNET_ATS_performance_init (GDS_cfg, NULL, NULL);
   coreAPI =
       GNUNET_CORE_connect (GDS_cfg, NULL, &core_init, &handle_core_connect,
                            &handle_core_disconnect, NULL, GNUNET_NO, NULL,

Modified: gnunet/src/dv/gnunet-service-dv.c
===================================================================
--- gnunet/src/dv/gnunet-service-dv.c   2013-03-26 14:35:22 UTC (rev 26611)
+++ gnunet/src/dv/gnunet-service-dv.c   2013-03-26 15:02:37 UTC (rev 26612)
@@ -962,7 +962,8 @@
  */
 static void
 handle_ats_update (void *cls,
-                  const struct GNUNET_PeerIdentity *peer,
+                  const struct GNUNET_HELLO_Address *address,
+                  int active,
                   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
                   struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
                   const struct GNUNET_ATS_Information *ats, 
@@ -971,11 +972,12 @@
   struct DirectNeighbor *neighbor;
   uint32_t distance;
 
-  /* FIXME: ignore CB if this address is not the one that is in use! */
+  if (GNUNET_NO == active)
+       return;
   distance = get_atsi_distance (ats, ats_count); 
   /* check if entry exists */
   neighbor = GNUNET_CONTAINER_multihashmap_get (direct_neighbors, 
-                                                       &peer->hashPubKey);
+                                                       
&address->peer.hashPubKey);
   if (NULL != neighbor)
   {    
     if ( (DIRECT_NEIGHBOR_COST == neighbor->distance) &&
@@ -1002,10 +1004,10 @@
     return;
   }
   neighbor = GNUNET_malloc (sizeof (struct DirectNeighbor));
-  neighbor->peer = (*peer);
+  neighbor->peer = address->peer;
   GNUNET_assert (GNUNET_YES ==
                 GNUNET_CONTAINER_multihashmap_put (direct_neighbors,
-                                                   &peer->hashPubKey,
+                                                   &address->peer.hashPubKey,
                                                    neighbor,
                                                    
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
   neighbor->connected = GNUNET_NO; /* not yet */
@@ -1699,7 +1701,7 @@
 
   if (NULL == core_api)
     return;
-  ats = GNUNET_ATS_performance_init (cfg, &handle_ats_update, NULL, NULL, 
NULL);
+  ats = GNUNET_ATS_performance_init (cfg, &handle_ats_update, NULL);
   if (NULL == ats)
   {
     GNUNET_CORE_disconnect (core_api);

Modified: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c   2013-03-26 14:35:22 UTC (rev 26611)
+++ gnunet/src/fs/gnunet-service-fs.c   2013-03-26 15:02:37 UTC (rev 26612)
@@ -243,7 +243,7 @@
 static void
 update_latencies (void *cls,
                  const struct GNUNET_HELLO_Address *address,
-                 unsigned int active,
+                 int active,
                  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
                  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
                  const struct GNUNET_ATS_Information *ats, 
@@ -692,7 +692,7 @@
   GSF_plan_init ();
   GSF_pending_request_init_ ();
   GSF_connected_peer_init_ ();
-  GSF_ats = GNUNET_ATS_performance_init (GSF_cfg, NULL, NULL, 
&update_latencies, NULL);
+  GSF_ats = GNUNET_ATS_performance_init (GSF_cfg, &update_latencies, NULL);
   GSF_push_init_ ();
   GSF_put_init_ ();
   if ((GNUNET_OK != GNUNET_FS_indexing_init (cfg, GSF_dsh)) ||

Modified: gnunet/src/include/gnunet_ats_service.h
===================================================================
--- gnunet/src/include/gnunet_ats_service.h     2013-03-26 14:35:22 UTC (rev 
26611)
+++ gnunet/src/include/gnunet_ats_service.h     2013-03-26 15:02:37 UTC (rev 
26612)
@@ -698,23 +698,6 @@
 struct GNUNET_ATS_PerformanceHandle;
 
 /**
- * Signature of a function that is called with QoS information about an peer.
- *
- * @param cls closure
- * @param peer the peer
- * @param ats data for the peer
- * @param ats_count number of performance records in 'ats'
- */
-typedef void
-(*GNUNET_ATS_PerformanceMonitorCb) (void *cls,
-                                                                               
                                        const struct GNUNET_PeerIdentity *peer,
-                                                                               
                                        const struct 
GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
-                                                                               
                                        const struct 
GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
-                                                                               
                                        const struct GNUNET_ATS_Information 
*ats,
-                                                                               
                                        uint32_t ats_count);
-
-
-/**
  * Signature of a function that is called with QoS information about an 
address.
  *
  * @param cls closure
@@ -728,7 +711,7 @@
  */
 typedef void (*GNUNET_ATS_AddressInformationCallback) (void *cls,
                                                                                
                                const struct GNUNET_HELLO_Address *address,
-                                                                               
                                unsigned int address_active,
+                                                                               
                                int address_active,
                                                                                
                                struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_out,
                                                                                
                                struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
                                                                                
                                const struct GNUNET_ATS_Information *ats,
@@ -744,9 +727,6 @@
  * Get handle to access performance API of the ATS subsystem.
  *
  * @param cfg configuration to use
- * @param perf_monitor_cb callback called when performance characteristics for
- *     a peer change
- * @param perf_monitor_cb closure for the perf_monitor_cb
  * @param addr_info_cb callback called when performance characteristics for
  *     an address change
  * @param addr_info_cb_cls closure for infocb
@@ -754,37 +734,11 @@
  */
 struct GNUNET_ATS_PerformanceHandle *
 GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                                                                               
                                 GNUNET_ATS_PerformanceMonitorCb 
perf_monitor_cb,
-                                                                               
                                 void *perf_monitor_cb_cls,
                              GNUNET_ATS_AddressInformationCallback 
addr_info_cb,
                              void *addr_info_cb_cls);
 
 
 /**
- * Start monitoring performance information
- *
- * @param ph performance handle to use
- * @param monitor_cb function to call on performance changes
- * @param monitor_cb_cls closure for infocb
- * @return a performance monitor handle
- */
-struct GNUNET_ATS_PerformanceMonitorHandle *
-GNUNET_ATS_performance_monitor_start (struct GNUNET_ATS_PerformanceHandle * ph,
-                                                                               
                                                                        
GNUNET_ATS_PerformanceMonitorCb monitor_cb,
-                                                                               
                                                                        void * 
monitor_cb_cls);
-
-
-/**
- * Stop monitoring performance information
- *
- * @param phm performance monitoring handle to use
- */
-void
-GNUNET_ATS_performance_monitor_stop (struct 
GNUNET_ATS_PerformanceMonitorHandle * phm);
-
-
-
-/**
  * Get information about addresses known to the ATS subsystem.
  *
  * @param handle the performance handle to use




reply via email to

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