-ftbfs
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh_local.c
index 989def2112fe8948d6037be3e16e4b37478f8e93..d8733cac7b0a74e077e319a278d692fc7026550c 100644 (file)
@@ -22,7 +22,9 @@
 #include "platform.h"
 #include "mesh_enc.h"
 #include "mesh_protocol_enc.h" // GNUNET_MESH_Data is shared
+
 #include "gnunet-service-mesh_local.h"
+#include "gnunet-service-mesh_tunnel.h"
 
 /******************************************************************************/
 /********************************   STRUCTS  **********************************/
@@ -30,7 +32,7 @@
 
 /**
  * Struct containing information about a client of the service
- * 
+ *
  * TODO: add a list of 'waiting' ports
  */
 struct MeshClient
@@ -157,8 +159,8 @@ client_release_ports (void *cls,
  * @param cls Closure (unused).
  * @param client Client handler.
  */
-void
-GMLH_client_connect (void *cls, struct GNUNET_SERVER_Client *client)
+static void
+handle_client_connect (void *cls, struct GNUNET_SERVER_Client *client)
 {
   struct MeshClient *c;
 
@@ -180,8 +182,8 @@ GMLH_client_connect (void *cls, struct GNUNET_SERVER_Client *client)
  * @param client identification of the client; NULL
  *        for the last call when the server is destroyed
  */
-void
-GMLH_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
+static void
+handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
 {
   struct MeshClient *c;
 
@@ -240,9 +242,9 @@ GMLH_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
  * @param client identification of the client
  * @param message the actual message, which includes messages the client wants
  */
-void
-GMLH_new_client (void *cls, struct GNUNET_SERVER_Client *client,
-                         const struct GNUNET_MessageHeader *message)
+static void
+handle_new_client (void *cls, struct GNUNET_SERVER_Client *client,
+                   const struct GNUNET_MessageHeader *message)
 {
   struct GNUNET_MESH_ClientConnect *cc_msg;
   struct MeshClient *c;
@@ -306,9 +308,9 @@ GMLH_new_client (void *cls, struct GNUNET_SERVER_Client *client,
  * @param client Identification of the client.
  * @param message The actual message.
  */
-void
-GMLH_channel_create (void *cls, struct GNUNET_SERVER_Client *client,
-                            const struct GNUNET_MessageHeader *message)
+static void
+handle_channel_create (void *cls, struct GNUNET_SERVER_Client *client,
+                       const struct GNUNET_MessageHeader *message)
 {
   struct GNUNET_MESH_ChannelMessage *msg;
   struct MeshPeer *peer;
@@ -394,7 +396,7 @@ GMLH_channel_create (void *cls, struct GNUNET_SERVER_Client *client,
     msgcc.port = msg->port;
     msgcc.opt = msg->opt;
 
-    tunnel_queue_data (t, ch, &msgcc.header, GNUNET_YES);
+    GMT_queue_data (t, ch, &msgcc.header, GNUNET_YES);
   }
 
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -409,9 +411,9 @@ GMLH_channel_create (void *cls, struct GNUNET_SERVER_Client *client,
  * @param client identification of the client
  * @param message the actual message
  */
-void
-GMLH_channel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
-                             const struct GNUNET_MessageHeader *message)
+static void
+handle_channel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
+                        const struct GNUNET_MessageHeader *message)
 {
   struct GNUNET_MESH_ChannelMessage *msg;
   struct MeshClient *c;
@@ -462,7 +464,7 @@ GMLH_channel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
   {
     ch->root = NULL;
   }
-  else 
+  else
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "  channel %X client %p (%p, %p)\n",
@@ -486,9 +488,9 @@ GMLH_channel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
  * @param client identification of the client
  * @param message the actual message
  */
-void
-GMLH_data (void *cls, struct GNUNET_SERVER_Client *client,
-                   const struct GNUNET_MessageHeader *message)
+static void
+handle_data (void *cls, struct GNUNET_SERVER_Client *client,
+             const struct GNUNET_MessageHeader *message)
 {
   struct GNUNET_MESH_LocalData *msg;
   struct MeshClient *c;
@@ -538,7 +540,7 @@ GMLH_data (void *cls, struct GNUNET_SERVER_Client *client,
            ch->root->handle == client)
          ||
           (!fwd &&
-           ch->dest && 
+           ch->dest &&
            ch->dest->handle == client) ) )
   {
     GNUNET_break (0);
@@ -584,9 +586,9 @@ GMLH_data (void *cls, struct GNUNET_SERVER_Client *client,
  * @param client Identification of the client.
  * @param message The actual message.
  */
-void
-GMLH_ack (void *cls, struct GNUNET_SERVER_Client *client,
-                  const struct GNUNET_MessageHeader *message)
+static void
+handle_ack (void *cls, struct GNUNET_SERVER_Client *client,
+            const struct GNUNET_MessageHeader *message)
 {
   struct GNUNET_MESH_LocalAck *msg;
   struct MeshChannelReliability *rel;
@@ -654,16 +656,16 @@ GMLH_ack (void *cls, struct GNUNET_SERVER_Client *client,
 //   struct GNUNET_SERVER_Client *client = cls;
 //   struct MeshChannel *ch = value;
 //   struct GNUNET_MESH_LocalMonitor *msg;
-// 
+//
 //   msg = GNUNET_malloc (sizeof(struct GNUNET_MESH_LocalMonitor));
 //   msg->channel_id = htonl (ch->gid);
 //   msg->header.size = htons (sizeof (struct GNUNET_MESH_LocalMonitor));
 //   msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS);
-// 
+//
 //   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
 //               "*  sending info about tunnel %s\n",
 //               GNUNET_i2s (&msg->owner));
-// 
+//
 //   GNUNET_SERVER_notification_context_unicast (nc, client,
 //                                               &msg->header, GNUNET_NO);
 //   return GNUNET_YES;
@@ -677,9 +679,9 @@ GMLH_ack (void *cls, struct GNUNET_SERVER_Client *client,
  * @param client Identification of the client.
  * @param message The actual message.
  */
-void
-GMLH_get_tunnels (void *cls, struct GNUNET_SERVER_Client *client,
-                          const struct GNUNET_MessageHeader *message)
+static void
+handle_get_tunnels (void *cls, struct GNUNET_SERVER_Client *client,
+                    const struct GNUNET_MessageHeader *message)
 {
   struct MeshClient *c;
 
@@ -712,8 +714,8 @@ GMLH_get_tunnels (void *cls, struct GNUNET_SERVER_Client *client,
  * @param message The actual message.
  */
 void
-GMLH_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client,
-                          const struct GNUNET_MessageHeader *message)
+handle_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client,
+                    const struct GNUNET_MessageHeader *message)
 {
   const struct GNUNET_MESH_LocalMonitor *msg;
   struct GNUNET_MESH_LocalMonitor *resp;
@@ -768,17 +770,17 @@ GMLH_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client,
  * Functions to handle messages from clients
  */
 static struct GNUNET_SERVER_MessageHandler client_handlers[] = {
-  {&GMLH_new_client, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT, 0},
-  {&GMLH_channel_create, NULL, GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE,
+  {&handle_new_client, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT, 0},
+  {&handle_channel_create, NULL, GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE,
    sizeof (struct GNUNET_MESH_ChannelMessage)},
-  {&GMLH_channel_destroy, NULL, GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY,
+  {&handle_channel_destroy, NULL, GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY,
    sizeof (struct GNUNET_MESH_ChannelMessage)},
-  {&GMLH_data, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA, 0},
-  {&GMLH_ack, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK,
+  {&handle_data, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA, 0},
+  {&handle_ack, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK,
    sizeof (struct GNUNET_MESH_LocalAck)},
-  {&GMLH_get_tunnels, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS,
+  {&handle_get_tunnels, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS,
    sizeof (struct GNUNET_MessageHeader)},
-  {&GMLH_show_tunnel, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL,
+  {&handle_show_tunnel, NULL, GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL,
    sizeof (struct GNUNET_MESH_LocalMonitor)},
   {NULL, NULL, 0, 0}
 };
@@ -802,6 +804,7 @@ GML_init (struct GNUNET_SERVER_Handle *handle)
   ports = GNUNET_CONTAINER_multihashmap32_create (32);
 }
 
+
 /**
  * Install server (service) handlers and start listening to clients.
  */
@@ -809,8 +812,8 @@ void
 GML_start (void)
 {
   GNUNET_SERVER_add_handlers (server_handle, client_handlers);
-  GNUNET_SERVER_connect_notify (server_handle,  &GMLH_client_connect, NULL);
-  GNUNET_SERVER_disconnect_notify (server_handle, &GMLH_client_disconnect,
+  GNUNET_SERVER_connect_notify (server_handle,  &handle_client_connect, NULL);
+  GNUNET_SERVER_disconnect_notify (server_handle, &handle_client_disconnect,
                                    NULL);
   nc = GNUNET_SERVER_notification_context_create (server_handle, 1);