- move get channel to local
authorBart Polot <bart@net.in.tum.de>
Wed, 9 Oct 2013 08:57:48 +0000 (08:57 +0000)
committerBart Polot <bart@net.in.tum.de>
Wed, 9 Oct 2013 08:57:48 +0000 (08:57 +0000)
src/mesh/gnunet-service-mesh_channel.c
src/mesh/gnunet-service-mesh_local.c
src/mesh/gnunet-service-mesh_local.h

index 7802e34a034798726d646687c496ed66c31290fc..933949b1689ef91d76b887c88f53891ab45ca039 100644 (file)
@@ -338,30 +338,6 @@ send_client_data (struct MeshChannel *ch,
 }
 
 
-/**
- * Search for a channel among the channels for a client
- *
- * @param c the client whose channels to search in
- * @param chid the local id of the channel
- *
- * @return channel handler, NULL if doesn't exist
- */
-static struct MeshChannel *
-channel_get_by_local_id (struct MeshClient *c, MESH_ChannelNumber chid)
-{
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "   -- get CHID %X\n", chid);
-  if (0 == (chid & GNUNET_MESH_LOCAL_CHANNEL_ID_CLI))
-  {
-    GNUNET_break_op (0);
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "CHID %X not a local chid\n", chid);
-    return NULL;
-  }
-  if (chid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV)
-    return GNUNET_CONTAINER_multihashmap32_get (c->incoming_channels, chid);
-  return GNUNET_CONTAINER_multihashmap32_get (c->own_channels, chid);
-}
-
-
 /**
  * Add a client to a channel, initializing all needed data structures.
  *
@@ -380,7 +356,7 @@ channel_add_client (struct MeshChannel *ch, struct MeshClient *c)
   }
 
   /* Assign local id as destination */
-  while (NULL != channel_get_by_local_id (c, t->next_local_chid))
+  while (NULL != GML_channel_get (c, t->next_local_chid))
     t->next_local_chid = (t->next_local_chid + 1) | GNUNET_MESH_LOCAL_CHANNEL_ID_SERV;
   ch->lid_dest = t->next_local_chid++;
   t->next_local_chid = t->next_local_chid | GNUNET_MESH_LOCAL_CHANNEL_ID_SERV;
@@ -985,7 +961,7 @@ channel_send_destroy (struct MeshChannel *ch)
               peer2s (ch->t->peer),
               ch->gid);
 
-  if (channel_is_terminal (ch, GNUNET_NO))
+  if (GMCH_is_terminal (ch, GNUNET_NO))
   {
     if (NULL != ch->root && GNUNET_NO == ch->root->shutting_down)
     {
@@ -999,7 +975,7 @@ channel_send_destroy (struct MeshChannel *ch)
     GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_NO);
   }
 
-  if (channel_is_terminal (ch, GNUNET_YES))
+  if (GMCH_is_terminal (ch, GNUNET_YES))
   {
     if (NULL != ch->dest && GNUNET_NO == ch->dest->shutting_down)
     {
@@ -1574,7 +1550,7 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
   LOG (GNUNET_ERROR_TYPE_DEBUG, "  %s\n",
        GNUNET_MESH_DEBUG_M2S (ntohs (message->type)));
   
-  if (channel_is_terminal (ch, fwd) || ch->t->peer->id == myid)
+  if (GMCH_is_terminal (ch, fwd) || ch->t->peer->id == myid)
   {
     GMT_handle_decrypted (ch->t, message, fwd);
     return;
index e7a30df0fdb045159f9ead308b821b5a180d46c6..9d7db28bc1d753dfaa8159a3fdde16b580df9f02 100644 (file)
@@ -848,6 +848,27 @@ GML_shutdown (void)
   }
 }
 
+/**
+ * Get a chennel from a client
+ *
+ * @param c the client to check
+ * @param chid Channel ID, must be local (> 0x800...)
+ *
+ * @return non-NULL if channel exists in the clients lists
+ */
+struct MeshChannel *
+GML_channel_get (struct MeshClient *c, MESH_ChannelNumber chid)
+{
+  if (0 == (chid & GNUNET_MESH_LOCAL_CHANNEL_ID_CLI))
+  {
+    GNUNET_break_op (0);
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "CHID %X not a local chid\n", chid);
+    return NULL;
+  }
+  if (chid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV)
+    return GNUNET_CONTAINER_multihashmap32_get (c->incoming_channels, chid);
+  return GNUNET_CONTAINER_multihashmap32_get (c->own_channels, chid);
+}
 
 /**
  * Check if client has registered with the service and has not disconnected
index 9c0069d0408ba2f891196a91827037ecbd04cd7b..22a8f8e6d5809941325ee1e9bf326f079f2f23cf 100644 (file)
@@ -71,6 +71,17 @@ GML_start (void);
 void
 GML_shutdown (void);
 
+/**
+ * Get a chennel from a client
+ *
+ * @param client the client to check
+ * @param chid Channel ID
+ *
+ * @return non-NULL if channel exists in the global DLL
+ */
+struct MeshChannel *
+GML_channel_get (struct MeshClient *client, uint32_t chid);
+
 /**
  * Check if client has registered with the service and has not disconnected
  *