aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dv/dv_api.c2
-rw-r--r--src/dv/gnunet-service-dv.c60
-rw-r--r--src/dv/plugin_transport_dv.c17
-rw-r--r--src/set/gnunet-service-set.c6
-rw-r--r--src/set/set_api.c3
5 files changed, 65 insertions, 23 deletions
diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c
index cd12a0a21..a24965e84 100644
--- a/src/dv/dv_api.c
+++ b/src/dv/dv_api.c
@@ -516,7 +516,7 @@ GNUNET_DV_service_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
516{ 516{
517 struct GNUNET_DV_ServiceHandle *sh; 517 struct GNUNET_DV_ServiceHandle *sh;
518 518
519 sh = GNUNET_malloc (sizeof (struct GNUNET_DV_ServiceHandle)); 519 sh = GNUNET_new (struct GNUNET_DV_ServiceHandle);
520 sh->cfg = cfg; 520 sh->cfg = cfg;
521 sh->cls = cls; 521 sh->cls = cls;
522 sh->connect_cb = connect_cb; 522 sh->connect_cb = connect_cb;
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c
index 92ca5d9da..8f6e7ed44 100644
--- a/src/dv/gnunet-service-dv.c
+++ b/src/dv/gnunet-service-dv.c
@@ -769,8 +769,10 @@ build_set (void *cls)
769 if (DEFAULT_FISHEYE_DEPTH - 1 == neighbor->consensus_insertion_distance) 769 if (DEFAULT_FISHEYE_DEPTH - 1 == neighbor->consensus_insertion_distance)
770 { 770 {
771 /* we have added all elements to the set, run the operation */ 771 /* we have added all elements to the set, run the operation */
772 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
773 "Finished building my SET, committing\n");
772 GNUNET_SET_commit (neighbor->set_op, 774 GNUNET_SET_commit (neighbor->set_op,
773 neighbor->my_set); 775 neighbor->my_set);
774 GNUNET_SET_destroy (neighbor->my_set); 776 GNUNET_SET_destroy (neighbor->my_set);
775 neighbor->my_set = NULL; 777 neighbor->my_set = NULL;
776 return; 778 return;
@@ -783,6 +785,8 @@ build_set (void *cls)
783 (consensi[neighbor->consensus_insertion_distance].array_length < neighbor->consensus_insertion_offset) && 785 (consensi[neighbor->consensus_insertion_distance].array_length < neighbor->consensus_insertion_offset) &&
784 (NULL == consensi[neighbor->consensus_insertion_distance].targets[neighbor->consensus_insertion_offset]) ) 786 (NULL == consensi[neighbor->consensus_insertion_distance].targets[neighbor->consensus_insertion_offset]) )
785 neighbor->consensus_insertion_offset++; 787 neighbor->consensus_insertion_offset++;
788 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
789 "Adding element to SET\n");
786 GNUNET_SET_add_element (neighbor->my_set, 790 GNUNET_SET_add_element (neighbor->my_set,
787 &element, 791 &element,
788 &build_set, neighbor); 792 &build_set, neighbor);
@@ -801,6 +805,9 @@ handle_direct_connect (struct DirectNeighbor *neighbor)
801 struct Route *route; 805 struct Route *route;
802 struct GNUNET_HashCode session_id; 806 struct GNUNET_HashCode session_id;
803 807
808 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
809 "Direct connection to %s established, routing table exchange begins.\n",
810 GNUNET_i2s (&neighbor->peer));
804 GNUNET_STATISTICS_update (stats, 811 GNUNET_STATISTICS_update (stats,
805 "# peers connected (1-hop)", 812 "# peers connected (1-hop)",
806 1, GNUNET_NO); 813 1, GNUNET_NO);
@@ -823,15 +830,21 @@ handle_direct_connect (struct DirectNeighbor *neighbor)
823 &session_id, sizeof (session_id), 830 &session_id, sizeof (session_id),
824 NULL, 0); 831 NULL, 0);
825 if (1 == GNUNET_CRYPTO_hash_cmp (&neighbor->peer.hashPubKey, 832 if (1 == GNUNET_CRYPTO_hash_cmp (&neighbor->peer.hashPubKey,
826 &my_identity.hashPubKey)) 833 &my_identity.hashPubKey))
834 {
827 neighbor->initiate_task = GNUNET_SCHEDULER_add_now (&initiate_set_union, 835 neighbor->initiate_task = GNUNET_SCHEDULER_add_now (&initiate_set_union,
828 neighbor); 836 neighbor);
837 }
829 else 838 else
839 {
840 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
841 "Starting SET listen operation\n");
830 neighbor->listen_handle = GNUNET_SET_listen (cfg, 842 neighbor->listen_handle = GNUNET_SET_listen (cfg,
831 GNUNET_SET_OPERATION_UNION, 843 GNUNET_SET_OPERATION_UNION,
832 &neighbor->real_session_id, 844 &neighbor->real_session_id,
833 &listen_set_union, 845 &listen_set_union,
834 neighbor); 846 neighbor);
847 }
835} 848}
836 849
837 850
@@ -842,7 +855,8 @@ handle_direct_connect (struct DirectNeighbor *neighbor)
842 * @param peer peer identity this notification is about 855 * @param peer peer identity this notification is about
843 */ 856 */
844static void 857static void
845handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer) 858handle_core_connect (void *cls,
859 const struct GNUNET_PeerIdentity *peer)
846{ 860{
847 struct DirectNeighbor *neighbor; 861 struct DirectNeighbor *neighbor;
848 862
@@ -868,7 +882,7 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
868 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 882 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
869 "Core connected to %s (distance unknown)\n", 883 "Core connected to %s (distance unknown)\n",
870 GNUNET_i2s (peer)); 884 GNUNET_i2s (peer));
871 neighbor = GNUNET_malloc (sizeof (struct DirectNeighbor)); 885 neighbor = GNUNET_new (struct DirectNeighbor);
872 neighbor->peer = *peer; 886 neighbor->peer = *peer;
873 GNUNET_assert (GNUNET_YES == 887 GNUNET_assert (GNUNET_YES ==
874 GNUNET_CONTAINER_multihashmap_put (direct_neighbors, 888 GNUNET_CONTAINER_multihashmap_put (direct_neighbors,
@@ -909,14 +923,16 @@ free_targets (void *cls,
909 * @return GNUNET_YES to continue iteration, GNUNET_NO to stop 923 * @return GNUNET_YES to continue iteration, GNUNET_NO to stop
910 */ 924 */
911static int 925static int
912check_possible_route (void *cls, const struct GNUNET_HashCode * key, void *value) 926check_possible_route (void *cls,
927 const struct GNUNET_HashCode *key,
928 void *value)
913{ 929{
914 struct DirectNeighbor *neighbor = cls; 930 struct DirectNeighbor *neighbor = cls;
915 struct Target *target = value; 931 struct Target *target = value;
916 struct Route *route; 932 struct Route *route;
917 933
918 route = GNUNET_CONTAINER_multihashmap_get (all_routes, 934 route = GNUNET_CONTAINER_multihashmap_get (all_routes,
919 key); 935 key);
920 if (NULL != route) 936 if (NULL != route)
921 { 937 {
922 if (ntohl (route->target.distance) > ntohl (target->distance) + 1) 938 if (ntohl (route->target.distance) > ntohl (target->distance) + 1)
@@ -928,7 +944,7 @@ check_possible_route (void *cls, const struct GNUNET_HashCode * key, void *value
928 } 944 }
929 return GNUNET_YES; /* got a route to this target already */ 945 return GNUNET_YES; /* got a route to this target already */
930 } 946 }
931 route = GNUNET_malloc (sizeof (struct Route)); 947 route = GNUNET_new (struct Route);
932 route->next_hop = neighbor; 948 route->next_hop = neighbor;
933 route->target.distance = htonl (ntohl (target->distance) + 1); 949 route->target.distance = htonl (ntohl (target->distance) + 1);
934 route->target.peer = target->peer; 950 route->target.peer = target->peer;
@@ -953,7 +969,9 @@ check_possible_route (void *cls, const struct GNUNET_HashCode * key, void *value
953 * @return GNUNET_YES to continue iteration 969 * @return GNUNET_YES to continue iteration
954 */ 970 */
955static int 971static int
956refresh_routes (void *cls, const struct GNUNET_HashCode * key, void *value) 972refresh_routes (void *cls,
973 const struct GNUNET_HashCode *key,
974 void *value)
957{ 975{
958 struct DirectNeighbor *neighbor = value; 976 struct DirectNeighbor *neighbor = value;
959 977
@@ -1000,7 +1018,9 @@ get_atsi_distance (const struct GNUNET_ATS_Information *atsi,
1000 * @return GNUNET_YES to continue iteration, GNUNET_NO to stop 1018 * @return GNUNET_YES to continue iteration, GNUNET_NO to stop
1001 */ 1019 */
1002static int 1020static int
1003cull_routes (void *cls, const struct GNUNET_HashCode * key, void *value) 1021cull_routes (void *cls,
1022 const struct GNUNET_HashCode *key,
1023 void *value)
1004{ 1024{
1005 struct DirectNeighbor *neighbor = cls; 1025 struct DirectNeighbor *neighbor = cls;
1006 struct Route *route = value; 1026 struct Route *route = value;
@@ -1133,7 +1153,7 @@ handle_ats_update (void *cls,
1133 handle_direct_connect (neighbor); 1153 handle_direct_connect (neighbor);
1134 return; 1154 return;
1135 } 1155 }
1136 neighbor = GNUNET_malloc (sizeof (struct DirectNeighbor)); 1156 neighbor = GNUNET_new (struct DirectNeighbor);
1137 neighbor->peer = address->peer; 1157 neighbor->peer = address->peer;
1138 GNUNET_assert (GNUNET_YES == 1158 GNUNET_assert (GNUNET_YES ==
1139 GNUNET_CONTAINER_multihashmap_put (direct_neighbors, 1159 GNUNET_CONTAINER_multihashmap_put (direct_neighbors,
@@ -1201,8 +1221,8 @@ check_target_removed (void *cls,
1201 */ 1221 */
1202static int 1222static int
1203check_target_added (void *cls, 1223check_target_added (void *cls,
1204 const struct GNUNET_HashCode *key, 1224 const struct GNUNET_HashCode *key,
1205 void *value) 1225 void *value)
1206{ 1226{
1207 struct DirectNeighbor *neighbor = cls; 1227 struct DirectNeighbor *neighbor = cls;
1208 struct Target *target = value; 1228 struct Target *target = value;
@@ -1244,7 +1264,7 @@ check_target_added (void *cls,
1244 "Discovered new route to %s using %u hops\n", 1264 "Discovered new route to %s using %u hops\n",
1245 GNUNET_i2s (&target->peer), 1265 GNUNET_i2s (&target->peer),
1246 (unsigned int) (ntohl (target->distance) + 1)); 1266 (unsigned int) (ntohl (target->distance) + 1));
1247 current_route = GNUNET_malloc (sizeof (struct Route)); 1267 current_route = GNUNET_new (struct Route);
1248 current_route->next_hop = neighbor; 1268 current_route->next_hop = neighbor;
1249 current_route->target.peer = target->peer; 1269 current_route->target.peer = target->peer;
1250 current_route->target.distance = htonl (ntohl (target->distance) + 1); 1270 current_route->target.distance = htonl (ntohl (target->distance) + 1);
@@ -1277,6 +1297,9 @@ handle_set_union_result (void *cls,
1277 struct DirectNeighbor *neighbor = cls; 1297 struct DirectNeighbor *neighbor = cls;
1278 struct Target *target; 1298 struct Target *target;
1279 1299
1300 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1301 "Got SET union result: %d\n",
1302 status);
1280 switch (status) 1303 switch (status)
1281 { 1304 {
1282 case GNUNET_SET_STATUS_OK: 1305 case GNUNET_SET_STATUS_OK:
@@ -1285,7 +1308,7 @@ handle_set_union_result (void *cls,
1285 GNUNET_break_op (0); 1308 GNUNET_break_op (0);
1286 return; 1309 return;
1287 } 1310 }
1288 target = GNUNET_malloc (sizeof (struct Target)); 1311 target = GNUNET_new (struct Target);
1289 memcpy (target, element->data, sizeof (struct Target)); 1312 memcpy (target, element->data, sizeof (struct Target));
1290 if (GNUNET_YES != 1313 if (GNUNET_YES !=
1291 GNUNET_CONTAINER_multihashmap_put (neighbor->neighbor_table_consensus, 1314 GNUNET_CONTAINER_multihashmap_put (neighbor->neighbor_table_consensus,
@@ -1422,6 +1445,8 @@ initiate_set_union (void *cls,
1422{ 1445{
1423 struct DirectNeighbor *neighbor = cls; 1446 struct DirectNeighbor *neighbor = cls;
1424 1447
1448 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1449 "Initiating SET union\n");
1425 neighbor->initiate_task = GNUNET_SCHEDULER_NO_TASK; 1450 neighbor->initiate_task = GNUNET_SCHEDULER_NO_TASK;
1426 neighbor->my_set = GNUNET_SET_create (cfg, 1451 neighbor->my_set = GNUNET_SET_create (cfg,
1427 GNUNET_SET_OPERATION_UNION); 1452 GNUNET_SET_OPERATION_UNION);
@@ -1455,6 +1480,8 @@ handle_dv_route_message (void *cls, const struct GNUNET_PeerIdentity *peer,
1455 const struct GNUNET_MessageHeader *payload; 1480 const struct GNUNET_MessageHeader *payload;
1456 struct Route *route; 1481 struct Route *route;
1457 1482
1483 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1484 "Handling DV message\n");
1458 if (ntohs (message->size) < sizeof (struct RouteMessage) + sizeof (struct GNUNET_MessageHeader)) 1485 if (ntohs (message->size) < sizeof (struct RouteMessage) + sizeof (struct GNUNET_MessageHeader))
1459 { 1486 {
1460 GNUNET_break_op (0); 1487 GNUNET_break_op (0);
@@ -1506,6 +1533,9 @@ handle_dv_route_message (void *cls, const struct GNUNET_PeerIdentity *peer,
1506 1, GNUNET_NO); 1533 1, GNUNET_NO);
1507 return GNUNET_OK; 1534 return GNUNET_OK;
1508 } 1535 }
1536 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1537 "Forwarding message to %s\n",
1538 GNUNET_i2s (&rm->target));
1509 forward_payload (route->next_hop, 1539 forward_payload (route->next_hop,
1510 ntohl (route->target.distance), 1540 ntohl (route->target.distance),
1511 0, 1541 0,
diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c
index 8f22246eb..9d1e06777 100644
--- a/src/dv/plugin_transport_dv.c
+++ b/src/dv/plugin_transport_dv.c
@@ -38,6 +38,9 @@
38#include "dv.h" 38#include "dv.h"
39 39
40 40
41#define LOG(kind,...) GNUNET_log_from (kind, "transport-dv",__VA_ARGS__)
42
43
41/** 44/**
42 * Encapsulation of all of the state of the plugin. 45 * Encapsulation of all of the state of the plugin.
43 */ 46 */
@@ -287,7 +290,7 @@ handle_dv_connect (void *cls,
287 notify_distance_change (session); 290 notify_distance_change (session);
288 return; /* nothing to do */ 291 return; /* nothing to do */
289 } 292 }
290 session = GNUNET_malloc (sizeof (struct Session)); 293 session = GNUNET_new (struct Session);
291 session->sender = *peer; 294 session->sender = *peer;
292 session->distance = distance; 295 session->distance = distance;
293 GNUNET_assert (GNUNET_YES == 296 GNUNET_assert (GNUNET_YES ==
@@ -451,7 +454,7 @@ dv_plugin_send (void *cls,
451 memcpy (&box[1], msgbuf, msgbuf_size); 454 memcpy (&box[1], msgbuf, msgbuf_size);
452 msg = box; 455 msg = box;
453 } 456 }
454 pr = GNUNET_malloc (sizeof (struct PendingRequest)); 457 pr = GNUNET_new (struct PendingRequest);
455 pr->transmit_cont = cont; 458 pr->transmit_cont = cont;
456 pr->transmit_cont_cls = cont_cls; 459 pr->transmit_cont_cls = cont_cls;
457 pr->session = session; 460 pr->session = session;
@@ -656,6 +659,9 @@ dv_get_network (void *cls,
656 659
657/** 660/**
658 * Entry point for the plugin. 661 * Entry point for the plugin.
662 *
663 * @param cls closure with the plugin environment
664 * @return plugin API
659 */ 665 */
660void * 666void *
661libgnunet_plugin_transport_dv_init (void *cls) 667libgnunet_plugin_transport_dv_init (void *cls)
@@ -664,7 +670,7 @@ libgnunet_plugin_transport_dv_init (void *cls)
664 struct GNUNET_TRANSPORT_PluginFunctions *api; 670 struct GNUNET_TRANSPORT_PluginFunctions *api;
665 struct Plugin *plugin; 671 struct Plugin *plugin;
666 672
667 plugin = GNUNET_malloc (sizeof (struct Plugin)); 673 plugin = GNUNET_new (struct Plugin);
668 plugin->env = env; 674 plugin->env = env;
669 plugin->sessions = GNUNET_CONTAINER_multihashmap_create (1024 * 8, GNUNET_YES); 675 plugin->sessions = GNUNET_CONTAINER_multihashmap_create (1024 * 8, GNUNET_YES);
670 plugin->mst = GNUNET_SERVER_mst_create (&unbox_cb, 676 plugin->mst = GNUNET_SERVER_mst_create (&unbox_cb,
@@ -682,7 +688,7 @@ libgnunet_plugin_transport_dv_init (void *cls)
682 GNUNET_free (plugin); 688 GNUNET_free (plugin);
683 return NULL; 689 return NULL;
684 } 690 }
685 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); 691 api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions);
686 api->cls = plugin; 692 api->cls = plugin;
687 api->send = &dv_plugin_send; 693 api->send = &dv_plugin_send;
688 api->disconnect = &dv_plugin_disconnect; 694 api->disconnect = &dv_plugin_disconnect;
@@ -718,6 +724,9 @@ free_session_iterator (void *cls,
718 724
719/** 725/**
720 * Exit point from the plugin. 726 * Exit point from the plugin.
727 *
728 * @param cls plugin API
729 * @return NULL
721 */ 730 */
722void * 731void *
723libgnunet_plugin_transport_dv_done (void *cls) 732libgnunet_plugin_transport_dv_done (void *cls)
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c
index e5c42eca0..c25c2cbad 100644
--- a/src/set/gnunet-service-set.c
+++ b/src/set/gnunet-service-set.c
@@ -561,8 +561,9 @@ handle_client_reject (void *cls,
561 const struct GNUNET_MessageHeader *m) 561 const struct GNUNET_MessageHeader *m)
562{ 562{
563 struct Incoming *incoming; 563 struct Incoming *incoming;
564 struct GNUNET_SET_AcceptRejectMessage *msg = (struct GNUNET_SET_AcceptRejectMessage *) m; 564 const struct GNUNET_SET_AcceptRejectMessage *msg;
565 565
566 msg = (const struct GNUNET_SET_AcceptRejectMessage *) m;
566 GNUNET_break (0 == ntohl (msg->request_id)); 567 GNUNET_break (0 == ntohl (msg->request_id));
567 568
568 incoming = get_incoming (ntohl (msg->accept_reject_id)); 569 incoming = get_incoming (ntohl (msg->accept_reject_id));
@@ -603,7 +604,8 @@ handle_client_add_remove (void *cls,
603 } 604 }
604 msg = (const struct GNUNET_SET_ElementMessage *) m; 605 msg = (const struct GNUNET_SET_ElementMessage *) m;
605 el.size = ntohs (m->size) - sizeof *msg; 606 el.size = ntohs (m->size) - sizeof *msg;
606 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "client ins/rem element of size %u\n", el.size); 607 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
608 "client ins/rem element of size %u\n", el.size);
607 el.data = &msg[1]; 609 el.data = &msg[1];
608 if (GNUNET_MESSAGE_TYPE_SET_REMOVE == ntohs (m->type)) 610 if (GNUNET_MESSAGE_TYPE_SET_REMOVE == ntohs (m->type))
609 set->vt->remove (set->state, &el); 611 set->vt->remove (set->state, &el);
diff --git a/src/set/set_api.c b/src/set/set_api.c
index d3131648b..b98f9fd92 100644
--- a/src/set/set_api.c
+++ b/src/set/set_api.c
@@ -157,12 +157,13 @@ struct GNUNET_SET_ListenHandle
157static void 157static void
158handle_result (void *cls, const struct GNUNET_MessageHeader *mh) 158handle_result (void *cls, const struct GNUNET_MessageHeader *mh)
159{ 159{
160 struct GNUNET_SET_ResultMessage *msg = (struct GNUNET_SET_ResultMessage *) mh; 160 const struct GNUNET_SET_ResultMessage *msg;
161 struct GNUNET_SET_Handle *set = cls; 161 struct GNUNET_SET_Handle *set = cls;
162 struct GNUNET_SET_OperationHandle *oh; 162 struct GNUNET_SET_OperationHandle *oh;
163 struct GNUNET_SET_Element e; 163 struct GNUNET_SET_Element e;
164 enum GNUNET_SET_Status result_status; 164 enum GNUNET_SET_Status result_status;
165 165
166 msg = (const struct GNUNET_SET_ResultMessage *) mh;
166 GNUNET_assert (NULL != set); 167 GNUNET_assert (NULL != set);
167 GNUNET_assert (NULL != set->mq); 168 GNUNET_assert (NULL != set->mq);
168 169