diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-10-18 12:49:23 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-10-18 12:49:23 +0000 |
commit | 2128c61720c9019302a1add71796c69d2ee36fc4 (patch) | |
tree | b665fa4994da1132b6e5d85312bfacab9460d8a9 | |
parent | 9cd0d5068f3341fe8451a61872894f28a5ac9047 (diff) |
add 'strength' argument to address suggestion request for ATS
-rw-r--r-- | src/ats/ats.h | 8 | ||||
-rw-r--r-- | src/ats/ats_api_connectivity.c | 17 | ||||
-rw-r--r-- | src/ats/ats_api_scheduling.c | 1 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_connectivity.c | 13 | ||||
-rw-r--r-- | src/include/gnunet_ats_service.h | 5 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 3 |
6 files changed, 29 insertions, 18 deletions
diff --git a/src/ats/ats.h b/src/ats/ats.h index 3a7f28a642..5c1e806b6d 100644 --- a/src/ats/ats.h +++ b/src/ats/ats.h @@ -82,7 +82,7 @@ struct ClientStartMessage /** - * Scheduling client to ATS service: we would like to have + * Connectivity client to ATS service: we would like to have * address suggestions for this peer. */ struct RequestAddressMessage @@ -95,9 +95,9 @@ struct RequestAddressMessage struct GNUNET_MessageHeader header; /** - * Always zero. + * How "strong" is our need for an address for this peer? */ - uint32_t reserved GNUNET_PACKED; + uint32_t strength GNUNET_PACKED; /** * Peer to get address suggestions for. @@ -107,7 +107,7 @@ struct RequestAddressMessage /** - * ATS client to ATS service: here is another address you can use. + * Scheduling client to ATS service: here is another address you can use. */ struct AddressAddMessage { diff --git a/src/ats/ats_api_connectivity.c b/src/ats/ats_api_connectivity.c index 4099cadbd8..1012e9ceee 100644 --- a/src/ats/ats_api_connectivity.c +++ b/src/ats/ats_api_connectivity.c @@ -45,6 +45,11 @@ struct GNUNET_ATS_ConnectivitySuggestHandle * Connecitivity handle this suggestion handle belongs to. */ struct GNUNET_ATS_ConnectivityHandle *ch; + + /** + * How urgent is the request. + */ + uint32_t strength; }; @@ -174,13 +179,14 @@ transmit_suggestion (void *cls, void *value) { struct GNUNET_ATS_ConnectivityHandle *ch = cls; + struct GNUNET_ATS_ConnectivitySuggestHandle *sh = value; struct GNUNET_MQ_Envelope *ev; struct RequestAddressMessage *m; if (NULL == ch->mq) return GNUNET_SYSERR; ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS); - m->reserved = htonl (0); + m->strength = htonl (sh->strength); m->peer = *peer; GNUNET_MQ_send (ch->mq, ev); return GNUNET_OK; @@ -244,7 +250,7 @@ GNUNET_ATS_connectivity_init (const struct GNUNET_CONFIGURATION_Handle *cfg) /** - * Function called to free all `struct GNUNET_ATS_SuggestHandles` + * Function called to free all `struct GNUNET_ATS_ConnectivitySuggestHandle`s * in the map. * * @param cls NULL @@ -303,11 +309,13 @@ GNUNET_ATS_connectivity_done (struct GNUNET_ATS_ConnectivityHandle *ch) * * @param ch handle * @param peer identity of the peer we need an address for + * @param strength how urgent is the need for such a suggestion * @return suggest handle, NULL if a request is already pending */ struct GNUNET_ATS_ConnectivitySuggestHandle * GNUNET_ATS_connectivity_suggest (struct GNUNET_ATS_ConnectivityHandle *ch, - const struct GNUNET_PeerIdentity *peer) + const struct GNUNET_PeerIdentity *peer, + uint32_t strength) { struct GNUNET_ATS_ConnectivitySuggestHandle *s; @@ -317,6 +325,7 @@ GNUNET_ATS_connectivity_suggest (struct GNUNET_ATS_ConnectivityHandle *ch, s = GNUNET_new (struct GNUNET_ATS_ConnectivitySuggestHandle); s->ch = ch; s->id = *peer; + s->strength = strength; if (GNUNET_OK != GNUNET_CONTAINER_multipeermap_put (ch->sug_requests, &s->id, @@ -360,7 +369,7 @@ GNUNET_ATS_connectivity_suggest_cancel (struct GNUNET_ATS_ConnectivitySuggestHan return; } ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL); - m->reserved = htonl (0); + m->strength = htonl (0); m->peer = sh->id; GNUNET_MQ_send (ch->mq, ev); GNUNET_free (sh); diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index d7a5a83a1b..ab8a8711d7 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c @@ -247,7 +247,6 @@ find_session (struct GNUNET_ATS_SchedulingHandle *sh, sizeof (struct GNUNET_PeerIdentity))) { GNUNET_break (0); - force_reconnect (sh); return NULL; } return ar; diff --git a/src/ats/gnunet-service-ats_connectivity.c b/src/ats/gnunet-service-ats_connectivity.c index 8c103a33c4..7bde6e354c 100644 --- a/src/ats/gnunet-service-ats_connectivity.c +++ b/src/ats/gnunet-service-ats_connectivity.c @@ -73,7 +73,7 @@ GAS_connectivity_has_peer (void *cls, /** - * Handle 'request address' messages from clients. + * Handle #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS messages from clients. * * @param cls unused, NULL * @param client client that sent the request @@ -90,8 +90,8 @@ GAS_handle_request_address (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", - "REQUEST_ADDRESS"); - GNUNET_break (0 == ntohl (msg->reserved)); + "GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS"); + /* FIXME: should not ignore "msg->strength" */ cr = GNUNET_new (struct ConnectionRequest); cr->client = client; (void) GNUNET_CONTAINER_multipeermap_put (connection_requests, @@ -137,7 +137,8 @@ free_matching_requests (void *cls, /** - * Handle 'request address cancel' messages from clients. + * Handle #GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL messages + * from clients. * * @param cls unused, NULL * @param client client that sent the request @@ -152,9 +153,9 @@ GAS_handle_request_address_cancel (void *cls, (const struct RequestAddressMessage *) message; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received REQUEST_ADDRESS_CANCEL message for peer %s\n", + "Received GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL message for peer %s\n", GNUNET_i2s (&msg->peer)); - GNUNET_break (0 == ntohl (msg->reserved)); + GNUNET_break (0 == ntohl (msg->strength)); GNUNET_CONTAINER_multipeermap_get_multiple (connection_requests, &msg->peer, &free_matching_requests, diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h index 4264f22a45..32e98abd61 100644 --- a/src/include/gnunet_ats_service.h +++ b/src/include/gnunet_ats_service.h @@ -302,12 +302,13 @@ GNUNET_ATS_connectivity_done (struct GNUNET_ATS_ConnectivityHandle *ch); * * @param ch handle * @param peer identity of the peer we need an address for - * TODO: add argument to allow client to express 'strength's of request + * @param strength how urgent is the need for such a suggestion * @return suggestion handle, NULL if request is already pending */ struct GNUNET_ATS_ConnectivitySuggestHandle * GNUNET_ATS_connectivity_suggest (struct GNUNET_ATS_ConnectivityHandle *ch, - const struct GNUNET_PeerIdentity *peer); + const struct GNUNET_PeerIdentity *peer, + uint32_t strength); /** diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index d41fa65826..07af225c12 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -2213,7 +2213,8 @@ setup_neighbour (const struct GNUNET_PeerIdentity *peer) n, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); n->suggest_handle = GNUNET_ATS_connectivity_suggest (GST_ats_connect, - peer); + peer, + 0); return n; } |