aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-12-18 12:58:12 +0000
committerChristian Grothoff <christian@grothoff.org>2013-12-18 12:58:12 +0000
commit3d0126a5abcd82af3993a586db26fe145e2de858 (patch)
tree84c361f24e015c4c76a1e213b46128308ebcd464
parent461f50cad2fd434523b3f0b8854a354cf9064261 (diff)
downloadgnunet-3d0126a5abcd82af3993a586db26fe145e2de858.tar.gz
gnunet-3d0126a5abcd82af3993a586db26fe145e2de858.zip
-misc fixes
-rw-r--r--src/dv/gnunet-service-dv.c73
1 files changed, 54 insertions, 19 deletions
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c
index 50d21feef..670fbb0d2 100644
--- a/src/dv/gnunet-service-dv.c
+++ b/src/dv/gnunet-service-dv.c
@@ -145,9 +145,9 @@ struct PendingMessage
145 const struct GNUNET_MessageHeader *msg; 145 const struct GNUNET_MessageHeader *msg;
146 146
147 /** 147 /**
148 * Ultimate target for the message. 148 * Next target for the message (a neighbour of ours).
149 */ 149 */
150 struct GNUNET_PeerIdentity ultimate_target; 150 struct GNUNET_PeerIdentity next_target;
151 151
152 /** 152 /**
153 * Unique ID of the message. 153 * Unique ID of the message.
@@ -615,12 +615,22 @@ core_transmit_notify (void *cls, size_t size, void *buf)
615 pending); 615 pending);
616 memcpy (&cbuf[off], pending->msg, msize); 616 memcpy (&cbuf[off], pending->msg, msize);
617 if (0 != pending->uid) 617 if (0 != pending->uid)
618 send_ack_to_plugin (&pending->ultimate_target, 618 {
619 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
620 "Acking transmission of %u bytes to %s with plugin\n",
621 msize,
622 GNUNET_i2s (&pending->next_target));
623 send_ack_to_plugin (&pending->next_target,
619 pending->uid, 624 pending->uid,
620 GNUNET_NO); 625 GNUNET_NO);
626 }
621 GNUNET_free (pending); 627 GNUNET_free (pending);
622 off += msize; 628 off += msize;
623 } 629 }
630 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
631 "Transmitting total of %u bytes to %s\n",
632 off,
633 GNUNET_i2s (&dn->peer));
624 GNUNET_assert (NULL != core_api); 634 GNUNET_assert (NULL != core_api);
625 if (NULL != dn->pm_head) 635 if (NULL != dn->pm_head)
626 dn->cth = 636 dn->cth =
@@ -641,7 +651,7 @@ core_transmit_notify (void *cls, size_t size, void *buf)
641 * @param target where to send the message 651 * @param target where to send the message
642 * @param distance expected (remaining) distance to the target 652 * @param distance expected (remaining) distance to the target
643 * @param uid unique ID for the message 653 * @param uid unique ID for the message
644 * @param ultimate_target ultimate recipient for the message 654 * @param actual_target ultimate recipient for the message
645 * @param sender original sender of the message 655 * @param sender original sender of the message
646 * @param payload payload of the message 656 * @param payload payload of the message
647 */ 657 */
@@ -650,7 +660,7 @@ forward_payload (struct DirectNeighbor *target,
650 uint32_t distance, 660 uint32_t distance,
651 uint32_t uid, 661 uint32_t uid,
652 const struct GNUNET_PeerIdentity *sender, 662 const struct GNUNET_PeerIdentity *sender,
653 const struct GNUNET_PeerIdentity *ultimate_target, 663 const struct GNUNET_PeerIdentity *actual_target,
654 const struct GNUNET_MessageHeader *payload) 664 const struct GNUNET_MessageHeader *payload)
655{ 665{
656 struct PendingMessage *pm; 666 struct PendingMessage *pm;
@@ -676,14 +686,14 @@ forward_payload (struct DirectNeighbor *target,
676 return; 686 return;
677 } 687 }
678 pm = GNUNET_malloc (sizeof (struct PendingMessage) + msize); 688 pm = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
679 pm->ultimate_target = *ultimate_target; 689 pm->next_target = target->peer;
680 pm->uid = uid; 690 pm->uid = uid;
681 pm->msg = (const struct GNUNET_MessageHeader *) &pm[1]; 691 pm->msg = (const struct GNUNET_MessageHeader *) &pm[1];
682 rm = (struct RouteMessage *) &pm[1]; 692 rm = (struct RouteMessage *) &pm[1];
683 rm->header.size = htons ((uint16_t) msize); 693 rm->header.size = htons ((uint16_t) msize);
684 rm->header.type = htons (GNUNET_MESSAGE_TYPE_DV_ROUTE); 694 rm->header.type = htons (GNUNET_MESSAGE_TYPE_DV_ROUTE);
685 rm->distance = htonl (distance); 695 rm->distance = htonl (distance);
686 rm->target = target->peer; 696 rm->target = *actual_target;
687 rm->sender = *sender; 697 rm->sender = *sender;
688 memcpy (&rm[1], payload, ntohs (payload->size)); 698 memcpy (&rm[1], payload, ntohs (payload->size));
689 GNUNET_CONTAINER_DLL_insert_tail (target->pm_head, 699 GNUNET_CONTAINER_DLL_insert_tail (target->pm_head,
@@ -1746,9 +1756,12 @@ handle_dv_route_message (void *cls, const struct GNUNET_PeerIdentity *peer,
1746 const struct RouteMessage *rm; 1756 const struct RouteMessage *rm;
1747 const struct GNUNET_MessageHeader *payload; 1757 const struct GNUNET_MessageHeader *payload;
1748 struct Route *route; 1758 struct Route *route;
1759 struct DirectNeighbor *neighbor;
1760 uint32_t distance;
1749 1761
1750 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1762 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1751 "Handling DV message\n"); 1763 "Handling DV message from %s\n",
1764 GNUNET_i2s (peer));
1752 if (ntohs (message->size) < sizeof (struct RouteMessage) + sizeof (struct GNUNET_MessageHeader)) 1765 if (ntohs (message->size) < sizeof (struct RouteMessage) + sizeof (struct GNUNET_MessageHeader))
1753 { 1766 {
1754 GNUNET_break_op (0); 1767 GNUNET_break_op (0);
@@ -1771,6 +1784,10 @@ handle_dv_route_message (void *cls, const struct GNUNET_PeerIdentity *peer,
1771 if (NULL == route) 1784 if (NULL == route)
1772 { 1785 {
1773 /* don't have reverse route, drop */ 1786 /* don't have reverse route, drop */
1787 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1788 "No reverse route to %s, dropping %u bytes!\n",
1789 GNUNET_i2s (&rm->sender),
1790 ntohs (payload->size));
1774 GNUNET_STATISTICS_update (stats, 1791 GNUNET_STATISTICS_update (stats,
1775 "# message discarded (no reverse route)", 1792 "# message discarded (no reverse route)",
1776 1, GNUNET_NO); 1793 1, GNUNET_NO);
@@ -1788,23 +1805,41 @@ handle_dv_route_message (void *cls, const struct GNUNET_PeerIdentity *peer,
1788 &rm->target); 1805 &rm->target);
1789 if (NULL == route) 1806 if (NULL == route)
1790 { 1807 {
1791 GNUNET_STATISTICS_update (stats, 1808 neighbor = GNUNET_CONTAINER_multipeermap_get (direct_neighbors,
1792 "# messages discarded (no route)", 1809 peer);
1793 1, GNUNET_NO); 1810 if (NULL == neighbor)
1794 return GNUNET_OK; 1811 {
1812 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1813 "No route to %s, not routing %u bytes!\n",
1814 GNUNET_i2s (&rm->target),
1815 ntohs (payload->size));
1816 GNUNET_STATISTICS_update (stats,
1817 "# messages discarded (no route)",
1818 1, GNUNET_NO);
1819 return GNUNET_OK;
1820 }
1821 distance = DIRECT_NEIGHBOR_COST;
1795 } 1822 }
1796 if (ntohl (route->target.distance) > ntohl (rm->distance) + 1) 1823 else
1797 { 1824 {
1798 GNUNET_STATISTICS_update (stats, 1825 if (ntohl (route->target.distance) > ntohl (rm->distance) + 1)
1799 "# messages discarded (target too far)", 1826 {
1800 1, GNUNET_NO); 1827 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1801 return GNUNET_OK; 1828 "Distance too far, not routing %u bytes!\n",
1829 ntohs (payload->size));
1830 GNUNET_STATISTICS_update (stats,
1831 "# messages discarded (target too far)",
1832 1, GNUNET_NO);
1833 return GNUNET_OK;
1834 }
1835 neighbor = route->next_hop;
1836 distance = ntohl (route->target.distance);
1802 } 1837 }
1803 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1838 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1804 "Forwarding message to %s\n", 1839 "Forwarding message to %s\n",
1805 GNUNET_i2s (&rm->target)); 1840 GNUNET_i2s (&rm->target));
1806 forward_payload (route->next_hop, 1841 forward_payload (neighbor,
1807 ntohl (route->target.distance), 1842 distance,
1808 0, 1843 0,
1809 &rm->target, 1844 &rm->target,
1810 &rm->sender, 1845 &rm->sender,