use new PriorityPreferences consistently, note on deprecation
authorChristian Grothoff <christian@grothoff.org>
Sun, 5 May 2019 12:02:24 +0000 (14:02 +0200)
committerChristian Grothoff <christian@grothoff.org>
Sun, 5 May 2019 12:02:24 +0000 (14:02 +0200)
src/include/gnunet_mq_lib.h
src/include/gnunet_transport_address_service.h
src/include/gnunet_transport_application_service.h
src/include/gnunet_transport_hello_service.h
src/transport/gnunet-service-tng.c
src/transport/transport_api2_address.c
src/transport/transport_api2_application.c

index 4fe5c8df96523dd75bc847f0a4212aec8f6a07ce..81100d7d815b5f3794f80a5c18293babf58aaf0f 100644 (file)
@@ -1043,6 +1043,8 @@ GNUNET_MQ_impl_current (struct GNUNET_MQ_Handle *mq);
 
 /**
  * Enum defining all known preference categories.
+ *
+ * @deprecated will be replaced by `enum GNUNET_MQ_PriorityPreference`
  */
 enum GNUNET_MQ_PreferenceKind
 {
@@ -1083,6 +1085,8 @@ enum GNUNET_MQ_PreferenceKind
  *
  * @param type the preference type
  * @return a string or NULL if invalid
+ *
+ * @deprecated will be replaced by `enum GNUNET_MQ_PriorityPreference`
  */
 const char *
 GNUNET_MQ_preference_to_string (enum GNUNET_MQ_PreferenceKind type);
index 9f0717d00651642a10b7b32cc2302a32543917ec..b33a11411c01451289dc4b3181a9d3155692c7d1 100644 (file)
@@ -21,6 +21,9 @@
 /**
  * @author Christian Grothoff
  *
+ * @deprecated NOTE: we may want to drop this API and
+ *  only keep the gnunet_transport_application_service.h in the future!
+ *
  * @file
  * Provide addresses to transport for validation
  *
@@ -36,9 +39,8 @@
 #define GNUNET_TRANSPORT_ADDRESS_SERVICE_H
 
 #ifdef __cplusplus
-extern "C"
-{
-#if 0                           /* keep Emacsens' auto-indent happy */
+extern "C" {
+#if 0 /* keep Emacsens' auto-indent happy */
 }
 #endif
 #endif
@@ -65,7 +67,8 @@ struct GNUNET_TRANSPORT_AddressHandle;
  * @return NULL on error
  */
 struct GNUNET_TRANSPORT_AddressHandle *
-GNUNET_TRANSPORT_address_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
+GNUNET_TRANSPORT_address_connect (
+  const struct GNUNET_CONFIGURATION_Handle *cfg);
 
 
 /**
@@ -101,7 +104,7 @@ GNUNET_TRANSPORT_address_try (struct GNUNET_TRANSPORT_AddressHandle *ch,
                               const size_t raw_size);
 
 
-#if 0                           /* keep Emacsens' auto-indent happy */
+#if 0 /* keep Emacsens' auto-indent happy */
 {
 #endif
 #ifdef __cplusplus
@@ -111,6 +114,6 @@ GNUNET_TRANSPORT_address_try (struct GNUNET_TRANSPORT_AddressHandle *ch,
 /* ifndef GNUNET_TRANSPORT_ADDRESS_SERVICE_H */
 #endif
 
-/** @} */  /* end of group */
+/** @} */ /* end of group */
 
 /* end of gnunet_transport_address_service.h */
index 8c63a82342faf32449360cc66abd9026775bdc95..c12bd74414a7e1f961bfac9ee0ce3e943f817362 100644 (file)
@@ -64,6 +64,34 @@ GNUNET_TRANSPORT_application_done (
   struct GNUNET_TRANSPORT_ApplicationHandle *ch);
 
 
+/**
+ * An application would like TRANSPORT to connect to a peer.
+ *
+ * @param ch handle
+ * @param peer identity of the peer we need an address for
+ * @param pk what kind of application will the application require (can be
+ *         #GNUNET_MQ_PRIO_BACKGROUND, we will still try to connect)
+ * @param bw desired bandwith, can be zero (we will still try to connect)
+ * @return suggest handle, NULL if a request is already pending
+ */
+struct GNUNET_TRANSPORT_ApplicationSuggestHandle *
+GNUNET_TRANSPORT_application_suggest (
+  struct GNUNET_TRANSPORT_ApplicationHandle *ch,
+  const struct GNUNET_PeerIdentity *peer,
+  enum GNUNET_MQ_PriorityPreferences pk,
+  struct GNUNET_BANDWIDTH_Value32NBO bw);
+
+
+/**
+ * We no longer care about being connected to a peer.
+ *
+ * @param sh handle to stop
+ */
+void
+GNUNET_TRANSPORT_application_suggest_cancel (
+  struct GNUNET_TRANSPORT_ApplicationSuggestHandle *sh);
+
+
 /**
  * An application (or a communicator) has received a HELLO (or other address
  * data of another peer) and wants TRANSPORT to validate that the address is
index 58a1e997951857b4ccfe212cc261d396034e3bc4..fe863c0582500c235163c30e98bd651be7ea7242 100644 (file)
@@ -24,6 +24,8 @@
  * @file
  * obtain information about our current address
  *
+ * @deprecated, in TNG applications should query PEERSTORE directly!
+ *
  * @defgroup transport  Transport service
  * address information
  *
@@ -35,9 +37,8 @@
 #define GNUNET_TRANSPORT_HELLO_SERVICE_H
 
 #ifdef __cplusplus
-extern "C"
-{
-#if 0                           /* keep Emacsens' auto-indent happy */
+extern "C" {
+#if 0 /* keep Emacsens' auto-indent happy */
 }
 #endif
 #endif
@@ -118,9 +119,9 @@ enum GNUNET_TRANSPORT_AddressClass
  * @param cls closure
  * @param hello our updated HELLO
  */
-typedef void
-(*GNUNET_TRANSPORT_HelloUpdateCallback) (void *cls,
-                                         const struct GNUNET_MessageHeader *hello);
+typedef void (*GNUNET_TRANSPORT_HelloUpdateCallback) (
+  void *cls,
+  const struct GNUNET_MessageHeader *hello);
 
 
 /**
@@ -164,12 +165,12 @@ GNUNET_TRANSPORT_hello_get_cancel (struct GNUNET_TRANSPORT_HelloGetHandle *ghh);
  * @param nt network type of the address
  * @param expiration when does this address expire?
  */
-typedef void
-(*GNUNET_TRANSPORT_AddressCallback) (void *cls,
-                                     const struct GNUNET_PeerIdentity *peer,
-                                     const char *address,
-                                     enum GNUNET_NetworkType nt,
-                                     struct GNUNET_TIME_Absolute expiration);
+typedef void (*GNUNET_TRANSPORT_AddressCallback) (
+  void *cls,
+  const struct GNUNET_PeerIdentity *peer,
+  const char *address,
+  enum GNUNET_NetworkType nt,
+  struct GNUNET_TIME_Absolute expiration);
 
 
 /**
@@ -187,7 +188,7 @@ GNUNET_TRANSPORT_hello_parse (const struct GNUNET_MessageHeader *hello,
                               void *cb_cls);
 
 
-#if 0                           /* keep Emacsens' auto-indent happy */
+#if 0 /* keep Emacsens' auto-indent happy */
 {
 #endif
 #ifdef __cplusplus
@@ -197,6 +198,6 @@ GNUNET_TRANSPORT_hello_parse (const struct GNUNET_MessageHeader *hello,
 /* ifndef GNUNET_TRANSPORT_HELLO_SERVICE_H */
 #endif
 
-/** @} */  /* end of group */
+/** @} */ /* end of group */
 
 /* end of gnunet_transport_hello_service.h */
index 443c7f2458014eb1e7d69892697d85602d0e85e8..ab91599637de3f7c665fc3edfa764f1aeac4a6a7 100644 (file)
@@ -1757,8 +1757,10 @@ struct PeerRequest
 
   /**
    * What kind of performance preference does this @e tc have?
+   *
+   * TODO: use this!
    */
-  enum GNUNET_MQ_PreferenceKind pk;
+  enum GNUNET_MQ_PriorityPreferences pk;
 
   /**
    * How much bandwidth would this @e tc like to see?
@@ -1952,6 +1954,12 @@ struct PendingMessage
    */
   enum PendingMessageType pmt;
 
+  /**
+   * Preferences for this message.
+   * TODO: actually use this!
+   */
+  enum GNUNET_MQ_PriorityPreferences prefs;
+
   /**
    * Size of the original message.
    */
@@ -3736,7 +3744,6 @@ handle_client_send (void *cls, const struct OutboundMessage *obm)
   obmm = (const struct GNUNET_MessageHeader *) &obm[1];
   bytes_msg = ntohs (obmm->size);
   pp = (enum GNUNET_MQ_PriorityPreferences) ntohl (obm->priority);
-  /* FIXME: actually make use of pp */ (void) pp;
   vl = GNUNET_CONTAINER_multipeermap_get (links, &obm->peer);
   if (NULL == vl)
   {
@@ -3790,6 +3797,7 @@ handle_client_send (void *cls, const struct OutboundMessage *obm)
 
   was_empty = (NULL == target->pending_msg_head);
   pm = GNUNET_malloc (sizeof (struct PendingMessage) + payload_size);
+  pm->prefs = pp;
   pm->client = tc;
   pm->target = target;
   pm->bytes_msg = payload_size;
@@ -8559,7 +8567,7 @@ handle_suggest (void *cls, const struct ExpressPreferenceMessage *msg)
   pr->tc = tc;
   pr->pid = msg->peer;
   pr->bw = msg->bw;
-  pr->pk = (enum GNUNET_MQ_PreferenceKind) ntohl (msg->pk);
+  pr->pk = (enum GNUNET_MQ_PriorityPreferences) ntohl (msg->pk);
   if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_put (
                       tc->details.application.requests,
                       &pr->pid,
index 1ff599efb7bf2c4bb1271d775aa0e9a90835dfb3..d2cab27d513dc04ec7843f7121076d34eb353f52 100644 (file)
@@ -31,7 +31,8 @@
 #include "gnunet_ats_transport_service.h"
 #include "transport.h"
 
-#define LOG(kind,...) GNUNET_log_from (kind, "transport-api-address",__VA_ARGS__)
+#define LOG(kind, ...) \
+  GNUNET_log_from (kind, "transport-api-address", __VA_ARGS__)
 
 
 /**
@@ -60,7 +61,6 @@ struct GNUNET_TRANSPORT_AddressHandle
    * Delay until we try to reconnect.
    */
   struct GNUNET_TIME_Relative reconnect_delay;
-
 };
 
 
@@ -84,8 +84,7 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_AddressHandle *h);
  * @param error error code
  */
 static void
-mq_error_handler (void *cls,
-                  enum GNUNET_MQ_Error error)
+mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 {
   struct GNUNET_TRANSPORT_AddressHandle *h = cls;
 
@@ -104,19 +103,13 @@ static void
 reconnect (void *cls)
 {
   struct GNUNET_TRANSPORT_AddressHandle *h = cls;
-  struct GNUNET_MQ_MessageHandler handlers[] = {
-    GNUNET_MQ_handler_end ()
-  };
+  struct GNUNET_MQ_MessageHandler handlers[] = {GNUNET_MQ_handler_end ()};
 
   h->reconnect_task = NULL;
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Connecting to transport service.\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service.\n");
   GNUNET_assert (NULL == h->mq);
-  h->mq = GNUNET_CLIENT_connect (h->cfg,
-                                 "transport",
-                                 handlers,
-                                 &mq_error_handler,
-                                 h);
+  h->mq =
+    GNUNET_CLIENT_connect (h->cfg, "transport", handlers, &mq_error_handler, h);
 }
 
 
@@ -149,12 +142,9 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_AddressHandle *h)
   disconnect (h);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Scheduling task to reconnect to transport service in %s.\n",
-       GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay,
-                                               GNUNET_YES));
+       GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay, GNUNET_YES));
   h->reconnect_task =
-      GNUNET_SCHEDULER_add_delayed (h->reconnect_delay,
-                                    &reconnect,
-                                    h);
+    GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
   h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
 }
 
@@ -173,8 +163,7 @@ GNUNET_TRANSPORT_address_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
   h = GNUNET_new (struct GNUNET_TRANSPORT_AddressHandle);
   h->cfg = cfg;
   h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Connecting to transport service\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service\n");
   reconnect (h);
   if (NULL == h->mq)
   {
@@ -191,10 +180,10 @@ GNUNET_TRANSPORT_address_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
  * @param handle handle to the service as returned from #GNUNET_TRANSPORT_address_connect()
  */
 void
-GNUNET_TRANSPORT_address_disconnect (struct GNUNET_TRANSPORT_AddressHandle *handle)
+GNUNET_TRANSPORT_address_disconnect (
+  struct GNUNET_TRANSPORT_AddressHandle *handle)
 {
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Transport disconnect called!\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Transport disconnect called!\n");
   /* this disconnects all neighbours... */
   disconnect (handle);
   /* and now we stop trying to connect again... */
@@ -233,17 +222,14 @@ GNUNET_TRANSPORT_address_try (struct GNUNET_TRANSPORT_AddressHandle *ch,
   struct GNUNET_MQ_Envelope *env;
   struct GNUNET_TRANSPORT_AddressToVerify *hdr;
 
-  env = GNUNET_MQ_msg_extra (hdr,
-                             raw_size,
-                             GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY);
+  env =
+    GNUNET_MQ_msg_extra (hdr,
+                         raw_size,
+                         GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY);
   hdr->peer = *pid;
-  memcpy (&hdr[1],
-          raw,
-          raw_size);
-  GNUNET_MQ_send (ch->mq,
-                  env);
+  memcpy (&hdr[1], raw, raw_size);
+  GNUNET_MQ_send (ch->mq, env);
 }
 
 
-
 /* end of transport_api2_address.c */
index 49f0f36c7c3c82bc2047f21701b1fc3c5eda3008..7d790d7383a662f973061ebd0d651fe1f6b65712 100644 (file)
@@ -51,7 +51,7 @@ struct GNUNET_TRANSPORT_ApplicationSuggestHandle
   /**
    * What preference is being expressed?
    */
-  enum GNUNET_MQ_PreferenceKind pk;
+  enum GNUNET_MQ_PriorityPreferences pk;
 
   /**
    * How much bandwidth does the client expect?
@@ -277,15 +277,12 @@ GNUNET_TRANSPORT_application_done (
 
 
 /**
- * We would like to receive address suggestions for a peer. TRANSPORT will
- * respond with a call to the continuation immediately containing an address or
- * no address if none is available. TRANSPORT can suggest more addresses until we call
- * #GNUNET_TRANSPORT_application_suggest_cancel().
+ * An application would like TRANSPORT to connect to a peer.
  *
  * @param ch handle
  * @param peer identity of the peer we need an address for
  * @param pk what kind of application will the application require (can be
- *         #GNUNET_MQ_PREFERENCE_NONE, we will still try to connect)
+ *         #GNUNET_MQ_PRIO_BACKGROUND, we will still try to connect)
  * @param bw desired bandwith, can be zero (we will still try to connect)
  * @return suggest handle, NULL if a request is already pending
  */
@@ -293,7 +290,7 @@ struct GNUNET_TRANSPORT_ApplicationSuggestHandle *
 GNUNET_TRANSPORT_application_suggest (
   struct GNUNET_TRANSPORT_ApplicationHandle *ch,
   const struct GNUNET_PeerIdentity *peer,
-  enum GNUNET_MQ_PreferenceKind pk,
+  enum GNUNET_MQ_PriorityPreferences pk,
   struct GNUNET_BANDWIDTH_Value32NBO bw)
 {
   struct GNUNET_TRANSPORT_ApplicationSuggestHandle *s;