gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r16465 - gnunet/src/transport
Date: Fri, 12 Aug 2011 12:00:40 +0200

Author: grothoff
Date: 2011-08-12 12:00:39 +0200 (Fri, 12 Aug 2011)
New Revision: 16465

Modified:
   gnunet/src/transport/gnunet-service-transport_ats-new.c
   gnunet/src/transport/gnunet-service-transport_ats-new.h
   gnunet/src/transport/gnunet-service-transport_clients.c
   gnunet/src/transport/gnunet-service-transport_neighbours.c
   gnunet/src/transport/gnunet-service-transport_validation.c
   gnunet/src/transport/gnunet-service-transport_validation.h
Log:
moving API around to make ATS implementable and separable

Modified: gnunet/src/transport/gnunet-service-transport_ats-new.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_ats-new.c     2011-08-12 
09:02:38 UTC (rev 16464)
+++ gnunet/src/transport/gnunet-service-transport_ats-new.c     2011-08-12 
10:00:39 UTC (rev 16465)
@@ -34,6 +34,11 @@
 {
 
   /**
+   * Public key of the peer.
+   */
+  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;                   
                             
+
+  /**
    * Performance information associated with this address (array).
    */
   struct GNUNET_TRANSPORT_ATS_Information *ats;
@@ -77,6 +82,35 @@
 
 
 /**
+ * Opaque handle to stop incremental validation address callbacks.
+ */
+struct GST_AtsSuggestionContext
+{
+
+  /**
+   * Function to call with our final suggestion.
+   */
+  GST_AtsAddressSuggestionCallback cb;
+
+  /**
+   * Closure for 'cb'.
+   */
+  void *cb_cls;
+
+  /**
+   * Global ATS handle.
+   */ 
+  struct GST_AtsHandle *atc;
+
+  /**
+   * Which peer are we monitoring?
+   */   
+  struct GNUNET_PeerIdentity target;
+
+};
+
+
+/**
  * Handle to the ATS subsystem.
  */
 struct GST_AtsHandle
@@ -103,6 +137,12 @@
   struct GNUNET_CONTAINER_MultiHashMap *peers;
 
   /**
+   * Map of PeerIdentities to 'struct GST_AtsSuggestionContext's.
+   */
+  struct GNUNET_CONTAINER_MultiHashMap *notify_map;
+
+
+  /**
    * Task scheduled to update our bandwidth assignment.
    */
   GNUNET_SCHEDULER_TaskIdentifier ba_task;
@@ -228,6 +268,82 @@
 
 
 /**
+ * Function called with feasbile addresses we might want to suggest.
+ *
+ * @param cls the 'struct GST_AtsSuggestionContext'
+ * @param key identity of the peer
+ * @param value a 'struct AllocationRecord' for the peer
+ * @return GNUNET_NO if we're done, GNUNET_YES if we did not suggest an 
address yet
+ */
+static int
+suggest_address (void *cls,
+                const GNUNET_HashCode *key,
+                void *value)
+{
+  struct GST_AtsSuggestionContest *asc = cls;
+  struct AllocationRecord *ar = value;
+
+  // FIXME...
+  return GNUNET_YES;
+}
+
+
+/**
+ * We would like to establish a new connection with a peer.
+ * ATS should suggest a good address to begin with.
+ *
+ * @param atc handle
+ * @param peer identity of the new peer
+ * @param cb function to call with the address
+ * @param cb_cls closure for cb
+ */
+struct GST_AtsSuggestionContext *
+GST_ats_suggest_address (struct GST_AtsHandle *atc,
+                        const struct GNUNET_PeerIdentity *peer,
+                        GST_AtsAddressSuggestionCallback cb,
+                        void *cb_cls)
+{
+  struct GST_AtsSuggestionContext *asc;
+
+  asc = GNUNET_malloc (sizeof (struct GST_AtsSuggestionContext));
+  asc->cb = cb;
+  asc->cb_cls = cb_cls;
+  asc->atc = atc;
+  asc->target = *peer;
+  GNUNET_CONTAINER_multihashmap_get_multiple (atc->peers,
+                                              &peer->hashPubKey,
+                                              &suggest_address,
+                                             asc);
+  if (NULL == asc->cb)
+    {
+      GNUNET_free (asc);
+      return NULL;
+    }
+  GNUNET_CONTAINER_multihashmap_put (atc->notify_map,
+                                    &peer->hashPubKey,
+                                    asc,
+                                    
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+  return asc;
+}
+
+
+/**
+ * Cancel suggestion request.
+ *
+ * @param asc handle of the request to cancel
+ */
+void
+GST_ats_suggest_address_cancel (struct GST_AtsSuggestionContext *asc)
+{
+  GNUNET_assert (GNUNET_OK ==
+                GNUNET_CONTAINER_multihashmap_remove (asc->atc->notify_map,
+                                                      &asc->target.hashPubKey,
+                                                      asc));
+  GNUNET_free (asc);
+}
+
+
+/**
  * Initialize the ATS subsystem.
  *
  * @param cfg configuration to use
@@ -294,6 +410,9 @@
                                         &destroy_allocation_record,
                                         NULL);
   GNUNET_CONTAINER_multihashmap_destroy (atc->peers);
+  GNUNET_assert (GNUNET_CONTAINER_multihashmap_size (atc->notify_map) == 0);
+  GNUNET_CONTAINER_multihashmap_destroy (atc->notify_map);
+  atc->notify_map = NULL;
   GNUNET_free (atc);
 }
 
@@ -377,7 +496,8 @@
  * @param ats_count number of performance records in 'ats'
  */
 static struct AllocationRecord *
-create_allocation_record (const char *plugin_name,
+create_allocation_record (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 
*public_key,
+                         const char *plugin_name,
                          struct Session *session,
                          const void *plugin_addr,
                          size_t plugin_addr_len,
@@ -387,6 +507,7 @@
   struct AllocationRecord *ar;
 
   ar = GNUNET_malloc (sizeof (struct AllocationRecord) + plugin_addr_len);
+  ar->public_key = *public_key;
   ar->plugin_name = GNUNET_strdup (plugin_name);
   ar->plugin_addr = &ar[1];
   memcpy (&ar[1], plugin_addr, plugin_addr_len);
@@ -433,6 +554,7 @@
  * Calculate bandwidth assignments including the new peer.
  *
  * @param atc handle
+ * @param public_key public key of the peer
  * @param peer identity of the new peer
  * @param plugin_name name of the currently used transport plugin
  * @param session session in use (if available)
@@ -443,6 +565,7 @@
  */
 void
 GST_ats_peer_connect (struct GST_AtsHandle *atc,
+                     const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 
*public_key,
                      const struct GNUNET_PeerIdentity *peer,
                      const char *plugin_name,
                      struct Session *session,
@@ -457,7 +580,8 @@
   (void) GNUNET_CONTAINER_multihashmap_iterate (atc->peers,
                                                &disconnect_peer,
                                                atc);
-  ar = create_allocation_record (plugin_name,
+  ar = create_allocation_record (public_key,
+                                plugin_name,
                                 session,
                                 plugin_addr,
                                 plugin_addr_len,
@@ -576,6 +700,33 @@
 
 
 /**
+ * Notify validation watcher that an entry is now valid
+ *
+ * @param cls 'struct ValidationEntry' that is now valid
+ * @param key peer identity (unused)
+ * @param value a 'GST_ValidationIteratorContext' to notify
+ * @return GNUNET_YES (continue to iterate)
+ */
+static int
+notify_valid (void *cls,
+             const GNUNET_HashCode *key,
+             void *value)
+{
+  struct AllocationRecord *ar = cls;
+  struct GST_AtsSuggestionContext *asc = value;
+
+  asc->cb (asc->cb_cls,
+          &ar->public_key,
+          &asc->target,
+          ar->plugin_name,
+          ar->plugin_addr,
+          ar->plugin_addr_len,
+          ar->ats, ar->ats_count);
+  return GNUNET_OK;
+}
+
+
+/**
  * We have updated performance statistics for a given address.  Note
  * that this function can be called for addresses that are currently
  * in use as well as addresses that are valid but not actively in use.
@@ -584,7 +735,8 @@
  * for later use).  Update bandwidth assignments.
  *
  * @param atc handle
- * @param peer identity of the new peer
+ * @param public_key public key of the peer
+ * @param peer identity of the peer
  * @param plugin_name name of the transport plugin
  * @param session session handle (if available)
  * @param plugin_addr address  (if available)
@@ -594,6 +746,7 @@
  */
 void
 GST_ats_address_update (struct GST_AtsHandle *atc,
+                       const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 
*public_key,
                        const struct GNUNET_PeerIdentity *peer,
                        const char *plugin_name,
                        struct Session *session,
@@ -605,7 +758,8 @@
   struct AllocationRecord *ar;
   struct UpdateSessionContext usc;
 
-  ar = create_allocation_record (plugin_name,
+  ar = create_allocation_record (public_key,
+                                plugin_name,                            
                                 session,
                                 plugin_addr,
                                 plugin_addr_len,
@@ -626,6 +780,10 @@
                                                    &peer->hashPubKey,
                                                    ar,
                                                    
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); 
+  GNUNET_CONTAINER_multihashmap_get_multiple (atc->notify_map,
+                                             &peer->hashPubKey,
+                                             &notify_valid,
+                                             ar);
 }
 
 /* end of file gnunet-service-transport_ats.c */

Modified: gnunet/src/transport/gnunet-service-transport_ats-new.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_ats-new.h     2011-08-12 
09:02:38 UTC (rev 16464)
+++ gnunet/src/transport/gnunet-service-transport_ats-new.h     2011-08-12 
10:00:39 UTC (rev 16465)
@@ -80,6 +80,7 @@
              GNUNET_TRANSPORT_ATS_AllocationNotification alloc_cb,
              void *alloc_cb_cls);
 
+
 /**
  * Shutdown the ATS subsystem.
  *
@@ -90,11 +91,65 @@
 
 
 /**
+ * Signature of a function that takes an address suggestion 
+ *
+ * @param cls closure
+ * @param public_key public key of the peer
+ * @param peer identity of the new peer
+ * @param plugin_name name of the plugin, NULL if we have no suggestion
+ * @param plugin_addr suggested address, NULL if we have no suggestion
+ * @param plugin_addr_len number of bytes in plugin_addr
+ * @param ats performance data for the address (as far as known)
+ * @param ats_count number of performance records in 'ats'
+ */
+typedef void (*GST_AtsAddressSuggestionCallback)(void *cls,
+                                                const struct 
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key,
+                                                const struct 
GNUNET_PeerIdentity *peer,
+                                                const char *plugin_name,
+                                                const void *plugin_addr,
+                                                size_t plugin_addr_len,
+                                                const struct 
GNUNET_TRANSPORT_ATS_Information *ats,
+                                                uint32_t ats_count);
+
+
+/**
+ * Handle to cancel suggestion request.
+ */
+struct GST_AtsSuggestionContext;
+
+
+/**
+ * We would like to establish a new connection with a peer.
+ * ATS should suggest a good address to begin with.
+ *
+ * @param atc handle
+ * @param peer identity of the new peer
+ * @param cb function to call with the address
+ * @param cb_cls closure for cb
+ */
+struct GST_AtsSuggestionContext *
+GST_ats_suggest_address (struct GST_AtsHandle *atc,
+                        const struct GNUNET_PeerIdentity *peer,
+                        GST_AtsAddressSuggestionCallback cb,
+                        void *cb_cls);
+
+
+/**
+ * Cancel suggestion request.
+ *
+ * @param asc handle of the request to cancel
+ */
+void
+GST_ats_suggest_address_cancel (struct GST_AtsSuggestionContext *asc);
+
+
+/**
  * We established a new connection with a peer (for example, because
  * core asked for it or because the other peer connected to us).
  * Calculate bandwidth assignments including the new peer.
  *
  * @param atc handle
+ * @param public_key public key of the peer
  * @param peer identity of the new peer
  * @param plugin_name name of the currently used transport plugin
  * @param session session in use (if available)
@@ -105,6 +160,7 @@
  */
 void
 GST_ats_peer_connect (struct GST_AtsHandle *atc,
+                     const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 
*public_key,
                      const struct GNUNET_PeerIdentity *peer,
                      const char *plugin_name,
                      struct Session *session,
@@ -149,6 +205,7 @@
  * for later use).  Update bandwidth assignments.
  *
  * @param atc handle
+ * @param public_key public key of the peer
  * @param peer identity of the new peer
  * @param plugin_name name of the transport plugin
  * @param session session handle (if available)
@@ -159,6 +216,7 @@
  */
 void
 GST_ats_address_update (struct GST_AtsHandle *atc,
+                       const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 
*public_key,
                        const struct GNUNET_PeerIdentity *peer,
                        const char *plugin_name,
                        struct Session *session,

Modified: gnunet/src/transport/gnunet-service-transport_clients.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.c     2011-08-12 
09:02:38 UTC (rev 16464)
+++ gnunet/src/transport/gnunet-service-transport_clients.c     2011-08-12 
10:00:39 UTC (rev 16465)
@@ -745,10 +745,9 @@
   peer_address_lookup = (const struct PeerAddressLookupMessage *) message;
   GNUNET_break (ntohl (peer_address_lookup->reserved) == 0);
   tc = GNUNET_SERVER_transmit_context_create (client);
-  (void) GST_validation_get_addresses (&peer_address_lookup->peer,
-                                      GNUNET_YES,
-                                      &send_address_to_client,
-                                      tc);
+  GST_validation_get_addresses (&peer_address_lookup->peer,
+                               &send_address_to_client,
+                               tc);
   GNUNET_SERVER_transmit_context_append_data (tc,
                                              NULL, 0,
                                              
GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY);

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c  2011-08-12 
09:02:38 UTC (rev 16464)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c  2011-08-12 
10:00:39 UTC (rev 16465)
@@ -126,10 +126,10 @@
   struct MessageQueue *messages_tail;
 
   /**
-   * Context for validation address iteration.
+   * Context for address suggestion.
    * NULL after we are connected.
    */
-  struct GST_ValidationIteratorContext *vic;
+  struct GST_AtsSuggestionContext *asc;
 
   /**
    * Performance data for the peer.
@@ -339,10 +339,10 @@
                                   mq);
       GNUNET_free (mq);
     }
-  if (NULL != n->vic)
+  if (NULL != n->asc)
     {
-      GST_validation_get_addresses_cancel (n->vic);
-      n->vic = NULL;
+      GST_ats_suggest_address_cancel (n->asc);
+      n->asc = NULL;
     }
   GNUNET_array_grow (n->ats,
                     n->ats_count,
@@ -400,35 +400,31 @@
  * @param cls the 'struct NeighbourMapEntry' of the target
  * @param public_key public key for the peer, never NULL
  * @param target identity of the target peer
- * @param valid_until is ZERO if we never validated the address,
- *                    otherwise a time up to when we consider it (or was) valid
- * @param validation_block  is FOREVER if the address is for an unsupported 
plugin (from PEERINFO)
- *                          is ZERO if the address is considered valid (no 
validation needed)
- *                          otherwise a time in the future if we're currently 
denying re-validation
  * @param plugin_name name of the plugin
  * @param plugin_address binary address
  * @param plugin_address_len length of address
+ * @param ats performance data for the address (as far as known)
+ * @param ats_count number of performance records in 'ats'
  */
 static void
 try_connect_using_address (void *cls,
                           const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 
*public_key,
                           const struct GNUNET_PeerIdentity *target,
-                          struct GNUNET_TIME_Absolute valid_until,
-                          struct GNUNET_TIME_Absolute validation_block,
                           const char *plugin_name,
                           const void *plugin_address,
-                          size_t plugin_address_len)
+                          size_t plugin_address_len,
+                          const struct GNUNET_TRANSPORT_ATS_Information *ats,
+                          uint32_t ats_count)
 {
   struct NeighbourMapEntry *n = cls;
 
+  n->asc = NULL;
   if (n->public_key_valid == GNUNET_NO)
     {
       n->public_key = *public_key;
       n->public_key_valid = GNUNET_YES;
     }
-  if (GNUNET_TIME_absolute_get_remaining (valid_until).rel_value == 0)
-    return; /* address is not valid right now */
-  /* FIXME: do ATS here! */
+  /* FIXME: do connect! */
 
 }
 
@@ -488,12 +484,12 @@
                                                        n,
                                                        
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
     }
-  if (n->vic != NULL)
+  if (n->asc != NULL)
     return; /* already trying */
-  n->vic = GST_validation_get_addresses (target,
-                                        GNUNET_NO,
-                                        &try_connect_using_address,
-                                        n); 
+  n->asc = GST_ats_suggest_address (GST_ats,
+                                   target,
+                                   &try_connect_using_address,
+                                   n); 
 }
 
 

Modified: gnunet/src/transport/gnunet-service-transport_validation.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_validation.c  2011-08-12 
09:02:38 UTC (rev 16464)
+++ gnunet/src/transport/gnunet-service-transport_validation.c  2011-08-12 
10:00:39 UTC (rev 16465)
@@ -27,6 +27,7 @@
 #include "gnunet-service-transport_validation.h"
 #include "gnunet-service-transport_plugins.h"
 #include "gnunet-service-transport_hello.h"
+#include "gnunet-service-transport_ats-new.h"
 #include "gnunet-service-transport.h"
 #include "gnunet_hello_lib.h"
 #include "gnunet_peerinfo_service.h"
@@ -249,28 +250,6 @@
 
 
 /**
- * Opaque handle to stop incremental validation address callbacks.
- */
-struct GST_ValidationIteratorContext
-{
-  /**
-   * Function to call on each address.
-   */
-  GST_ValidationAddressCallback cb;
-
-  /**
-   * Closure for 'cb'.
-   */
-  void *cb_cls;
-
-  /**
-   * Which peer are we monitoring?
-   */   
-  struct GNUNET_PeerIdentity target;
-};
-
-
-/**
  * Head of linked list of HELLOs awaiting validation.
  */
 static struct CheckHelloValidatedContext *chvc_head;
@@ -288,11 +267,6 @@
 static struct GNUNET_CONTAINER_MultiHashMap *validation_map;
 
 /**
- * Map of PeerIdentities to 'struct GST_ValidationIteratorContext's.
- */
-static struct GNUNET_CONTAINER_MultiHashMap *notify_map;
-
-/**
  * Context for peerinfo iteration.
  */
 static struct GNUNET_PEERINFO_NotifyContext *pnc;
@@ -409,34 +383,6 @@
 
 
 /**
- * Notify validation watcher that an entry is now valid
- *
- * @param cls 'struct ValidationEntry' that is now valid
- * @param key peer identity (unused)
- * @param value a 'GST_ValidationIteratorContext' to notify
- * @return GNUNET_YES (continue to iterate)
- */
-static int
-notify_valid (void *cls,
-             const GNUNET_HashCode *key,
-             void *value)
-{
-  struct ValidationEntry *ve = cls;
-  struct GST_ValidationIteratorContext *vic = value;
-
-  vic->cb (vic->cb_cls,
-          &ve->public_key,
-          &vic->target,
-          ve->valid_until,
-          ve->validation_block,
-          ve->transport_name,
-          ve->addr,
-          ve->addrlen);           
-  return GNUNET_OK;
-}
-
-
-/**
  * Iterator which adds the given address to the set of validated
  * addresses.
  *
@@ -472,10 +418,14 @@
   ve = find_validation_entry (&public_key, &pid, tname, addr, addrlen);
   ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until,
                                              expiration);
-  GNUNET_CONTAINER_multihashmap_get_multiple (notify_map,
-                                             &pid.hashPubKey,
-                                             &notify_valid,
-                                             ve);
+  GST_ats_address_update (GST_ats,
+                         &public_key,
+                         &pid,
+                         tname,
+                         NULL,
+                         addr,
+                         addrlen,
+                         NULL, 0);
   return GNUNET_OK;
 }
 
@@ -512,7 +462,6 @@
 GST_validation_start ()
 {
   validation_map = GNUNET_CONTAINER_multihashmap_create (VALIDATION_MAP_SIZE);
-  notify_map = GNUNET_CONTAINER_multihashmap_create (VALIDATION_MAP_SIZE);
   pnc = GNUNET_PEERINFO_notify (GST_cfg,
                                &process_peerinfo_hello,
                                NULL);
@@ -558,9 +507,6 @@
                                         NULL);
   GNUNET_CONTAINER_multihashmap_destroy (validation_map);
   validation_map = NULL;
-  GNUNET_assert (GNUNET_CONTAINER_multihashmap_size (notify_map) == 0);
-  GNUNET_CONTAINER_multihashmap_destroy (notify_map);
-  notify_map = NULL;
   while (NULL != (chvc = chvc_head))
     {
       GNUNET_CONTAINER_DLL_remove (chvc_head,
@@ -801,10 +747,9 @@
                            gettext_noop ("# PONGs multicast to all available 
addresses"),
                            1,
                            GNUNET_NO);
-  (void) GST_validation_get_addresses (sender,
-                                      GNUNET_YES,
-                                      &multicast_pong,
-                                      pong);
+  GST_validation_get_addresses (sender,
+                               &multicast_pong,
+                               pong);
   GNUNET_free (pong);
 }
 
@@ -1092,6 +1037,14 @@
   
   /* validity achieved, remember it! */
   ve->valid_until = GNUNET_TIME_relative_to_absolute 
(HELLO_ADDRESS_EXPIRATION);
+  GST_ats_address_update (GST_ats,
+                         &ve->public_key,
+                         &ve->pid,
+                         ve->transport_name,
+                         NULL,
+                         ve->addr,
+                         ve->addrlen,
+                         NULL, 0); /* FIXME: compute and add latency here... */
 
   /* build HELLO to store in PEERINFO */
   hello = GNUNET_HELLO_create (&ve->public_key,
@@ -1146,6 +1099,24 @@
 
 
 /**
+ * Closure for 'iterate_addresses'
+ */
+struct IteratorContext
+{
+  /**
+   * Function to call on each address.
+   */
+  GST_ValidationAddressCallback cb;
+
+  /**
+   * Closure for 'cb'.
+   */
+  void *cb_cls;
+
+};
+
+
+/**
  * Call the callback in the closure for each validation entry.
  *
  * @param cls the 'struct GST_ValidationIteratorContext'
@@ -1158,17 +1129,17 @@
                   const GNUNET_HashCode *key,
                   void *value)
 {
-  struct GST_ValidationIteratorContext *vic = cls;
+  struct IteratorContext *ic = cls;
   struct ValidationEntry *ve = value;
 
-  vic->cb (vic->cb_cls,
-          &ve->public_key,
-          &ve->pid,
-          ve->valid_until,
-          ve->validation_block,
-          ve->transport_name,
-          ve->addr,
-          ve->addrlen);
+  ic->cb (ic->cb_cls,
+         &ve->public_key,
+         &ve->pid,
+         ve->valid_until,
+         ve->validation_block,
+         ve->transport_name,
+         ve->addr,
+         ve->addrlen);
   return GNUNET_OK;
 }
 
@@ -1185,49 +1156,20 @@
  * @param cb_cls closure for 'cb'
  * @return context to cancel, NULL if 'snapshot_only' is GNUNET_YES
  */
-struct GST_ValidationIteratorContext *
+void
 GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
-                             int snapshot_only,
                              GST_ValidationAddressCallback cb,
                              void *cb_cls)
 {
-  struct GST_ValidationIteratorContext *vic;
+  struct IteratorContext  ic;
 
-  vic = GNUNET_malloc (sizeof (struct GST_ValidationIteratorContext));
-  vic->cb = cb;
-  vic->cb_cls = cb_cls;
-  vic->target = *target;
+  ic.cb = cb;
+  ic.cb_cls = cb_cls;
   GNUNET_CONTAINER_multihashmap_get_multiple (validation_map,
                                              &target->hashPubKey,
                                              &iterate_addresses,
-                                             vic);
-  if (GNUNET_YES == snapshot_only)
-    {
-      GNUNET_free (vic);
-      return NULL;
-    }
-  GNUNET_CONTAINER_multihashmap_put (notify_map,
-                                    &target->hashPubKey,
-                                    vic,
-                                    
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
-  return vic;
+                                             &ic);
 }
 
 
-/**
- * Cancel an active validation address iteration.
- *
- * @param ctx the context of the operation that is cancelled
- */
-void
-GST_validation_get_addresses_cancel (struct GST_ValidationIteratorContext *ctx)
-{
-  GNUNET_assert (GNUNET_OK ==
-                GNUNET_CONTAINER_multihashmap_remove (notify_map,
-                                                      &ctx->target.hashPubKey,
-                                                      ctx));
-  GNUNET_free (ctx);
-}
-
-
 /* end of file gnunet-service-transport_validation.c */

Modified: gnunet/src/transport/gnunet-service-transport_validation.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_validation.h  2011-08-12 
09:02:38 UTC (rev 16464)
+++ gnunet/src/transport/gnunet-service-transport_validation.h  2011-08-12 
10:00:39 UTC (rev 16465)
@@ -95,12 +95,6 @@
 
 
 /**
- * Opaque handle to stop incremental validation address callbacks.
- */
-struct GST_ValidationIteratorContext;
-
-
-/**
  * Function called for each address (or address status change) that
  * the validation module is aware of (for the given target).
  *
@@ -128,32 +122,18 @@
 
 /**
  * Call the given function for each address for the given target.
- * Can either give a snapshot (synchronous API) or be continuous.
  *
  * @param target peer information is requested for
- * @param snapshot_only GNUNET_YES to iterate over addresses once, GNUNET_NO to
- *                      continue to give information about addresses as it 
evolves
  * @param cb function to call; will not be called after this function returns
  *                             if snapshot_only is GNUNET_YES
  * @param cb_cls closure for 'cb'
  * @return context to cancel, NULL if 'snapshot_only' is GNUNET_YES
  */
-struct GST_ValidationIteratorContext *
+void
 GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
-                             int snapshot_only,
                              GST_ValidationAddressCallback cb,
                              void *cb_cls);
 
 
-/**
- * Cancel an active validation address iteration.
- *
- * @param ctx the context of the operation that is cancelled
- */
-void
-GST_validation_get_addresses_cancel (struct GST_ValidationIteratorContext 
*ctx);
-
-
-
 #endif
 /* end of file gnunet-service-transport_validation.h */




reply via email to

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