/**
- * 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
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.
/**
- * 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
{
* Connecitivity handle this suggestion handle belongs to.
*/
struct GNUNET_ATS_ConnectivityHandle *ch;
+
+ /**
+ * How urgent is the request.
+ */
+ uint32_t strength;
};
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;
/**
- * 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
*
* @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;
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,
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);
sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_break (0);
- force_reconnect (sh);
return NULL;
}
return ar;
/**
- * 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
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,
/**
- * 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
(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,
*
* @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);
/**
n,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
n->suggest_handle = GNUNET_ATS_connectivity_suggest (GST_ats_connect,
- peer);
+ peer,
+ 0);
return n;
}