diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-11-27 18:11:03 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-11-27 18:11:03 +0000 |
commit | 7faa62d0e03329190ad48489d09daa087c9456e2 (patch) | |
tree | 04572563db489c8ef2a7636acb8c488872931f1e /src/mesh/gnunet-service-mesh_connection.c | |
parent | 41dc74fc9ebb29931fc7f78cc2d3cef7eb1bee7b (diff) | |
download | gnunet-7faa62d0e03329190ad48489d09daa087c9456e2.tar.gz gnunet-7faa62d0e03329190ad48489d09daa087c9456e2.zip |
- revamp mesh_common code, minor refactoring
Diffstat (limited to 'src/mesh/gnunet-service-mesh_connection.c')
-rw-r--r-- | src/mesh/gnunet-service-mesh_connection.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index 73e947753..c08f64f6d 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c | |||
@@ -449,7 +449,7 @@ send_ack (struct MeshConnection *c, unsigned int buffer, int fwd, int force) | |||
449 | 449 | ||
450 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 450 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
451 | "connection send %s ack on %s\n", | 451 | "connection send %s ack on %s\n", |
452 | fwd ? "FWD" : "BCK", GMC_2s (c)); | 452 | GM_f2s (fwd), GMC_2s (c)); |
453 | 453 | ||
454 | /* Check if we need to transmit the ACK. */ | 454 | /* Check if we need to transmit the ACK. */ |
455 | delta = prev_fc->last_ack_sent - prev_fc->last_pid_recv; | 455 | delta = prev_fc->last_ack_sent - prev_fc->last_pid_recv; |
@@ -478,7 +478,7 @@ send_ack (struct MeshConnection *c, unsigned int buffer, int fwd, int force) | |||
478 | /* Check if message is already in queue */ | 478 | /* Check if message is already in queue */ |
479 | if (NULL != prev_fc->ack_msg) | 479 | if (NULL != prev_fc->ack_msg) |
480 | { | 480 | { |
481 | if (GMC_is_pid_bigger (ack, prev_fc->last_ack_sent)) | 481 | if (GM_is_pid_bigger (ack, prev_fc->last_ack_sent)) |
482 | { | 482 | { |
483 | LOG (GNUNET_ERROR_TYPE_DEBUG, " canceling old ACK\n"); | 483 | LOG (GNUNET_ERROR_TYPE_DEBUG, " canceling old ACK\n"); |
484 | GMC_cancel (prev_fc->ack_msg); | 484 | GMC_cancel (prev_fc->ack_msg); |
@@ -530,8 +530,8 @@ message_sent (void *cls, | |||
530 | fc = fwd ? &c->fwd_fc : &c->bck_fc; | 530 | fc = fwd ? &c->fwd_fc : &c->bck_fc; |
531 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 531 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
532 | "! sent %s %s\n", | 532 | "! sent %s %s\n", |
533 | fwd ? "FWD" : "BCK", | 533 | GM_f2s (fwd), |
534 | GNUNET_MESH_DEBUG_M2S (type)); | 534 | GM_m2s (type)); |
535 | LOG (GNUNET_ERROR_TYPE_DEBUG, "! C_P- %p %u\n", c, c->pending_messages); | 535 | LOG (GNUNET_ERROR_TYPE_DEBUG, "! C_P- %p %u\n", c, c->pending_messages); |
536 | if (NULL != q) | 536 | if (NULL != q) |
537 | { | 537 | { |
@@ -704,7 +704,7 @@ send_connection_ack (struct MeshConnection *connection, int fwd) | |||
704 | 704 | ||
705 | t = connection->t; | 705 | t = connection->t; |
706 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Send connection %s ACK\n", | 706 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Send connection %s ACK\n", |
707 | !fwd ? "FWD" : "BCK"); | 707 | !GM_f2s (fwd)); |
708 | GMP_queue_add (get_hop (connection, fwd), NULL, | 708 | GMP_queue_add (get_hop (connection, fwd), NULL, |
709 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK, | 709 | GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK, |
710 | sizeof (struct GNUNET_MESH_ConnectionACK), | 710 | sizeof (struct GNUNET_MESH_ConnectionACK), |
@@ -760,7 +760,7 @@ connection_keepalive (struct MeshConnection *c, int fwd) | |||
760 | 760 | ||
761 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 761 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
762 | "sending %s keepalive for connection %s]\n", | 762 | "sending %s keepalive for connection %s]\n", |
763 | fwd ? "FWD" : "BCK", GMC_2s (c)); | 763 | GM_f2s (fwd), GMC_2s (c)); |
764 | 764 | ||
765 | msg = (struct GNUNET_MESH_ConnectionKeepAlive *) cbuf; | 765 | msg = (struct GNUNET_MESH_ConnectionKeepAlive *) cbuf; |
766 | msg->header.size = htons (size); | 766 | msg->header.size = htons (size); |
@@ -876,7 +876,7 @@ connection_unlock_queue (struct MeshConnection *c, int fwd) | |||
876 | 876 | ||
877 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 877 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
878 | "connection_unlock_queue %s on %s\n", | 878 | "connection_unlock_queue %s on %s\n", |
879 | fwd ? "FWD" : "BCK", GMC_2s (c)); | 879 | GM_f2s (fwd), GMC_2s (c)); |
880 | 880 | ||
881 | if (GMC_is_terminal (c, fwd)) | 881 | if (GMC_is_terminal (c, fwd)) |
882 | { | 882 | { |
@@ -906,7 +906,7 @@ connection_cancel_queues (struct MeshConnection *c, int fwd) | |||
906 | 906 | ||
907 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 907 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
908 | " *** Cancel %s queues for connection %s\n", | 908 | " *** Cancel %s queues for connection %s\n", |
909 | fwd ? "FWD" : "BCK", GMC_2s (c)); | 909 | GM_f2s (fwd), GMC_2s (c)); |
910 | if (NULL == c) | 910 | if (NULL == c) |
911 | { | 911 | { |
912 | GNUNET_break (0); | 912 | GNUNET_break (0); |
@@ -1564,7 +1564,7 @@ handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer, | |||
1564 | type = ntohs (msg->header.type); | 1564 | type = ntohs (msg->header.type); |
1565 | LOG (GNUNET_ERROR_TYPE_DEBUG, "\n\n"); | 1565 | LOG (GNUNET_ERROR_TYPE_DEBUG, "\n\n"); |
1566 | LOG (GNUNET_ERROR_TYPE_DEBUG, "got a %s message (#%u) from %s\n", | 1566 | LOG (GNUNET_ERROR_TYPE_DEBUG, "got a %s message (#%u) from %s\n", |
1567 | GNUNET_MESH_DEBUG_M2S (type), ntohl (msg->pid), GNUNET_i2s (peer)); | 1567 | GM_m2s (type), ntohl (msg->pid), GNUNET_i2s (peer)); |
1568 | 1568 | ||
1569 | /* Check connection */ | 1569 | /* Check connection */ |
1570 | c = connection_get (&msg->cid); | 1570 | c = connection_get (&msg->cid); |
@@ -1602,7 +1602,7 @@ handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer, | |||
1602 | /* Check PID */ | 1602 | /* Check PID */ |
1603 | fc = fwd ? &c->bck_fc : &c->fwd_fc; | 1603 | fc = fwd ? &c->bck_fc : &c->fwd_fc; |
1604 | pid = ntohl (msg->pid); | 1604 | pid = ntohl (msg->pid); |
1605 | if (GMC_is_pid_bigger (pid, fc->last_ack_sent)) | 1605 | if (GM_is_pid_bigger (pid, fc->last_ack_sent)) |
1606 | { | 1606 | { |
1607 | GNUNET_STATISTICS_update (stats, "# unsolicited message", 1, GNUNET_NO); | 1607 | GNUNET_STATISTICS_update (stats, "# unsolicited message", 1, GNUNET_NO); |
1608 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1608 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1610,7 +1610,7 @@ handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer, | |||
1610 | pid, fc->last_pid_recv, fc->last_ack_sent); | 1610 | pid, fc->last_pid_recv, fc->last_ack_sent); |
1611 | return GNUNET_OK; | 1611 | return GNUNET_OK; |
1612 | } | 1612 | } |
1613 | if (GNUNET_NO == GMC_is_pid_bigger (pid, fc->last_pid_recv)) | 1613 | if (GNUNET_NO == GM_is_pid_bigger (pid, fc->last_pid_recv)) |
1614 | { | 1614 | { |
1615 | GNUNET_STATISTICS_update (stats, "# duplicate PID", 1, GNUNET_NO); | 1615 | GNUNET_STATISTICS_update (stats, "# duplicate PID", 1, GNUNET_NO); |
1616 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1616 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1691,7 +1691,7 @@ handle_mesh_kx (const struct GNUNET_PeerIdentity *peer, | |||
1691 | type = ntohs (msg->header.type); | 1691 | type = ntohs (msg->header.type); |
1692 | LOG (GNUNET_ERROR_TYPE_DEBUG, "\n\n"); | 1692 | LOG (GNUNET_ERROR_TYPE_DEBUG, "\n\n"); |
1693 | LOG (GNUNET_ERROR_TYPE_DEBUG, "got a %s message from %s\n", | 1693 | LOG (GNUNET_ERROR_TYPE_DEBUG, "got a %s message from %s\n", |
1694 | GNUNET_MESH_DEBUG_M2S (type), GNUNET_i2s (peer)); | 1694 | GM_m2s (type), GNUNET_i2s (peer)); |
1695 | 1695 | ||
1696 | /* Check connection */ | 1696 | /* Check connection */ |
1697 | c = connection_get (&msg->cid); | 1697 | c = connection_get (&msg->cid); |
@@ -1853,12 +1853,12 @@ GMC_handle_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1853 | ack = ntohl (msg->ack); | 1853 | ack = ntohl (msg->ack); |
1854 | LOG (GNUNET_ERROR_TYPE_DEBUG, " ACK %u (was %u)\n", | 1854 | LOG (GNUNET_ERROR_TYPE_DEBUG, " ACK %u (was %u)\n", |
1855 | ack, fc->last_ack_recv); | 1855 | ack, fc->last_ack_recv); |
1856 | if (GMC_is_pid_bigger (ack, fc->last_ack_recv)) | 1856 | if (GM_is_pid_bigger (ack, fc->last_ack_recv)) |
1857 | fc->last_ack_recv = ack; | 1857 | fc->last_ack_recv = ack; |
1858 | 1858 | ||
1859 | /* Cancel polling if the ACK is big enough. */ | 1859 | /* Cancel polling if the ACK is big enough. */ |
1860 | if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task && | 1860 | if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task && |
1861 | GMC_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent)) | 1861 | GM_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent)) |
1862 | { | 1862 | { |
1863 | LOG (GNUNET_ERROR_TYPE_DEBUG, " Cancel poll\n"); | 1863 | LOG (GNUNET_ERROR_TYPE_DEBUG, " Cancel poll\n"); |
1864 | GNUNET_SCHEDULER_cancel (fc->poll_task); | 1864 | GNUNET_SCHEDULER_cancel (fc->poll_task); |
@@ -2024,7 +2024,7 @@ GMC_send_ack (struct MeshConnection *c, int fwd, int force) | |||
2024 | 2024 | ||
2025 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2025 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2026 | "GMC send %s ACK on %s\n", | 2026 | "GMC send %s ACK on %s\n", |
2027 | fwd ? "FWD" : "BCK", GMC_2s (c)); | 2027 | GM_f2s (fwd), GMC_2s (c)); |
2028 | 2028 | ||
2029 | if (NULL == c) | 2029 | if (NULL == c) |
2030 | { | 2030 | { |
@@ -2342,7 +2342,7 @@ GMC_get_allowed (struct MeshConnection *c, int fwd) | |||
2342 | struct MeshFlowControl *fc; | 2342 | struct MeshFlowControl *fc; |
2343 | 2343 | ||
2344 | fc = fwd ? &c->fwd_fc : &c->bck_fc; | 2344 | fc = fwd ? &c->fwd_fc : &c->bck_fc; |
2345 | if (GMC_is_pid_bigger(fc->last_pid_recv, fc->last_ack_sent)) | 2345 | if (GM_is_pid_bigger(fc->last_pid_recv, fc->last_ack_sent)) |
2346 | { | 2346 | { |
2347 | return 0; | 2347 | return 0; |
2348 | } | 2348 | } |
@@ -2477,7 +2477,7 @@ GMC_is_sendable (struct MeshConnection *c, int fwd) | |||
2477 | struct MeshFlowControl *fc; | 2477 | struct MeshFlowControl *fc; |
2478 | 2478 | ||
2479 | fc = fwd ? &c->fwd_fc : &c->bck_fc; | 2479 | fc = fwd ? &c->fwd_fc : &c->bck_fc; |
2480 | if (GMC_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent)) | 2480 | if (GM_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent)) |
2481 | return GNUNET_YES; | 2481 | return GNUNET_YES; |
2482 | return GNUNET_NO; | 2482 | return GNUNET_NO; |
2483 | } | 2483 | } |
@@ -2514,7 +2514,7 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2514 | memcpy (data, message, size); | 2514 | memcpy (data, message, size); |
2515 | type = ntohs (message->type); | 2515 | type = ntohs (message->type); |
2516 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Send %s (%u bytes) on connection %s\n", | 2516 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Send %s (%u bytes) on connection %s\n", |
2517 | GNUNET_MESH_DEBUG_M2S (type), size, GMC_2s (c)); | 2517 | GM_m2s (type), size, GMC_2s (c)); |
2518 | 2518 | ||
2519 | fc = fwd ? &c->fwd_fc : &c->bck_fc; | 2519 | fc = fwd ? &c->fwd_fc : &c->bck_fc; |
2520 | droppable = GNUNET_YES; | 2520 | droppable = GNUNET_YES; |
@@ -2545,7 +2545,7 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2545 | LOG (GNUNET_ERROR_TYPE_DEBUG, "pid %u\n", ntohl (emsg->pid)); | 2545 | LOG (GNUNET_ERROR_TYPE_DEBUG, "pid %u\n", ntohl (emsg->pid)); |
2546 | LOG (GNUNET_ERROR_TYPE_DEBUG, "last pid sent %u\n", fc->last_pid_sent); | 2546 | LOG (GNUNET_ERROR_TYPE_DEBUG, "last pid sent %u\n", fc->last_pid_sent); |
2547 | LOG (GNUNET_ERROR_TYPE_DEBUG, " ack recv %u\n", fc->last_ack_recv); | 2547 | LOG (GNUNET_ERROR_TYPE_DEBUG, " ack recv %u\n", fc->last_ack_recv); |
2548 | if (GMC_is_pid_bigger (fc->last_pid_sent + 1, fc->last_ack_recv)) | 2548 | if (GM_is_pid_bigger (fc->last_pid_sent + 1, fc->last_ack_recv)) |
2549 | { | 2549 | { |
2550 | GMC_start_poll (c, fwd); | 2550 | GMC_start_poll (c, fwd); |
2551 | } | 2551 | } |
@@ -2733,7 +2733,7 @@ GMC_start_poll (struct MeshConnection *c, int fwd) | |||
2733 | 2733 | ||
2734 | fc = fwd ? &c->fwd_fc : &c->bck_fc; | 2734 | fc = fwd ? &c->fwd_fc : &c->bck_fc; |
2735 | LOG (GNUNET_ERROR_TYPE_DEBUG, " *** POLL %s requested\n", | 2735 | LOG (GNUNET_ERROR_TYPE_DEBUG, " *** POLL %s requested\n", |
2736 | fwd ? "FWD" : "BCK"); | 2736 | GM_f2s (fwd)); |
2737 | if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task || NULL != fc->poll_msg) | 2737 | if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task || NULL != fc->poll_msg) |
2738 | { | 2738 | { |
2739 | LOG (GNUNET_ERROR_TYPE_DEBUG, " *** not needed (%u, %p)\n", | 2739 | LOG (GNUNET_ERROR_TYPE_DEBUG, " *** not needed (%u, %p)\n", |