summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-05-06 17:05:44 +0000
committerBart Polot <bart@net.in.tum.de>2011-05-06 17:05:44 +0000
commit6ed107622e537d73eb5462feedc7700dfeba5b5b (patch)
tree49a047f289d7aa3072c7bac649e22020e1bfb6e2 /src
parent3812cf28795be58bce2eabccfd8b6e004e6be291 (diff)
WiP
Diffstat (limited to 'src')
-rw-r--r--src/mesh/mesh_api_new.c24
-rw-r--r--src/mesh/test_mesh_api.c37
2 files changed, 56 insertions, 5 deletions
diff --git a/src/mesh/mesh_api_new.c b/src/mesh/mesh_api_new.c
index 6483e0c5b..597bf6c5e 100644
--- a/src/mesh/mesh_api_new.c
+++ b/src/mesh/mesh_api_new.c
@@ -54,6 +54,7 @@ struct GNUNET_MESH_Handle {
* 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 @@ struct GNUNET_MESH_Handle {
* 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_Tunnel {
};
struct GNUNET_MESH_TransmitHandle {
-
+ // TODO
};
@@ -193,22 +195,36 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
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;
}
diff --git a/src/mesh/test_mesh_api.c b/src/mesh/test_mesh_api.c
index 63a62a1e1..04e3a4388 100644
--- a/src/mesh/test_mesh_api.c
+++ b/src/mesh/test_mesh_api.c
@@ -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;
}