add 'strength' argument to address suggestion request for ATS
authorChristian Grothoff <christian@grothoff.org>
Sun, 18 Oct 2015 12:49:23 +0000 (12:49 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sun, 18 Oct 2015 12:49:23 +0000 (12:49 +0000)
src/ats/ats.h
src/ats/ats_api_connectivity.c
src/ats/ats_api_scheduling.c
src/ats/gnunet-service-ats_connectivity.c
src/include/gnunet_ats_service.h
src/transport/gnunet-service-transport_neighbours.c

index 3a7f28a6423ef33ba211991ac052b0083fdc6ac6..5c1e806b6d2c90e6c08263a8a2db95a8d93fca50 100644 (file)
@@ -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
 {
index 4099cadbd870b7ebb5e5460364085c000fedc604..1012e9ceee55769400e998caf9383ca945e2601c 100644 (file)
@@ -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);
index d7a5a83a1bf3e3661e22db2396b39f9d08f92b99..ab8a8711d757475f0a598df069ec9cba54f8c001 100644 (file)
@@ -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;
index 8c103a33c474f1645d7ceb6a57790566b9d472a7..7bde6e354c3b0cd14a8a5cb631591b7c1fe86cd5 100644 (file)
@@ -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,
index 4264f22a4567608350ddc80da3c522ca0c7ab80b..32e98abd617c5e406fd6811d461bba52903f8bde 100644 (file)
@@ -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);
 
 
 /**
index d41fa658261cf8ee46b02e2fc3ecf598fe0dc882..07af225c1296e4934847db2f8e474f858c66468e 100644 (file)
@@ -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;
 }