aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/mesh_api_new.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesh/mesh_api_new.c')
-rw-r--r--src/mesh/mesh_api_new.c67
1 files changed, 33 insertions, 34 deletions
diff --git a/src/mesh/mesh_api_new.c b/src/mesh/mesh_api_new.c
index 83ac2a818..f765aca1c 100644
--- a/src/mesh/mesh_api_new.c
+++ b/src/mesh/mesh_api_new.c
@@ -239,18 +239,20 @@ send_connect_packet (void *cls, size_t size, void *buf)
239 239
240 for (napps = 0, apps = NULL; napps < h->n_applications; napps++) 240 for (napps = 0, apps = NULL; napps < h->n_applications; napps++)
241 { 241 {
242 apps = GNUNET_realloc (apps, 242 apps =
243 sizeof (GNUNET_MESH_ApplicationType) * (napps + 1)); 243 GNUNET_realloc (apps,
244 sizeof (GNUNET_MESH_ApplicationType) * (napps + 1));
244 apps[napps] = h->applications[napps]; 245 apps[napps] = h->applications[napps];
245 } 246 }
246 247
247 msg->header.size = htons (sizeof (struct GNUNET_MESH_ClientConnect) + 248 msg->header.size =
248 sizeof (uint16_t) * ntypes + 249 htons (sizeof (struct GNUNET_MESH_ClientConnect) +
249 sizeof (GNUNET_MESH_ApplicationType) * napps); 250 sizeof (uint16_t) * ntypes +
251 sizeof (GNUNET_MESH_ApplicationType) * napps);
250 252
251 memcpy (&msg[1], types, sizeof (uint16_t) * ntypes); 253 memcpy (&msg[1], types, sizeof (uint16_t) * ntypes);
252 memcpy (&msg[1] + sizeof (uint16_t) * ntypes, 254 memcpy (&msg[1] + sizeof (uint16_t) * ntypes, apps,
253 apps, sizeof (GNUNET_MESH_ApplicationType) * napps); 255 sizeof (GNUNET_MESH_ApplicationType) * napps);
254 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 256 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
255 "Sent %lu bytes long message %d types and %d apps\n", 257 "Sent %lu bytes long message %d types and %d apps\n",
256 ntohs (msg->header.size), ntypes, napps); 258 ntohs (msg->header.size), ntypes, napps);
@@ -303,8 +305,8 @@ send_tunnel_create_packet (void *cls, size_t size, void *buf)
303 msg->header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage)); 305 msg->header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage));
304 msg->tunnel_id = htonl (t->tid); 306 msg->tunnel_id = htonl (t->tid);
305 307
306 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 308 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent %lu bytes long message\n",
307 "Sent %lu bytes long message\n", ntohs (msg->header.size)); 309 ntohs (msg->header.size));
308 310
309 return ntohs (msg->header.size); 311 return ntohs (msg->header.size);
310} 312}
@@ -502,8 +504,8 @@ msg_received (void *cls, const struct GNUNET_MessageHeader *msg)
502 } 504 }
503 505
504 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "received a message from mesh\n"); 506 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "received a message from mesh\n");
505 GNUNET_CLIENT_receive (h->client, 507 GNUNET_CLIENT_receive (h->client, &msg_received, h,
506 &msg_received, h, GNUNET_TIME_UNIT_FOREVER_REL); 508 GNUNET_TIME_UNIT_FOREVER_REL);
507 return; 509 return;
508} 510}
509 511
@@ -527,8 +529,7 @@ msg_received (void *cls, const struct GNUNET_MessageHeader *msg)
527 * NULL on error (in this case, init is never called) 529 * NULL on error (in this case, init is never called)
528 */ 530 */
529struct GNUNET_MESH_Handle * 531struct GNUNET_MESH_Handle *
530GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 532GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls,
531 void *cls,
532 GNUNET_MESH_TunnelEndHandler cleaner, 533 GNUNET_MESH_TunnelEndHandler cleaner,
533 const struct GNUNET_MESH_MessageHandler *handlers, 534 const struct GNUNET_MESH_MessageHandler *handlers,
534 const GNUNET_MESH_ApplicationType *stypes) 535 const GNUNET_MESH_ApplicationType *stypes)
@@ -540,8 +541,8 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
540 541
541 h->cleaner = cleaner; 542 h->cleaner = cleaner;
542 h->client = GNUNET_CLIENT_connect ("mesh", cfg); 543 h->client = GNUNET_CLIENT_connect ("mesh", cfg);
543 GNUNET_CLIENT_receive (h->client, 544 GNUNET_CLIENT_receive (h->client, &msg_received, h,
544 &msg_received, h, GNUNET_TIME_UNIT_FOREVER_REL); 545 GNUNET_TIME_UNIT_FOREVER_REL);
545 if (h->client == NULL) 546 if (h->client == NULL)
546 { 547 {
547 GNUNET_free (h); 548 GNUNET_free (h);
@@ -560,12 +561,11 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
560 size += h->n_handlers * sizeof (uint16_t); 561 size += h->n_handlers * sizeof (uint16_t);
561 size += h->n_applications * sizeof (GNUNET_MESH_ApplicationType); 562 size += h->n_applications * sizeof (GNUNET_MESH_ApplicationType);
562 563
563 h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, 564 h->th =
564 size, 565 GNUNET_CLIENT_notify_transmit_ready (h->client, size,
565 GNUNET_TIME_UNIT_FOREVER_REL, 566 GNUNET_TIME_UNIT_FOREVER_REL,
566 GNUNET_YES, 567 GNUNET_YES, &send_connect_packet,
567 &send_connect_packet, 568 (void *) h);
568 (void *) h);
569 569
570 return h; 570 return h;
571} 571}
@@ -602,8 +602,7 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle)
602 */ 602 */
603struct GNUNET_MESH_Tunnel * 603struct GNUNET_MESH_Tunnel *
604GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, 604GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h,
605 GNUNET_MESH_TunnelConnectHandler 605 GNUNET_MESH_TunnelConnectHandler connect_handler,
606 connect_handler,
607 GNUNET_MESH_TunnelDisconnectHandler 606 GNUNET_MESH_TunnelDisconnectHandler
608 disconnect_handler, void *handler_cls) 607 disconnect_handler, void *handler_cls)
609{ 608{
@@ -619,13 +618,14 @@ GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h,
619 tunnel->tid = h->next_tid++; 618 tunnel->tid = h->next_tid++;
620 h->next_tid |= GNUNET_MESH_LOCAL_TUNNEL_ID_MARK; // keep in range 619 h->next_tid |= GNUNET_MESH_LOCAL_TUNNEL_ID_MARK; // keep in range
621 620
622 h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, 621 h->th =
623 sizeof (struct 622 GNUNET_CLIENT_notify_transmit_ready (h->client,
624 GNUNET_MESH_TunnelMessage), 623 sizeof (struct
625 GNUNET_TIME_UNIT_FOREVER_REL, 624 GNUNET_MESH_TunnelMessage),
626 GNUNET_YES, 625 GNUNET_TIME_UNIT_FOREVER_REL,
627 &send_tunnel_create_packet, 626 GNUNET_YES,
628 (void *) tunnel); 627 &send_tunnel_create_packet,
628 (void *) tunnel);
629 629
630 return tunnel; 630 return tunnel;
631} 631}
@@ -714,14 +714,13 @@ GNUNET_MESH_peer_request_connect_by_type (struct GNUNET_MESH_Tunnel *tunnel,
714 * memory); if NULL is returned, "notify" will NOT be called. 714 * memory); if NULL is returned, "notify" will NOT be called.
715 */ 715 */
716struct GNUNET_MESH_TransmitHandle * 716struct GNUNET_MESH_TransmitHandle *
717GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, 717GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, int cork,
718 int cork,
719 uint32_t priority, 718 uint32_t priority,
720 struct GNUNET_TIME_Relative maxdelay, 719 struct GNUNET_TIME_Relative maxdelay,
721 const struct GNUNET_PeerIdentity *target, 720 const struct GNUNET_PeerIdentity *target,
722 size_t notify_size, 721 size_t notify_size,
723 GNUNET_CONNECTION_TransmitReadyNotify 722 GNUNET_CONNECTION_TransmitReadyNotify notify,
724 notify, void *notify_cls) 723 void *notify_cls)
725{ 724{
726 struct GNUNET_MESH_TransmitHandle *handle; 725 struct GNUNET_MESH_TransmitHandle *handle;
727 726