aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-12 11:09:57 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-12 11:09:57 +0000
commit3117f4738bd6c23ac8af5893ba26ac1c86736608 (patch)
tree8b9358aeaa04f06eb7a7e6894d0e6bdcd6731823
parent55e8339431dbd7e0d426662376f9a65ea518955b (diff)
downloadgnunet-3117f4738bd6c23ac8af5893ba26ac1c86736608.tar.gz
gnunet-3117f4738bd6c23ac8af5893ba26ac1c86736608.zip
add address timeout
-rw-r--r--src/ats/ats_api.c28
-rw-r--r--src/include/gnunet_ats_service.h2
-rw-r--r--src/transport/gnunet-service-transport_validation.c30
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,
179 return GNUNET_YES; 179 return GNUNET_YES;
180} 180}
181 181
182
183/**
184 * Closure for 'set_bw_connections'.
185 */
182struct SetBandwidthContext 186struct SetBandwidthContext
183{ 187{
188 /**
189 * ATS handle.
190 */
184 struct GNUNET_ATS_Handle *atc; 191 struct GNUNET_ATS_Handle *atc;
192
193 /**
194 * Bandwidth to assign.
195 */
185 struct GNUNET_BANDWIDTH_Value32NBO bw; 196 struct GNUNET_BANDWIDTH_Value32NBO bw;
186}; 197};
187 198
199
188/** 200/**
189 * Set bandwidth based on record. 201 * Set bandwidth based on record.
190 * 202 *
@@ -303,9 +315,9 @@ suggest_address (void *cls,
303 */ 315 */
304struct GNUNET_ATS_SuggestionContext * 316struct GNUNET_ATS_SuggestionContext *
305GNUNET_ATS_suggest_address (struct GNUNET_ATS_Handle *atc, 317GNUNET_ATS_suggest_address (struct GNUNET_ATS_Handle *atc,
306 const struct GNUNET_PeerIdentity *peer, 318 const struct GNUNET_PeerIdentity *peer,
307 GNUNET_ATS_AddressSuggestionCallback cb, 319 GNUNET_ATS_AddressSuggestionCallback cb,
308 void *cb_cls) 320 void *cb_cls)
309{ 321{
310 struct GNUNET_ATS_SuggestionContext *asc; 322 struct GNUNET_ATS_SuggestionContext *asc;
311 323
@@ -357,8 +369,8 @@ GNUNET_ATS_suggest_address_cancel (struct GNUNET_ATS_SuggestionContext *asc)
357 */ 369 */
358struct GNUNET_ATS_Handle * 370struct GNUNET_ATS_Handle *
359GNUNET_ATS_init (const struct GNUNET_CONFIGURATION_Handle *cfg, 371GNUNET_ATS_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
360 GNUNET_TRANSPORT_ATS_AllocationNotification alloc_cb, 372 GNUNET_TRANSPORT_ATS_AllocationNotification alloc_cb,
361 void *alloc_cb_cls) 373 void *alloc_cb_cls)
362{ 374{
363 struct GNUNET_ATS_Handle *atc; 375 struct GNUNET_ATS_Handle *atc;
364 376
@@ -690,8 +702,8 @@ destroy_session (void *cls,
690 */ 702 */
691void 703void
692GNUNET_ATS_session_destroyed (struct GNUNET_ATS_Handle *atc, 704GNUNET_ATS_session_destroyed (struct GNUNET_ATS_Handle *atc,
693 const struct GNUNET_PeerIdentity *peer, 705 const struct GNUNET_PeerIdentity *peer,
694 const struct Session *session) 706 const struct Session *session)
695{ 707{
696 struct SessionDestroyContext sdc; 708 struct SessionDestroyContext sdc;
697 709
@@ -741,6 +753,7 @@ notify_valid (void *cls,
741 * @param atc handle 753 * @param atc handle
742 * @param public_key public key of the peer 754 * @param public_key public key of the peer
743 * @param peer identity of the peer 755 * @param peer identity of the peer
756 * @param valid_until how long is the address valid?
744 * @param plugin_name name of the transport plugin 757 * @param plugin_name name of the transport plugin
745 * @param session session handle (if available) 758 * @param session session handle (if available)
746 * @param plugin_addr address (if available) 759 * @param plugin_addr address (if available)
@@ -752,6 +765,7 @@ void
752GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc, 765GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc,
753 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key, 766 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key,
754 const struct GNUNET_PeerIdentity *peer, 767 const struct GNUNET_PeerIdentity *peer,
768 struct GNUNET_TIME_Absolute valid_until,
755 const char *plugin_name, 769 const char *plugin_name,
756 struct Session *session, 770 struct Session *session,
757 const void *plugin_addr, 771 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,
207 * @param atc handle 207 * @param atc handle
208 * @param public_key public key of the peer 208 * @param public_key public key of the peer
209 * @param peer identity of the new peer 209 * @param peer identity of the new peer
210 * @param valid_until how long is the address valid?
210 * @param plugin_name name of the transport plugin 211 * @param plugin_name name of the transport plugin
211 * @param session session handle (if available) 212 * @param session session handle (if available)
212 * @param plugin_addr address (if available) 213 * @param plugin_addr address (if available)
@@ -218,6 +219,7 @@ void
218GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc, 219GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc,
219 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key, 220 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key,
220 const struct GNUNET_PeerIdentity *peer, 221 const struct GNUNET_PeerIdentity *peer,
222 struct GNUNET_TIME_Absolute valid_until,
221 const char *plugin_name, 223 const char *plugin_name,
222 struct Session *session, 224 struct Session *session,
223 const void *plugin_addr, 225 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,
419 ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, 419 ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until,
420 expiration); 420 expiration);
421 GNUNET_ATS_address_update (GST_ats, 421 GNUNET_ATS_address_update (GST_ats,
422 &public_key, 422 &public_key,
423 &pid, 423 &pid,
424 tname, 424 ve->valid_until,
425 NULL, 425 tname,
426 addr, 426 NULL,
427 addrlen, 427 addr,
428 NULL, 0); 428 addrlen,
429 NULL, 0);
429 return GNUNET_OK; 430 return GNUNET_OK;
430} 431}
431 432
@@ -1038,13 +1039,14 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1038 /* validity achieved, remember it! */ 1039 /* validity achieved, remember it! */
1039 ve->valid_until = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION); 1040 ve->valid_until = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION);
1040 GNUNET_ATS_address_update (GST_ats, 1041 GNUNET_ATS_address_update (GST_ats,
1041 &ve->public_key, 1042 &ve->public_key,
1042 &ve->pid, 1043 &ve->pid,
1043 ve->transport_name, 1044 ve->valid_until,
1044 NULL, 1045 ve->transport_name,
1045 ve->addr, 1046 NULL,
1046 ve->addrlen, 1047 ve->addr,
1047 NULL, 0); /* FIXME: compute and add latency here... */ 1048 ve->addrlen,
1049 NULL, 0); /* FIXME: compute and add latency here... */
1048 1050
1049 /* build HELLO to store in PEERINFO */ 1051 /* build HELLO to store in PEERINFO */
1050 hello = GNUNET_HELLO_create (&ve->public_key, 1052 hello = GNUNET_HELLO_create (&ve->public_key,