aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_neighbours.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-12 10:00:39 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-12 10:00:39 +0000
commit180f2e637029d045e3c72dc3e13fddb1f9f30141 (patch)
tree91356b1fe1c93c8ff69f6136d454d5d12e5978a2 /src/transport/gnunet-service-transport_neighbours.c
parentf76896d09afabb721219d3217037cc7a7f26d570 (diff)
downloadgnunet-180f2e637029d045e3c72dc3e13fddb1f9f30141.tar.gz
gnunet-180f2e637029d045e3c72dc3e13fddb1f9f30141.zip
moving API around to make ATS implementable and separable
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index a7c1136f2..cff2bb595 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -126,10 +126,10 @@ struct NeighbourMapEntry
126 struct MessageQueue *messages_tail; 126 struct MessageQueue *messages_tail;
127 127
128 /** 128 /**
129 * Context for validation address iteration. 129 * Context for address suggestion.
130 * NULL after we are connected. 130 * NULL after we are connected.
131 */ 131 */
132 struct GST_ValidationIteratorContext *vic; 132 struct GST_AtsSuggestionContext *asc;
133 133
134 /** 134 /**
135 * Performance data for the peer. 135 * Performance data for the peer.
@@ -339,10 +339,10 @@ disconnect_neighbour (struct NeighbourMapEntry *n)
339 mq); 339 mq);
340 GNUNET_free (mq); 340 GNUNET_free (mq);
341 } 341 }
342 if (NULL != n->vic) 342 if (NULL != n->asc)
343 { 343 {
344 GST_validation_get_addresses_cancel (n->vic); 344 GST_ats_suggest_address_cancel (n->asc);
345 n->vic = NULL; 345 n->asc = NULL;
346 } 346 }
347 GNUNET_array_grow (n->ats, 347 GNUNET_array_grow (n->ats,
348 n->ats_count, 348 n->ats_count,
@@ -400,35 +400,31 @@ GST_neighbours_stop ()
400 * @param cls the 'struct NeighbourMapEntry' of the target 400 * @param cls the 'struct NeighbourMapEntry' of the target
401 * @param public_key public key for the peer, never NULL 401 * @param public_key public key for the peer, never NULL
402 * @param target identity of the target peer 402 * @param target identity of the target peer
403 * @param valid_until is ZERO if we never validated the address,
404 * otherwise a time up to when we consider it (or was) valid
405 * @param validation_block is FOREVER if the address is for an unsupported plugin (from PEERINFO)
406 * is ZERO if the address is considered valid (no validation needed)
407 * otherwise a time in the future if we're currently denying re-validation
408 * @param plugin_name name of the plugin 403 * @param plugin_name name of the plugin
409 * @param plugin_address binary address 404 * @param plugin_address binary address
410 * @param plugin_address_len length of address 405 * @param plugin_address_len length of address
406 * @param ats performance data for the address (as far as known)
407 * @param ats_count number of performance records in 'ats'
411 */ 408 */
412static void 409static void
413try_connect_using_address (void *cls, 410try_connect_using_address (void *cls,
414 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key, 411 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key,
415 const struct GNUNET_PeerIdentity *target, 412 const struct GNUNET_PeerIdentity *target,
416 struct GNUNET_TIME_Absolute valid_until,
417 struct GNUNET_TIME_Absolute validation_block,
418 const char *plugin_name, 413 const char *plugin_name,
419 const void *plugin_address, 414 const void *plugin_address,
420 size_t plugin_address_len) 415 size_t plugin_address_len,
416 const struct GNUNET_TRANSPORT_ATS_Information *ats,
417 uint32_t ats_count)
421{ 418{
422 struct NeighbourMapEntry *n = cls; 419 struct NeighbourMapEntry *n = cls;
423 420
421 n->asc = NULL;
424 if (n->public_key_valid == GNUNET_NO) 422 if (n->public_key_valid == GNUNET_NO)
425 { 423 {
426 n->public_key = *public_key; 424 n->public_key = *public_key;
427 n->public_key_valid = GNUNET_YES; 425 n->public_key_valid = GNUNET_YES;
428 } 426 }
429 if (GNUNET_TIME_absolute_get_remaining (valid_until).rel_value == 0) 427 /* FIXME: do connect! */
430 return; /* address is not valid right now */
431 /* FIXME: do ATS here! */
432 428
433} 429}
434 430
@@ -488,12 +484,12 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target)
488 n, 484 n,
489 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 485 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
490 } 486 }
491 if (n->vic != NULL) 487 if (n->asc != NULL)
492 return; /* already trying */ 488 return; /* already trying */
493 n->vic = GST_validation_get_addresses (target, 489 n->asc = GST_ats_suggest_address (GST_ats,
494 GNUNET_NO, 490 target,
495 &try_connect_using_address, 491 &try_connect_using_address,
496 n); 492 n);
497} 493}
498 494
499 495