From 9f0dcc2fb248ea2507832ab999739359ee1dbf60 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Thu, 9 Jan 2014 14:09:29 +0000 Subject: [PATCH] extending ATS api suggest callback with peer id adding suggest continuation --- src/ats/ats_api_scheduling.c | 17 +++++++++++++---- ...est_ats_api_performance_list_all_addresses.c | 4 +++- ..._api_performance_list_all_addresses_active.c | 4 +++- ...st_ats_api_performance_list_peer_addresses.c | 4 +++- src/ats/test_ats_api_performance_monitor.c | 5 ++++- ...s_api_performance_monitor_initial_callback.c | 5 ++++- src/ats/test_ats_api_scheduling_add_address.c | 4 +++- ...t_ats_api_scheduling_add_address_duplicate.c | 5 ++++- ...est_ats_api_scheduling_add_address_inbound.c | 4 +++- src/ats/test_ats_api_scheduling_add_session.c | 4 +++- .../test_ats_api_scheduling_destroy_address.c | 4 +++- ...t_ats_api_scheduling_destroy_address_twice.c | 4 +++- .../test_ats_api_scheduling_destroy_session.c | 4 +++- src/ats/test_ats_api_scheduling_init.c | 4 +++- src/ats/test_ats_simplistic_pref_aging.c | 4 +++- src/ats/test_ats_solver_add_address.c | 4 +++- .../test_ats_solver_add_address_and_request.c | 6 ++++-- ...ts_solver_alternative_after_delete_address.c | 6 ++++-- src/ats/test_ats_solver_convergence.c | 4 +++- src/ats/test_ats_solver_preferences.c | 14 +++++++++----- .../test_ats_solver_request_and_add_address.c | 6 ++++-- ...test_ats_solver_request_and_delete_address.c | 6 ++++-- src/include/gnunet_ats_service.h | 13 ++++++++++++- src/transport/gnunet-service-transport.c | 2 ++ .../gnunet-service-transport_neighbours.c | 17 ++++++++++++++--- 25 files changed, 117 insertions(+), 37 deletions(-) diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index 7750ad1cf..d23de8940 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c @@ -656,7 +656,9 @@ process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg) return; } - sh->suggest_cb (sh->suggest_cb_cls, &address, s, m->bandwidth_out, + sh->suggest_cb (sh->suggest_cb_cls, + (const struct GNUNET_PeerIdentity *) &m->peer, + &address, s, m->bandwidth_out, m->bandwidth_in, atsi, ats_count); GNUNET_CLIENT_receive (sh->client, &process_ats_message, sh, @@ -1055,16 +1057,23 @@ GNUNET_ATS_reset_backoff (struct GNUNET_ATS_SchedulingHandle *sh, } /** - * We would like to establish a new connection with a peer. ATS - * should suggest a good address to begin with. + * We would like to receive address suggestions for a peer. ATS will + * respond with a call to the continuation immediately containing an address or + * no address if none is available. ATS can suggest more addresses until we call + * #GNUNET_ATS_suggest_address_cancel. + * * * @param sh handle * @param peer identity of the peer we need an address for + * @param cont the continuation to call with the address + * @param cont_cls the cls for the continuation * @return suggest handle */ struct GNUNET_ATS_SuggestHandle * GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *sh, - const struct GNUNET_PeerIdentity *peer) + const struct GNUNET_PeerIdentity *peer, + GNUNET_ATS_AddressSuggestionCallback cont, + void *cont_cls) { struct PendingMessage *p; struct RequestAddressMessage *m; diff --git a/src/ats/test_ats_api_performance_list_all_addresses.c b/src/ats/test_ats_api_performance_list_all_addresses.c index c02177cac..4512739e1 100644 --- a/src/ats/test_ats_api_performance_list_all_addresses.c +++ b/src/ats/test_ats_api_performance_list_all_addresses.c @@ -146,7 +146,9 @@ stat_cb(void *cls, const char *subsystem, } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, diff --git a/src/ats/test_ats_api_performance_list_all_addresses_active.c b/src/ats/test_ats_api_performance_list_all_addresses_active.c index 21cedb897..5cc4d4c65 100644 --- a/src/ats/test_ats_api_performance_list_all_addresses_active.c +++ b/src/ats/test_ats_api_performance_list_all_addresses_active.c @@ -154,7 +154,9 @@ stat_cb(void *cls, const char *subsystem, } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, diff --git a/src/ats/test_ats_api_performance_list_peer_addresses.c b/src/ats/test_ats_api_performance_list_peer_addresses.c index 70f2f711d..1f64a6ae9 100644 --- a/src/ats/test_ats_api_performance_list_peer_addresses.c +++ b/src/ats/test_ats_api_performance_list_peer_addresses.c @@ -155,7 +155,9 @@ stat_cb(void *cls, const char *subsystem, } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, diff --git a/src/ats/test_ats_api_performance_monitor.c b/src/ats/test_ats_api_performance_monitor.c index 887a139e8..6ccac45d1 100644 --- a/src/ats/test_ats_api_performance_monitor.c +++ b/src/ats/test_ats_api_performance_monitor.c @@ -144,12 +144,15 @@ stat_cb(void *cls, const char *subsystem, } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, const struct GNUNET_ATS_Information *atsi, uint32_t ats_count) + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not expect suggestion callback!\n"); GNUNET_SCHEDULER_add_now (&end_badly, NULL); diff --git a/src/ats/test_ats_api_performance_monitor_initial_callback.c b/src/ats/test_ats_api_performance_monitor_initial_callback.c index 89fc06792..6d305d3a5 100644 --- a/src/ats/test_ats_api_performance_monitor_initial_callback.c +++ b/src/ats/test_ats_api_performance_monitor_initial_callback.c @@ -152,12 +152,15 @@ stat_cb(void *cls, const char *subsystem, } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, const struct GNUNET_ATS_Information *atsi, uint32_t ats_count) + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not expect suggestion callback!\n"); GNUNET_SCHEDULER_add_now (&end_badly, NULL); diff --git a/src/ats/test_ats_api_scheduling_add_address.c b/src/ats/test_ats_api_scheduling_add_address.c index c12802293..332e46d19 100644 --- a/src/ats/test_ats_api_scheduling_add_address.c +++ b/src/ats/test_ats_api_scheduling_add_address.c @@ -136,7 +136,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, diff --git a/src/ats/test_ats_api_scheduling_add_address_duplicate.c b/src/ats/test_ats_api_scheduling_add_address_duplicate.c index 0d2b8310d..f2c2b4fd6 100644 --- a/src/ats/test_ats_api_scheduling_add_address_duplicate.c +++ b/src/ats/test_ats_api_scheduling_add_address_duplicate.c @@ -147,12 +147,15 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, const struct GNUNET_ATS_Information *atsi, uint32_t ats_count) + { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not expect suggestion callback!\n"); GNUNET_SCHEDULER_add_now (&end_badly, NULL); diff --git a/src/ats/test_ats_api_scheduling_add_address_inbound.c b/src/ats/test_ats_api_scheduling_add_address_inbound.c index b5e3eb8b6..fb4ddd2da 100644 --- a/src/ats/test_ats_api_scheduling_add_address_inbound.c +++ b/src/ats/test_ats_api_scheduling_add_address_inbound.c @@ -142,7 +142,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, diff --git a/src/ats/test_ats_api_scheduling_add_session.c b/src/ats/test_ats_api_scheduling_add_session.c index c415b57e2..9d7fd99d1 100644 --- a/src/ats/test_ats_api_scheduling_add_session.c +++ b/src/ats/test_ats_api_scheduling_add_session.c @@ -149,7 +149,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, diff --git a/src/ats/test_ats_api_scheduling_destroy_address.c b/src/ats/test_ats_api_scheduling_destroy_address.c index d46872f6c..bc1b7bd83 100644 --- a/src/ats/test_ats_api_scheduling_destroy_address.c +++ b/src/ats/test_ats_api_scheduling_destroy_address.c @@ -147,7 +147,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, diff --git a/src/ats/test_ats_api_scheduling_destroy_address_twice.c b/src/ats/test_ats_api_scheduling_destroy_address_twice.c index fd9dde179..9b34effd1 100644 --- a/src/ats/test_ats_api_scheduling_destroy_address_twice.c +++ b/src/ats/test_ats_api_scheduling_destroy_address_twice.c @@ -149,7 +149,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, diff --git a/src/ats/test_ats_api_scheduling_destroy_session.c b/src/ats/test_ats_api_scheduling_destroy_session.c index 69d9b88a7..ae236ea32 100644 --- a/src/ats/test_ats_api_scheduling_destroy_session.c +++ b/src/ats/test_ats_api_scheduling_destroy_session.c @@ -153,7 +153,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, diff --git a/src/ats/test_ats_api_scheduling_init.c b/src/ats/test_ats_api_scheduling_init.c index 3a75a7802..a7914d5c6 100644 --- a/src/ats/test_ats_api_scheduling_init.c +++ b/src/ats/test_ats_api_scheduling_init.c @@ -116,7 +116,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, diff --git a/src/ats/test_ats_simplistic_pref_aging.c b/src/ats/test_ats_simplistic_pref_aging.c index f354ce1cc..c8485856c 100644 --- a/src/ats/test_ats_simplistic_pref_aging.c +++ b/src/ats/test_ats_simplistic_pref_aging.c @@ -144,7 +144,9 @@ end () static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, diff --git a/src/ats/test_ats_solver_add_address.c b/src/ats/test_ats_solver_add_address.c index 571a38dc6..4cc37e812 100644 --- a/src/ats/test_ats_solver_add_address.c +++ b/src/ats/test_ats_solver_add_address.c @@ -129,7 +129,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, diff --git a/src/ats/test_ats_solver_add_address_and_request.c b/src/ats/test_ats_solver_add_address_and_request.c index e761385cf..55a7469e7 100644 --- a/src/ats/test_ats_solver_add_address_and_request.c +++ b/src/ats/test_ats_solver_add_address_and_request.c @@ -128,7 +128,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, @@ -157,7 +159,7 @@ stat_cb(void *cls, const char *subsystem, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "ATS statistics: `%s' `%s' %llu\n", subsystem,name, value); - GNUNET_ATS_suggest_address (sched_ats, &p.id); + GNUNET_ATS_suggest_address (sched_ats, &p.id, NULL, NULL); return GNUNET_OK; } diff --git a/src/ats/test_ats_solver_alternative_after_delete_address.c b/src/ats/test_ats_solver_alternative_after_delete_address.c index 02a8b79c8..3bd038799 100644 --- a/src/ats/test_ats_solver_alternative_after_delete_address.c +++ b/src/ats/test_ats_solver_alternative_after_delete_address.c @@ -167,7 +167,9 @@ end_badly_now () } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, @@ -288,7 +290,7 @@ stat_cb(void *cls, const char *subsystem, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "All addresses added, requesting....\n"); /* We have 2 addresses, so we can request */ addresses_added = GNUNET_YES; - GNUNET_ATS_suggest_address (sched_ats, &p.id); + GNUNET_ATS_suggest_address (sched_ats, &p.id, NULL, NULL); } return GNUNET_OK; } diff --git a/src/ats/test_ats_solver_convergence.c b/src/ats/test_ats_solver_convergence.c index ff476a8c8..40733bc50 100755 --- a/src/ats/test_ats_solver_convergence.c +++ b/src/ats/test_ats_solver_convergence.c @@ -152,7 +152,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, diff --git a/src/ats/test_ats_solver_preferences.c b/src/ats/test_ats_solver_preferences.c index 0c7076ded..117af470b 100644 --- a/src/ats/test_ats_solver_preferences.c +++ b/src/ats/test_ats_solver_preferences.c @@ -150,10 +150,14 @@ perf_info_cb (void *cls, } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, - struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, - const struct GNUNET_ATS_Information *atsi, uint32_t ats_count) +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, + struct Session *session, + struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, + struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, + const struct GNUNET_ATS_Information *atsi, + uint32_t ats_count) { int c; double pref_val; @@ -249,7 +253,7 @@ run (void *cls, const struct GNUNET_CONFIGURATION_Handle *mycfg, /* Adding address */ GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session, test_ats_info, test_ats_count); - GNUNET_ATS_suggest_address(sched_ats, &test_hello_address.peer); + GNUNET_ATS_suggest_address(sched_ats, &test_hello_address.peer, NULL, NULL); } int diff --git a/src/ats/test_ats_solver_request_and_add_address.c b/src/ats/test_ats_solver_request_and_add_address.c index 757423200..a8389ea89 100644 --- a/src/ats/test_ats_solver_request_and_add_address.c +++ b/src/ats/test_ats_solver_request_and_add_address.c @@ -128,7 +128,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, @@ -199,7 +201,7 @@ run (void *cls, const struct GNUNET_CONFIGURATION_Handle *mycfg, test_hello_address.address_length = test_addr.addr_len; /* Request */ - GNUNET_ATS_suggest_address (sched_ats, &p.id); + GNUNET_ATS_suggest_address (sched_ats, &p.id, NULL, NULL); /* Adding address */ diff --git a/src/ats/test_ats_solver_request_and_delete_address.c b/src/ats/test_ats_solver_request_and_delete_address.c index 48ee8014c..05a045e3b 100644 --- a/src/ats/test_ats_solver_request_and_delete_address.c +++ b/src/ats/test_ats_solver_request_and_delete_address.c @@ -131,7 +131,9 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, +address_suggest_cb (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, @@ -184,7 +186,7 @@ stat_cb(void *cls, const char *subsystem, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "ATS statistics: `%s' `%s' %llu\n", subsystem,name, value); if (GNUNET_NO == address_deleted) - GNUNET_ATS_suggest_address (sched_ats, &p.id); + GNUNET_ATS_suggest_address (sched_ats, &p.id, NULL, NULL); return GNUNET_OK; } diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h index 329d81161..932446400 100644 --- a/src/include/gnunet_ats_service.h +++ b/src/include/gnunet_ats_service.h @@ -543,6 +543,11 @@ struct Session; * Signature of a function called by ATS with the current bandwidth * and address preferences as determined by ATS. * + * If an address is available immediately the address will be included. If no + * address can be suggested, address, session, bandwidth and ATS information will + * be NULL/0. ATS will suggest an address as soon as it can provide such an + * address + * * @param cls closure * @param address suggested address (including peer identity of the peer) * @param session session to use @@ -553,11 +558,13 @@ struct Session; */ typedef void (*GNUNET_ATS_AddressSuggestionCallback) (void *cls, + const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, const struct GNUNET_ATS_Information *ats, uint32_t ats_count); + /** * Initialize the ATS subsystem. * @@ -596,11 +603,15 @@ GNUNET_ATS_reset_backoff (struct GNUNET_ATS_SchedulingHandle *sh, * * @param sh handle * @param peer identity of the peer we need an address for + * @param cont the continuation to indicate success to call with the address + * @param cont_cls the cls for the continuation * @return suggestion handle */ struct GNUNET_ATS_SuggestHandle * GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *sh, - const struct GNUNET_PeerIdentity *peer); + const struct GNUNET_PeerIdentity *peer, + GNUNET_ATS_AddressSuggestionCallback cont, + void *cont_cls); /** diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 811ef5857..a5ce3fa4a 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -754,6 +754,7 @@ plugin_env_session_start (void *cls, */ static void ats_request_address_change (void *cls, + const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, @@ -773,6 +774,7 @@ ats_request_address_change (void *cls, GST_neighbours_force_disconnect (&address->peer); return; } + GST_neighbours_switch_to_address (&address->peer, address, session, ats, ats_count, bandwidth_in, bandwidth_out); diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 54a35caa6..f5d44fa1d 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -1742,6 +1742,18 @@ address_matches (const struct NeighbourAddress *a1, } +static void +address_suggest_cont (void *cls, + const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_HELLO_Address *address, struct Session *session, + struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, + struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, + const struct GNUNET_ATS_Information *ats, uint32_t ats_count) +{ + +} + + /** * Try to create a connection to the given target (eventually). * @@ -1814,7 +1826,7 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target) set_state_and_timeout (n, GNUNET_TRANSPORT_INIT_ATS, GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT)); GNUNET_ATS_reset_backoff (GST_ats, target); - n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, target); + n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, target, &address_suggest_cont, n); } @@ -1923,7 +1935,7 @@ handle_test_blacklist_cont (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggesting address for peer %s to ATS\n", GNUNET_i2s (peer)); - n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, peer); + n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, peer, &address_suggest_cont, n); break; case GNUNET_TRANSPORT_CONNECT_RECV_ATS: /* waiting on ATS suggestion, don't care about blacklist */ @@ -2214,7 +2226,6 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, n = setup_neighbour (peer); set_state (n, GNUNET_TRANSPORT_CONNECT_RECV_ATS); GNUNET_ATS_reset_backoff (GST_ats, peer); - n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, peer); break; case GNUNET_TRANSPORT_DISCONNECT_FINISHED: /* should not be possible */ -- 2.25.1