aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/mesh_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/mesh/mesh_api.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/mesh/mesh_api.c')
-rw-r--r--src/mesh/mesh_api.c77
1 files changed, 29 insertions, 48 deletions
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c
index 1ccd31dfe..3a50e44ee 100644
--- a/src/mesh/mesh_api.c
+++ b/src/mesh/mesh_api.c
@@ -171,8 +171,8 @@ call_connect_handler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
171} 171}
172 172
173static void 173static void
174core_startup (void *cls, 174core_startup (void *cls, struct GNUNET_CORE_Handle *core
175 struct GNUNET_CORE_Handle *core __attribute__ ((unused)), 175 __attribute__ ((unused)),
176 const struct GNUNET_PeerIdentity *my_identity, 176 const struct GNUNET_PeerIdentity *my_identity,
177 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey 177 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey
178 __attribute__ ((unused))) 178 __attribute__ ((unused)))
@@ -215,8 +215,7 @@ send_hello_message (void *cls, size_t size, void *buf)
215 * 215 *
216 */ 216 */
217static void 217static void
218core_connect (void *cls, 218core_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
219 const struct GNUNET_PeerIdentity *peer,
220 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 219 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
221{ 220{
222 struct GNUNET_MESH_Handle *handle = cls; 221 struct GNUNET_MESH_Handle *handle = cls;
@@ -225,11 +224,8 @@ core_connect (void *cls,
225 "Core tells us we are connected to peer %s\n", GNUNET_i2s (peer)); 224 "Core tells us we are connected to peer %s\n", GNUNET_i2s (peer));
226 225
227 /* Send a hello to this peer */ 226 /* Send a hello to this peer */
228 GNUNET_CORE_notify_transmit_ready (handle->core, 227 GNUNET_CORE_notify_transmit_ready (handle->core, GNUNET_NO, 42,
229 GNUNET_NO, 228 GNUNET_TIME_UNIT_SECONDS, peer,
230 42,
231 GNUNET_TIME_UNIT_SECONDS,
232 peer,
233 sizeof (struct GNUNET_MessageHeader) + 229 sizeof (struct GNUNET_MessageHeader) +
234 handle->hello_message_size, 230 handle->hello_message_size,
235 &send_hello_message, cls); 231 &send_hello_message, cls);
@@ -347,8 +343,7 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
347 * This is a hello-message, containing the application-types the other peer can receive 343 * This is a hello-message, containing the application-types the other peer can receive
348 */ 344 */
349static int 345static int
350receive_hello (void *cls, 346receive_hello (void *cls, const struct GNUNET_PeerIdentity *other,
351 const struct GNUNET_PeerIdentity *other,
352 const struct GNUNET_MessageHeader *message, 347 const struct GNUNET_MessageHeader *message,
353 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 348 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
354{ 349{
@@ -434,8 +429,7 @@ receive_hello (void *cls,
434 * Receive a message from core. 429 * Receive a message from core.
435 */ 430 */
436static int 431static int
437core_receive (void *cls, 432core_receive (void *cls, const struct GNUNET_PeerIdentity *other,
438 const struct GNUNET_PeerIdentity *other,
439 const struct GNUNET_MessageHeader *message, 433 const struct GNUNET_MessageHeader *message,
440 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 434 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
441{ 435{
@@ -448,9 +442,9 @@ core_receive (void *cls,
448 442
449 for (handler = handle->handlers; handler->callback != NULL; handler++) 443 for (handler = handle->handlers; handler->callback != NULL; handler++)
450 { 444 {
451 if ((ntohs (rmessage->type) == handler->type) 445 if ((ntohs (rmessage->type) == handler->type) &&
452 && ((handler->expected_size == 0) 446 ((handler->expected_size == 0) ||
453 || (handler->expected_size == ntohs (rmessage->size)))) 447 (handler->expected_size == ntohs (rmessage->size))))
454 { 448 {
455 break; 449 break;
456 } 450 }
@@ -474,10 +468,10 @@ core_receive (void *cls,
474 if (tunnel->tunnel.id.id == tmessage->id.id && 468 if (tunnel->tunnel.id.id == tmessage->id.id &&
475 (0 == 469 (0 ==
476 memcmp (&tmessage->id.initiator, &tunnel->tunnel.id.initiator, 470 memcmp (&tmessage->id.initiator, &tunnel->tunnel.id.initiator,
477 sizeof (struct GNUNET_PeerIdentity))) 471 sizeof (struct GNUNET_PeerIdentity))) &&
478 && (0 == 472 (0 ==
479 memcmp (&tmessage->id.target, &tunnel->tunnel.id.target, 473 memcmp (&tmessage->id.target, &tunnel->tunnel.id.target,
480 sizeof (struct GNUNET_PeerIdentity)))) 474 sizeof (struct GNUNET_PeerIdentity))))
481 break; 475 break;
482 tunnel = tunnel->next; 476 tunnel = tunnel->next;
483 } 477 }
@@ -507,8 +501,8 @@ core_receive (void *cls,
507 "Inbound message from peer %s; type %d.\n", GNUNET_i2s (other), 501 "Inbound message from peer %s; type %d.\n", GNUNET_i2s (other),
508 ntohs (rmessage->type)); 502 ntohs (rmessage->type));
509 503
510 return handler->callback (handle->cls, &tunnel->tunnel, 504 return handler->callback (handle->cls, &tunnel->tunnel, &tunnel->tunnel.ctx,
511 &tunnel->tunnel.ctx, other, rmessage, atsi); 505 other, rmessage, atsi);
512} 506}
513 507
514struct GNUNET_MESH_Tunnel * 508struct GNUNET_MESH_Tunnel *
@@ -691,19 +685,13 @@ core_notify (void *cls, size_t size, void *buf)
691 * memory); if NULL is returned, "notify" will NOT be called. 685 * memory); if NULL is returned, "notify" will NOT be called.
692 */ 686 */
693struct GNUNET_MESH_TransmitHandle * 687struct GNUNET_MESH_TransmitHandle *
694GNUNET_MESH_notify_transmit_ready (struct 688GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, int cork,
695 GNUNET_MESH_Tunnel
696 *tunnel,
697 int cork,
698 uint32_t priority, 689 uint32_t priority,
699 struct 690 struct GNUNET_TIME_Relative maxdelay,
700 GNUNET_TIME_Relative
701 maxdelay,
702 const struct GNUNET_PeerIdentity *target 691 const struct GNUNET_PeerIdentity *target
703 __attribute__ ((unused)), 692 __attribute__ ((unused)), size_t notify_size,
704 size_t notify_size, 693 GNUNET_CONNECTION_TransmitReadyNotify notify,
705 GNUNET_CONNECTION_TransmitReadyNotify 694 void *notify_cls)
706 notify, void *notify_cls)
707{ 695{
708 if (NULL != tunnel->notify_handle) 696 if (NULL != tunnel->notify_handle)
709 { 697 {
@@ -718,7 +706,8 @@ GNUNET_MESH_notify_transmit_ready (struct
718 cls->notify = notify; 706 cls->notify = notify;
719 cls->tunnel = tunnel; 707 cls->tunnel = tunnel;
720 708
721 tunnel->notify_handle = (struct GNUNET_MESH_TransmitHandle *) 709 tunnel->notify_handle =
710 (struct GNUNET_MESH_TransmitHandle *)
722 GNUNET_CORE_notify_transmit_ready (tunnel->handle->core, cork, priority, 711 GNUNET_CORE_notify_transmit_ready (tunnel->handle->core, cork, priority,
723 maxdelay, &tunnel->peer, 712 maxdelay, &tunnel->peer,
724 notify_size + 713 notify_size +
@@ -806,11 +795,8 @@ build_hello_message (struct GNUNET_MESH_Handle *handle,
806 795
807 796
808struct GNUNET_MESH_Handle * 797struct GNUNET_MESH_Handle *
809GNUNET_MESH_connect (const struct 798GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls,
810 GNUNET_CONFIGURATION_Handle 799 GNUNET_MESH_TunnelEndHandler cleaner,
811 *cfg, void *cls,
812 GNUNET_MESH_TunnelEndHandler
813 cleaner,
814 const struct GNUNET_MESH_MessageHandler *handlers, 800 const struct GNUNET_MESH_MessageHandler *handlers,
815 const GNUNET_MESH_ApplicationType *stypes) 801 const GNUNET_MESH_ApplicationType *stypes)
816{ 802{
@@ -845,15 +831,10 @@ GNUNET_MESH_connect (const struct
845 {NULL, 0, 0} 831 {NULL, 0, 0}
846 }; 832 };
847 833
848 ret->core = GNUNET_CORE_connect (cfg, 834 ret->core =
849 42, 835 GNUNET_CORE_connect (cfg, 42, ret, &core_startup, &core_connect,
850 ret, 836 &core_disconnect, NULL, NULL, GNUNET_NO, NULL,
851 &core_startup, 837 GNUNET_NO, core_handlers);
852 &core_connect,
853 &core_disconnect,
854 NULL,
855 NULL,
856 GNUNET_NO, NULL, GNUNET_NO, core_handlers);
857 return ret; 838 return ret;
858} 839}
859 840