remaing remaining mandatory functions for basic operation
authorChristian Grothoff <christian@grothoff.org>
Sat, 21 Jan 2017 13:49:23 +0000 (14:49 +0100)
committerChristian Grothoff <christian@grothoff.org>
Sat, 21 Jan 2017 13:49:23 +0000 (14:49 +0100)
13 files changed:
src/cadet/cadet.h
src/cadet/cadet_api.c
src/cadet/gnunet-service-cadet-new.c
src/cadet/gnunet-service-cadet-new.h
src/cadet/gnunet-service-cadet-new_channel.c
src/cadet/gnunet-service-cadet-new_hello.c
src/cadet/gnunet-service-cadet-new_peer.c
src/cadet/gnunet-service-cadet-new_peer.h
src/cadet/gnunet-service-cadet-new_tunnels.c
src/cadet/gnunet-service-cadet_channel.c
src/cadet/gnunet-service-cadet_channel.h
src/cadet/gnunet-service-cadet_local.c
src/include/gnunet_protocols.h

index 9d154fb99a5e8e813fa6226233f7691abbe824fe..205955b053ccdfc715442c7f6abc0303a8b2966c 100644 (file)
@@ -135,7 +135,7 @@ struct GNUNET_CADET_PortMessage
 /**
  * Message for a client to create channels.
  */
-struct GNUNET_CADET_ChannelOpenMessageMessage
+struct GNUNET_CADET_TunnelCreateMessage
 {
   /**
    * Type: #GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_CREATE
@@ -167,14 +167,12 @@ struct GNUNET_CADET_ChannelOpenMessageMessage
 
 
 /**
- * Message for a client to destroy channels.
+ * Message for or to a client to destroy tunnel.
  */
-struct GNUNET_CADET_ChannelDestroyMessage
+struct GNUNET_CADET_TunnelDestroyMessage
 {
   /**
    * Type: #GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_DESTROY
-   *
-   * Size: sizeof(struct GNUNET_CADET_ChannelDestroyMessage)
    */
   struct GNUNET_MessageHeader header;
 
index 5dcf43e46027b8896a897d33368aad252777ba03..fa67eb0942f2cb0ee88b9873c27629531138b74f 100644 (file)
@@ -588,7 +588,7 @@ request_data (void *cls)
  */
 static void
 handle_channel_created (void *cls,
-                        const struct GNUNET_CADET_ChannelOpenMessageMessage *msg)
+                        const struct GNUNET_CADET_TunnelCreateMessage *msg)
 {
   struct GNUNET_CADET_Handle *h = cls;
   struct GNUNET_CADET_Channel *ch;
@@ -628,11 +628,12 @@ handle_channel_created (void *cls,
   }
   else
   {
-    struct GNUNET_CADET_ChannelDestroyMessage *d_msg;
+    struct GNUNET_CADET_TunnelDestroyMessage *d_msg;
     struct GNUNET_MQ_Envelope *env;
 
     LOG (GNUNET_ERROR_TYPE_DEBUG, "No handler for incoming channels\n");
-    env = GNUNET_MQ_msg (d_msg, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY);
+    env = GNUNET_MQ_msg (d_msg,
+                         GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_DESTROY);
     d_msg->channel_id = msg->channel_id;
     GNUNET_MQ_send (h->mq, env);
   }
@@ -648,7 +649,7 @@ handle_channel_created (void *cls,
  */
 static void
 handle_channel_destroy (void *cls,
-                        const struct GNUNET_CADET_ChannelDestroyMessage *msg)
+                        const struct GNUNET_CADET_TunnelDestroyMessage *msg)
 {
   struct GNUNET_CADET_Handle *h = cls;
   struct GNUNET_CADET_Channel *ch;
@@ -1281,12 +1282,12 @@ do_reconnect (struct GNUNET_CADET_Handle *h)
 {
   struct GNUNET_MQ_MessageHandler handlers[] = {
     GNUNET_MQ_hd_fixed_size (channel_created,
-                             GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN,
-                             struct GNUNET_CADET_ChannelOpenMessageMessage,
+                             GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_CREATE,
+                             struct GNUNET_CADET_TunnelCreateMessage,
                              h),
     GNUNET_MQ_hd_fixed_size (channel_destroy,
-                             GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY,
-                             struct GNUNET_CADET_ChannelDestroyMessage,
+                             GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_DESTROY,
+                             struct GNUNET_CADET_TunnelDestroyMessage,
                              h),
     GNUNET_MQ_hd_var_size (local_data,
                            GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA,
@@ -1575,7 +1576,7 @@ GNUNET_CADET_channel_create (struct GNUNET_CADET_Handle *h,
                             const struct GNUNET_HashCode *port,
                             enum GNUNET_CADET_ChannelOption options)
 {
-  struct GNUNET_CADET_ChannelOpenMessageMessage *msg;
+  struct GNUNET_CADET_TunnelCreateMessage *msg;
   struct GNUNET_MQ_Envelope *env;
   struct GNUNET_CADET_Channel *ch;
   struct GNUNET_CADET_ClientChannelNumber chid;
@@ -1591,7 +1592,7 @@ GNUNET_CADET_channel_create (struct GNUNET_CADET_Handle *h,
   ch->ctx = channel_ctx;
   ch->peer = GNUNET_PEER_intern (peer);
 
-  env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN);
+  env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_CREATE);
   msg->channel_id = ch->chid;
   msg->port = *port;
   msg->peer = *peer;
@@ -1607,7 +1608,7 @@ void
 GNUNET_CADET_channel_destroy (struct GNUNET_CADET_Channel *channel)
 {
   struct GNUNET_CADET_Handle *h;
-  struct GNUNET_CADET_ChannelDestroyMessage *msg;
+  struct GNUNET_CADET_TunnelDestroyMessage *msg;
   struct GNUNET_MQ_Envelope *env;
   struct GNUNET_CADET_TransmitHandle *th;
   struct GNUNET_CADET_TransmitHandle *next;
@@ -1636,7 +1637,8 @@ GNUNET_CADET_channel_destroy (struct GNUNET_CADET_Channel *channel)
     }
   }
 
-  env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY);
+  env = GNUNET_MQ_msg (msg,
+                       GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_DESTROY);
   msg->channel_id = channel->chid;
   GNUNET_MQ_send (h->mq, env);
 
index 7801708c194d8616c8b40fa2d97cf18de28af64d..b6bdcc9fc79895a0809aaebcb0935b163ec9df1f 100644 (file)
@@ -114,6 +114,11 @@ struct CadetClient
 
 /****************************** Global variables ******************************/
 
+/**
+ * Handle to our configuration.
+ */
+const struct GNUNET_CONFIGURATION_Handle *cfg;
+
 /**
  * Handle to the statistics service.
  */
@@ -272,7 +277,7 @@ GSC_bind (struct CadetClient *c,
           uint32_t options)
 {
   struct GNUNET_MQ_Envelope *env;
-  struct GNUNET_CADET_ChannelOpenMessageMessage *msg;
+  struct GNUNET_CADET_TunnelCreateMessage *msg;
   struct GNUNET_CADET_ClientChannelNumber lid;
 
   lid = client_get_next_lid (c);
@@ -284,7 +289,7 @@ GSC_bind (struct CadetClient *c,
 
   /* notify local client about incoming connection! */
   env = GNUNET_MQ_msg (msg,
-                       GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN);
+                       GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_CREATE);
   msg->channel_id = lid;
   msg->port = *port;
   msg->opt = htonl (options);
@@ -396,7 +401,7 @@ handle_port_open (void *cls,
        c->id);
   if (NULL == c->ports)
     c->ports = GNUNET_CONTAINER_multihashmap_create (4,
-                                                     GNUNET_NO);
+                                                      GNUNET_NO);
   if (GNUNET_OK !=
       GNUNET_CONTAINER_multihashmap_put (c->ports,
                                          &pmsg->port,
@@ -460,18 +465,18 @@ handle_port_close (void *cls,
  * Handler for requests of new channels.
  *
  * @param cls Identification of the client.
- * @param ccm The actual message.
+ * @param tcm The actual message.
  */
 static void
-handle_channel_create (void *cls,
-                       const struct GNUNET_CADET_ChannelOpenMessageMessage *ccm)
+handle_tunnel_create (void *cls,
+                      const struct GNUNET_CADET_TunnelCreateMessage *tcm)
 {
   struct CadetClient *c = cls;
   struct CadetChannel *ch;
   struct GNUNET_CADET_ClientChannelNumber chid;
   struct CadetPeer *dst;
 
-  chid = ccm->channel_id;
+  chid = tcm->channel_id;
   if (ntohl (chid.channel_of_client) < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
   {
     /* Channel ID not in allowed range. */
@@ -489,15 +494,15 @@ handle_channel_create (void *cls,
     return;
   }
 
-  dst = GCP_get (&ccm->peer,
+  dst = GCP_get (&tcm->peer,
                  GNUNET_YES);
 
   /* Create channel */
   ch = GCCH_channel_local_new (c,
                                chid,
                                dst,
-                               &ccm->port,
-                               ntohl (ccm->opt));
+                               &tcm->port,
+                               ntohl (tcm->opt));
   if (NULL == ch)
   {
     GNUNET_break (0);
@@ -513,8 +518,8 @@ handle_channel_create (void *cls,
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "New channel %s to %s at port %s requested by client %u\n",
        GCCH_2s (ch),
-       GNUNET_i2s (&ccm->peer),
-       GNUNET_h2s (&ccm->port),
+       GNUNET_i2s (&tcm->peer),
+       GNUNET_h2s (&tcm->port),
        c->id);
   GNUNET_SERVICE_client_continue (c->client);
 }
@@ -544,8 +549,8 @@ get_map_by_chid (struct CadetClient *c,
  * @param msg the actual message
  */
 static void
-handle_channel_destroy (void *cls,
-                        const struct GNUNET_CADET_ChannelDestroyMessage *msg)
+handle_tunnel_destroy (void *cls,
+                       const struct GNUNET_CADET_TunnelDestroyMessage *msg)
 {
   struct CadetClient *c = cls;
   struct GNUNET_CADET_ClientChannelNumber chid;
@@ -1233,6 +1238,7 @@ run (void *cls,
      const struct GNUNET_CONFIGURATION_Handle *c,
      struct GNUNET_SERVICE_Handle *service)
 {
+  cfg = c;
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_number (c,
                                              "CADET",
@@ -1309,13 +1315,13 @@ GNUNET_SERVICE_MAIN
                           GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE,
                           struct GNUNET_CADET_PortMessage,
                           NULL),
- GNUNET_MQ_hd_fixed_size (channel_create,
-                          GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN,
-                          struct GNUNET_CADET_ChannelOpenMessageMessage,
+ GNUNET_MQ_hd_fixed_size (tunnel_create,
+                          GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_CREATE,
+                          struct GNUNET_CADET_TunnelCreateMessage,
                           NULL),
- GNUNET_MQ_hd_fixed_size (channel_destroy,
-                          GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY,
-                          struct GNUNET_CADET_ChannelDestroyMessage,
+ GNUNET_MQ_hd_fixed_size (tunnel_destroy,
+                          GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_DESTROY,
+                          struct GNUNET_CADET_TunnelDestroyMessage,
                           NULL),
  GNUNET_MQ_hd_var_size (data,
                         GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA,
index b3bb85d85eb1beae155697275396153edb834dcf..25f02bf899ddd0725dfd7c5b22ed6a113cda5696 100644 (file)
@@ -166,6 +166,11 @@ struct CadetRoute;
  */
 struct CadetChannel;
 
+/**
+ * Handle to our configuration.
+ */
+extern const struct GNUNET_CONFIGURATION_Handle *cfg;
+
 /**
  * Handle to the statistics service.
  */
index 75ec81992f2b1e4db3d92665bb6df716c648aa55..aac0d604d188d46b728f3e12ebcb53d7ed5cc162 100644 (file)
@@ -25,7 +25,8 @@
  * @author Christian Grothoff
  *
  * TODO:
- * - handle destroy
+ * - introduce shutdown so we can have half-closed channels, modify
+ *   destroy to include MID to have FIN-ACK equivalents, etc.
  * - estimate max bandwidth using bursts and use to for CONGESTION CONTROL!
  * - check that '0xFFULL' really is sufficient for flow control!
  * - revisit handling of 'unreliable' traffic!
@@ -663,6 +664,8 @@ void
 GCCH_bind (struct CadetChannel *ch,
            struct CadetClient *c)
 {
+  struct GNUNET_MQ_Envelope *env;
+  struct GNUNET_CADET_TunnelCreateMessage *tcm;
   uint32_t options;
 
   if (NULL != ch->retry_task)
@@ -690,6 +693,14 @@ GCCH_bind (struct CadetChannel *ch,
   ch->retry_task = GNUNET_SCHEDULER_add_now (&send_connect_ack,
                                              ch);
   /* give client it's initial supply of ACKs */
+  env = GNUNET_MQ_msg (tcm,
+                       GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_CREATE);
+  tcm->channel_id = ch->lid;
+  tcm->peer = *GCP_get_id (GCT_get_destination (ch->t));
+  tcm->port = ch->port;
+  tcm->opt = htonl (options);
+  GSC_send_to_client (ch->dest,
+                      env);
   for (unsigned int i=0;i<ch->max_pending_messages;i++)
     send_ack_to_client (ch,
                         ch->owner);
@@ -956,19 +967,21 @@ GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch,
  * connection.  Also needs to remove this channel from
  * the tunnel.
  *
- * FIXME: need to make it possible to defer destruction until we have
- * received all messages up to the destroy, and right now the destroy
- * message (and this API) fails to give is the information we need!
- *
- * FIXME: also need to know if the other peer got a destroy from
- * us before!
- *
  * @param ch channel to destroy
  */
 void
 GCCH_handle_remote_destroy (struct CadetChannel *ch)
 {
-  GNUNET_break (0); // FIXME!
+  struct GNUNET_MQ_Envelope *env;
+  struct GNUNET_CADET_TunnelDestroyMessage *tdm;
+
+  ch->destroy = GNUNET_YES;
+  env = GNUNET_MQ_msg (tdm,
+                       GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_DESTROY);
+  tdm->channel_id = ch->lid;
+  GSC_send_to_client ((NULL != ch->owner) ? ch->owner : ch->dest,
+                      env);
+  channel_destroy (ch);
 }
 
 
index 9d4635021c93749d2b8d636fe4f11af32641b528..d705cdd5f1d66e9d34bc1b2a79f7a8a5c6b1bb13 100644 (file)
      Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
      Boston, MA 02110-1301, USA.
 */
-
+/**
+ * @file cadet/gnunet-service-cadet-new_hello.c
+ * @brief spread knowledge about how to contact other peers from PEERINFO
+ * @author Bartlomiej Polot
+ * @author Christian Grothoff
+ *
+ * TODO:
+ * - is most of this necessary/helpful?
+ * - should we not simply restrict this to OUR hello?
+ */
 #include "platform.h"
 #include "gnunet_util_lib.h"
 
@@ -83,7 +92,6 @@ got_hello (void *cls,
                   GNUNET_YES);
   GCP_set_hello (peer,
                  hello);
-
 }
 
 
index 47f725e09c64824c7084c74711d055d0ad18022c..1cb79a02f51855cfc46c97057a9412fc6c54c569 100644 (file)
@@ -26,7 +26,6 @@
  * @author Christian Grothoff
  *
  * TODO:
- * - implement GCP_set_hello() / do HELLO advertising properly
  * - optimize stopping/restarting DHT search to situations
  *   where we actually need it (i.e. not if we have a direct connection,
  *   or if we already have plenty of good short ones, or maybe even
@@ -904,22 +903,37 @@ GCP_iterate_paths_at (struct CadetPeer *peer,
 /**
  * Get the tunnel towards a peer.
  *
- * @param peer Peer to get from.
+ * @param cp Peer to get from.
  * @param create #GNUNET_YES to create a tunnel if we do not have one
  * @return Tunnel towards peer.
  */
 struct CadetTunnel *
-GCP_get_tunnel (struct CadetPeer *peer,
+GCP_get_tunnel (struct CadetPeer *cp,
                 int create)
 {
-  if (NULL == peer)
+  if (NULL == cp)
     return NULL;
-  if ( (NULL != peer->t) ||
+  if ( (NULL != cp->t) ||
        (GNUNET_NO == create) )
-    return peer->t;
-  peer->t = GCT_create_tunnel (peer);
-  consider_peer_activate (peer);
-  return peer->t;
+    return cp->t;
+  cp->t = GCT_create_tunnel (cp);
+  consider_peer_activate (cp);
+  return cp->t;
+}
+
+
+/**
+ * Hello offer was passed to the transport service. Mark it
+ * as done.
+ *
+ * @param cls the `struct CadetPeer` where the offer completed
+ */
+static void
+hello_offer_done (void *cls)
+{
+  struct CadetPeer *cp = cls;
+
+  cp->hello_offer = NULL;
 }
 
 
@@ -927,16 +941,39 @@ GCP_get_tunnel (struct CadetPeer *peer,
  * We got a HELLO for a @a peer, remember it, and possibly
  * trigger adequate actions (like trying to connect).
  *
- * @param peer the peer we got a HELLO for
+ * @param cp the peer we got a HELLO for
  * @param hello the HELLO to remember
  */
 void
-GCP_set_hello (struct CadetPeer *peer,
+GCP_set_hello (struct CadetPeer *cp,
                const struct GNUNET_HELLO_Message *hello)
 {
-  /* FIXME: keep HELLO, possibly offer to TRANSPORT... */
+  struct GNUNET_HELLO_Message *mrg;
 
-  consider_peer_destroy (peer);
+  if (NULL != cp->hello_offer)
+  {
+    GNUNET_TRANSPORT_offer_hello_cancel (cp->hello_offer);
+    cp->hello_offer = NULL;
+  }
+  if (NULL != cp->hello)
+  {
+    mrg = GNUNET_HELLO_merge (hello,
+                              cp->hello);
+    GNUNET_free (cp->hello);
+    cp->hello = mrg;
+  }
+  else
+  {
+    cp->hello = GNUNET_memdup (hello,
+                               GNUNET_HELLO_size (hello));
+  }
+  cp->hello_offer
+    = GNUNET_TRANSPORT_offer_hello (cfg,
+                                    GNUNET_HELLO_get_header (cp->hello) ,
+                                    &hello_offer_done,
+                                    cp);
+  /* New HELLO means cp's destruction time may change... */
+  consider_peer_destroy (cp);
 }
 
 
@@ -944,16 +981,16 @@ GCP_set_hello (struct CadetPeer *peer,
  * The tunnel to the given peer no longer exists, remove it from our
  * data structures, and possibly clean up the peer itself.
  *
- * @param peer the peer affected
+ * @param cp the peer affected
  * @param t the dead tunnel
  */
 void
-GCP_drop_tunnel (struct CadetPeer *peer,
+GCP_drop_tunnel (struct CadetPeer *cp,
                  struct CadetTunnel *t)
 {
-  GNUNET_assert (peer->t == t);
-  peer->t = NULL;
-  consider_peer_destroy (peer);
+  GNUNET_assert (cp->t == t);
+  cp->t = NULL;
+  consider_peer_destroy (cp);
 }
 
 
index c633f47e5d28e75d5512126b7416e1fbd73a92e9..b59a43b861f6c013c098398fc46d3f7aea026397 100644 (file)
@@ -123,14 +123,14 @@ GCP_iterate_paths (struct CadetPeer *cp,
  * Iterate over the paths to @a peer where
  * @a peer is at distance @a dist from us.
  *
- * @param peer Peer to get path info.
+ * @param cp Peer to get path info.
  * @param dist desired distance of @a peer to us on the path
  * @param callback Function to call for every path.
  * @param callback_cls Closure for @a callback.
  * @return Number of iterated paths.
  */
 unsigned int
-GCP_iterate_paths_at (struct CadetPeer *peer,
+GCP_iterate_paths_at (struct CadetPeer *cp,
                       unsigned int dist,
                       GCP_PathIterator callback,
                       void *callback_cls);
index 8f1a19d5bdd03caa4cef8742d480f7d382bb09a5..a6502de0198fd0a7adb74588a1579bc125a8518d 100644 (file)
@@ -1724,6 +1724,7 @@ handle_plaintext_keepalive (void *cls,
                             const struct GNUNET_MessageHeader *msg)
 {
   struct CadetTunnel *t = cls;
+
   GNUNET_break (0); // FIXME
 }
 
index dee0c37d7390fe211fbf2d2f4c0bf5d34ccb09d1..750acd8fdafc80b14cee411ad49f77cdc0f7dcef 100644 (file)
@@ -1308,17 +1308,18 @@ handle_loopback (struct CadetChannel *ch,
       break;
 
     case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK:
-      GCCH_handle_data_ack (ch, (struct GNUNET_CADET_ChannelDataAckMessage *) msgh, fwd);
+      GCCH_handle_data_ack (ch,
+                            (const struct GNUNET_CADET_ChannelDataAckMessage *) msgh, fwd);
       break;
 
     case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN:
       GCCH_handle_create (ch->t,
-                          (struct GNUNET_CADET_ChannelOpenMessage *) msgh);
+                          (const struct GNUNET_CADET_ChannelOpenMessage *) msgh);
       break;
 
     case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK:
       GCCH_handle_ack (ch,
-                       (struct GNUNET_CADET_ChannelManageMessage *) msgh,
+                       (const struct GNUNET_CADET_ChannelManageMessage *) msgh,
                        fwd);
       break;
 
@@ -1328,7 +1329,7 @@ handle_loopback (struct CadetChannel *ch,
 
     case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY:
       GCCH_handle_destroy (ch,
-                           (struct GNUNET_CADET_ChannelManageMessage *) msgh,
+                           (const struct GNUNET_CADET_ChannelManageMessage *) msgh,
                            fwd);
       break;
 
@@ -1842,11 +1843,11 @@ GCCH_handle_local_destroy (struct CadetChannel *ch,
  * @param c Client that requested the creation (will be the root).
  * @param msg Create Channel message.
  *
- * @return GNUNET_OK if everything went fine, GNUNET_SYSERR otherwise.
+ * @return #GNUNET_OK if everything went fine, #GNUNET_SYSERR otherwise.
  */
 int
 GCCH_handle_local_create (struct CadetClient *c,
-                          struct GNUNET_CADET_ChannelOpenMessageMessage *msg)
+                          struct GNUNET_CADET_TunnelCreateMessage *msg)
 {
   struct CadetChannel *ch;
   struct CadetTunnel *t;
index 855d85b6c317413cc3cd33ed7197deb8a51112ee..e3926995f5cd135db15e6f9a3663fe632ec8663d 100644 (file)
@@ -226,7 +226,7 @@ GCCH_handle_local_destroy (struct CadetChannel *ch,
  */
 int
 GCCH_handle_local_create (struct CadetClient *c,
-                          struct GNUNET_CADET_ChannelOpenMessageMessage *msg);
+                          struct GNUNET_CADET_TunnelCreateMessage *msg);
 
 /**
  * Handler for cadet network payload traffic.
index c476f6ac269d33a58cc75b87de9cb8213143f03c..bfb4195a5bb61b57aa1d04bda47889da1ee9fe38 100644 (file)
@@ -440,7 +440,7 @@ handle_channel_create (void *cls, struct GNUNET_SERVER_Client *client,
   LOG (GNUNET_ERROR_TYPE_DEBUG, "  by client %u\n", c->id);
 
   /* Message size sanity check */
-  if (sizeof (struct GNUNET_CADET_ChannelOpenMessageMessage)
+  if (sizeof (struct GNUNET_CADET_TunnelCreateMessage)
       != ntohs (message->size))
   {
     GNUNET_break (0);
@@ -450,7 +450,7 @@ handle_channel_create (void *cls, struct GNUNET_SERVER_Client *client,
 
   if (GNUNET_OK !=
       GCCH_handle_local_create (c,
-                                (struct GNUNET_CADET_ChannelOpenMessageMessage *)
+                                (struct GNUNET_CADET_TunnelCreateMessage *)
                                 message))
   {
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
@@ -472,7 +472,7 @@ static void
 handle_channel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
                         const struct GNUNET_MessageHeader *message)
 {
-  struct GNUNET_CADET_ChannelDestroyMessage *msg;
+  const struct GNUNET_CADET_TunnelDestroyMessage *msg;
   struct CadetClient *c;
   struct CadetChannel *ch;
   struct GNUNET_CADET_ClientChannelNumber chid;
@@ -489,7 +489,7 @@ handle_channel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
   LOG (GNUNET_ERROR_TYPE_DEBUG, "  by client %u\n", c->id);
 
   /* Message sanity check */
-  if (sizeof (struct GNUNET_CADET_ChannelDestroyMessage)
+  if (sizeof (struct GNUNET_CADET_TunnelDestroyMessage)
       != ntohs (message->size))
   {
     GNUNET_break (0);
@@ -497,7 +497,7 @@ handle_channel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
     return;
   }
 
-  msg = (struct GNUNET_CADET_ChannelDestroyMessage *) message;
+  msg = (const struct GNUNET_CADET_TunnelDestroyMessage *) message;
 
   /* Retrieve tunnel */
   chid = msg->channel_id;
@@ -521,7 +521,6 @@ handle_channel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
                              ntohl (chid.channel_of_client) < GNUNET_CADET_LOCAL_CHANNEL_ID_CLI);
 
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
-  return;
 }
 
 
@@ -1128,10 +1127,10 @@ static struct GNUNET_SERVER_MessageHandler client_handlers[] = {
     sizeof (struct GNUNET_CADET_PortMessage)},
   {&handle_port_close, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE,
     sizeof (struct GNUNET_CADET_PortMessage)},
-  {&handle_channel_create, NULL, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN,
-   sizeof (struct GNUNET_CADET_ChannelOpenMessageMessage)},
-  {&handle_channel_destroy, NULL, GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY,
-   sizeof (struct GNUNET_CADET_ChannelDestroyMessage)},
+  {&handle_channel_create, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_CREATE,
+   sizeof (struct GNUNET_CADET_TunnelCreateMessage)},
+  {&handle_channel_destroy, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_DESTROY,
+   sizeof (struct GNUNET_CADET_TunnelDestroyMessage)},
   {&handle_data, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA, 0},
   {&handle_ack, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK,
    sizeof (struct GNUNET_CADET_LocalAck)},
@@ -1434,10 +1433,10 @@ GML_send_channel_create (struct CadetClient *c,
                          uint32_t opt,
                          const struct GNUNET_PeerIdentity *peer)
 {
-  struct GNUNET_CADET_ChannelOpenMessageMessage msg;
+  struct GNUNET_CADET_TunnelCreateMessage msg;
 
   msg.header.size = htons (sizeof (msg));
-  msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN);
+  msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_CREATE);
   msg.channel_id = id;
   msg.port = *port;
   msg.opt = htonl (opt);
@@ -1484,7 +1483,7 @@ void
 GML_send_channel_destroy (struct CadetClient *c,
                           struct GNUNET_CADET_ClientChannelNumber id)
 {
-  struct GNUNET_CADET_ChannelDestroyMessage msg;
+  struct GNUNET_CADET_TunnelDestroyMessage msg;
 
   if (NULL == c)
   {
@@ -1494,7 +1493,7 @@ GML_send_channel_destroy (struct CadetClient *c,
   if (GNUNET_YES == c->shutting_down)
     return;
   msg.header.size = htons (sizeof (msg));
-  msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY);
+  msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_DESTROY);
   msg.channel_id = id;
   GNUNET_SERVER_notification_context_unicast (nc, c->handle,
                                               &msg.header, GNUNET_NO);
index e8f5ead37239a0f6e3fca428cf29db1a94ad12da..cae19d5d82b1db578d60bfbcb0f4301233baa7eb 100644 (file)
@@ -2732,6 +2732,16 @@ extern "C"
  */
 #define GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE 1023
 
+/**
+ * Ask the cadet service to create a new channel.
+ */
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_CREATE 1024
+
+/**
+ * Tell client that a channel was destroyed.
+ */
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_TUNNEL_DESTROY 1025
+
 /**********************************  Monitor  *********************************/