From 3117f4738bd6c23ac8af5893ba26ac1c86736608 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 12 Aug 2011 11:09:57 +0000 Subject: [PATCH] add address timeout --- src/ats/ats_api.c | 28 ++++++++++++----- src/include/gnunet_ats_service.h | 2 ++ .../gnunet-service-transport_validation.c | 30 ++++++++++--------- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/src/ats/ats_api.c b/src/ats/ats_api.c index 8609ac5a5..36b215e5b 100644 --- a/src/ats/ats_api.c +++ b/src/ats/ats_api.c @@ -179,12 +179,24 @@ count_connections (void *cls, return GNUNET_YES; } + +/** + * Closure for 'set_bw_connections'. + */ struct SetBandwidthContext { + /** + * ATS handle. + */ struct GNUNET_ATS_Handle *atc; + + /** + * Bandwidth to assign. + */ struct GNUNET_BANDWIDTH_Value32NBO bw; }; + /** * Set bandwidth based on record. * @@ -303,9 +315,9 @@ suggest_address (void *cls, */ struct GNUNET_ATS_SuggestionContext * GNUNET_ATS_suggest_address (struct GNUNET_ATS_Handle *atc, - const struct GNUNET_PeerIdentity *peer, - GNUNET_ATS_AddressSuggestionCallback cb, - void *cb_cls) + const struct GNUNET_PeerIdentity *peer, + GNUNET_ATS_AddressSuggestionCallback cb, + void *cb_cls) { struct GNUNET_ATS_SuggestionContext *asc; @@ -357,8 +369,8 @@ GNUNET_ATS_suggest_address_cancel (struct GNUNET_ATS_SuggestionContext *asc) */ struct GNUNET_ATS_Handle * GNUNET_ATS_init (const struct GNUNET_CONFIGURATION_Handle *cfg, - GNUNET_TRANSPORT_ATS_AllocationNotification alloc_cb, - void *alloc_cb_cls) + GNUNET_TRANSPORT_ATS_AllocationNotification alloc_cb, + void *alloc_cb_cls) { struct GNUNET_ATS_Handle *atc; @@ -690,8 +702,8 @@ destroy_session (void *cls, */ void GNUNET_ATS_session_destroyed (struct GNUNET_ATS_Handle *atc, - const struct GNUNET_PeerIdentity *peer, - const struct Session *session) + const struct GNUNET_PeerIdentity *peer, + const struct Session *session) { struct SessionDestroyContext sdc; @@ -741,6 +753,7 @@ notify_valid (void *cls, * @param atc handle * @param public_key public key of the peer * @param peer identity of the peer + * @param valid_until how long is the address valid? * @param plugin_name name of the transport plugin * @param session session handle (if available) * @param plugin_addr address (if available) @@ -752,6 +765,7 @@ void GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key, const struct GNUNET_PeerIdentity *peer, + struct GNUNET_TIME_Absolute valid_until, const char *plugin_name, struct Session *session, const void *plugin_addr, diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h index da54b24be..64ed9a9a3 100644 --- a/src/include/gnunet_ats_service.h +++ b/src/include/gnunet_ats_service.h @@ -207,6 +207,7 @@ GNUNET_ATS_session_destroyed (struct GNUNET_ATS_Handle *atc, * @param atc handle * @param public_key public key of the peer * @param peer identity of the new peer + * @param valid_until how long is the address valid? * @param plugin_name name of the transport plugin * @param session session handle (if available) * @param plugin_addr address (if available) @@ -218,6 +219,7 @@ void GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key, const struct GNUNET_PeerIdentity *peer, + struct GNUNET_TIME_Absolute valid_until, const char *plugin_name, struct Session *session, const void *plugin_addr, diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 2b03e3805..f5e2bf820 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c @@ -419,13 +419,14 @@ add_valid_address (void *cls, ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, expiration); GNUNET_ATS_address_update (GST_ats, - &public_key, - &pid, - tname, - NULL, - addr, - addrlen, - NULL, 0); + &public_key, + &pid, + ve->valid_until, + tname, + NULL, + addr, + addrlen, + NULL, 0); return GNUNET_OK; } @@ -1038,13 +1039,14 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, /* validity achieved, remember it! */ ve->valid_until = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION); GNUNET_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... */ + &ve->public_key, + &ve->pid, + ve->valid_until, + 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, -- 2.25.1