diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/mesh/mesh_api.c | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/mesh/mesh_api.c')
-rw-r--r-- | src/mesh/mesh_api.c | 77 |
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 | ||
173 | static void | 173 | static void |
174 | core_startup (void *cls, | 174 | core_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 | */ |
217 | static void | 217 | static void |
218 | core_connect (void *cls, | 218 | core_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 | */ |
349 | static int | 345 | static int |
350 | receive_hello (void *cls, | 346 | receive_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 | */ |
436 | static int | 431 | static int |
437 | core_receive (void *cls, | 432 | core_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 | ||
514 | struct GNUNET_MESH_Tunnel * | 508 | struct 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 | */ |
693 | struct GNUNET_MESH_TransmitHandle * | 687 | struct GNUNET_MESH_TransmitHandle * |
694 | GNUNET_MESH_notify_transmit_ready (struct | 688 | GNUNET_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 | ||
808 | struct GNUNET_MESH_Handle * | 797 | struct GNUNET_MESH_Handle * |
809 | GNUNET_MESH_connect (const struct | 798 | GNUNET_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 | ||