gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] branch master updated: more work towards fixing #5


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: more work towards fixing #5385
Date: Sun, 27 Jan 2019 04:21:33 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new f0b35049f more work towards fixing #5385
f0b35049f is described below

commit f0b35049f6d9e743d2bc5fcf11664633d130d6fc
Author: Christian Grothoff <address@hidden>
AuthorDate: Sun Jan 27 04:21:27 2019 +0100

    more work towards fixing #5385
---
 src/cadet/cadet_api_list_tunnels.c | 81 ++++++++++++++++----------------------
 src/cadet/gnunet-cadet.c           | 45 ++++++++++-----------
 src/cadet/gnunet-service-cadet.c   |  8 ++--
 src/include/gnunet_cadet_service.h | 44 ++++++++++++++++-----
 src/include/gnunet_protocols.h     |  9 +++++
 5 files changed, 103 insertions(+), 84 deletions(-)

diff --git a/src/cadet/cadet_api_list_tunnels.c 
b/src/cadet/cadet_api_list_tunnels.c
index 631b321b7..a2ba65993 100644
--- a/src/cadet/cadet_api_list_tunnels.c
+++ b/src/cadet/cadet_api_list_tunnels.c
@@ -71,26 +71,25 @@ struct GNUNET_CADET_ListTunnels
 
 
 /**
- * Check that message received from CADET service is well-formed.
+ * Process a local reply about info on all tunnels, pass info to the user.
  *
- * @param cls the `struct GNUNET_CADET_Handle`
- * @param message the message we got
- * @return #GNUNET_OK if the message is well-formed,
- *         #GNUNET_SYSERR otherwise
+ * @param cls a `struct GNUNET_CADET_ListTunnels *`
+ * @param info Message itself.
  */
-static int
-check_get_tunnels (void *cls,
-                   const struct GNUNET_MessageHeader *message)
+static void
+handle_get_tunnels (void *cls,
+                   const struct GNUNET_CADET_LocalInfoTunnel *info)
 {
-  size_t esize;
-
-  (void) cls;
-  esize = ntohs (message->size);
-  if (sizeof (struct GNUNET_CADET_LocalInfoTunnel) == esize)
-    return GNUNET_OK;
-  if (sizeof (struct GNUNET_MessageHeader) == esize)
-    return GNUNET_OK;
-  return GNUNET_SYSERR;
+  struct GNUNET_CADET_ListTunnels *lt = cls;
+  struct GNUNET_CADET_TunnelDetails td;
+  
+  td.peer = info->destination;
+  td.channels = ntohl (info->channels);
+  td.connections = ntohl (info->connections);
+  td.estate = ntohs (info->estate);
+  td.cstate = ntohs (info->cstate);
+  lt->tunnels_cb (lt->tunnels_cb_cls,
+                 &td);
 }
 
 
@@ -101,31 +100,15 @@ check_get_tunnels (void *cls,
  * @param message Message itself.
  */
 static void
-handle_get_tunnels (void *cls,
-                    const struct GNUNET_MessageHeader *msg)
+handle_get_tunnels_end (void *cls,
+                       const struct GNUNET_MessageHeader *msg)
 {
   struct GNUNET_CADET_ListTunnels *lt = cls;
-  const struct GNUNET_CADET_LocalInfoTunnel *info =
-    (const struct GNUNET_CADET_LocalInfoTunnel *) msg;
-
-  // FIXME: use two message types!
-  if (sizeof (struct GNUNET_CADET_LocalInfoTunnel) == ntohs (msg->size))
-    lt->tunnels_cb (lt->tunnels_cb_cls,
-                   &info->destination,
-                   ntohl (info->channels),
-                   ntohl (info->connections),
-                   ntohs (info->estate),
-                   ntohs (info->cstate));
-  else
-  {
-    lt->tunnels_cb (lt->tunnels_cb_cls,
-                   NULL,
-                   0,
-                   0,
-                   0,
-                   0);
-    GNUNET_CADET_list_tunnels_cancel (lt);
-  }
+  (void) msg;
+  
+  lt->tunnels_cb (lt->tunnels_cb_cls,
+                 NULL);
+  GNUNET_CADET_list_tunnels_cancel (lt);
 }
 
 
@@ -170,10 +153,14 @@ reconnect (void *cls)
 {
   struct GNUNET_CADET_ListTunnels *lt = cls;
   struct GNUNET_MQ_MessageHandler handlers[] = {
-    GNUNET_MQ_hd_var_size (get_tunnels,
-                           GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS,
-                           struct GNUNET_MessageHeader,
-                           lt),
+    GNUNET_MQ_hd_fixed_size (get_tunnels,
+                            GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS,
+                            struct GNUNET_CADET_LocalInfoTunnel,
+                            lt),
+    GNUNET_MQ_hd_fixed_size (get_tunnels_end,
+                            GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS_END,
+                            struct GNUNET_MessageHeader,
+                            lt),
     GNUNET_MQ_handler_end ()
   };
   struct GNUNET_MessageHeader *msg;
@@ -188,7 +175,7 @@ reconnect (void *cls)
   if (NULL == lt->mq)
     return;
   env = GNUNET_MQ_msg (msg,
-                      GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS);
+                      GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS);
   GNUNET_MQ_send (lt->mq,
                   env);
 }
@@ -199,9 +186,7 @@ reconnect (void *cls)
  * The callback will be called for every tunnel of the service.
  * Only one info request (of any kind) can be active at once.
  *
- * WARNING: unstable API, likely to change in the future!
- *
- * @param h Handle to the cadet peer.
+ * @param cfg configuration to use
  * @param callback Function to call with the requested data.
  * @param callback_cls Closure for @c callback.
  * @return NULL on error
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c
index 3386f7464..9e2d105b3 100644
--- a/src/cadet/gnunet-cadet.c
+++ b/src/cadet/gnunet-cadet.c
@@ -109,7 +109,12 @@ static struct GNUNET_CADET_GetPath *gpo;
 /**
  * Active peer listing operation.
  */ 
-struct GNUNET_CADET_PeersLister *plo;
+static struct GNUNET_CADET_PeersLister *plo;
+
+/**
+ * Active tunnel listing operation.
+ */
+static struct GNUNET_CADET_ListTunnels *tio;
 
 /**
  * Channel handle.
@@ -231,6 +236,11 @@ shutdown_task (void *cls)
     GNUNET_CADET_list_peers_cancel (plo);
     plo = NULL;
   }
+  if (NULL != tio)
+  {
+    GNUNET_CADET_list_tunnels_cancel (tio);
+    tio = NULL;
+  }
   if (NULL != mh)
   {
     GNUNET_CADET_disconnect (mh);
@@ -569,32 +579,25 @@ path_callback (void *cls,
  * Method called to retrieve information about all tunnels in CADET.
  *
  * @param cls Closure.
- * @param peer Destination peer.
- * @param channels Number of channels.
- * @param connections Number of connections.
- * @param estate Encryption state.
- * @param cstate Connectivity state.
+ * @param td tunnel details
  */
 static void
 tunnels_callback (void *cls,
-                  const struct GNUNET_PeerIdentity *peer,
-                  unsigned int channels,
-                  unsigned int connections,
-                  uint16_t estate,
-                  uint16_t cstate)
+                 const struct GNUNET_CADET_TunnelDetails *td)
 {
-  if (NULL == peer)
+  if (NULL == td)
   {
+    tio = NULL;
     GNUNET_SCHEDULER_shutdown();
     return;
   }
   FPRINTF (stdout,
            "%s [ENC: %s, CON: %s] CHs: %u, CONNs: %u\n",
-           GNUNET_i2s_full (peer),
-           enc_2s (estate),
-           conn_2s (cstate),
-           channels,
-           connections);
+           GNUNET_i2s_full (&td->peer),
+           enc_2s (td->estate),
+           conn_2s (td->cstate),
+           td->channels,
+           td->connections);
 }
 
 
@@ -692,11 +695,9 @@ static void
 get_tunnels (void *cls)
 {
   job = NULL;
-#if FIXME5385
-  GNUNET_CADET_list_tunnels (my_cfg,
-                            &tunnels_callback,
-                            NULL);
-#endif
+  tio = GNUNET_CADET_list_tunnels (my_cfg,
+                                  &tunnels_callback,
+                                  NULL);
 }
 
 
diff --git a/src/cadet/gnunet-service-cadet.c b/src/cadet/gnunet-service-cadet.c
index a62ce4cb0..ef5fa6d7e 100644
--- a/src/cadet/gnunet-service-cadet.c
+++ b/src/cadet/gnunet-service-cadet.c
@@ -974,7 +974,7 @@ get_all_tunnels_iterator (void *cls,
 
 
 /**
- * Handler for client's #GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS request.
+ * Handler for client's #GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS 
request.
  *
  * @param cls client Identification of the client.
  * @param message The actual message.
@@ -990,7 +990,7 @@ handle_info_tunnels (void *cls,
   GCP_iterate_all (&get_all_tunnels_iterator,
                    c);
   env = GNUNET_MQ_msg (reply,
-                       GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS);
+                       GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS_END);
   GNUNET_MQ_send (c->mq,
                   env);
   GNUNET_SERVICE_client_continue (c->client);
@@ -1036,7 +1036,7 @@ iter_channel (void *cls,
 
 
 /**
- * Handler for client's #GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL request.
+ * Handler for client's #GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNEL 
request.
  *
  * @param cls Identification of the client.
  * @param msg The actual message.
@@ -1435,7 +1435,7 @@ GNUNET_SERVICE_MAIN
                           struct GNUNET_CADET_RequestPathInfoMessage,
                           NULL),
  GNUNET_MQ_hd_fixed_size (info_tunnels,
-                          GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS,
+                          GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS,
                           struct GNUNET_MessageHeader,
                           NULL),
  GNUNET_MQ_hd_fixed_size (info_tunnel,
diff --git a/src/include/gnunet_cadet_service.h 
b/src/include/gnunet_cadet_service.h
index ce44be88a..82350ed32 100644
--- a/src/include/gnunet_cadet_service.h
+++ b/src/include/gnunet_cadet_service.h
@@ -571,6 +571,38 @@ void *
 GNUNET_CADET_get_path_cancel (struct GNUNET_CADET_GetPath *gp);
 
 
+/**
+ * Details about a tunnel managed by CADET.
+ */
+struct GNUNET_CADET_TunnelDetails
+{
+  /**
+   * Target of the tunnel.
+   */
+  struct GNUNET_PeerIdentity peer;
+
+  /**
+   * How many channels use the tunnel.
+   */ 
+  uint32_t channels;
+
+  /**
+   * How many connections support the tunnel.
+   */
+  uint32_t connections;
+
+  /**
+   * What is our encryption state?
+   */
+  uint16_t estate;
+
+  /**
+   * What is our connectivity state? 
+   */ 
+  uint16_t cstate;
+};
+
+
 /**
  * Method called to retrieve information about all tunnels in CADET, called
  * once per tunnel.
@@ -578,19 +610,11 @@ GNUNET_CADET_get_path_cancel (struct GNUNET_CADET_GetPath 
*gp);
  * After last tunnel has been reported, an additional call with NULL is done.
  *
  * @param cls Closure.
- * @param peer Destination peer, or NULL on "EOF".
- * @param channels Number of channels.
- * @param connections Number of connections.
- * @param estate Encryption state.
- * @param cstate Connectivity state.
+ * @param td tunnel details, NULL for end of list
  */
 typedef void
 (*GNUNET_CADET_TunnelsCB) (void *cls,
-                           const struct GNUNET_PeerIdentity *peer,
-                           unsigned int channels,
-                           unsigned int connections,
-                           uint16_t estate,
-                           uint16_t cstate);
+                          const struct GNUNET_CADET_TunnelDetails *td);
 
 
 /**
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 1b1bdc099..9d3280d36 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -2916,6 +2916,15 @@ extern "C"
  */
 #define GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_PATH 1042
 
+/**
+ * End of local information about all tunnels of service.
+ */
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS_END 1043
+
+/**
+ * Request local information about all tunnels of service.
+ */
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS 1044
 
 /********************************  Application  
*******************************/
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]