gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r26598 - in gnunet/src: ats ats-tool dht fs include
Date: Mon, 25 Mar 2013 17:06:08 +0100

Author: wachs
Date: 2013-03-25 17:06:07 +0100 (Mon, 25 Mar 2013)
New Revision: 26598

Modified:
   gnunet/src/ats-tool/gnunet-ats.c
   gnunet/src/ats/ats_api_performance.c
   gnunet/src/ats/gnunet-service-ats.c
   gnunet/src/ats/gnunet-service-ats_performance.c
   gnunet/src/ats/test_ats_api_performance.c
   gnunet/src/ats/test_ats_api_performance_monitor.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/fs/gnunet-service-fs.c
   gnunet/src/include/gnunet_ats_service.h
   gnunet/src/include/gnunet_protocols.h
Log:
ats api change


Modified: gnunet/src/ats/ats_api_performance.c
===================================================================
--- gnunet/src/ats/ats_api_performance.c        2013-03-25 14:23:36 UTC (rev 
26597)
+++ gnunet/src/ats/ats_api_performance.c        2013-03-25 16:06:07 UTC (rev 
26598)
@@ -159,20 +159,6 @@
 
 
 
-struct GNUNET_ATS_PerformanceMonitorHandle
-{
-       struct GNUNET_ATS_PerformanceMonitorHandle *next;
-       struct GNUNET_ATS_PerformanceMonitorHandle *prev;
-
-       struct GNUNET_ATS_PerformanceHandle * ph;
-
-       GNUNET_ATS_PerformanceMonitorCb moncb;
-       void *moncb_cls;
-
-       uint32_t id;
-};
-
-
 /**
  * ATS Handle to obtain and/or modify performance information.
  */
@@ -185,16 +171,26 @@
   const struct GNUNET_CONFIGURATION_Handle *cfg;
 
   /**
-   * Callback to invoke on performance changes.
+   * Callback to invoke when an address has performance changes.
    */
-  GNUNET_ATS_AddressInformationCallback infocb;
+  GNUNET_ATS_AddressInformationCallback addr_info_cb;
 
   /**
-   * Closure for 'infocb'.
+   * Closure for 'addr_info_cb'.
    */
-  void *infocb_cls;
+  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;
@@ -229,17 +225,8 @@
    */
   struct GNUNET_ATS_AddressListHandle *addresslist_tail;
 
-  /**
-   * Head of linked list of pending performance monitors.
-   */
-  struct GNUNET_ATS_PerformanceMonitorHandle *monitor_head;
 
   /**
-   * Tail of linked list of pending performance monitors.
-   */
-  struct GNUNET_ATS_PerformanceMonitorHandle *monitor_tail;
-
-  /**
    * Current request for transmission to ATS.
    */
   struct GNUNET_CLIENT_TransmitHandle *th;
@@ -372,6 +359,7 @@
   uint16_t plugin_address_length;
   uint16_t plugin_name_length;
   uint32_t ats_count;
+  int addr_active;
 
   if (ntohs (msg->size) < sizeof (struct PeerInformationMessage))
   {
@@ -383,6 +371,7 @@
   ats_count = ntohl (pi->ats_count);
   plugin_address_length = ntohs (pi->address_length);
   plugin_name_length = ntohs (pi->plugin_name_length);
+  addr_active = ntohl (pi->address_active);
   atsi = (const struct GNUNET_ATS_Information *) &pi[1];
   plugin_address = (const char *) &atsi[ats_count];
   plugin_name = &plugin_address[plugin_address_length];
@@ -396,17 +385,26 @@
     GNUNET_break (0);
     return GNUNET_SYSERR;
   }
-  if (ph->infocb == NULL)
+
+  if (NULL != ph->addr_info_cb)
   {
-    return GNUNET_OK;
-  }
+         address.peer = pi->peer;
+         address.address = plugin_address;
+         address.address_length = plugin_address_length;
+         address.transport_name = plugin_name;
 
-  address.peer = pi->peer;
-  address.address = plugin_address;
-  address.address_length = plugin_address_length;
-  address.transport_name = plugin_name;
-  ph->infocb (ph->infocb_cls, &address, pi->bandwidth_out, pi->bandwidth_in,
+               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;
 }
 
@@ -539,8 +537,9 @@
           _("Received last message for %s \n"), "ATS_ADDRESSLIST_RESPONSE");
       bandwidth_zero.value__ = htonl (0);
       if (NULL != alh->cb)
-        alh->cb (ph->infocb_cls,
+        alh->cb (ph->addr_info_cb_cls,
               NULL,
+              GNUNET_NO,
               bandwidth_zero, bandwidth_zero,
               NULL, 0);
       GNUNET_CONTAINER_DLL_remove (ph->addresslist_head, ph->addresslist_tail, 
alh);
@@ -556,72 +555,16 @@
   if ((GNUNET_YES == alh->all_addresses) || (GNUNET_YES == active))
   {
     if (NULL != alh->cb)
-      alh->cb (ph->infocb_cls,
+      alh->cb (ph->addr_info_cb_cls,
             &address,
+            active,
             pi->bandwidth_out, pi->bandwidth_in,
             atsi, ats_count);
   }
   return GNUNET_OK;
 }
 
-/**
- * We received a monitor response message.  Validate and process it.
- *
- * @param ph our context with the callback
- * @param msg the message
- * @return GNUNET_OK if the message was well-formed
- */
-static int
-process_mr_message (struct GNUNET_ATS_PerformanceHandle *ph,
-                    const struct GNUNET_MessageHeader *msg)
-{
-       struct MonitorResponseMessage *mrm = (struct MonitorResponseMessage *) 
msg;
-       struct GNUNET_ATS_PerformanceMonitorHandle *cur;
-       struct GNUNET_ATS_Information *ats;
-       size_t msg_size;
-       uint32_t ats_count;
-       uint32_t id;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-      _("Received %s message\n"), "ATS_MONITOR_RESPONSE");
-
-       msg_size = ntohs (msg->size);
-       if (msg_size < sizeof (struct MonitorResponseMessage))
-       {
-               GNUNET_break (0);
-               return GNUNET_SYSERR;
-       }
-
-       ats_count = ntohl (mrm->ats_count);
-       if (msg_size != (sizeof (struct MonitorResponseMessage) +
-                       ats_count * sizeof (struct GNUNET_ATS_Information)))
-               {
-                       GNUNET_break (0);
-                       return GNUNET_SYSERR;
-               }
-
-       id = ntohl (mrm->id);
-       /* Do work here */
-       for (cur = ph->monitor_head; NULL != cur; cur = cur->next)
-       {
-                       if (id == cur->id)
-                               break;
-       }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-      _("Received %s message for id %u\n"), "ATS_MONITOR_RESPONSE", id);
-       if (NULL == cur)
-       {
-               GNUNET_break (0);
-               return GNUNET_SYSERR;
-       }
-
-       ats = (struct GNUNET_ATS_Information *) &mrm[1];
-       cur->moncb (cur->moncb_cls, &mrm->peer, ats, ats_count);
-
-       return GNUNET_OK;
-}
-
-
 /**
  * Type of a function to call when we receive a message
  * from the service.
@@ -650,10 +593,6 @@
     if (GNUNET_OK != process_ar_message (ph, msg))
       goto reconnect;
     break;
-  case GNUNET_MESSAGE_TYPE_ATS_MONITOR_RESPONSE:
-    if (GNUNET_OK != process_mr_message (ph, msg))
-      goto reconnect;
-    break;
   default:
     GNUNET_break (0);
     goto reconnect;
@@ -701,9 +640,8 @@
     init->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_START);
     init->header.size = htons (sizeof (struct ClientStartMessage));
     init->start_flag =
-        htonl ((ph->infocb ==
-                NULL) ? START_FLAG_PERFORMANCE_NO_PIC :
-               START_FLAG_PERFORMANCE_WITH_PIC);
+        htonl (((NULL ==ph->addr_info_cb) && (NULL == ph->perf_monitor_cb)) ?
+                       START_FLAG_PERFORMANCE_NO_PIC : 
START_FLAG_PERFORMANCE_WITH_PIC);
     GNUNET_CONTAINER_DLL_insert (ph->pending_head, ph->pending_tail, p);
   }
   do_transmit (ph);
@@ -715,101 +653,35 @@
  * Get handle to access performance API of the ATS subsystem.
  *
  * @param cfg configuration to use
- * @param infocb function to call on allocation changes, can be NULL
- * @param infocb_cls closure for infocb
+ * @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
  * @return ats performance context
  */
 struct GNUNET_ATS_PerformanceHandle *
 GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                             GNUNET_ATS_AddressInformationCallback infocb,
-                             void *infocb_cls)
+                                                                               
                                 GNUNET_ATS_PerformanceMonitorCb 
perf_monitor_cb,
+                                                                               
                                 void *perf_monitor_cb_cls,
+                             GNUNET_ATS_AddressInformationCallback 
addr_info_cb,
+                             void *addr_info_cb_cls)
 {
   struct GNUNET_ATS_PerformanceHandle *ph;
 
   ph = GNUNET_malloc (sizeof (struct GNUNET_ATS_PerformanceHandle));
   ph->cfg = cfg;
-  ph->infocb = infocb;
-  ph->infocb_cls = infocb_cls;
+  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;
 }
 
-
 /**
- * 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)
-{
-       struct MonitorMessage *m;
-       struct PendingMessage *p;
-       GNUNET_assert (NULL != ph);
-
-       if (NULL == monitor_cb)
-               return NULL;
-
-       struct GNUNET_ATS_PerformanceMonitorHandle *phm =
-                       GNUNET_malloc (sizeof (struct 
GNUNET_ATS_PerformanceMonitorHandle));
-
-       ph->monitor_id ++;
-       phm->id = ph->monitor_id;
-       phm->ph = ph;
-       phm->moncb = monitor_cb;
-       phm->moncb_cls = monitor_cb_cls;
-       GNUNET_CONTAINER_DLL_insert (ph->monitor_head, ph->monitor_tail, phm);
-
-  p = GNUNET_malloc (sizeof (struct PendingMessage) +
-                     sizeof (struct MonitorMessage));
-  p->size = sizeof (struct MonitorMessage);
-  m = (struct MonitorMessage *) &p[1];
-  m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_MONITOR);
-  m->header.size = htons (sizeof (struct MonitorMessage));
-  m->id = htonl (phm->id);
-  m->op = htonl (GNUNET_YES);
-  GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head, ph->pending_tail, p);
-  do_transmit (ph);
-
-       return phm;
-}
-
-
-/**
- * Stop monitoring performance information
- *
- * @param phm performance monitor handle to use
- */
-void
-GNUNET_ATS_performance_monitor_stop (struct 
GNUNET_ATS_PerformanceMonitorHandle * phm)
-{
-       struct MonitorMessage *m;
-       struct PendingMessage *p;
-
-       GNUNET_assert (NULL != phm);
-
-  p = GNUNET_malloc (sizeof (struct PendingMessage) +
-                     sizeof (struct MonitorMessage));
-  p->size = sizeof (struct MonitorMessage);
-  m = (struct MonitorMessage *) &p[1];
-  m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_MONITOR);
-  m->header.size = htons (sizeof (struct MonitorMessage));
-  m->id = htonl (phm->id);
-  m->op = htonl (GNUNET_NO);
-  GNUNET_CONTAINER_DLL_insert_tail (phm->ph->pending_head, 
phm->ph->pending_tail, p);
-  do_transmit (phm->ph);
-
-       GNUNET_CONTAINER_DLL_remove (phm->ph->monitor_head, 
phm->ph->monitor_tail, phm);
-       GNUNET_free (phm);
-}
-
-/**
  * Client is done using the ATS performance subsystem, release resources.
  *
  * @param ph handle
@@ -820,7 +692,6 @@
   struct PendingMessage *p;
   struct GNUNET_ATS_ReservationContext *rc;
   struct GNUNET_ATS_AddressListHandle *alh;
-  struct GNUNET_ATS_PerformanceMonitorHandle *phm;
 
   while (NULL != (p = ph->pending_head))
   {
@@ -840,11 +711,7 @@
     GNUNET_break (NULL == rc->rcb);
     GNUNET_free (rc);
   }
-  while (NULL != (phm = ph->monitor_head))
-  {
-    GNUNET_CONTAINER_DLL_remove (ph->monitor_head, ph->monitor_tail, phm);
-    GNUNET_free (phm);
-  }
+
   if (GNUNET_SCHEDULER_NO_TASK != ph->task)
   {
     GNUNET_SCHEDULER_cancel (ph->task);

Modified: gnunet/src/ats/gnunet-service-ats.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats.c 2013-03-25 14:23:36 UTC (rev 26597)
+++ gnunet/src/ats/gnunet-service-ats.c 2013-03-25 16:06:07 UTC (rev 26598)
@@ -162,9 +162,6 @@
     {&GAS_handle_reset_backoff, NULL,
      GNUNET_MESSAGE_TYPE_ATS_RESET_BACKOFF,
      sizeof (struct ResetBackoffMessage)},
-    {&GAS_handle_monitor, NULL,
-     GNUNET_MESSAGE_TYPE_ATS_MONITOR,
-     sizeof (struct MonitorMessage)},
     {NULL, NULL, 0, 0}
   };
   GSA_server = server;

Modified: gnunet/src/ats/gnunet-service-ats_performance.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_performance.c     2013-03-25 14:23:36 UTC 
(rev 26597)
+++ gnunet/src/ats/gnunet-service-ats_performance.c     2013-03-25 16:06:07 UTC 
(rev 26598)
@@ -31,16 +31,6 @@
 #include "gnunet-service-ats_reservations.h"
 #include "ats.h"
 
-struct PerformanceMonitorClient
-{
-       struct PerformanceMonitorClient *next;
-       struct PerformanceMonitorClient *prev;
-
-       struct GNUNET_SERVER_Client *client;
-
-       uint32_t id;
-};
-
 /**
  * We keep clients that are interested in performance in a linked list.
  */
@@ -138,18 +128,9 @@
 GAS_performance_remove_client (struct GNUNET_SERVER_Client *client)
 {
   struct PerformanceClient *pc;
-  struct PerformanceMonitorClient *cur;
-  struct PerformanceMonitorClient *next;
   pc = find_client (client);
   if (NULL == pc)
     return;
-  next = pc->pm_head;
-  while (NULL != (cur = next))
-       {
-               next = cur->next;
-               GNUNET_CONTAINER_DLL_remove (pc->pm_head, pc->pm_tail, cur);
-               GNUNET_free (cur);
-       }
   GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc);
   GNUNET_SERVER_client_drop (client);
   GNUNET_free (pc);
@@ -293,7 +274,9 @@
               ntohl (bandwidth_in.value__));
   GAS_performance_notify_client(pc,
                                 id,
-                                plugin_name, plugin_addr, plugin_addr_len,
+                                plugin_name,
+                                plugin_addr,
+                                plugin_addr_len,
                                 active,
                                 atsi, atsi_count,
                                 bandwidth_out, bandwidth_in);
@@ -529,6 +512,9 @@
                                                                                
                                         struct GNUNET_ATS_Information *ats,
                                                                                
                                         uint32_t ats_count)
 {
+/* Notify here */
+
+#if 0
        struct PerformanceClient *cur;
        struct PerformanceMonitorClient *curm;
        struct MonitorResponseMessage *mrm;
@@ -555,143 +541,11 @@
                                        GNUNET_YES);
                }
        GNUNET_free (mrm);
+#endif
 }
 
 
-static void
-mon_peerinfo_it (void *cls,
-             const struct GNUNET_PeerIdentity *id,
-             const char *plugin_name,
-             const void *plugin_addr, size_t plugin_addr_len,
-             const int active,
-             const struct GNUNET_ATS_Information *atsi,
-             uint32_t atsi_count,
-             struct GNUNET_BANDWIDTH_Value32NBO
-             bandwidth_out,
-             struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
-{
-       struct PerformanceMonitorClient *pmc = cls;
-       struct MonitorResponseMessage *mrm;
-       size_t msglen;
-
-       if (NULL == id)
-               return; /* last callback */
-
-       msglen = sizeof (struct MonitorResponseMessage) +
-                       atsi_count * sizeof (struct GNUNET_ATS_Information);
-       mrm = GNUNET_malloc (msglen);
-
-       mrm->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_MONITOR_RESPONSE);
-       mrm->header.size = htons (msglen);
-       mrm->id = htonl(pmc->id);
-       mrm->ats_count = htonl (atsi_count);
-       mrm->peer = *id;
-       memcpy (&mrm[1], atsi, atsi_count * sizeof (struct 
GNUNET_ATS_Information));
-
-       /* Send initial information about peers to client */
-
-  GNUNET_SERVER_notification_context_unicast (nc,
-               pmc->client,
-               (struct GNUNET_MessageHeader *) mrm,
-               GNUNET_YES);
-  GNUNET_free (mrm);
-}
-
 /**
- * Iterator for GAS_handle_monitor
- *
- * @param cls the performance monitoring client requesting information
- * @param id result
- */
-static void
-mon_peer_it (void *cls,
-         const struct GNUNET_PeerIdentity *id)
-{
-  struct PerformanceMonitorClient *pmc = cls;
-  if (NULL != id)
-    GAS_addresses_get_peer_info (GSA_addresses, id, &mon_peerinfo_it, pmc);
-}
-
-
-void
-GAS_handle_monitor (void *cls,
-                                                                               
struct GNUNET_SERVER_Client *client,
-                                                                               
const struct GNUNET_MessageHeader *message)
-{
-  struct PerformanceClient *pc;
-       struct PerformanceMonitorClient *pmc;
-       struct MonitorMessage *mm = (struct MonitorMessage *) message;
-       size_t msg_size;
-       uint32_t id;
-       uint32_t op;
-
-       pc = find_client (client);
-       if (NULL == pc)
-       {
-                       GNUNET_break (0);
-                       return;
-       }
-
-       msg_size = ntohs (message->size);
-       if (msg_size < sizeof (struct MonitorMessage))
-       {
-                 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
-                       return;
-       }
-
-       id = ntohl (mm->id);
-       op = ntohl (mm->op);
-
-       for (pmc = pc->pm_head; NULL != pmc; pmc = pmc->next)
-               if ((pmc->id == id) && (client == pmc->client))
-                       break;
-
-       if (GNUNET_YES == op)
-       {
-                       /* Start monitoring */
-                       if (NULL != pmc)
-                       {
-                               GNUNET_break (0);
-                               GNUNET_SERVER_receive_done (client, 
GNUNET_SYSERR);
-                               return; /* Duplicate*/
-                       }
-                       pmc = GNUNET_malloc (sizeof (struct 
PerformanceMonitorClient));
-                       pmc->client = client;
-                       pmc->id = id;
-                       GNUNET_CONTAINER_DLL_insert (pc->pm_head, pc->pm_tail, 
pmc);
-                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                                       "Added performance monitoring client %p 
id %u\n",
-                                       client, id);
-                       /* Return all values here */
-                 GAS_addresses_iterate_peers (GSA_addresses, &mon_peer_it, 
pmc);
-
-       }
-       else if (GNUNET_NO == op)
-       {
-                       /* Stop monitoring */
-                       if (NULL == pmc)
-                       {
-                               GNUNET_break (0);
-                               GNUNET_SERVER_receive_done (client, 
GNUNET_SYSERR);
-                               return; /* Not existing */
-                       }
-                       GNUNET_CONTAINER_DLL_remove (pc->pm_head, pc->pm_tail, 
pmc);
-                       GNUNET_free (pmc);
-                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                                       "Removed performance monitoring client 
%p id %u\n",
-                                       client, id);
-       }
-       else
-       {
-               GNUNET_break (0);
-               GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
-               return;
-       }
-       GNUNET_SERVER_receive_done (client, GNUNET_OK);
-}
-
-
-/**
  * Handle 'reservation request' messages from clients.
  *
  * @param cls unused, NULL

Modified: gnunet/src/ats/test_ats_api_performance.c
===================================================================
--- gnunet/src/ats/test_ats_api_performance.c   2013-03-25 14:23:36 UTC (rev 
26597)
+++ gnunet/src/ats/test_ats_api_performance.c   2013-03-25 16:06:07 UTC (rev 
26598)
@@ -129,18 +129,12 @@
 test_performance_api (void *cls, const struct GNUNET_SCHEDULER_TaskContext 
*tc);
 
 void all_active_addresses_peer_cb (void *cls,
-                      const struct
-                      GNUNET_HELLO_Address *
-                      address,
-                      struct
-                      GNUNET_BANDWIDTH_Value32NBO
-                      bandwidth_out,
-                      struct
-                      GNUNET_BANDWIDTH_Value32NBO
-                      bandwidth_in,
-                      const struct
-                      GNUNET_ATS_Information *
-                      ats, uint32_t ats_count)
+               const struct GNUNET_HELLO_Address *address,
+               unsigned int active,
+               struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
+               struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+               const struct GNUNET_ATS_Information *ats,
+               uint32_t ats_count)
 {
   static int cb = 0;
   int fail = GNUNET_NO;
@@ -198,18 +192,12 @@
 }
 
 void all_active_addresses_cb (void *cls,
-                      const struct
-                      GNUNET_HELLO_Address *
-                      address,
-                      struct
-                      GNUNET_BANDWIDTH_Value32NBO
-                      bandwidth_out,
-                      struct
-                      GNUNET_BANDWIDTH_Value32NBO
-                      bandwidth_in,
-                      const struct
-                      GNUNET_ATS_Information *
-                      ats, uint32_t ats_count)
+                                                                               
                                        const struct GNUNET_HELLO_Address 
*address,
+                                                                               
                                        unsigned int active,
+                                                                               
                                        struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_out,
+                                                                               
                                        struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_in,
+                                                                               
                                        const struct GNUNET_ATS_Information 
*ats,
+                                                                               
                                        uint32_t ats_count)
 {
   static int cb = 0;
   int fail = GNUNET_NO;
@@ -279,18 +267,12 @@
 
 
 void all_addresses_peer_cb (void *cls,
-                      const struct
-                      GNUNET_HELLO_Address *
-                      address,
-                      struct
-                      GNUNET_BANDWIDTH_Value32NBO
-                      bandwidth_out,
-                      struct
-                      GNUNET_BANDWIDTH_Value32NBO
-                      bandwidth_in,
-                      const struct
-                      GNUNET_ATS_Information *
-                      ats, uint32_t ats_count)
+                                                                               
                                const struct GNUNET_HELLO_Address *address,
+                                                                               
                                unsigned int active,
+                                                                               
                                struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_out,
+                                                                               
                                struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+                                                                               
                                const struct GNUNET_ATS_Information *ats,
+                                                                               
                                uint32_t ats_count)
 {
   static int cb = 0;
   int fail = GNUNET_NO;
@@ -334,18 +316,12 @@
 }
 
 void all_addresses_cb (void *cls,
-                              const struct
-                              GNUNET_HELLO_Address *
-                              address,
-                              struct
-                              GNUNET_BANDWIDTH_Value32NBO
-                              bandwidth_out,
-                              struct
-                              GNUNET_BANDWIDTH_Value32NBO
-                              bandwidth_in,
-                              const struct
-                              GNUNET_ATS_Information *
-                              ats, uint32_t ats_count)
+                                                                               
        const struct GNUNET_HELLO_Address *address,
+                                                                               
        unsigned int active,
+                                                                               
        struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
+                                                                               
        struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+                                                                               
        const struct GNUNET_ATS_Information *ats,
+                                                                               
        uint32_t ats_count)
 {
   static int cb = 0;
 
@@ -404,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);
+    ph = GNUNET_ATS_performance_init (cfg, NULL, NULL, NULL, NULL);
   if (NULL == ph)
   {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize performance 
handle\n");

Modified: gnunet/src/ats/test_ats_api_performance_monitor.c
===================================================================
--- gnunet/src/ats/test_ats_api_performance_monitor.c   2013-03-25 14:23:36 UTC 
(rev 26597)
+++ gnunet/src/ats/test_ats_api_performance_monitor.c   2013-03-25 16:06:07 UTC 
(rev 26598)
@@ -42,8 +42,6 @@
 
 static struct GNUNET_ATS_PerformanceHandle *ph;
 
-static struct GNUNET_ATS_PerformanceMonitorHandle *phm;
-
 static struct GNUNET_HELLO_Address addr;
 
 static struct GNUNET_ATS_Information atsi[ATS_COUNT];
@@ -91,12 +89,6 @@
 
        cleanup_addresses ();
 
-       if (NULL != phm)
-       {
-               GNUNET_ATS_performance_monitor_stop (phm);
-               phm = NULL;
-       }
-
        if (NULL != ph)
        {
                GNUNET_ATS_performance_done (ph);
@@ -129,9 +121,6 @@
        {
                GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stop performance 
monitoring\n");
 
-               GNUNET_ATS_performance_monitor_stop (phm);
-               phm = NULL;
-
                stage_task = GNUNET_SCHEDULER_add_delayed (SHUTDOWN_CORRECT, 
&next_stage, NULL);
                stage_counter++;
                return;
@@ -151,8 +140,10 @@
 
 static void
 perf_mon_cb (void *cls,
-                                               struct GNUNET_PeerIdentity 
*peer,
-                                               struct GNUNET_ATS_Information 
*ats,
+                                               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)
 {
        static int stage_counter = 0;
@@ -273,11 +264,9 @@
 
   setup_addresses ();
 
-  ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
+  ph = GNUNET_ATS_performance_init (cfg, &perf_mon_cb, &ret, NULL, NULL);
   GNUNET_assert (NULL != ph);
 
-  phm = GNUNET_ATS_performance_monitor_start (ph, &perf_mon_cb, &ret);
-  GNUNET_assert (NULL != phm);
 
   stage_task = GNUNET_SCHEDULER_add_delayed (SHUTDOWN_CORRECT, &next_stage, 
NULL);
 }

Modified: gnunet/src/ats/test_ats_simplistic_change_preference.c
===================================================================
--- gnunet/src/ats/test_ats_simplistic_change_preference.c      2013-03-25 
14:23:36 UTC (rev 26597)
+++ gnunet/src/ats/test_ats_simplistic_change_preference.c      2013-03-25 
16:06:07 UTC (rev 26598)
@@ -318,7 +318,7 @@
     return;
   }
 
-  perf_ats = GNUNET_ATS_performance_init (cfg, NULL, NULL);
+  perf_ats = GNUNET_ATS_performance_init (cfg, NULL, NULL, 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-25 14:23:36 UTC 
(rev 26597)
+++ gnunet/src/ats/test_ats_simplistic_pref_aging.c     2013-03-25 16:06:07 UTC 
(rev 26598)
@@ -368,7 +368,7 @@
   }
 
   /* Connect to ATS performance */
-  perf_ats = GNUNET_ATS_performance_init(cfg, NULL, NULL);
+  perf_ats = GNUNET_ATS_performance_init(cfg, NULL, NULL, 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-25 14:23:36 UTC (rev 26597)
+++ gnunet/src/ats-tool/gnunet-ats.c    2013-03-25 16:06:07 UTC (rev 26598)
@@ -221,18 +221,12 @@
 }
 
 void ats_perf_cb (void *cls,
-                  const struct
-                  GNUNET_HELLO_Address *
-                  address,
-                  struct
-                  GNUNET_BANDWIDTH_Value32NBO
-                  bandwidth_out,
-                  struct
-                  GNUNET_BANDWIDTH_Value32NBO
-                  bandwidth_in,
-                  const struct
-                  GNUNET_ATS_Information *
-                  ats, uint32_t ats_count)
+                                                                       const 
struct GNUNET_HELLO_Address *address,
+                                                                       
unsigned int active,
+                                                                       struct 
GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
+                                                                       struct 
GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+                                                                       const 
struct GNUNET_ATS_Information *ats,
+                                                                       
uint32_t ats_count)
 {
   struct PendingResolutions * pr;
 
@@ -373,7 +367,7 @@
     }
     if (op_list_all)
     {
-        ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
+        ph = GNUNET_ATS_performance_init (cfg, NULL, NULL, NULL, NULL);
         if (NULL == ph)
         {
           fprintf (stderr, _("Cannot connect to ATS service, exiting...\n"));
@@ -393,7 +387,7 @@
     }
     else if (op_list_used)
     {
-        ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
+        ph = GNUNET_ATS_performance_init (cfg, NULL, NULL, NULL, NULL);
         if (NULL == ph)
           fprintf (stderr, _("Cannot connect to ATS service, exiting...\n"));
 
@@ -410,7 +404,7 @@
     }
     else if (op_monitor)
     {
-        ph = GNUNET_ATS_performance_init (cfg, ats_perf_cb, NULL);
+        ph = GNUNET_ATS_performance_init (cfg, NULL, NULL, 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);
@@ -435,7 +429,7 @@
         }
 
             /* set */
-            ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
+            ph = GNUNET_ATS_performance_init (cfg, NULL, NULL, 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-25 14:23:36 UTC 
(rev 26597)
+++ gnunet/src/dht/gnunet-service-dht_neighbours.c      2013-03-25 16:06:07 UTC 
(rev 26598)
@@ -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);
+  atsAPI = GNUNET_ATS_performance_init (GDS_cfg, NULL, NULL, NULL, NULL);
   coreAPI =
       GNUNET_CORE_connect (GDS_cfg, NULL, &core_init, &handle_core_connect,
                            &handle_core_disconnect, NULL, GNUNET_NO, NULL,

Modified: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c   2013-03-25 14:23:36 UTC (rev 26597)
+++ gnunet/src/fs/gnunet-service-fs.c   2013-03-25 16:06:07 UTC (rev 26598)
@@ -243,6 +243,7 @@
 static void
 update_latencies (void *cls,
                  const struct GNUNET_HELLO_Address *address,
+                 unsigned int active,
                  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
                  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
                  const struct GNUNET_ATS_Information *ats, 
@@ -251,7 +252,8 @@
   unsigned int i;
   struct GNUNET_TIME_Relative latency;
 
-  // FIXME: if (GNUNET_YES != current_address) return;
+  if (GNUNET_YES != active)
+       return;
   for (i = 0; i < ats_count; i++)
   {
     if (GNUNET_ATS_QUALITY_NET_DELAY != ntohl (ats[i].type))
@@ -690,7 +692,7 @@
   GSF_plan_init ();
   GSF_pending_request_init_ ();
   GSF_connected_peer_init_ ();
-  GSF_ats = GNUNET_ATS_performance_init (GSF_cfg, &update_latencies, NULL);
+  GSF_ats = GNUNET_ATS_performance_init (GSF_cfg, NULL, NULL, 
&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-25 14:23:36 UTC (rev 
26597)
+++ gnunet/src/include/gnunet_ats_service.h     2013-03-25 16:06:07 UTC (rev 
26598)
@@ -707,9 +707,11 @@
  */
 typedef void
 (*GNUNET_ATS_PerformanceMonitorCb) (void *cls,
-                                                                               
                                                                struct 
GNUNET_PeerIdentity *peer,
-                                                                               
                                                                struct 
GNUNET_ATS_Information *ats,
-                                                                               
                                                                uint32_t 
ats_count);
+                                                                               
                                        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);
 
 
 /**
@@ -717,24 +719,20 @@
  *
  * @param cls closure
  * @param address the address
+ * @param address_active is this address actively used to maintain a connection
+ *                             to a peer
  * @param bandwidth_out assigned outbound bandwidth for the connection
  * @param bandwidth_in assigned inbound bandwidth for the connection
  * @param ats performance data for the address (as far as known)
  * @param ats_count number of performance records in 'ats'
  */
 typedef void (*GNUNET_ATS_AddressInformationCallback) (void *cls,
-                                                    const struct
-                                                    GNUNET_HELLO_Address *
-                                                    address,
-                                                    struct
-                                                    GNUNET_BANDWIDTH_Value32NBO
-                                                    bandwidth_out,
-                                                    struct
-                                                    GNUNET_BANDWIDTH_Value32NBO
-                                                    bandwidth_in,
-                                                    const struct
-                                                    GNUNET_ATS_Information *
-                                                    ats, uint32_t ats_count);
+                                                                               
                                const struct GNUNET_HELLO_Address *address,
+                                                                               
                                unsigned int address_active,
+                                                                               
                                struct GNUNET_BANDWIDTH_Value32NBO 
bandwidth_out,
+                                                                               
                                struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+                                                                               
                                const struct GNUNET_ATS_Information *ats,
+                                                                               
                                uint32_t ats_count);
 
 /**
  * Handle for an address listing operation
@@ -746,14 +744,20 @@
  * Get handle to access performance API of the ATS subsystem.
  *
  * @param cfg configuration to use
- * @param infocb function to call on performance changes, can be NULL
- * @param infocb_cls closure for infocb
+ * @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
  * @return ats performance context
  */
 struct GNUNET_ATS_PerformanceHandle *
 GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                             GNUNET_ATS_AddressInformationCallback infocb,
-                             void *infocb_cls);
+                                                                               
                                 GNUNET_ATS_PerformanceMonitorCb 
perf_monitor_cb,
+                                                                               
                                 void *perf_monitor_cb_cls,
+                             GNUNET_ATS_AddressInformationCallback 
addr_info_cb,
+                             void *addr_info_cb_cls);
 
 
 /**

Modified: gnunet/src/include/gnunet_protocols.h
===================================================================
--- gnunet/src/include/gnunet_protocols.h       2013-03-25 14:23:36 UTC (rev 
26597)
+++ gnunet/src/include/gnunet_protocols.h       2013-03-25 16:06:07 UTC (rev 
26598)
@@ -1149,15 +1149,8 @@
  */
 #define GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE 355
 
-/**
- * Type of the 'struct AddressListRequestMessage' sent by client to ATS
- * to request information about addresses
- */
-#define GNUNET_MESSAGE_TYPE_ATS_MONITOR 356
 
-#define GNUNET_MESSAGE_TYPE_ATS_MONITOR_RESPONSE 357
 
-
 
/*******************************************************************************
  * TRANSPORT message types
  
******************************************************************************/




reply via email to

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