diff options
Diffstat (limited to 'src/mesh/mesh_api_new.c')
-rw-r--r-- | src/mesh/mesh_api_new.c | 24 |
1 files changed, 20 insertions, 4 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 | ||
113 | struct GNUNET_MESH_TransmitHandle { | 115 | struct 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 | } |