gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r15177 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r15177 - gnunet/src/mesh
Date: Fri, 6 May 2011 19:05:44 +0200

Author: bartpolot
Date: 2011-05-06 19:05:44 +0200 (Fri, 06 May 2011)
New Revision: 15177

Modified:
   gnunet/src/mesh/mesh_api_new.c
   gnunet/src/mesh/test_mesh_api.c
Log:
WiP


Modified: gnunet/src/mesh/mesh_api_new.c
===================================================================
--- gnunet/src/mesh/mesh_api_new.c      2011-05-06 16:42:29 UTC (rev 15176)
+++ gnunet/src/mesh/mesh_api_new.c      2011-05-06 17:05:44 UTC (rev 15177)
@@ -54,6 +54,7 @@
      * Set of handlers used for processing incoming messages in the tunnels
      */
     const struct GNUNET_MESH_MessageHandler     *message_handlers;
+    int                                         n_handlers;
 
     /**
      * Set of applications that should be claimed to be offered at this node.
@@ -62,6 +63,7 @@
      * client application.
      */
     const GNUNET_MESH_ApplicationType           *applications;
+    int                                         n_applications;
 
     /**
      * Double linked list of the tunnels this client is connected to.
@@ -111,7 +113,7 @@
 };
 
 struct GNUNET_MESH_TransmitHandle {
-    
+    // TODO
 };
 
 
@@ -193,22 +195,36 @@
                      const struct GNUNET_MESH_MessageHandler *handlers,
                      const GNUNET_MESH_ApplicationType *stypes) {
     struct GNUNET_MESH_Handle           *h;
+    size_t                              size;
 
     h = GNUNET_malloc(sizeof(struct GNUNET_MESH_Handle));
 
+
     h->cleaner = cleaner;
     h->mesh = GNUNET_CLIENT_connect("mesh", cfg);
+    if(h->mesh == NULL) {
+        GNUNET_free(h);
+        return NULL;
+    }
     h->cls = cls;
     h->message_handlers = handlers;
     h->applications = stypes;
 
+    for(h->n_handlers = 0; handlers[h->n_handlers].type; h->n_handlers++);
+    for(h->n_applications = 0; stypes[h->n_applications]; h->n_applications++);
+    h->n_handlers--;
+    h->n_applications--;
+
+    size = sizeof(struct GNUNET_MESH_ClientConnect);
+    size += h->n_handlers * sizeof(uint16_t);
+    size += h->n_applications * sizeof(GNUNET_MESH_ApplicationType);
+
     GNUNET_CLIENT_notify_transmit_ready(h->mesh,
-                                        sizeof(int),
+                                        size,
                                         GNUNET_TIME_relative_get_forever(),
                                         GNUNET_YES,
                                         &send_connect_packet,
-                                        (void *)h
-                                       );
+                                        (void *)h);
 
     return h;
 }

Modified: gnunet/src/mesh/test_mesh_api.c
===================================================================
--- gnunet/src/mesh/test_mesh_api.c     2011-05-06 16:42:29 UTC (rev 15176)
+++ gnunet/src/mesh/test_mesh_api.c     2011-05-06 17:05:44 UTC (rev 15177)
@@ -1,3 +1,38 @@
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_mesh_service_new.h"
+
+static struct GNUNET_MESH_MessageHandler handlers[] = {
+    {NULL, 0, 0}
+};
+
 int main (int argc, char *argv[]) {
-  return 0;
+    struct GNUNET_OS_Process            *arm_pid;
+    struct GNUNET_MESH_Handle           *mesh;
+//     struct GNUNET_MESH_Tunnel           *t;
+    struct GNUNET_CONFIGURATION_Handle  *cfg;
+
+    cfg = GNUNET_CONFIGURATION_create();
+
+    arm_pid = GNUNET_OS_start_process (NULL, NULL,
+                                       "gnunet-service-arm",
+                                       "gnunet-service-arm",
+                                       "-L", "DEBUG",
+                                       NULL);
+    mesh = GNUNET_MESH_connect(cfg, NULL, NULL, handlers, NULL);
+    if(NULL == mesh) {
+        fprintf(stderr, "Couldn't connect to mesh :(\n");
+//         return 1; // succeed anyway
+    }
+    mesh = realloc(mesh, 0); // don't complain about *mesh
+//     printf("MESH TEST\n");
+//     t = GNUNET_MESH_tunnel_create(mesh, );
+
+    /* do real test work here */
+    if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM))
+        GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
+    GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (arm_pid));
+    GNUNET_OS_process_close (arm_pid);
+
+    return 0;
 }




reply via email to

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