aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 {
54 * Set of handlers used for processing incoming messages in the tunnels 54 * Set of handlers used for processing incoming messages in the tunnels
55 */ 55 */
56 const struct GNUNET_MESH_MessageHandler *message_handlers; 56 const struct GNUNET_MESH_MessageHandler *message_handlers;
57 int n_handlers;
57 58
58 /** 59 /**
59 * Set of applications that should be claimed to be offered at this node. 60 * Set of applications that should be claimed to be offered at this node.
@@ -62,6 +63,7 @@ struct GNUNET_MESH_Handle {
62 * client application. 63 * client application.
63 */ 64 */
64 const GNUNET_MESH_ApplicationType *applications; 65 const GNUNET_MESH_ApplicationType *applications;
66 int n_applications;
65 67
66 /** 68 /**
67 * Double linked list of the tunnels this client is connected to. 69 * Double linked list of the tunnels this client is connected to.
@@ -111,7 +113,7 @@ struct GNUNET_MESH_Tunnel {
111}; 113};
112 114
113struct GNUNET_MESH_TransmitHandle { 115struct GNUNET_MESH_TransmitHandle {
114 116 // TODO
115}; 117};
116 118
117 119
@@ -193,22 +195,36 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
193 const struct GNUNET_MESH_MessageHandler *handlers, 195 const struct GNUNET_MESH_MessageHandler *handlers,
194 const GNUNET_MESH_ApplicationType *stypes) { 196 const GNUNET_MESH_ApplicationType *stypes) {
195 struct GNUNET_MESH_Handle *h; 197 struct GNUNET_MESH_Handle *h;
198 size_t size;
196 199
197 h = GNUNET_malloc(sizeof(struct GNUNET_MESH_Handle)); 200 h = GNUNET_malloc(sizeof(struct GNUNET_MESH_Handle));
198 201
202
199 h->cleaner = cleaner; 203 h->cleaner = cleaner;
200 h->mesh = GNUNET_CLIENT_connect("mesh", cfg); 204 h->mesh = GNUNET_CLIENT_connect("mesh", cfg);
205 if(h->mesh == NULL) {
206 GNUNET_free(h);
207 return NULL;
208 }
201 h->cls = cls; 209 h->cls = cls;
202 h->message_handlers = handlers; 210 h->message_handlers = handlers;
203 h->applications = stypes; 211 h->applications = stypes;
204 212
213 for(h->n_handlers = 0; handlers[h->n_handlers].type; h->n_handlers++);
214 for(h->n_applications = 0; stypes[h->n_applications]; h->n_applications++);
215 h->n_handlers--;
216 h->n_applications--;
217
218 size = sizeof(struct GNUNET_MESH_ClientConnect);
219 size += h->n_handlers * sizeof(uint16_t);
220 size += h->n_applications * sizeof(GNUNET_MESH_ApplicationType);
221
205 GNUNET_CLIENT_notify_transmit_ready(h->mesh, 222 GNUNET_CLIENT_notify_transmit_ready(h->mesh,
206 sizeof(int), 223 size,
207 GNUNET_TIME_relative_get_forever(), 224 GNUNET_TIME_relative_get_forever(),
208 GNUNET_YES, 225 GNUNET_YES,
209 &send_connect_packet, 226 &send_connect_packet,
210 (void *)h 227 (void *)h);
211 );
212 228
213 return h; 229 return h;
214} 230}
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 @@
1#include "platform.h"
2#include "gnunet_util_lib.h"
3#include "gnunet_mesh_service_new.h"
4
5static struct GNUNET_MESH_MessageHandler handlers[] = {
6 {NULL, 0, 0}
7};
8
1int main (int argc, char *argv[]) { 9int main (int argc, char *argv[]) {
2 return 0; 10 struct GNUNET_OS_Process *arm_pid;
11 struct GNUNET_MESH_Handle *mesh;
12// struct GNUNET_MESH_Tunnel *t;
13 struct GNUNET_CONFIGURATION_Handle *cfg;
14
15 cfg = GNUNET_CONFIGURATION_create();
16
17 arm_pid = GNUNET_OS_start_process (NULL, NULL,
18 "gnunet-service-arm",
19 "gnunet-service-arm",
20 "-L", "DEBUG",
21 NULL);
22 mesh = GNUNET_MESH_connect(cfg, NULL, NULL, handlers, NULL);
23 if(NULL == mesh) {
24 fprintf(stderr, "Couldn't connect to mesh :(\n");
25// return 1; // succeed anyway
26 }
27 mesh = realloc(mesh, 0); // don't complain about *mesh
28// printf("MESH TEST\n");
29// t = GNUNET_MESH_tunnel_create(mesh, );
30
31 /* do real test work here */
32 if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM))
33 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
34 GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (arm_pid));
35 GNUNET_OS_process_close (arm_pid);
36
37 return 0;
3} 38}