diff options
Diffstat (limited to 'src/dv/gnunet-service-dv.c')
-rw-r--r-- | src/dv/gnunet-service-dv.c | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index 19303ed83..cd4517164 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c | |||
@@ -92,7 +92,7 @@ struct Target | |||
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Message exchanged between DV services (via core), requesting a | 94 | * Message exchanged between DV services (via core), requesting a |
95 | * message to be routed. | 95 | * message to be routed. |
96 | */ | 96 | */ |
97 | struct RouteMessage | 97 | struct RouteMessage |
98 | { | 98 | { |
@@ -176,7 +176,7 @@ struct DirectNeighbor | |||
176 | * with other applications. | 176 | * with other applications. |
177 | */ | 177 | */ |
178 | struct GNUNET_HashCode real_session_id; | 178 | struct GNUNET_HashCode real_session_id; |
179 | 179 | ||
180 | /** | 180 | /** |
181 | * Head of linked list of messages to send to this peer. | 181 | * Head of linked list of messages to send to this peer. |
182 | */ | 182 | */ |
@@ -197,7 +197,7 @@ struct DirectNeighbor | |||
197 | * Keys are peer identities, values are 'struct Target' entries. | 197 | * Keys are peer identities, values are 'struct Target' entries. |
198 | * Note that the distances in the targets are from the point-of-view | 198 | * Note that the distances in the targets are from the point-of-view |
199 | * of the peer, not from us! | 199 | * of the peer, not from us! |
200 | */ | 200 | */ |
201 | struct GNUNET_CONTAINER_MultiPeerMap *neighbor_table; | 201 | struct GNUNET_CONTAINER_MultiPeerMap *neighbor_table; |
202 | 202 | ||
203 | /** | 203 | /** |
@@ -206,7 +206,7 @@ struct DirectNeighbor | |||
206 | * Keys are peer identities, values are 'struct Target' entries. | 206 | * Keys are peer identities, values are 'struct Target' entries. |
207 | * Note that the distances in the targets are from the point-of-view | 207 | * Note that the distances in the targets are from the point-of-view |
208 | * of the peer, not from us! | 208 | * of the peer, not from us! |
209 | */ | 209 | */ |
210 | struct GNUNET_CONTAINER_MultiPeerMap *neighbor_table_consensus; | 210 | struct GNUNET_CONTAINER_MultiPeerMap *neighbor_table_consensus; |
211 | 211 | ||
212 | /** | 212 | /** |
@@ -318,13 +318,13 @@ struct ConsensusSet | |||
318 | 318 | ||
319 | /** | 319 | /** |
320 | * Peermap of all of our neighbors; processing these usually requires | 320 | * Peermap of all of our neighbors; processing these usually requires |
321 | * first checking to see if the peer is core-connected and if the | 321 | * first checking to see if the peer is core-connected and if the |
322 | * distance is 1, in which case they are direct neighbors. | 322 | * distance is 1, in which case they are direct neighbors. |
323 | */ | 323 | */ |
324 | static struct GNUNET_CONTAINER_MultiPeerMap *direct_neighbors; | 324 | static struct GNUNET_CONTAINER_MultiPeerMap *direct_neighbors; |
325 | 325 | ||
326 | /** | 326 | /** |
327 | * Hashmap with all routes that we currently support; contains | 327 | * Hashmap with all routes that we currently support; contains |
328 | * routing information for all peers from distance 2 | 328 | * routing information for all peers from distance 2 |
329 | * up to distance DEFAULT_FISHEYE_DEPTH. | 329 | * up to distance DEFAULT_FISHEYE_DEPTH. |
330 | */ | 330 | */ |
@@ -367,7 +367,7 @@ static struct GNUNET_STATISTICS_Handle *stats; | |||
367 | * Handle to ATS service. | 367 | * Handle to ATS service. |
368 | */ | 368 | */ |
369 | static struct GNUNET_ATS_PerformanceHandle *ats; | 369 | static struct GNUNET_ATS_PerformanceHandle *ats; |
370 | 370 | ||
371 | 371 | ||
372 | /** | 372 | /** |
373 | * Start creating a new DV set union by initiating the connection. | 373 | * Start creating a new DV set union by initiating the connection. |
@@ -375,7 +375,7 @@ static struct GNUNET_ATS_PerformanceHandle *ats; | |||
375 | * @param cls the 'struct DirectNeighbor' of the peer we're building | 375 | * @param cls the 'struct DirectNeighbor' of the peer we're building |
376 | * a routing consensus with | 376 | * a routing consensus with |
377 | * @param tc scheduler context | 377 | * @param tc scheduler context |
378 | */ | 378 | */ |
379 | static void | 379 | static void |
380 | initiate_set_union (void *cls, | 380 | initiate_set_union (void *cls, |
381 | const struct GNUNET_SCHEDULER_TaskContext *tc); | 381 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
@@ -396,7 +396,7 @@ initiate_set_union (void *cls, | |||
396 | * necessary to specify the set we want to do the operation with, | 396 | * necessary to specify the set we want to do the operation with, |
397 | * whith sometimes can be derived from the context message. | 397 | * whith sometimes can be derived from the context message. |
398 | * Also necessary to specify the timeout. | 398 | * Also necessary to specify the timeout. |
399 | */ | 399 | */ |
400 | static void | 400 | static void |
401 | listen_set_union (void *cls, | 401 | listen_set_union (void *cls, |
402 | const struct GNUNET_PeerIdentity *other_peer, | 402 | const struct GNUNET_PeerIdentity *other_peer, |
@@ -412,7 +412,7 @@ listen_set_union (void *cls, | |||
412 | * @param distance distance to the original sender of the message | 412 | * @param distance distance to the original sender of the message |
413 | */ | 413 | */ |
414 | static void | 414 | static void |
415 | send_data_to_plugin (const struct GNUNET_MessageHeader *message, | 415 | send_data_to_plugin (const struct GNUNET_MessageHeader *message, |
416 | const struct GNUNET_PeerIdentity *origin, | 416 | const struct GNUNET_PeerIdentity *origin, |
417 | uint32_t distance) | 417 | uint32_t distance) |
418 | { | 418 | { |
@@ -422,10 +422,10 @@ send_data_to_plugin (const struct GNUNET_MessageHeader *message, | |||
422 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 422 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
423 | "Delivering message from peer `%s'\n", | 423 | "Delivering message from peer `%s'\n", |
424 | GNUNET_i2s (origin)); | 424 | GNUNET_i2s (origin)); |
425 | size = sizeof (struct GNUNET_DV_ReceivedMessage) + | 425 | size = sizeof (struct GNUNET_DV_ReceivedMessage) + |
426 | ntohs (message->size); | 426 | ntohs (message->size); |
427 | if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 427 | if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) |
428 | { | 428 | { |
429 | GNUNET_break (0); /* too big */ | 429 | GNUNET_break (0); /* too big */ |
430 | return; | 430 | return; |
431 | } | 431 | } |
@@ -435,7 +435,7 @@ send_data_to_plugin (const struct GNUNET_MessageHeader *message, | |||
435 | received_msg->distance = htonl (distance); | 435 | received_msg->distance = htonl (distance); |
436 | received_msg->sender = *origin; | 436 | received_msg->sender = *origin; |
437 | memcpy (&received_msg[1], message, ntohs (message->size)); | 437 | memcpy (&received_msg[1], message, ntohs (message->size)); |
438 | GNUNET_SERVER_notification_context_broadcast (nc, | 438 | GNUNET_SERVER_notification_context_broadcast (nc, |
439 | &received_msg->header, | 439 | &received_msg->header, |
440 | GNUNET_YES); | 440 | GNUNET_YES); |
441 | GNUNET_free (received_msg); | 441 | GNUNET_free (received_msg); |
@@ -450,7 +450,7 @@ send_data_to_plugin (const struct GNUNET_MessageHeader *message, | |||
450 | static void | 450 | static void |
451 | send_control_to_plugin (const struct GNUNET_MessageHeader *message) | 451 | send_control_to_plugin (const struct GNUNET_MessageHeader *message) |
452 | { | 452 | { |
453 | GNUNET_SERVER_notification_context_broadcast (nc, | 453 | GNUNET_SERVER_notification_context_broadcast (nc, |
454 | message, | 454 | message, |
455 | GNUNET_NO); | 455 | GNUNET_NO); |
456 | } | 456 | } |
@@ -464,7 +464,7 @@ send_control_to_plugin (const struct GNUNET_MessageHeader *message) | |||
464 | * @param nack GNUNET_NO to send ACK, GNUNET_YES to send NACK | 464 | * @param nack GNUNET_NO to send ACK, GNUNET_YES to send NACK |
465 | */ | 465 | */ |
466 | static void | 466 | static void |
467 | send_ack_to_plugin (const struct GNUNET_PeerIdentity *target, | 467 | send_ack_to_plugin (const struct GNUNET_PeerIdentity *target, |
468 | uint32_t uid, | 468 | uint32_t uid, |
469 | int nack) | 469 | int nack) |
470 | { | 470 | { |
@@ -474,7 +474,7 @@ send_ack_to_plugin (const struct GNUNET_PeerIdentity *target, | |||
474 | "Delivering ACK for message to peer `%s'\n", | 474 | "Delivering ACK for message to peer `%s'\n", |
475 | GNUNET_i2s (target)); | 475 | GNUNET_i2s (target)); |
476 | ack_msg.header.size = htons (sizeof (ack_msg)); | 476 | ack_msg.header.size = htons (sizeof (ack_msg)); |
477 | ack_msg.header.type = htons ((GNUNET_YES == nack) | 477 | ack_msg.header.type = htons ((GNUNET_YES == nack) |
478 | ? GNUNET_MESSAGE_TYPE_DV_SEND_NACK | 478 | ? GNUNET_MESSAGE_TYPE_DV_SEND_NACK |
479 | : GNUNET_MESSAGE_TYPE_DV_SEND_ACK); | 479 | : GNUNET_MESSAGE_TYPE_DV_SEND_ACK); |
480 | ack_msg.uid = htonl (uid); | 480 | ack_msg.uid = htonl (uid); |
@@ -490,7 +490,7 @@ send_ack_to_plugin (const struct GNUNET_PeerIdentity *target, | |||
490 | * @param distance new distance to the peer | 490 | * @param distance new distance to the peer |
491 | */ | 491 | */ |
492 | static void | 492 | static void |
493 | send_distance_change_to_plugin (const struct GNUNET_PeerIdentity *peer, | 493 | send_distance_change_to_plugin (const struct GNUNET_PeerIdentity *peer, |
494 | uint32_t distance) | 494 | uint32_t distance) |
495 | { | 495 | { |
496 | struct GNUNET_DV_DistanceUpdateMessage du_msg; | 496 | struct GNUNET_DV_DistanceUpdateMessage du_msg; |
@@ -513,7 +513,7 @@ send_distance_change_to_plugin (const struct GNUNET_PeerIdentity *peer, | |||
513 | * @param distance distance to the target | 513 | * @param distance distance to the target |
514 | */ | 514 | */ |
515 | static void | 515 | static void |
516 | send_connect_to_plugin (const struct GNUNET_PeerIdentity *target, | 516 | send_connect_to_plugin (const struct GNUNET_PeerIdentity *target, |
517 | uint32_t distance) | 517 | uint32_t distance) |
518 | { | 518 | { |
519 | struct GNUNET_DV_ConnectMessage cm; | 519 | struct GNUNET_DV_ConnectMessage cm; |
@@ -585,7 +585,7 @@ core_transmit_notify (void *cls, size_t size, void *buf) | |||
585 | dn->pm_tail, | 585 | dn->pm_tail, |
586 | pending); | 586 | pending); |
587 | memcpy (&cbuf[off], pending->msg, msize); | 587 | memcpy (&cbuf[off], pending->msg, msize); |
588 | if (0 != pending->uid) | 588 | if (0 != pending->uid) |
589 | send_ack_to_plugin (&pending->ultimate_target, | 589 | send_ack_to_plugin (&pending->ultimate_target, |
590 | pending->uid, | 590 | pending->uid, |
591 | GNUNET_NO); | 591 | GNUNET_NO); |
@@ -599,7 +599,7 @@ core_transmit_notify (void *cls, size_t size, void *buf) | |||
599 | 0 /* priority */, | 599 | 0 /* priority */, |
600 | GNUNET_TIME_UNIT_FOREVER_REL, | 600 | GNUNET_TIME_UNIT_FOREVER_REL, |
601 | &dn->peer, | 601 | &dn->peer, |
602 | msize, | 602 | msize, |
603 | &core_transmit_notify, dn); | 603 | &core_transmit_notify, dn); |
604 | return off; | 604 | return off; |
605 | } | 605 | } |
@@ -662,7 +662,7 @@ forward_payload (struct DirectNeighbor *target, | |||
662 | 0 /* priority */, | 662 | 0 /* priority */, |
663 | GNUNET_TIME_UNIT_FOREVER_REL, | 663 | GNUNET_TIME_UNIT_FOREVER_REL, |
664 | &target->peer, | 664 | &target->peer, |
665 | msize, | 665 | msize, |
666 | &core_transmit_notify, target); | 666 | &core_transmit_notify, target); |
667 | } | 667 | } |
668 | 668 | ||
@@ -738,7 +738,7 @@ move_route (struct Route *route, | |||
738 | release_route (route); | 738 | release_route (route); |
739 | i = get_consensus_slot (new_distance); | 739 | i = get_consensus_slot (new_distance); |
740 | route->set_offset = i; | 740 | route->set_offset = i; |
741 | consensi[new_distance].targets[i] = route; | 741 | consensi[new_distance].targets[i] = route; |
742 | route->target.distance = htonl (new_distance); | 742 | route->target.distance = htonl (new_distance); |
743 | } | 743 | } |
744 | 744 | ||
@@ -785,13 +785,13 @@ build_set (void *cls) | |||
785 | while ( (DEFAULT_FISHEYE_DEPTH - 1 > neighbor->consensus_insertion_distance) && | 785 | while ( (DEFAULT_FISHEYE_DEPTH - 1 > neighbor->consensus_insertion_distance) && |
786 | (consensi[neighbor->consensus_insertion_distance].array_length < neighbor->consensus_insertion_offset) && | 786 | (consensi[neighbor->consensus_insertion_distance].array_length < neighbor->consensus_insertion_offset) && |
787 | (NULL == consensi[neighbor->consensus_insertion_distance].targets[neighbor->consensus_insertion_offset]) ) | 787 | (NULL == consensi[neighbor->consensus_insertion_distance].targets[neighbor->consensus_insertion_offset]) ) |
788 | neighbor->consensus_insertion_offset++; | 788 | neighbor->consensus_insertion_offset++; |
789 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 789 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
790 | "Adding element to SET\n"); | 790 | "Adding element to SET\n"); |
791 | GNUNET_SET_add_element (neighbor->my_set, | 791 | GNUNET_SET_add_element (neighbor->my_set, |
792 | &element, | 792 | &element, |
793 | &build_set, neighbor); | 793 | &build_set, neighbor); |
794 | 794 | ||
795 | } | 795 | } |
796 | 796 | ||
797 | 797 | ||
@@ -814,9 +814,9 @@ handle_direct_connect (struct DirectNeighbor *neighbor) | |||
814 | GNUNET_STATISTICS_update (stats, | 814 | GNUNET_STATISTICS_update (stats, |
815 | "# peers connected (1-hop)", | 815 | "# peers connected (1-hop)", |
816 | 1, GNUNET_NO); | 816 | 1, GNUNET_NO); |
817 | route = GNUNET_CONTAINER_multipeermap_get (all_routes, | 817 | route = GNUNET_CONTAINER_multipeermap_get (all_routes, |
818 | &neighbor->peer); | 818 | &neighbor->peer); |
819 | if (NULL != route) | 819 | if (NULL != route) |
820 | { | 820 | { |
821 | send_disconnect_to_plugin (&neighbor->peer); | 821 | send_disconnect_to_plugin (&neighbor->peer); |
822 | release_route (route); | 822 | release_route (route); |
@@ -839,7 +839,7 @@ handle_direct_connect (struct DirectNeighbor *neighbor) | |||
839 | sizeof (struct GNUNET_PeerIdentity))) | 839 | sizeof (struct GNUNET_PeerIdentity))) |
840 | { | 840 | { |
841 | neighbor->initiate_task = GNUNET_SCHEDULER_add_now (&initiate_set_union, | 841 | neighbor->initiate_task = GNUNET_SCHEDULER_add_now (&initiate_set_union, |
842 | neighbor); | 842 | neighbor); |
843 | } | 843 | } |
844 | else | 844 | else |
845 | { | 845 | { |
@@ -861,16 +861,16 @@ handle_direct_connect (struct DirectNeighbor *neighbor) | |||
861 | * @param peer peer identity this notification is about | 861 | * @param peer peer identity this notification is about |
862 | */ | 862 | */ |
863 | static void | 863 | static void |
864 | handle_core_connect (void *cls, | 864 | handle_core_connect (void *cls, |
865 | const struct GNUNET_PeerIdentity *peer) | 865 | const struct GNUNET_PeerIdentity *peer) |
866 | { | 866 | { |
867 | struct DirectNeighbor *neighbor; | 867 | struct DirectNeighbor *neighbor; |
868 | 868 | ||
869 | /* Check for connect to self message */ | 869 | /* Check for connect to self message */ |
870 | if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity))) | 870 | if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity))) |
871 | return; | 871 | return; |
872 | /* check if entry exists */ | 872 | /* check if entry exists */ |
873 | neighbor = GNUNET_CONTAINER_multipeermap_get (direct_neighbors, | 873 | neighbor = GNUNET_CONTAINER_multipeermap_get (direct_neighbors, |
874 | peer); | 874 | peer); |
875 | if (NULL != neighbor) | 875 | if (NULL != neighbor) |
876 | { | 876 | { |
@@ -929,14 +929,14 @@ free_targets (void *cls, | |||
929 | * @return GNUNET_YES to continue iteration, GNUNET_NO to stop | 929 | * @return GNUNET_YES to continue iteration, GNUNET_NO to stop |
930 | */ | 930 | */ |
931 | static int | 931 | static int |
932 | check_possible_route (void *cls, | 932 | check_possible_route (void *cls, |
933 | const struct GNUNET_PeerIdentity *key, | 933 | const struct GNUNET_PeerIdentity *key, |
934 | void *value) | 934 | void *value) |
935 | { | 935 | { |
936 | struct DirectNeighbor *neighbor = cls; | 936 | struct DirectNeighbor *neighbor = cls; |
937 | struct Target *target = value; | 937 | struct Target *target = value; |
938 | struct Route *route; | 938 | struct Route *route; |
939 | 939 | ||
940 | route = GNUNET_CONTAINER_multipeermap_get (all_routes, | 940 | route = GNUNET_CONTAINER_multipeermap_get (all_routes, |
941 | key); | 941 | key); |
942 | if (NULL != route) | 942 | if (NULL != route) |
@@ -975,15 +975,15 @@ check_possible_route (void *cls, | |||
975 | * @return GNUNET_YES to continue iteration | 975 | * @return GNUNET_YES to continue iteration |
976 | */ | 976 | */ |
977 | static int | 977 | static int |
978 | refresh_routes (void *cls, | 978 | refresh_routes (void *cls, |
979 | const struct GNUNET_PeerIdentity *key, | 979 | const struct GNUNET_PeerIdentity *key, |
980 | void *value) | 980 | void *value) |
981 | { | 981 | { |
982 | struct DirectNeighbor *neighbor = value; | 982 | struct DirectNeighbor *neighbor = value; |
983 | 983 | ||
984 | if ( (GNUNET_YES != neighbor->connected) || | 984 | if ( (GNUNET_YES != neighbor->connected) || |
985 | (DIRECT_NEIGHBOR_COST != neighbor->distance) ) | 985 | (DIRECT_NEIGHBOR_COST != neighbor->distance) ) |
986 | return GNUNET_YES; | 986 | return GNUNET_YES; |
987 | if (NULL != neighbor->neighbor_table) | 987 | if (NULL != neighbor->neighbor_table) |
988 | GNUNET_CONTAINER_multipeermap_iterate (neighbor->neighbor_table, | 988 | GNUNET_CONTAINER_multipeermap_iterate (neighbor->neighbor_table, |
989 | &check_possible_route, | 989 | &check_possible_route, |
@@ -1024,8 +1024,8 @@ get_atsi_distance (const struct GNUNET_ATS_Information *atsi, | |||
1024 | * @return GNUNET_YES to continue iteration, GNUNET_NO to stop | 1024 | * @return GNUNET_YES to continue iteration, GNUNET_NO to stop |
1025 | */ | 1025 | */ |
1026 | static int | 1026 | static int |
1027 | cull_routes (void *cls, | 1027 | cull_routes (void *cls, |
1028 | const struct GNUNET_PeerIdentity *key, | 1028 | const struct GNUNET_PeerIdentity *key, |
1029 | void *value) | 1029 | void *value) |
1030 | { | 1030 | { |
1031 | struct DirectNeighbor *neighbor = cls; | 1031 | struct DirectNeighbor *neighbor = cls; |
@@ -1047,7 +1047,7 @@ cull_routes (void *cls, | |||
1047 | * disrupted. Remove all routes via that peer and | 1047 | * disrupted. Remove all routes via that peer and |
1048 | * stop the consensus with it. | 1048 | * stop the consensus with it. |
1049 | * | 1049 | * |
1050 | * @param neighbor peer that was disconnected (or at least is no | 1050 | * @param neighbor peer that was disconnected (or at least is no |
1051 | * longer at distance 1) | 1051 | * longer at distance 1) |
1052 | */ | 1052 | */ |
1053 | static void | 1053 | static void |
@@ -1118,7 +1118,7 @@ handle_ats_update (void *cls, | |||
1118 | int active, | 1118 | int active, |
1119 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 1119 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
1120 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 1120 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
1121 | const struct GNUNET_ATS_Information *ats, | 1121 | const struct GNUNET_ATS_Information *ats, |
1122 | uint32_t ats_count) | 1122 | uint32_t ats_count) |
1123 | { | 1123 | { |
1124 | struct DirectNeighbor *neighbor; | 1124 | struct DirectNeighbor *neighbor; |
@@ -1126,25 +1126,25 @@ handle_ats_update (void *cls, | |||
1126 | 1126 | ||
1127 | if (GNUNET_NO == active) | 1127 | if (GNUNET_NO == active) |
1128 | return; | 1128 | return; |
1129 | distance = get_atsi_distance (ats, ats_count); | 1129 | distance = get_atsi_distance (ats, ats_count); |
1130 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1130 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1131 | "ATS says distance to %s is %u\n", | 1131 | "ATS says distance to %s is %u\n", |
1132 | GNUNET_i2s (&address->peer), | 1132 | GNUNET_i2s (&address->peer), |
1133 | (unsigned int) distance); | 1133 | (unsigned int) distance); |
1134 | /* check if entry exists */ | 1134 | /* check if entry exists */ |
1135 | neighbor = GNUNET_CONTAINER_multipeermap_get (direct_neighbors, | 1135 | neighbor = GNUNET_CONTAINER_multipeermap_get (direct_neighbors, |
1136 | &address->peer); | 1136 | &address->peer); |
1137 | if (NULL != neighbor) | 1137 | if (NULL != neighbor) |
1138 | { | 1138 | { |
1139 | if ( (DIRECT_NEIGHBOR_COST == neighbor->distance) && | 1139 | if ( (DIRECT_NEIGHBOR_COST == neighbor->distance) && |
1140 | (DIRECT_NEIGHBOR_COST == distance) ) | 1140 | (DIRECT_NEIGHBOR_COST == distance) ) |
1141 | return; /* no change */ | 1141 | return; /* no change */ |
1142 | if (DIRECT_NEIGHBOR_COST == neighbor->distance) | 1142 | if (DIRECT_NEIGHBOR_COST == neighbor->distance) |
1143 | { | 1143 | { |
1144 | neighbor->distance = distance; | 1144 | neighbor->distance = distance; |
1145 | GNUNET_STATISTICS_update (stats, | 1145 | GNUNET_STATISTICS_update (stats, |
1146 | "# peers connected (1-hop)", | 1146 | "# peers connected (1-hop)", |
1147 | -1, GNUNET_NO); | 1147 | -1, GNUNET_NO); |
1148 | handle_direct_disconnect (neighbor); | 1148 | handle_direct_disconnect (neighbor); |
1149 | GNUNET_CONTAINER_multipeermap_iterate (direct_neighbors, | 1149 | GNUNET_CONTAINER_multipeermap_iterate (direct_neighbors, |
1150 | &refresh_routes, | 1150 | &refresh_routes, |
@@ -1153,7 +1153,7 @@ handle_ats_update (void *cls, | |||
1153 | } | 1153 | } |
1154 | neighbor->distance = distance; | 1154 | neighbor->distance = distance; |
1155 | if (DIRECT_NEIGHBOR_COST != neighbor->distance) | 1155 | if (DIRECT_NEIGHBOR_COST != neighbor->distance) |
1156 | return; | 1156 | return; |
1157 | if (GNUNET_YES != neighbor->connected) | 1157 | if (GNUNET_YES != neighbor->connected) |
1158 | return; | 1158 | return; |
1159 | handle_direct_connect (neighbor); | 1159 | handle_direct_connect (neighbor); |
@@ -1167,7 +1167,7 @@ handle_ats_update (void *cls, | |||
1167 | neighbor, | 1167 | neighbor, |
1168 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 1168 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
1169 | neighbor->connected = GNUNET_NO; /* not yet */ | 1169 | neighbor->connected = GNUNET_NO; /* not yet */ |
1170 | neighbor->distance = distance; | 1170 | neighbor->distance = distance; |
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | 1173 | ||
@@ -1357,7 +1357,7 @@ handle_set_union_result (void *cls, | |||
1357 | /* check if we got an alternative for the removed routes */ | 1357 | /* check if we got an alternative for the removed routes */ |
1358 | GNUNET_CONTAINER_multipeermap_iterate (direct_neighbors, | 1358 | GNUNET_CONTAINER_multipeermap_iterate (direct_neighbors, |
1359 | &refresh_routes, | 1359 | &refresh_routes, |
1360 | NULL); | 1360 | NULL); |
1361 | } | 1361 | } |
1362 | /* add targets that appeared (and check for improved routes) */ | 1362 | /* add targets that appeared (and check for improved routes) */ |
1363 | GNUNET_CONTAINER_multipeermap_iterate (neighbor->neighbor_table_consensus, | 1363 | GNUNET_CONTAINER_multipeermap_iterate (neighbor->neighbor_table_consensus, |
@@ -1406,7 +1406,7 @@ handle_set_union_result (void *cls, | |||
1406 | * necessary to specify the set we want to do the operation with, | 1406 | * necessary to specify the set we want to do the operation with, |
1407 | * whith sometimes can be derived from the context message. | 1407 | * whith sometimes can be derived from the context message. |
1408 | * Also necessary to specify the timeout. | 1408 | * Also necessary to specify the timeout. |
1409 | */ | 1409 | */ |
1410 | static void | 1410 | static void |
1411 | listen_set_union (void *cls, | 1411 | listen_set_union (void *cls, |
1412 | const struct GNUNET_PeerIdentity *other_peer, | 1412 | const struct GNUNET_PeerIdentity *other_peer, |
@@ -1446,7 +1446,7 @@ listen_set_union (void *cls, | |||
1446 | * @param cls the 'struct DirectNeighbor' of the peer we're building | 1446 | * @param cls the 'struct DirectNeighbor' of the peer we're building |
1447 | * a routing consensus with | 1447 | * a routing consensus with |
1448 | * @param tc scheduler context | 1448 | * @param tc scheduler context |
1449 | */ | 1449 | */ |
1450 | static void | 1450 | static void |
1451 | initiate_set_union (void *cls, | 1451 | initiate_set_union (void *cls, |
1452 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 1452 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -1550,7 +1550,7 @@ handle_dv_route_message (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1550 | &rm->target, | 1550 | &rm->target, |
1551 | &rm->sender, | 1551 | &rm->sender, |
1552 | payload); | 1552 | payload); |
1553 | return GNUNET_OK; | 1553 | return GNUNET_OK; |
1554 | } | 1554 | } |
1555 | 1555 | ||
1556 | 1556 | ||
@@ -1627,12 +1627,12 @@ cleanup_neighbor (struct DirectNeighbor *neighbor) | |||
1627 | neighbor->pm_queue_size--; | 1627 | neighbor->pm_queue_size--; |
1628 | GNUNET_CONTAINER_DLL_remove (neighbor->pm_head, | 1628 | GNUNET_CONTAINER_DLL_remove (neighbor->pm_head, |
1629 | neighbor->pm_tail, | 1629 | neighbor->pm_tail, |
1630 | pending); | 1630 | pending); |
1631 | GNUNET_free (pending); | 1631 | GNUNET_free (pending); |
1632 | } | 1632 | } |
1633 | handle_direct_disconnect (neighbor); | 1633 | handle_direct_disconnect (neighbor); |
1634 | GNUNET_assert (GNUNET_YES == | 1634 | GNUNET_assert (GNUNET_YES == |
1635 | GNUNET_CONTAINER_multipeermap_remove (direct_neighbors, | 1635 | GNUNET_CONTAINER_multipeermap_remove (direct_neighbors, |
1636 | &neighbor->peer, | 1636 | &neighbor->peer, |
1637 | neighbor)); | 1637 | neighbor)); |
1638 | GNUNET_free (neighbor); | 1638 | GNUNET_free (neighbor); |
@@ -1669,7 +1669,7 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
1669 | { | 1669 | { |
1670 | GNUNET_STATISTICS_update (stats, | 1670 | GNUNET_STATISTICS_update (stats, |
1671 | "# peers connected (1-hop)", | 1671 | "# peers connected (1-hop)", |
1672 | -1, GNUNET_NO); | 1672 | -1, GNUNET_NO); |
1673 | } | 1673 | } |
1674 | cleanup_neighbor (neighbor); | 1674 | cleanup_neighbor (neighbor); |
1675 | GNUNET_CONTAINER_multipeermap_iterate (direct_neighbors, | 1675 | GNUNET_CONTAINER_multipeermap_iterate (direct_neighbors, |
@@ -1770,13 +1770,13 @@ add_route (void *cls, | |||
1770 | struct GNUNET_SERVER_Client *client = cls; | 1770 | struct GNUNET_SERVER_Client *client = cls; |
1771 | struct Route *route = value; | 1771 | struct Route *route = value; |
1772 | struct GNUNET_DV_ConnectMessage cm; | 1772 | struct GNUNET_DV_ConnectMessage cm; |
1773 | 1773 | ||
1774 | cm.header.size = htons (sizeof (cm)); | 1774 | cm.header.size = htons (sizeof (cm)); |
1775 | cm.header.type = htons (GNUNET_MESSAGE_TYPE_DV_CONNECT); | 1775 | cm.header.type = htons (GNUNET_MESSAGE_TYPE_DV_CONNECT); |
1776 | cm.distance = htonl (route->target.distance); | 1776 | cm.distance = htonl (route->target.distance); |
1777 | cm.peer = route->target.peer; | 1777 | cm.peer = route->target.peer; |
1778 | 1778 | ||
1779 | GNUNET_SERVER_notification_context_unicast (nc, | 1779 | GNUNET_SERVER_notification_context_unicast (nc, |
1780 | client, | 1780 | client, |
1781 | &cm.header, | 1781 | &cm.header, |
1782 | GNUNET_NO); | 1782 | GNUNET_NO); |
@@ -1796,7 +1796,7 @@ static void | |||
1796 | handle_start (void *cls, struct GNUNET_SERVER_Client *client, | 1796 | handle_start (void *cls, struct GNUNET_SERVER_Client *client, |
1797 | const struct GNUNET_MessageHeader *message) | 1797 | const struct GNUNET_MessageHeader *message) |
1798 | { | 1798 | { |
1799 | GNUNET_SERVER_notification_context_add (nc, client); | 1799 | GNUNET_SERVER_notification_context_add (nc, client); |
1800 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1800 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1801 | GNUNET_CONTAINER_multipeermap_iterate (all_routes, | 1801 | GNUNET_CONTAINER_multipeermap_iterate (all_routes, |
1802 | &add_route, | 1802 | &add_route, |
@@ -1837,11 +1837,11 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1837 | {NULL, 0, 0} | 1837 | {NULL, 0, 0} |
1838 | }; | 1838 | }; |
1839 | static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = { | 1839 | static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = { |
1840 | {&handle_start, NULL, | 1840 | {&handle_start, NULL, |
1841 | GNUNET_MESSAGE_TYPE_DV_START, | 1841 | GNUNET_MESSAGE_TYPE_DV_START, |
1842 | sizeof (struct GNUNET_MessageHeader) }, | 1842 | sizeof (struct GNUNET_MessageHeader) }, |
1843 | { &handle_dv_send_message, NULL, | 1843 | { &handle_dv_send_message, NULL, |
1844 | GNUNET_MESSAGE_TYPE_DV_SEND, | 1844 | GNUNET_MESSAGE_TYPE_DV_SEND, |
1845 | 0}, | 1845 | 0}, |
1846 | {NULL, NULL, 0, 0} | 1846 | {NULL, NULL, 0, 0} |
1847 | }; | 1847 | }; |
@@ -1850,11 +1850,11 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1850 | direct_neighbors = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); | 1850 | direct_neighbors = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); |
1851 | all_routes = GNUNET_CONTAINER_multipeermap_create (65536, GNUNET_NO); | 1851 | all_routes = GNUNET_CONTAINER_multipeermap_create (65536, GNUNET_NO); |
1852 | core_api = GNUNET_CORE_connect (cfg, NULL, | 1852 | core_api = GNUNET_CORE_connect (cfg, NULL, |
1853 | &core_init, | 1853 | &core_init, |
1854 | &handle_core_connect, | 1854 | &handle_core_connect, |
1855 | &handle_core_disconnect, | 1855 | &handle_core_disconnect, |
1856 | NULL, GNUNET_NO, | 1856 | NULL, GNUNET_NO, |
1857 | NULL, GNUNET_NO, | 1857 | NULL, GNUNET_NO, |
1858 | core_handlers); | 1858 | core_handlers); |
1859 | 1859 | ||
1860 | if (NULL == core_api) | 1860 | if (NULL == core_api) |