diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-12-18 14:39:57 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-12-18 14:39:57 +0000 |
commit | 3b5bda2f04b755d527fcaa69f71ee66f83e3a324 (patch) | |
tree | 545c65b118f3b028eda4eb98f43c8b25dc982719 | |
parent | bcc375bf6c191efd5243ff21e274d261354d99a4 (diff) | |
download | gnunet-3b5bda2f04b755d527fcaa69f71ee66f83e3a324.tar.gz gnunet-3b5bda2f04b755d527fcaa69f71ee66f83e3a324.zip |
-fix distance calculations / ntohs vs ntohl
-rw-r--r-- | src/dv/gnunet-service-dv.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index 5a1e0b274..1c185197a 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c | |||
@@ -444,8 +444,9 @@ send_data_to_plugin (const struct GNUNET_MessageHeader *message, | |||
444 | size_t size; | 444 | size_t size; |
445 | 445 | ||
446 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 446 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
447 | "Delivering message from peer `%s'\n", | 447 | "Delivering message from peer `%s' at distance %u\n", |
448 | GNUNET_i2s (origin)); | 448 | GNUNET_i2s (origin), |
449 | (unsigned int) distance); | ||
449 | size = sizeof (struct GNUNET_DV_ReceivedMessage) + | 450 | size = sizeof (struct GNUNET_DV_ReceivedMessage) + |
450 | ntohs (message->size); | 451 | ntohs (message->size); |
451 | if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 452 | if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) |
@@ -863,7 +864,7 @@ build_set (void *cls) | |||
863 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 864 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
864 | "Adding peer `%s' with distance %u to SET\n", | 865 | "Adding peer `%s' with distance %u to SET\n", |
865 | GNUNET_i2s (&target->peer), | 866 | GNUNET_i2s (&target->peer), |
866 | ntohl (target->distance)); | 867 | ntohl (target->distance) + 1); |
867 | GNUNET_SET_add_element (neighbor->my_set, | 868 | GNUNET_SET_add_element (neighbor->my_set, |
868 | &element, | 869 | &element, |
869 | &build_set, neighbor); | 870 | &build_set, neighbor); |
@@ -1814,7 +1815,7 @@ handle_dv_route_message (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1814 | if ( (NULL == route) && | 1815 | if ( (NULL == route) && |
1815 | (NULL == GNUNET_CONTAINER_multipeermap_get (direct_neighbors, | 1816 | (NULL == GNUNET_CONTAINER_multipeermap_get (direct_neighbors, |
1816 | &rm->sender)) && | 1817 | &rm->sender)) && |
1817 | (ntohs (rm->distance) < DEFAULT_FISHEYE_DEPTH) ) | 1818 | (ntohl (rm->distance) < DEFAULT_FISHEYE_DEPTH) ) |
1818 | { | 1819 | { |
1819 | /* don't have reverse route yet, learn it! */ | 1820 | /* don't have reverse route yet, learn it! */ |
1820 | neighbor = GNUNET_CONTAINER_multipeermap_get (direct_neighbors, | 1821 | neighbor = GNUNET_CONTAINER_multipeermap_get (direct_neighbors, |
@@ -1830,7 +1831,7 @@ handle_dv_route_message (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1830 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1831 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1831 | "Learning target %s at distance %u from delivery!\n", | 1832 | "Learning target %s at distance %u from delivery!\n", |
1832 | GNUNET_i2s (&rm->sender), | 1833 | GNUNET_i2s (&rm->sender), |
1833 | 1 + ntohs (rm->distance)); | 1834 | 1 + ntohl (rm->distance)); |
1834 | if (NULL == neighbor->neighbor_table) | 1835 | if (NULL == neighbor->neighbor_table) |
1835 | neighbor->neighbor_table = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); | 1836 | neighbor->neighbor_table = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); |
1836 | if (GNUNET_YES != | 1837 | if (GNUNET_YES != |
@@ -1849,7 +1850,7 @@ handle_dv_route_message (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1849 | ntohs (payload->size)); | 1850 | ntohs (payload->size)); |
1850 | send_data_to_plugin (payload, | 1851 | send_data_to_plugin (payload, |
1851 | &rm->sender, | 1852 | &rm->sender, |
1852 | ntohl (route->target.distance)); | 1853 | 1 + ntohl (rm->distance)); |
1853 | return GNUNET_OK; | 1854 | return GNUNET_OK; |
1854 | } | 1855 | } |
1855 | if ( (NULL == GNUNET_CONTAINER_multipeermap_get (direct_neighbors, | 1856 | if ( (NULL == GNUNET_CONTAINER_multipeermap_get (direct_neighbors, |
@@ -1860,7 +1861,7 @@ handle_dv_route_message (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1860 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1861 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1861 | "Learning target %s at distance %u from forwarding!\n", | 1862 | "Learning target %s at distance %u from forwarding!\n", |
1862 | GNUNET_i2s (&rm->sender), | 1863 | GNUNET_i2s (&rm->sender), |
1863 | 1 + ntohs (rm->distance)); | 1864 | 1 + ntohl (rm->distance)); |
1864 | neighbor = GNUNET_CONTAINER_multipeermap_get (direct_neighbors, | 1865 | neighbor = GNUNET_CONTAINER_multipeermap_get (direct_neighbors, |
1865 | peer); | 1866 | peer); |
1866 | if (NULL == neighbor) | 1867 | if (NULL == neighbor) |