aboutsummaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/gnunet-rps-profiler.c122
-rw-r--r--src/rps/gnunet-rps.c3
-rw-r--r--src/rps/gnunet-service-rps.c36
-rw-r--r--src/rps/gnunet-service-rps_custommap.c10
-rw-r--r--src/rps/gnunet-service-rps_sampler.c1
-rw-r--r--src/rps/gnunet-service-rps_sampler_elem.c2
-rw-r--r--src/rps/gnunet-service-rps_view.c1
-rw-r--r--src/rps/rps-sampler_common.c2
-rw-r--r--src/rps/rps-test_util.c16
-rw-r--r--src/rps/rps.h1
-rw-r--r--src/rps/rps_api.c6
-rw-r--r--src/rps/test_rps.c157
-rw-r--r--src/rps/test_rps_api.c1
-rw-r--r--src/rps/test_service_rps_custommap.c1
-rw-r--r--src/rps/test_service_rps_sampler_elem.c1
-rw-r--r--src/rps/test_service_rps_view.c1
16 files changed, 255 insertions, 106 deletions
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index 03b96f264..af43a0fa1 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -160,7 +160,8 @@ struct STATcls
160 * 160 *
161 * @return corresponding enum 161 * @return corresponding enum
162 */ 162 */
163enum STAT_TYPE stat_str_2_type (const char *stat_str) 163enum STAT_TYPE
164stat_str_2_type (const char *stat_str)
164{ 165{
165 if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_NO_PULL], 166 if (0 == strncmp (stat_type_strings[STAT_TYPE_BLOCKS_NO_PULL],
166 stat_str, 167 stat_str,
@@ -890,9 +891,7 @@ tofile_ (const char *file_name, const char *line)
890 "Failed to write string to buffer (size: %i)\n", 891 "Failed to write string to buffer (size: %i)\n",
891 size); 892 size);
892 return; 893 return;
893 } */ 894 } */size = strlen (line) * sizeof(char);
894
895 size = strlen (line) * sizeof(char);
896 895
897 size2 = GNUNET_DISK_file_write (f, line, size); 896 size2 = GNUNET_DISK_file_write (f, line, size);
898 if (size != size2) 897 if (size != size2)
@@ -916,6 +915,7 @@ tofile_ (const char *file_name, const char *line)
916 } 915 }
917} 916}
918 917
918
919/** 919/**
920 * This function is used to facilitate writing important information to disk 920 * This function is used to facilitate writing important information to disk
921 */ 921 */
@@ -1000,7 +1000,8 @@ make_oplist_entry ()
1000 * @return #GNUNET_YES if so 1000 * @return #GNUNET_YES if so
1001 * #GNUNET_NO otherwise 1001 * #GNUNET_NO otherwise
1002 */ 1002 */
1003static int check_statistics_collect_completed_single_peer ( 1003static int
1004check_statistics_collect_completed_single_peer (
1004 const struct RPSPeer *rps_peer) 1005 const struct RPSPeer *rps_peer)
1005{ 1006{
1006 if (cur_test_run.stat_collect_flags != 1007 if (cur_test_run.stat_collect_flags !=
@@ -1011,6 +1012,8 @@ static int check_statistics_collect_completed_single_peer (
1011 } 1012 }
1012 return GNUNET_YES; 1013 return GNUNET_YES;
1013} 1014}
1015
1016
1014/** 1017/**
1015 * @brief Checks if all peers already received their statistics value from the 1018 * @brief Checks if all peers already received their statistics value from the
1016 * statistics service. 1019 * statistics service.
@@ -1018,7 +1021,8 @@ static int check_statistics_collect_completed_single_peer (
1018 * @return #GNUNET_YES if so 1021 * @return #GNUNET_YES if so
1019 * #GNUNET_NO otherwise 1022 * #GNUNET_NO otherwise
1020 */ 1023 */
1021static int check_statistics_collect_completed () 1024static int
1025check_statistics_collect_completed ()
1022{ 1026{
1023 uint32_t i; 1027 uint32_t i;
1024 1028
@@ -1039,6 +1043,7 @@ static int check_statistics_collect_completed ()
1039 return GNUNET_YES; 1043 return GNUNET_YES;
1040} 1044}
1041 1045
1046
1042static void 1047static void
1043rps_disconnect_adapter (void *cls, 1048rps_disconnect_adapter (void *cls,
1044 void *op_result); 1049 void *op_result);
@@ -1059,6 +1064,7 @@ cancel_pending_req (struct PendingRequest *pending_req)
1059 GNUNET_free (pending_req); 1064 GNUNET_free (pending_req);
1060} 1065}
1061 1066
1067
1062static void 1068static void
1063cancel_request (struct PendingReply *pending_rep) 1069cancel_request (struct PendingReply *pending_rep)
1064{ 1070{
@@ -1078,6 +1084,7 @@ cancel_request (struct PendingReply *pending_rep)
1078 pending_rep = NULL; 1084 pending_rep = NULL;
1079} 1085}
1080 1086
1087
1081void 1088void
1082clean_peer (unsigned peer_index) 1089clean_peer (unsigned peer_index)
1083{ 1090{
@@ -1111,6 +1118,7 @@ clean_peer (unsigned peer_index)
1111 } 1118 }
1112} 1119}
1113 1120
1121
1114/** 1122/**
1115 * Task run on timeout to shut everything down. 1123 * Task run on timeout to shut everything down.
1116 */ 1124 */
@@ -1158,6 +1166,7 @@ shutdown_op (void *cls)
1158 close_all_files (); 1166 close_all_files ();
1159} 1167}
1160 1168
1169
1161static void 1170static void
1162trigger_shutdown (void *cls) 1171trigger_shutdown (void *cls)
1163{ 1172{
@@ -1209,7 +1218,7 @@ post_test_op (void *cls)
1209 } 1218 }
1210 } 1219 }
1211 /* If we do not collect statistics, shut down directly */ 1220 /* If we do not collect statistics, shut down directly */
1212 if ((NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics)|| 1221 if ((NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics) ||
1213 (GNUNET_YES == check_statistics_collect_completed ()) ) 1222 (GNUNET_YES == check_statistics_collect_completed ()) )
1214 { 1223 {
1215 GNUNET_SCHEDULER_cancel (shutdown_task); 1224 GNUNET_SCHEDULER_cancel (shutdown_task);
@@ -1255,12 +1264,12 @@ info_cb (void *cb_cls,
1255 1264
1256 (void) op; 1265 (void) op;
1257 1266
1258 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1267 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1259 { 1268 {
1260 return; 1269 return;
1261 } 1270 }
1262 1271
1263 if ((NULL == pinfo)||(NULL != emsg)) 1272 if ((NULL == pinfo) || (NULL != emsg))
1264 { 1273 {
1265 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg); 1274 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg);
1266 GNUNET_TESTBED_operation_done (entry->op); 1275 GNUNET_TESTBED_operation_done (entry->op);
@@ -1309,7 +1318,7 @@ rps_connect_complete_cb (void *cls,
1309 struct RPSPeer *rps_peer = cls; 1318 struct RPSPeer *rps_peer = cls;
1310 struct GNUNET_RPS_Handle *rps = ca_result; 1319 struct GNUNET_RPS_Handle *rps = ca_result;
1311 1320
1312 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1321 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1313 { 1322 {
1314 return; 1323 return;
1315 } 1324 }
@@ -1361,6 +1370,7 @@ rps_connect_adapter (void *cls,
1361 return h; 1370 return h;
1362} 1371}
1363 1372
1373
1364/** 1374/**
1365 * Called to open a connection to the peer's statistics 1375 * Called to open a connection to the peer's statistics
1366 * 1376 *
@@ -1380,6 +1390,7 @@ stat_connect_adapter (void *cls,
1380 return peer->stats_h; 1390 return peer->stats_h;
1381} 1391}
1382 1392
1393
1383/** 1394/**
1384 * Called to disconnect from peer's statistics service 1395 * Called to disconnect from peer's statistics service
1385 * 1396 *
@@ -1401,6 +1412,7 @@ stat_disconnect_adapter (void *cls, void *op_result)
1401 peer->stats_h = NULL; 1412 peer->stats_h = NULL;
1402} 1413}
1403 1414
1415
1404/** 1416/**
1405 * Called after successfully opening a connection to a peer's statistics 1417 * Called after successfully opening a connection to a peer's statistics
1406 * service; we register statistics monitoring for CORE and NSE here. 1418 * service; we register statistics monitoring for CORE and NSE here.
@@ -1551,7 +1563,7 @@ request_peers (void *cls)
1551 rps_peer->pending_req_tail, 1563 rps_peer->pending_req_tail,
1552 pending_req); 1564 pending_req);
1553 rps_peer->num_pending_reqs--; 1565 rps_peer->num_pending_reqs--;
1554 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1566 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1555 return; 1567 return;
1556 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1568 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1557 "Requesting one peer\n"); 1569 "Requesting one peer\n");
@@ -1604,6 +1616,7 @@ schedule_missing_requests (struct RPSPeer *rps_peer)
1604 } 1616 }
1605} 1617}
1606 1618
1619
1607void 1620void
1608cancel_pending_req_rep (struct RPSPeer *rps_peer) 1621cancel_pending_req_rep (struct RPSPeer *rps_peer)
1609{ 1622{
@@ -1617,6 +1630,7 @@ cancel_pending_req_rep (struct RPSPeer *rps_peer)
1617 GNUNET_assert (0 == rps_peer->num_pending_reps); 1630 GNUNET_assert (0 == rps_peer->num_pending_reps);
1618} 1631}
1619 1632
1633
1620/*********************************** 1634/***********************************
1621* MALICIOUS 1635* MALICIOUS
1622***********************************/ 1636***********************************/
@@ -1624,7 +1638,8 @@ cancel_pending_req_rep (struct RPSPeer *rps_peer)
1624/** 1638/**
1625 * Initialise only non-mal RPSPeers 1639 * Initialise only non-mal RPSPeers
1626 */ 1640 */
1627static void mal_init_peer (struct RPSPeer *rps_peer) 1641static void
1642mal_init_peer (struct RPSPeer *rps_peer)
1628{ 1643{
1629 if (rps_peer->index >= round (portion * num_peers)) 1644 if (rps_peer->index >= round (portion * num_peers))
1630 rps_peer->num_ids_to_request = 1; 1645 rps_peer->num_ids_to_request = 1;
@@ -1664,12 +1679,13 @@ mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
1664 #endif /* ENABLE_MALICIOUS */ 1679 #endif /* ENABLE_MALICIOUS */
1665} 1680}
1666 1681
1682
1667static void 1683static void
1668mal_cb (struct RPSPeer *rps_peer) 1684mal_cb (struct RPSPeer *rps_peer)
1669{ 1685{
1670 uint32_t num_mal_peers; 1686 uint32_t num_mal_peers;
1671 1687
1672 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1688 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1673 { 1689 {
1674 return; 1690 return;
1675 } 1691 }
@@ -1690,6 +1706,7 @@ mal_cb (struct RPSPeer *rps_peer)
1690 #endif /* ENABLE_MALICIOUS */ 1706 #endif /* ENABLE_MALICIOUS */
1691} 1707}
1692 1708
1709
1693/*********************************** 1710/***********************************
1694* CHURN 1711* CHURN
1695***********************************/ 1712***********************************/
@@ -1711,13 +1728,13 @@ churn (void *cls);
1711static void 1728static void
1712churn_test_cb (struct RPSPeer *rps_peer) 1729churn_test_cb (struct RPSPeer *rps_peer)
1713{ 1730{
1714 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1731 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1715 { 1732 {
1716 return; 1733 return;
1717 } 1734 }
1718 1735
1719 /* Start churn */ 1736 /* Start churn */
1720 if ((HAVE_CHURN == cur_test_run.have_churn)&&(NULL == churn_task)) 1737 if ((HAVE_CHURN == cur_test_run.have_churn) && (NULL == churn_task))
1721 { 1738 {
1722 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1739 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1723 "Starting churn task\n"); 1740 "Starting churn task\n");
@@ -1735,6 +1752,7 @@ churn_test_cb (struct RPSPeer *rps_peer)
1735 schedule_missing_requests (rps_peer); 1752 schedule_missing_requests (rps_peer);
1736} 1753}
1737 1754
1755
1738/*********************************** 1756/***********************************
1739* PROFILER 1757* PROFILER
1740***********************************/ 1758***********************************/
@@ -1756,7 +1774,7 @@ churn_cb (void *cls,
1756 1774
1757 (void) op; 1775 (void) op;
1758 1776
1759 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1777 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1760 { 1778 {
1761 return; 1779 return;
1762 } 1780 }
@@ -1828,6 +1846,7 @@ churn_cb (void *cls,
1828 // run_round (); 1846 // run_round ();
1829} 1847}
1830 1848
1849
1831/** 1850/**
1832 * @brief Set the rps-service up or down for a specific peer 1851 * @brief Set the rps-service up or down for a specific peer
1833 * 1852 *
@@ -1895,7 +1914,7 @@ churn (void *cls)
1895 1914
1896 (void) cls; 1915 (void) cls;
1897 1916
1898 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1917 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1899 { 1918 {
1900 return; 1919 return;
1901 } 1920 }
@@ -1956,7 +1975,8 @@ churn (void *cls)
1956/** 1975/**
1957 * Initialise given RPSPeer 1976 * Initialise given RPSPeer
1958 */ 1977 */
1959static void profiler_init_peer (struct RPSPeer *rps_peer) 1978static void
1979profiler_init_peer (struct RPSPeer *rps_peer)
1960{ 1980{
1961 rps_peer->num_ids_to_request = cur_test_run.num_requests; 1981 rps_peer->num_ids_to_request = cur_test_run.num_requests;
1962 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "peer shall request %i peers\n", 1982 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "peer shall request %i peers\n",
@@ -2111,13 +2131,13 @@ profiler_reply_handle_info (void *cls,
2111static void 2131static void
2112profiler_cb (struct RPSPeer *rps_peer) 2132profiler_cb (struct RPSPeer *rps_peer)
2113{ 2133{
2114 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 2134 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
2115 { 2135 {
2116 return; 2136 return;
2117 } 2137 }
2118 2138
2119 /* Start churn */ 2139 /* Start churn */
2120 if ((HAVE_CHURN == cur_test_run.have_churn)&&(NULL == churn_task)) 2140 if ((HAVE_CHURN == cur_test_run.have_churn) && (NULL == churn_task))
2121 { 2141 {
2122 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2142 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2123 "Starting churn task\n"); 2143 "Starting churn task\n");
@@ -2139,6 +2159,7 @@ profiler_cb (struct RPSPeer *rps_peer)
2139 schedule_missing_requests (rps_peer); 2159 schedule_missing_requests (rps_peer);
2140} 2160}
2141 2161
2162
2142/** 2163/**
2143 * Function called from #profiler_eval with a filename. 2164 * Function called from #profiler_eval with a filename.
2144 * 2165 *
@@ -2175,6 +2196,7 @@ file_name_cb (void *cls, const char *filename)
2175 return GNUNET_OK; 2196 return GNUNET_OK;
2176} 2197}
2177 2198
2199
2178/** 2200/**
2179 * This is run after the test finished. 2201 * This is run after the test finished.
2180 * 2202 *
@@ -2202,7 +2224,8 @@ profiler_eval (void)
2202 * 2224 *
2203 * @return 2225 * @return
2204 */ 2226 */
2205static int is_in_view (uint32_t a, uint32_t b) 2227static int
2228is_in_view (uint32_t a, uint32_t b)
2206{ 2229{
2207 uint32_t i; 2230 uint32_t i;
2208 2231
@@ -2218,7 +2241,9 @@ static int is_in_view (uint32_t a, uint32_t b)
2218 return GNUNET_NO; 2241 return GNUNET_NO;
2219} 2242}
2220 2243
2221static uint32_t get_idx_of_pid (const struct GNUNET_PeerIdentity *pid) 2244
2245static uint32_t
2246get_idx_of_pid (const struct GNUNET_PeerIdentity *pid)
2222{ 2247{
2223 uint32_t i; 2248 uint32_t i;
2224 2249
@@ -2238,6 +2263,7 @@ static uint32_t get_idx_of_pid (const struct GNUNET_PeerIdentity *pid)
2238 GNUNET_assert (0); 2263 GNUNET_assert (0);
2239} 2264}
2240 2265
2266
2241/** 2267/**
2242 * @brief Counts number of peers in view of a that have b in their view 2268 * @brief Counts number of peers in view of a that have b in their view
2243 * 2269 *
@@ -2246,7 +2272,8 @@ static uint32_t get_idx_of_pid (const struct GNUNET_PeerIdentity *pid)
2246 * 2272 *
2247 * @return 2273 * @return
2248 */ 2274 */
2249static uint32_t count_containing_views (uint32_t a, uint32_t b) 2275static uint32_t
2276count_containing_views (uint32_t a, uint32_t b)
2250{ 2277{
2251 uint32_t i; 2278 uint32_t i;
2252 uint32_t peer_idx; 2279 uint32_t peer_idx;
@@ -2263,13 +2290,15 @@ static uint32_t count_containing_views (uint32_t a, uint32_t b)
2263 return count; 2290 return count;
2264} 2291}
2265 2292
2293
2266/** 2294/**
2267 * @brief Computes the probability for each other peer to be selected by the 2295 * @brief Computes the probability for each other peer to be selected by the
2268 * sampling process based on the views of all peers 2296 * sampling process based on the views of all peers
2269 * 2297 *
2270 * @param peer_idx index of the peer that is about to sample 2298 * @param peer_idx index of the peer that is about to sample
2271 */ 2299 */
2272static void compute_probabilities (uint32_t peer_idx) 2300static void
2301compute_probabilities (uint32_t peer_idx)
2273{ 2302{
2274 // double probs[num_peers] = { 0 }; 2303 // double probs[num_peers] = { 0 };
2275 double probs[num_peers]; 2304 double probs[num_peers];
@@ -2427,6 +2456,7 @@ static void compute_probabilities (uint32_t peer_idx)
2427 GNUNET_free (probs_as_str); 2456 GNUNET_free (probs_as_str);
2428} 2457}
2429 2458
2459
2430/** 2460/**
2431 * @brief This counts the number of peers in which views a given peer occurs. 2461 * @brief This counts the number of peers in which views a given peer occurs.
2432 * 2462 *
@@ -2436,7 +2466,8 @@ static void compute_probabilities (uint32_t peer_idx)
2436 * 2466 *
2437 * @return the number of occurrences 2467 * @return the number of occurrences
2438 */ 2468 */
2439static uint32_t count_peer_in_views_2 (uint32_t peer_idx) 2469static uint32_t
2470count_peer_in_views_2 (uint32_t peer_idx)
2440{ 2471{
2441 uint32_t i, j; 2472 uint32_t i, j;
2442 uint32_t count = 0; 2473 uint32_t count = 0;
@@ -2458,7 +2489,9 @@ static uint32_t count_peer_in_views_2 (uint32_t peer_idx)
2458 return count; 2489 return count;
2459} 2490}
2460 2491
2461static uint32_t cumulated_view_sizes () 2492
2493static uint32_t
2494cumulated_view_sizes ()
2462{ 2495{
2463 uint32_t i; 2496 uint32_t i;
2464 2497
@@ -2470,7 +2503,9 @@ static uint32_t cumulated_view_sizes ()
2470 return view_sizes; 2503 return view_sizes;
2471} 2504}
2472 2505
2473static void count_peer_in_views (uint32_t *count_peers) 2506
2507static void
2508count_peer_in_views (uint32_t *count_peers)
2474{ 2509{
2475 uint32_t i, j; 2510 uint32_t i, j;
2476 2511
@@ -2488,7 +2523,9 @@ static void count_peer_in_views (uint32_t *count_peers)
2488 } 2523 }
2489} 2524}
2490 2525
2491void compute_diversity () 2526
2527void
2528compute_diversity ()
2492{ 2529{
2493 uint32_t i; 2530 uint32_t i;
2494 /* ith entry represents the numer of occurrences in other peer's views */ 2531 /* ith entry represents the numer of occurrences in other peer's views */
@@ -2531,7 +2568,9 @@ void compute_diversity ()
2531 GNUNET_free (deviation); 2568 GNUNET_free (deviation);
2532} 2569}
2533 2570
2534void print_view_sizes () 2571
2572void
2573print_view_sizes ()
2535{ 2574{
2536 uint32_t i; 2575 uint32_t i;
2537 2576
@@ -2545,15 +2584,19 @@ void print_view_sizes ()
2545 } 2584 }
2546} 2585}
2547 2586
2548void all_views_updated_cb () 2587
2588void
2589all_views_updated_cb ()
2549{ 2590{
2550 compute_diversity (); 2591 compute_diversity ();
2551 print_view_sizes (); 2592 print_view_sizes ();
2552} 2593}
2553 2594
2554void view_update_cb (void *cls, 2595
2555 uint64_t view_size, 2596void
2556 const struct GNUNET_PeerIdentity *peers) 2597view_update_cb (void *cls,
2598 uint64_t view_size,
2599 const struct GNUNET_PeerIdentity *peers)
2557{ 2600{
2558 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2601 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2559 "View was updated (%" PRIu64 ")\n", view_size); 2602 "View was updated (%" PRIu64 ")\n", view_size);
@@ -2602,6 +2645,7 @@ void view_update_cb (void *cls,
2602 all_views_updated_cb (); 2645 all_views_updated_cb ();
2603} 2646}
2604 2647
2648
2605static void 2649static void
2606pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) 2650pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
2607{ 2651{
@@ -2612,7 +2656,9 @@ pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
2612 GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer); 2656 GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer);
2613} 2657}
2614 2658
2615void write_final_stats (void) 2659
2660void
2661write_final_stats (void)
2616{ 2662{
2617 uint64_t sums[STAT_TYPE_MAX] = { 0 }; 2663 uint64_t sums[STAT_TYPE_MAX] = { 0 };
2618 2664
@@ -2732,6 +2778,7 @@ void write_final_stats (void)
2732 sums[STAT_TYPE_VIEW_SIZE_AIM]); 2778 sums[STAT_TYPE_VIEW_SIZE_AIM]);
2733} 2779}
2734 2780
2781
2735/** 2782/**
2736 * Continuation called by #GNUNET_STATISTICS_get() functions. 2783 * Continuation called by #GNUNET_STATISTICS_get() functions.
2737 * 2784 *
@@ -2766,7 +2813,7 @@ post_test_shutdown_ready_cb (void *cls,
2766 return; 2813 return;
2767 } 2814 }
2768 2815
2769 if ((NULL != rps_peer->stat_op)&& 2816 if ((NULL != rps_peer->stat_op) &&
2770 (GNUNET_YES == check_statistics_collect_completed_single_peer ( 2817 (GNUNET_YES == check_statistics_collect_completed_single_peer (
2771 rps_peer)) ) 2818 rps_peer)) )
2772 { 2819 {
@@ -2788,6 +2835,7 @@ post_test_shutdown_ready_cb (void *cls,
2788 } 2835 }
2789} 2836}
2790 2837
2838
2791/** 2839/**
2792 * Callback function to process statistic values. 2840 * Callback function to process statistic values.
2793 * 2841 *
@@ -2907,7 +2955,7 @@ test_run (void *cls,
2907 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n"); 2955 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n");
2908 2956
2909 /* Check whether we timed out */ 2957 /* Check whether we timed out */
2910 if ((n_peers != num_peers)|| 2958 if ((n_peers != num_peers) ||
2911 (NULL == peers) || 2959 (NULL == peers) ||
2912 (0 == links_succeeded) ) 2960 (0 == links_succeeded) )
2913 { 2961 {
@@ -3127,6 +3175,7 @@ run (void *cls,
3127 NULL); 3175 NULL);
3128} 3176}
3129 3177
3178
3130/** 3179/**
3131 * Entry point for the testcase, sets up the testbed. 3180 * Entry point for the testcase, sets up the testbed.
3132 * 3181 *
@@ -3204,4 +3253,5 @@ main (int argc, char *argv[])
3204 return ret_value; 3253 return ret_value;
3205} 3254}
3206 3255
3256
3207/* end of test_rps.c */ 3257/* end of test_rps.c */
diff --git a/src/rps/gnunet-rps.c b/src/rps/gnunet-rps.c
index 6c1c96cc9..33c03f006 100644
--- a/src/rps/gnunet-rps.c
+++ b/src/rps/gnunet-rps.c
@@ -106,6 +106,7 @@ reply_handle (void *cls,
106 GNUNET_SCHEDULER_shutdown (); 106 GNUNET_SCHEDULER_shutdown ();
107} 107}
108 108
109
109/** 110/**
110 * Callback called on receipt view update. 111 * Callback called on receipt view update.
111 * Prints view. 112 * Prints view.
@@ -249,6 +250,7 @@ run (void *cls,
249 } 250 }
250} 251}
251 252
253
252/** 254/**
253 * The main function to rps. 255 * The main function to rps.
254 * 256 *
@@ -288,4 +290,5 @@ main (int argc, char *const *argv)
288 options, &run, NULL)) ? ret : 1; 290 options, &run, NULL)) ? ret : 1;
289} 291}
290 292
293
291/* end of gnunet-rps.c */ 294/* end of gnunet-rps.c */
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 66ffd173a..58fbd6a18 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -85,7 +85,6 @@
85#define unset_channel_flag(channel_flags, mask) ((*channel_flags) &= ~(mask)) 85#define unset_channel_flag(channel_flags, mask) ((*channel_flags) &= ~(mask))
86 86
87 87
88
89/** 88/**
90 * Pending operation on peer consisting of callback and closure 89 * Pending operation on peer consisting of callback and closure
91 * 90 *
@@ -623,6 +622,7 @@ get_peer_ctx (const struct GNUNET_CONTAINER_MultiPeerMap *peer_map,
623 return ctx; 622 return ctx;
624} 623}
625 624
625
626/** 626/**
627 * @brief Check whether we have information about the given peer. 627 * @brief Check whether we have information about the given peer.
628 * 628 *
@@ -856,6 +856,7 @@ add_valid_peer (const struct GNUNET_PeerIdentity *peer,
856 return ret; 856 return ret;
857} 857}
858 858
859
859static void 860static void
860remove_pending_message (struct PendingMessage *pending_msg, int cancel); 861remove_pending_message (struct PendingMessage *pending_msg, int cancel);
861 862
@@ -900,6 +901,7 @@ set_peer_online (struct PeerContext *peer_ctx)
900 GNUNET_array_grow (peer_ctx->pending_ops, peer_ctx->num_pending_ops, 0); 901 GNUNET_array_grow (peer_ctx->pending_ops, peer_ctx->num_pending_ops, 0);
901} 902}
902 903
904
903static void 905static void
904cleanup_destroyed_channel (void *cls, 906cleanup_destroyed_channel (void *cls,
905 const struct GNUNET_CADET_Channel *channel); 907 const struct GNUNET_CADET_Channel *channel);
@@ -1048,6 +1050,7 @@ get_mq (struct PeerContext *peer_ctx)
1048 return peer_ctx->mq; 1050 return peer_ctx->mq;
1049} 1051}
1050 1052
1053
1051/** 1054/**
1052 * @brief Add an envelope to a message passed to mq to list of pending messages 1055 * @brief Add an envelope to a message passed to mq to list of pending messages
1053 * 1056 *
@@ -1124,6 +1127,7 @@ mq_online_check_successful (void *cls)
1124 } 1127 }
1125} 1128}
1126 1129
1130
1127/** 1131/**
1128 * Issue a check whether peer is online 1132 * Issue a check whether peer is online
1129 * 1133 *
@@ -1758,6 +1762,7 @@ check_peer_flag (const struct GNUNET_CONTAINER_MultiPeerMap *peer_map,
1758 return check_peer_flag_set (peer_ctx, flags); 1762 return check_peer_flag_set (peer_ctx, flags);
1759} 1763}
1760 1764
1765
1761/** 1766/**
1762 * @brief Try connecting to a peer to see whether it is online 1767 * @brief Try connecting to a peer to see whether it is online
1763 * 1768 *
@@ -1969,6 +1974,7 @@ destroy_sending_channel (struct PeerContext *peer_ctx)
1969 return GNUNET_NO; 1974 return GNUNET_NO;
1970} 1975}
1971 1976
1977
1972/** 1978/**
1973 * @brief Send a message to another peer. 1979 * @brief Send a message to another peer.
1974 * 1980 *
@@ -1999,6 +2005,7 @@ send_message (struct PeerContext *peer_ctx,
1999 GNUNET_MQ_send (mq, ev); 2005 GNUNET_MQ_send (mq, ev);
2000} 2006}
2001 2007
2008
2002/** 2009/**
2003 * @brief Schedule a operation on given peer 2010 * @brief Schedule a operation on given peer
2004 * 2011 *
@@ -2035,6 +2042,7 @@ schedule_operation (struct PeerContext *peer_ctx,
2035 return GNUNET_NO; 2042 return GNUNET_NO;
2036} 2043}
2037 2044
2045
2038/*********************************************************************** 2046/***********************************************************************
2039* /Old gnunet-service-rps_peers.c 2047* /Old gnunet-service-rps_peers.c
2040***********************************************************************/ 2048***********************************************************************/
@@ -2122,9 +2130,6 @@ struct ClientContext *cli_ctx_tail;
2122***********************************************************************/ 2130***********************************************************************/
2123 2131
2124 2132
2125
2126
2127
2128/*********************************************************************** 2133/***********************************************************************
2129* Util functions 2134* Util functions
2130***********************************************************************/ 2135***********************************************************************/
@@ -2383,7 +2388,7 @@ clients_notify_stream_peer (const struct Sub *sub,
2383 cli_ctx_iter = cli_ctx_iter->next) 2388 cli_ctx_iter = cli_ctx_iter->next)
2384 { 2389 {
2385 if ((GNUNET_YES == cli_ctx_iter->stream_update) && 2390 if ((GNUNET_YES == cli_ctx_iter->stream_update) &&
2386 ((sub == cli_ctx_iter->sub) ||(sub == msub) )) 2391 ((sub == cli_ctx_iter->sub) || (sub == msub) ))
2387 { 2392 {
2388 send_stream_peers (cli_ctx_iter, num_peers, peers); 2393 send_stream_peers (cli_ctx_iter, num_peers, peers);
2389 } 2394 }
@@ -2828,7 +2833,7 @@ cleanup_destroyed_channel (void *cls,
2828 2833
2829 channel_ctx->channel = NULL; 2834 channel_ctx->channel = NULL;
2830 remove_channel_ctx (channel_ctx); 2835 remove_channel_ctx (channel_ctx);
2831 if ((NULL != peer_ctx)&& 2836 if ((NULL != peer_ctx) &&
2832 (peer_ctx->send_channel_ctx == channel_ctx) && 2837 (peer_ctx->send_channel_ctx == channel_ctx) &&
2833 (GNUNET_YES == check_sending_channel_needed (channel_ctx->peer_ctx)) ) 2838 (GNUNET_YES == check_sending_channel_needed (channel_ctx->peer_ctx)) )
2834 { 2839 {
@@ -2836,12 +2841,12 @@ cleanup_destroyed_channel (void *cls,
2836 } 2841 }
2837} 2842}
2838 2843
2844
2839/*********************************************************************** 2845/***********************************************************************
2840* /Util functions 2846* /Util functions
2841***********************************************************************/ 2847***********************************************************************/
2842 2848
2843 2849
2844
2845/*********************************************************************** 2850/***********************************************************************
2846* Sub 2851* Sub
2847***********************************************************************/ 2852***********************************************************************/
@@ -3016,6 +3021,8 @@ write_histogram_to_file (const uint32_t hist_array[],
3016 collect_str); 3021 collect_str);
3017 GNUNET_free (file_name_full); 3022 GNUNET_free (file_name_full);
3018} 3023}
3024
3025
3019#endif /* TO_FILE */ 3026#endif /* TO_FILE */
3020 3027
3021 3028
@@ -3148,6 +3155,7 @@ core_disconnects (void *cls,
3148 GNUNET_CONTAINER_multipeermap_remove_all (map_single_hop, peer); 3155 GNUNET_CONTAINER_multipeermap_remove_all (map_single_hop, peer);
3149} 3156}
3150 3157
3158
3151/*********************************************************************** 3159/***********************************************************************
3152* /Core handlers 3160* /Core handlers
3153***********************************************************************/ 3161***********************************************************************/
@@ -3442,7 +3450,7 @@ handle_client_start_sub (void *cls,
3442 struct ClientContext *cli_ctx = cls; 3450 struct ClientContext *cli_ctx = cls;
3443 3451
3444 LOG (GNUNET_ERROR_TYPE_DEBUG, "Client requested start of a new sub.\n"); 3452 LOG (GNUNET_ERROR_TYPE_DEBUG, "Client requested start of a new sub.\n");
3445 if ((NULL != cli_ctx->sub)&& 3453 if ((NULL != cli_ctx->sub) &&
3446 (0 != memcmp (&cli_ctx->sub->hash, 3454 (0 != memcmp (&cli_ctx->sub->hash,
3447 &msg->hash, 3455 &msg->hash,
3448 sizeof(struct GNUNET_HashCode))) ) 3456 sizeof(struct GNUNET_HashCode))) )
@@ -3633,7 +3641,7 @@ handle_peer_pull_request (void *cls,
3633 3641
3634 #if ENABLE_MALICIOUS 3642 #if ENABLE_MALICIOUS
3635 if ((1 == mal_type) 3643 if ((1 == mal_type)
3636 ||(3 == mal_type)) 3644 || (3 == mal_type))
3637 { /* Try to maximise representation */ 3645 { /* Try to maximise representation */
3638 send_pull_reply (peer_ctx, mal_peers, num_mal_peers); 3646 send_pull_reply (peer_ctx, mal_peers, num_mal_peers);
3639 } 3647 }
@@ -3774,13 +3782,13 @@ handle_peer_pull_reply (void *cls,
3774 3782
3775 #if ENABLE_MALICIOUS 3783 #if ENABLE_MALICIOUS
3776 if ((NULL != att_peer_set) && 3784 if ((NULL != att_peer_set) &&
3777 ((1 == mal_type) ||(3 == mal_type) )) 3785 ((1 == mal_type) || (3 == mal_type) ))
3778 { /* Add attacked peer to local list */ 3786 { /* Add attacked peer to local list */
3779 // TODO check if we sent a request and this was the first reply 3787 // TODO check if we sent a request and this was the first reply
3780 if ((GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (att_peer_set, 3788 if ((GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (att_peer_set,
3781 &peers[i])) 3789 &peers[i]))
3782 &&(GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (mal_peer_set, 3790 && (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (mal_peer_set,
3783 &peers[i])) ) 3791 &peers[i])) )
3784 { 3792 {
3785 tmp_att_peer = GNUNET_new (struct AttackedPeer); 3793 tmp_att_peer = GNUNET_new (struct AttackedPeer);
3786 tmp_att_peer->peer_id = peers[i]; 3794 tmp_att_peer->peer_id = peers[i];
@@ -3988,6 +3996,7 @@ check_client_act_malicious (void *cls,
3988 return GNUNET_OK; 3996 return GNUNET_OK;
3989} 3997}
3990 3998
3999
3991/** 4000/**
3992 * Turn RPS service to act malicious. 4001 * Turn RPS service to act malicious.
3993 * 4002 *
@@ -4236,6 +4245,8 @@ do_mal_round (void *cls)
4236 &do_mal_round, sub); 4245 &do_mal_round, sub);
4237 LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished round\n"); 4246 LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished round\n");
4238} 4247}
4248
4249
4239#endif /* ENABLE_MALICIOUS */ 4250#endif /* ENABLE_MALICIOUS */
4240 4251
4241 4252
@@ -4785,6 +4796,7 @@ client_connect_cb (void *cls,
4785 return cli_ctx; 4796 return cli_ctx;
4786} 4797}
4787 4798
4799
4788/** 4800/**
4789 * Callback called when a client disconnected from the service 4801 * Callback called when a client disconnected from the service
4790 * 4802 *
diff --git a/src/rps/gnunet-service-rps_custommap.c b/src/rps/gnunet-service-rps_custommap.c
index 8fcfc5558..54e361d32 100644
--- a/src/rps/gnunet-service-rps_custommap.c
+++ b/src/rps/gnunet-service-rps_custommap.c
@@ -87,6 +87,7 @@ CustomPeerMap_create (unsigned int len)
87 return c_peer_map; 87 return c_peer_map;
88} 88}
89 89
90
90/** 91/**
91 * Get the size of the custom peer map 92 * Get the size of the custom peer map
92 * 93 *
@@ -102,6 +103,7 @@ CustomPeerMap_size (const struct CustomPeerMap *c_peer_map)
102 return GNUNET_CONTAINER_multipeermap_size (c_peer_map->peer_map); 103 return GNUNET_CONTAINER_multipeermap_size (c_peer_map->peer_map);
103} 104}
104 105
106
105/** 107/**
106 * Insert peer into the custom peer map 108 * Insert peer into the custom peer map
107 * 109 *
@@ -149,6 +151,7 @@ CustomPeerMap_put (const struct CustomPeerMap *c_peer_map,
149 return GNUNET_NO; 151 return GNUNET_NO;
150} 152}
151 153
154
152/** 155/**
153 * Check whether custom peer map contains a peer 156 * Check whether custom peer map contains a peer
154 * 157 *
@@ -165,6 +168,7 @@ CustomPeerMap_contains_peer (const struct CustomPeerMap *c_peer_map,
165 return GNUNET_CONTAINER_multipeermap_contains (c_peer_map->peer_map, peer); 168 return GNUNET_CONTAINER_multipeermap_contains (c_peer_map->peer_map, peer);
166} 169}
167 170
171
168/** 172/**
169 * Get index of peer in custom peer map 173 * Get index of peer in custom peer map
170 * 174 *
@@ -184,6 +188,7 @@ CustomPeerMap_get_index_pointer (const struct CustomPeerMap *c_peer_map,
184 return index; 188 return index;
185} 189}
186 190
191
187/** 192/**
188 * Remove peer from custom peer map 193 * Remove peer from custom peer map
189 * 194 *
@@ -243,6 +248,7 @@ CustomPeerMap_remove_peer (const struct CustomPeerMap *c_peer_map,
243 return GNUNET_OK; 248 return GNUNET_OK;
244} 249}
245 250
251
246/** 252/**
247 * Get a peer by index 253 * Get a peer by index
248 * 254 *
@@ -264,6 +270,7 @@ CustomPeerMap_get_peer_by_index (const struct CustomPeerMap *c_peer_map,
264 return NULL; 270 return NULL;
265} 271}
266 272
273
267/** 274/**
268 * Remove peer from custom peer map by index 275 * Remove peer from custom peer map by index
269 * 276 *
@@ -301,6 +308,7 @@ CustomPeerMap_remove_peer_by_index (const struct CustomPeerMap *c_peer_map,
301 return GNUNET_OK; 308 return GNUNET_OK;
302} 309}
303 310
311
304/** 312/**
305 * Clear the custom peer map 313 * Clear the custom peer map
306 * 314 *
@@ -326,6 +334,7 @@ CustomPeerMap_clear (const struct CustomPeerMap *c_peer_map)
326 GNUNET_assert (0 == CustomPeerMap_size (c_peer_map)); 334 GNUNET_assert (0 == CustomPeerMap_size (c_peer_map));
327} 335}
328 336
337
329/** 338/**
330 * Destroy peermap. 339 * Destroy peermap.
331 * 340 *
@@ -340,4 +349,5 @@ CustomPeerMap_destroy (struct CustomPeerMap *c_peer_map)
340 GNUNET_free (c_peer_map); 349 GNUNET_free (c_peer_map);
341} 350}
342 351
352
343/* end of gnunet-service-rps_custommap.c */ 353/* end of gnunet-service-rps_custommap.c */
diff --git a/src/rps/gnunet-service-rps_sampler.c b/src/rps/gnunet-service-rps_sampler.c
index 7573fd4eb..598cc887e 100644
--- a/src/rps/gnunet-service-rps_sampler.c
+++ b/src/rps/gnunet-service-rps_sampler.c
@@ -216,6 +216,7 @@ RPS_sampler_init (size_t init_size,
216 return sampler; 216 return sampler;
217} 217}
218 218
219
219/** 220/**
220 * Get one random peer out of the sampled peers. 221 * Get one random peer out of the sampled peers.
221 * 222 *
diff --git a/src/rps/gnunet-service-rps_sampler_elem.c b/src/rps/gnunet-service-rps_sampler_elem.c
index 17b3be6d2..aa8b72445 100644
--- a/src/rps/gnunet-service-rps_sampler_elem.c
+++ b/src/rps/gnunet-service-rps_sampler_elem.c
@@ -152,6 +152,7 @@ RPS_sampler_elem_next (struct RPS_SamplerElement *sampler_elem,
152 sampler_elem->is_empty = NOT_EMPTY; 152 sampler_elem->is_empty = NOT_EMPTY;
153} 153}
154 154
155
155/** 156/**
156 * Set the min-wise independent function of the given sampler element. 157 * Set the min-wise independent function of the given sampler element.
157 * 158 *
@@ -165,4 +166,5 @@ RPS_sampler_elem_set (struct RPS_SamplerElement *sampler_elem,
165 sampler_elem->auth_key = auth_key; 166 sampler_elem->auth_key = auth_key;
166} 167}
167 168
169
168/* end of gnunet-service-rps.c */ 170/* end of gnunet-service-rps.c */
diff --git a/src/rps/gnunet-service-rps_view.c b/src/rps/gnunet-service-rps_view.c
index 5de7c84dc..d58b995a3 100644
--- a/src/rps/gnunet-service-rps_view.c
+++ b/src/rps/gnunet-service-rps_view.c
@@ -290,4 +290,5 @@ View_destroy (struct View *view)
290 GNUNET_free (view); 290 GNUNET_free (view);
291} 291}
292 292
293
293/* end of gnunet-service-rps_view.c */ 294/* end of gnunet-service-rps_view.c */
diff --git a/src/rps/rps-sampler_common.c b/src/rps/rps-sampler_common.c
index ab8c65f17..488ed8e01 100644
--- a/src/rps/rps-sampler_common.c
+++ b/src/rps/rps-sampler_common.c
@@ -354,7 +354,7 @@ RPS_sampler_count_id (struct RPS_Sampler *sampler,
354 for (i = 0; i < sampler->sampler_size; i++) 354 for (i = 0; i < sampler->sampler_size; i++)
355 { 355 {
356 if ((0 == GNUNET_memcmp (&sampler->sampler_elements[i]->peer_id, id)) 356 if ((0 == GNUNET_memcmp (&sampler->sampler_elements[i]->peer_id, id))
357 &&(EMPTY != sampler->sampler_elements[i]->is_empty) ) 357 && (EMPTY != sampler->sampler_elements[i]->is_empty) )
358 count++; 358 count++;
359 } 359 }
360 return count; 360 return count;
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index 66f93d86f..d2cdd3aa7 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -61,7 +61,6 @@ static unsigned num_bits_buf_unaligned;
61static struct GNUNET_CONTAINER_MultiHashMap *open_files; 61static struct GNUNET_CONTAINER_MultiHashMap *open_files;
62 62
63 63
64
65/** 64/**
66 * @brief Get file handle 65 * @brief Get file handle
67 * 66 *
@@ -162,7 +161,6 @@ close_all_files ()
162} 161}
163 162
164 163
165
166void 164void
167to_file_raw (const char *file_name, const char *buf, size_t size_buf) 165to_file_raw (const char *file_name, const char *buf, size_t size_buf)
168{ 166{
@@ -206,6 +204,7 @@ to_file_raw (const char *file_name, const char *buf, size_t size_buf)
206 "Unable to close file\n"); 204 "Unable to close file\n");
207} 205}
208 206
207
209void 208void
210to_file_raw_unaligned (const char *file_name, 209to_file_raw_unaligned (const char *file_name,
211 const char *buf, 210 const char *buf,
@@ -372,6 +371,7 @@ to_file_raw_unaligned (const char *file_name,
372 LOG (GNUNET_ERROR_TYPE_DEBUG, "\n"); 371 LOG (GNUNET_ERROR_TYPE_DEBUG, "\n");
373} 372}
374 373
374
375char * 375char *
376auth_key_to_string (struct GNUNET_CRYPTO_AuthKey auth_key) 376auth_key_to_string (struct GNUNET_CRYPTO_AuthKey auth_key)
377{ 377{
@@ -414,6 +414,7 @@ auth_key_to_string (struct GNUNET_CRYPTO_AuthKey auth_key)
414 return name_buf; 414 return name_buf;
415} 415}
416 416
417
417#endif /* TO_FILE */ 418#endif /* TO_FILE */
418 419
419 420
@@ -470,7 +471,7 @@ store_prefix_file_name (const unsigned int index,
470 64, 471 64,
471 "%u", 472 "%u",
472 index); 473 index);
473 if ((64 < out_size)|| 474 if ((64 < out_size) ||
474 (0 > out_size) ) 475 (0 > out_size) )
475 { 476 {
476 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 477 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -488,7 +489,7 @@ store_prefix_file_name (const unsigned int index,
488 "/tmp/rps/%s-%s", 489 "/tmp/rps/%s-%s",
489 prefix, 490 prefix,
490 index_str); 491 index_str);
491 if ((len_file_name < out_size)|| 492 if ((len_file_name < out_size) ||
492 (0 > out_size) ) 493 (0 > out_size) )
493 { 494 {
494 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 495 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -507,7 +508,8 @@ store_prefix_file_name (const unsigned int index,
507 * 508 *
508 * @return Factorial of @a x 509 * @return Factorial of @a x
509 */ 510 */
510uint32_t fac (uint32_t x) 511uint32_t
512fac (uint32_t x)
511{ 513{
512 if (1 >= x) 514 if (1 >= x)
513 { 515 {
@@ -516,6 +518,7 @@ uint32_t fac (uint32_t x)
516 return x * fac (x - 1); 518 return x * fac (x - 1);
517} 519}
518 520
521
519/** 522/**
520 * @brief Binomial coefficient (n choose k) 523 * @brief Binomial coefficient (n choose k)
521 * 524 *
@@ -524,7 +527,8 @@ uint32_t fac (uint32_t x)
524 * 527 *
525 * @return Binomial coefficient of @a n and @a k 528 * @return Binomial coefficient of @a n and @a k
526 */ 529 */
527uint32_t binom (uint32_t n, uint32_t k) 530uint32_t
531binom (uint32_t n, uint32_t k)
528{ 532{
529 // GNUNET_assert (n >= k); 533 // GNUNET_assert (n >= k);
530 if (k > n) 534 if (k > n)
diff --git a/src/rps/rps.h b/src/rps/rps.h
index 32e5d07af..9d42a6104 100644
--- a/src/rps/rps.h
+++ b/src/rps/rps.h
@@ -56,7 +56,6 @@ struct GNUNET_RPS_P2P_PullReplyMessage
56}; 56};
57 57
58 58
59
60/*********************************************************************** 59/***********************************************************************
61* Client-Service Messages 60* Client-Service Messages
62***********************************************************************/ 61***********************************************************************/
diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c
index 19cbdcf8a..da24ca4c9 100644
--- a/src/rps/rps_api.c
+++ b/src/rps/rps_api.c
@@ -857,7 +857,7 @@ GNUNET_RPS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
857 GNUNET_free (h); 857 GNUNET_free (h);
858 return NULL; 858 return NULL;
859 } 859 }
860 if ((0 > h->desired_probability)|| 860 if ((0 > h->desired_probability) ||
861 (1 < h->desired_probability) ) 861 (1 < h->desired_probability) )
862 { 862 {
863 LOG (GNUNET_ERROR_TYPE_ERROR, 863 LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -876,7 +876,7 @@ GNUNET_RPS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
876 GNUNET_free (h); 876 GNUNET_free (h);
877 return NULL; 877 return NULL;
878 } 878 }
879 if ((0 > h->desired_probability)|| 879 if ((0 > h->desired_probability) ||
880 (1 < h->desired_probability) ) 880 (1 < h->desired_probability) )
881 { 881 {
882 LOG (GNUNET_ERROR_TYPE_ERROR, 882 LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -1186,6 +1186,8 @@ GNUNET_RPS_act_malicious (struct GNUNET_RPS_Handle *h,
1186 1186
1187 GNUNET_MQ_send (h->mq, ev); 1187 GNUNET_MQ_send (h->mq, ev);
1188} 1188}
1189
1190
1189#endif /* ENABLE_MALICIOUS */ 1191#endif /* ENABLE_MALICIOUS */
1190 1192
1191 1193
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index 3a01e73ff..81cf63c72 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -623,9 +623,7 @@ tofile_ (const char *file_name, const char *line)
623 "Failed to write string to buffer (size: %i)\n", 623 "Failed to write string to buffer (size: %i)\n",
624 size); 624 size);
625 return; 625 return;
626 } */ 626 } */size = strlen (line) * sizeof(char);
627
628 size = strlen (line) * sizeof(char);
629 627
630 size2 = GNUNET_DISK_file_write (f, line, size); 628 size2 = GNUNET_DISK_file_write (f, line, size);
631 if (size != size2) 629 if (size != size2)
@@ -649,6 +647,7 @@ tofile_ (const char *file_name, const char *line)
649 } 647 }
650} 648}
651 649
650
652/** 651/**
653 * This function is used to facilitate writing important information to disk 652 * This function is used to facilitate writing important information to disk
654 */ 653 */
@@ -740,7 +739,8 @@ make_oplist_entry ()
740 * @return #GNUNET_YES if so 739 * @return #GNUNET_YES if so
741 * #GNUNET_NO otherwise 740 * #GNUNET_NO otherwise
742 */ 741 */
743static int check_statistics_collect_completed_single_peer ( 742static int
743check_statistics_collect_completed_single_peer (
744 const struct RPSPeer *rps_peer) 744 const struct RPSPeer *rps_peer)
745{ 745{
746 if (cur_test_run.stat_collect_flags != 746 if (cur_test_run.stat_collect_flags !=
@@ -760,7 +760,8 @@ static int check_statistics_collect_completed_single_peer (
760 * @return #GNUNET_YES if so 760 * @return #GNUNET_YES if so
761 * #GNUNET_NO otherwise 761 * #GNUNET_NO otherwise
762 */ 762 */
763static int check_statistics_collect_completed () 763static int
764check_statistics_collect_completed ()
764{ 765{
765 uint32_t i; 766 uint32_t i;
766 767
@@ -853,7 +854,7 @@ post_test_op (void *cls)
853 } 854 }
854 } 855 }
855 /* If we do not collect statistics, shut down directly */ 856 /* If we do not collect statistics, shut down directly */
856 if ((NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics)|| 857 if ((NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics) ||
857 (GNUNET_YES == check_statistics_collect_completed ()) ) 858 (GNUNET_YES == check_statistics_collect_completed ()) )
858 { 859 {
859 GNUNET_SCHEDULER_shutdown (); 860 GNUNET_SCHEDULER_shutdown ();
@@ -871,7 +872,7 @@ seed_peers (void *cls)
871 unsigned int amount; 872 unsigned int amount;
872 unsigned int i; 873 unsigned int i;
873 874
874 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 875 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
875 { 876 {
876 return; 877 return;
877 } 878 }
@@ -925,6 +926,7 @@ seed_peers_big (void *cls)
925 GNUNET_RPS_seed_ids (peer->rps_handle, amount, ids_to_seed); 926 GNUNET_RPS_seed_ids (peer->rps_handle, amount, ids_to_seed);
926} 927}
927 928
929
928/** 930/**
929 * Get the id of peer i. 931 * Get the id of peer i.
930 */ 932 */
@@ -938,12 +940,12 @@ info_cb (void *cb_cls,
938 940
939 (void) op; 941 (void) op;
940 942
941 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 943 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
942 { 944 {
943 return; 945 return;
944 } 946 }
945 947
946 if ((NULL == pinfo)||(NULL != emsg)) 948 if ((NULL == pinfo) || (NULL != emsg))
947 { 949 {
948 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg); 950 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg);
949 GNUNET_TESTBED_operation_done (entry->op); 951 GNUNET_TESTBED_operation_done (entry->op);
@@ -994,7 +996,7 @@ rps_connect_complete_cb (void *cls,
994 996
995 GNUNET_assert (NULL != ca_result); 997 GNUNET_assert (NULL != ca_result);
996 998
997 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 999 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
998 { 1000 {
999 return; 1001 return;
1000 } 1002 }
@@ -1046,6 +1048,7 @@ rps_connect_adapter (void *cls,
1046 return h; 1048 return h;
1047} 1049}
1048 1050
1051
1049/** 1052/**
1050 * Called to open a connection to the peer's statistics 1053 * Called to open a connection to the peer's statistics
1051 * 1054 *
@@ -1065,6 +1068,7 @@ stat_connect_adapter (void *cls,
1065 return peer->stats_h; 1068 return peer->stats_h;
1066} 1069}
1067 1070
1071
1068/** 1072/**
1069 * Called to disconnect from peer's statistics service 1073 * Called to disconnect from peer's statistics service
1070 * 1074 *
@@ -1086,6 +1090,7 @@ stat_disconnect_adapter (void *cls, void *op_result)
1086 peer->stats_h = NULL; 1090 peer->stats_h = NULL;
1087} 1091}
1088 1092
1093
1089/** 1094/**
1090 * Called after successfully opening a connection to a peer's statistics 1095 * Called after successfully opening a connection to a peer's statistics
1091 * service; we register statistics monitoring for CORE and NSE here. 1096 * service; we register statistics monitoring for CORE and NSE here.
@@ -1156,20 +1161,24 @@ default_eval_cb (void)
1156 return evaluate (); 1161 return evaluate ();
1157} 1162}
1158 1163
1164
1159static int 1165static int
1160no_eval (void) 1166no_eval (void)
1161{ 1167{
1162 return 0; 1168 return 0;
1163} 1169}
1164 1170
1171
1165/** 1172/**
1166 * Initialise given RPSPeer 1173 * Initialise given RPSPeer
1167 */ 1174 */
1168static void default_init_peer (struct RPSPeer *rps_peer) 1175static void
1176default_init_peer (struct RPSPeer *rps_peer)
1169{ 1177{
1170 rps_peer->num_ids_to_request = 1; 1178 rps_peer->num_ids_to_request = 1;
1171} 1179}
1172 1180
1181
1173/** 1182/**
1174 * Callback to call on receipt of a reply 1183 * Callback to call on receipt of a reply
1175 * 1184 *
@@ -1206,7 +1215,7 @@ default_reply_handle (void *cls,
1206 rps_peer->num_recv_ids++; 1215 rps_peer->num_recv_ids++;
1207 } 1216 }
1208 1217
1209 if ((0 == evaluate ())&&(HAVE_QUICK_QUIT == cur_test_run.have_quick_quit)) 1218 if ((0 == evaluate ()) && (HAVE_QUICK_QUIT == cur_test_run.have_quick_quit))
1210 { 1219 {
1211 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test succeeded before timeout\n"); 1220 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test succeeded before timeout\n");
1212 GNUNET_assert (NULL != post_test_task); 1221 GNUNET_assert (NULL != post_test_task);
@@ -1216,6 +1225,7 @@ default_reply_handle (void *cls,
1216 } 1225 }
1217} 1226}
1218 1227
1228
1219/** 1229/**
1220 * Request random peers. 1230 * Request random peers.
1221 */ 1231 */
@@ -1226,7 +1236,7 @@ request_peers (void *cls)
1226 struct RPSPeer *rps_peer; 1236 struct RPSPeer *rps_peer;
1227 struct PendingReply *pending_rep; 1237 struct PendingReply *pending_rep;
1228 1238
1229 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1239 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1230 return; 1240 return;
1231 rps_peer = pending_req->rps_peer; 1241 rps_peer = pending_req->rps_peer;
1232 GNUNET_assert (1 <= rps_peer->num_pending_reqs); 1242 GNUNET_assert (1 <= rps_peer->num_pending_reqs);
@@ -1248,6 +1258,7 @@ request_peers (void *cls)
1248 rps_peer->num_pending_reqs--; 1258 rps_peer->num_pending_reqs--;
1249} 1259}
1250 1260
1261
1251static void 1262static void
1252cancel_pending_req (struct PendingRequest *pending_req) 1263cancel_pending_req (struct PendingRequest *pending_req)
1253{ 1264{
@@ -1264,6 +1275,7 @@ cancel_pending_req (struct PendingRequest *pending_req)
1264 GNUNET_free (pending_req); 1275 GNUNET_free (pending_req);
1265} 1276}
1266 1277
1278
1267static void 1279static void
1268cancel_request (struct PendingReply *pending_rep) 1280cancel_request (struct PendingReply *pending_rep)
1269{ 1281{
@@ -1280,6 +1292,7 @@ cancel_request (struct PendingReply *pending_rep)
1280 GNUNET_free (pending_rep); 1292 GNUNET_free (pending_rep);
1281} 1293}
1282 1294
1295
1283/** 1296/**
1284 * Cancel a request. 1297 * Cancel a request.
1285 */ 1298 */
@@ -1289,7 +1302,7 @@ cancel_request_cb (void *cls)
1289 struct RPSPeer *rps_peer = cls; 1302 struct RPSPeer *rps_peer = cls;
1290 struct PendingReply *pending_rep; 1303 struct PendingReply *pending_rep;
1291 1304
1292 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1305 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1293 return; 1306 return;
1294 pending_rep = rps_peer->pending_rep_head; 1307 pending_rep = rps_peer->pending_rep_head;
1295 GNUNET_assert (1 <= rps_peer->num_pending_reps); 1308 GNUNET_assert (1 <= rps_peer->num_pending_reps);
@@ -1330,6 +1343,7 @@ schedule_missing_requests (struct RPSPeer *rps_peer)
1330 } 1343 }
1331} 1344}
1332 1345
1346
1333void 1347void
1334cancel_pending_req_rep (struct RPSPeer *rps_peer) 1348cancel_pending_req_rep (struct RPSPeer *rps_peer)
1335{ 1349{
@@ -1343,6 +1357,7 @@ cancel_pending_req_rep (struct RPSPeer *rps_peer)
1343 GNUNET_assert (0 == rps_peer->num_pending_reps); 1357 GNUNET_assert (0 == rps_peer->num_pending_reps);
1344} 1358}
1345 1359
1360
1346/*********************************** 1361/***********************************
1347* MALICIOUS 1362* MALICIOUS
1348***********************************/ 1363***********************************/
@@ -1350,7 +1365,8 @@ cancel_pending_req_rep (struct RPSPeer *rps_peer)
1350/** 1365/**
1351 * Initialise only non-mal RPSPeers 1366 * Initialise only non-mal RPSPeers
1352 */ 1367 */
1353static void mal_init_peer (struct RPSPeer *rps_peer) 1368static void
1369mal_init_peer (struct RPSPeer *rps_peer)
1354{ 1370{
1355 if (rps_peer->index >= round (portion * num_peers)) 1371 if (rps_peer->index >= round (portion * num_peers))
1356 rps_peer->num_ids_to_request = 1; 1372 rps_peer->num_ids_to_request = 1;
@@ -1390,12 +1406,13 @@ mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
1390 #endif /* ENABLE_MALICIOUS */ 1406 #endif /* ENABLE_MALICIOUS */
1391} 1407}
1392 1408
1409
1393static void 1410static void
1394mal_cb (struct RPSPeer *rps_peer) 1411mal_cb (struct RPSPeer *rps_peer)
1395{ 1412{
1396 uint32_t num_mal_peers; 1413 uint32_t num_mal_peers;
1397 1414
1398 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1415 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1399 { 1416 {
1400 return; 1417 return;
1401 } 1418 }
@@ -1423,7 +1440,7 @@ mal_cb (struct RPSPeer *rps_peer)
1423static void 1440static void
1424single_req_cb (struct RPSPeer *rps_peer) 1441single_req_cb (struct RPSPeer *rps_peer)
1425{ 1442{
1426 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1443 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1427 { 1444 {
1428 return; 1445 return;
1429 } 1446 }
@@ -1431,13 +1448,14 @@ single_req_cb (struct RPSPeer *rps_peer)
1431 schedule_missing_requests (rps_peer); 1448 schedule_missing_requests (rps_peer);
1432} 1449}
1433 1450
1451
1434/*********************************** 1452/***********************************
1435* DELAYED_REQUESTS 1453* DELAYED_REQUESTS
1436***********************************/ 1454***********************************/
1437static void 1455static void
1438delay_req_cb (struct RPSPeer *rps_peer) 1456delay_req_cb (struct RPSPeer *rps_peer)
1439{ 1457{
1440 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1458 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1441 { 1459 {
1442 return; 1460 return;
1443 } 1461 }
@@ -1445,13 +1463,14 @@ delay_req_cb (struct RPSPeer *rps_peer)
1445 schedule_missing_requests (rps_peer); 1463 schedule_missing_requests (rps_peer);
1446} 1464}
1447 1465
1466
1448/*********************************** 1467/***********************************
1449* SEED 1468* SEED
1450***********************************/ 1469***********************************/
1451static void 1470static void
1452seed_cb (struct RPSPeer *rps_peer) 1471seed_cb (struct RPSPeer *rps_peer)
1453{ 1472{
1454 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1473 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1455 { 1474 {
1456 return; 1475 return;
1457 } 1476 }
@@ -1461,13 +1480,14 @@ seed_cb (struct RPSPeer *rps_peer)
1461 seed_peers, rps_peer); 1480 seed_peers, rps_peer);
1462} 1481}
1463 1482
1483
1464/*********************************** 1484/***********************************
1465* SEED_BIG 1485* SEED_BIG
1466***********************************/ 1486***********************************/
1467static void 1487static void
1468seed_big_cb (struct RPSPeer *rps_peer) 1488seed_big_cb (struct RPSPeer *rps_peer)
1469{ 1489{
1470 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1490 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1471 { 1491 {
1472 return; 1492 return;
1473 } 1493 }
@@ -1478,6 +1498,7 @@ seed_big_cb (struct RPSPeer *rps_peer)
1478 seed_peers_big, rps_peer); 1498 seed_peers_big, rps_peer);
1479} 1499}
1480 1500
1501
1481/*********************************** 1502/***********************************
1482* SINGLE_PEER_SEED 1503* SINGLE_PEER_SEED
1483***********************************/ 1504***********************************/
@@ -1488,13 +1509,14 @@ single_peer_seed_cb (struct RPSPeer *rps_peer)
1488 // TODO 1509 // TODO
1489} 1510}
1490 1511
1512
1491/*********************************** 1513/***********************************
1492* SEED_REQUEST 1514* SEED_REQUEST
1493***********************************/ 1515***********************************/
1494static void 1516static void
1495seed_req_cb (struct RPSPeer *rps_peer) 1517seed_req_cb (struct RPSPeer *rps_peer)
1496{ 1518{
1497 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1519 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1498 { 1520 {
1499 return; 1521 return;
1500 } 1522 }
@@ -1505,6 +1527,7 @@ seed_req_cb (struct RPSPeer *rps_peer)
1505 schedule_missing_requests (rps_peer); 1527 schedule_missing_requests (rps_peer);
1506} 1528}
1507 1529
1530
1508// TODO start big mal 1531// TODO start big mal
1509 1532
1510/*********************************** 1533/***********************************
@@ -1513,7 +1536,7 @@ seed_req_cb (struct RPSPeer *rps_peer)
1513static void 1536static void
1514req_cancel_cb (struct RPSPeer *rps_peer) 1537req_cancel_cb (struct RPSPeer *rps_peer)
1515{ 1538{
1516 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1539 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1517 { 1540 {
1518 return; 1541 return;
1519 } 1542 }
@@ -1525,6 +1548,7 @@ req_cancel_cb (struct RPSPeer *rps_peer)
1525 cancel_request_cb, rps_peer); 1548 cancel_request_cb, rps_peer);
1526} 1549}
1527 1550
1551
1528/*********************************** 1552/***********************************
1529* CHURN 1553* CHURN
1530***********************************/ 1554***********************************/
@@ -1546,13 +1570,13 @@ churn (void *cls);
1546static void 1570static void
1547churn_test_cb (struct RPSPeer *rps_peer) 1571churn_test_cb (struct RPSPeer *rps_peer)
1548{ 1572{
1549 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1573 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1550 { 1574 {
1551 return; 1575 return;
1552 } 1576 }
1553 1577
1554 /* Start churn */ 1578 /* Start churn */
1555 if ((HAVE_CHURN == cur_test_run.have_churn)&&(NULL == churn_task)) 1579 if ((HAVE_CHURN == cur_test_run.have_churn) && (NULL == churn_task))
1556 { 1580 {
1557 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1581 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1558 "Starting churn task\n"); 1582 "Starting churn task\n");
@@ -1570,6 +1594,7 @@ churn_test_cb (struct RPSPeer *rps_peer)
1570 schedule_missing_requests (rps_peer); 1594 schedule_missing_requests (rps_peer);
1571} 1595}
1572 1596
1597
1573/*********************************** 1598/***********************************
1574* SUB 1599* SUB
1575***********************************/ 1600***********************************/
@@ -1633,6 +1658,7 @@ sub_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
1633 rps_peer); 1658 rps_peer);
1634} 1659}
1635 1660
1661
1636/*********************************** 1662/***********************************
1637* PROFILER 1663* PROFILER
1638***********************************/ 1664***********************************/
@@ -1653,7 +1679,7 @@ churn_cb (void *cls,
1653 // FIXME 1679 // FIXME
1654 struct OpListEntry *entry = cls; 1680 struct OpListEntry *entry = cls;
1655 1681
1656 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1682 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1657 { 1683 {
1658 return; 1684 return;
1659 } 1685 }
@@ -1725,6 +1751,7 @@ churn_cb (void *cls,
1725 // run_round (); 1751 // run_round ();
1726} 1752}
1727 1753
1754
1728/** 1755/**
1729 * @brief Set the rps-service up or down for a specific peer 1756 * @brief Set the rps-service up or down for a specific peer
1730 * 1757 *
@@ -1791,7 +1818,7 @@ churn (void *cls)
1791 double portion_go_online; 1818 double portion_go_online;
1792 double portion_go_offline; 1819 double portion_go_offline;
1793 1820
1794 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1821 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1795 { 1822 {
1796 return; 1823 return;
1797 } 1824 }
@@ -1852,7 +1879,8 @@ churn (void *cls)
1852/** 1879/**
1853 * Initialise given RPSPeer 1880 * Initialise given RPSPeer
1854 */ 1881 */
1855static void profiler_init_peer (struct RPSPeer *rps_peer) 1882static void
1883profiler_init_peer (struct RPSPeer *rps_peer)
1856{ 1884{
1857 if (num_peers - 1 == rps_peer->index) 1885 if (num_peers - 1 == rps_peer->index)
1858 rps_peer->num_ids_to_request = cur_test_run.num_requests; 1886 rps_peer->num_ids_to_request = cur_test_run.num_requests;
@@ -1907,13 +1935,13 @@ profiler_reply_handle (void *cls,
1907static void 1935static void
1908profiler_cb (struct RPSPeer *rps_peer) 1936profiler_cb (struct RPSPeer *rps_peer)
1909{ 1937{
1910 if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test)) 1938 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1911 { 1939 {
1912 return; 1940 return;
1913 } 1941 }
1914 1942
1915 /* Start churn */ 1943 /* Start churn */
1916 if ((HAVE_CHURN == cur_test_run.have_churn)&&(NULL == churn_task)) 1944 if ((HAVE_CHURN == cur_test_run.have_churn) && (NULL == churn_task))
1917 { 1945 {
1918 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1946 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1919 "Starting churn task\n"); 1947 "Starting churn task\n");
@@ -1935,6 +1963,7 @@ profiler_cb (struct RPSPeer *rps_peer)
1935 schedule_missing_requests (rps_peer); 1963 schedule_missing_requests (rps_peer);
1936} 1964}
1937 1965
1966
1938/** 1967/**
1939 * Function called from #profiler_eval with a filename. 1968 * Function called from #profiler_eval with a filename.
1940 * 1969 *
@@ -1972,6 +2001,7 @@ file_name_cb (void *cls, const char *filename)
1972 return GNUNET_OK; 2001 return GNUNET_OK;
1973} 2002}
1974 2003
2004
1975/** 2005/**
1976 * This is run after the test finished. 2006 * This is run after the test finished.
1977 * 2007 *
@@ -1998,7 +2028,8 @@ profiler_eval (void)
1998 * 2028 *
1999 * @return 2029 * @return
2000 */ 2030 */
2001static int is_in_view (uint32_t a, uint32_t b) 2031static int
2032is_in_view (uint32_t a, uint32_t b)
2002{ 2033{
2003 uint32_t i; 2034 uint32_t i;
2004 2035
@@ -2014,7 +2045,9 @@ static int is_in_view (uint32_t a, uint32_t b)
2014 return GNUNET_NO; 2045 return GNUNET_NO;
2015} 2046}
2016 2047
2017static uint32_t get_idx_of_pid (const struct GNUNET_PeerIdentity *pid) 2048
2049static uint32_t
2050get_idx_of_pid (const struct GNUNET_PeerIdentity *pid)
2018{ 2051{
2019 uint32_t i; 2052 uint32_t i;
2020 2053
@@ -2034,6 +2067,7 @@ static uint32_t get_idx_of_pid (const struct GNUNET_PeerIdentity *pid)
2034 GNUNET_assert (0); 2067 GNUNET_assert (0);
2035} 2068}
2036 2069
2070
2037/** 2071/**
2038 * @brief Counts number of peers in view of a that have b in their view 2072 * @brief Counts number of peers in view of a that have b in their view
2039 * 2073 *
@@ -2042,7 +2076,8 @@ static uint32_t get_idx_of_pid (const struct GNUNET_PeerIdentity *pid)
2042 * 2076 *
2043 * @return 2077 * @return
2044 */ 2078 */
2045static uint32_t count_containing_views (uint32_t a, uint32_t b) 2079static uint32_t
2080count_containing_views (uint32_t a, uint32_t b)
2046{ 2081{
2047 uint32_t i; 2082 uint32_t i;
2048 uint32_t peer_idx; 2083 uint32_t peer_idx;
@@ -2059,13 +2094,15 @@ static uint32_t count_containing_views (uint32_t a, uint32_t b)
2059 return count; 2094 return count;
2060} 2095}
2061 2096
2097
2062/** 2098/**
2063 * @brief Computes the probability for each other peer to be selected by the 2099 * @brief Computes the probability for each other peer to be selected by the
2064 * sampling process based on the views of all peers 2100 * sampling process based on the views of all peers
2065 * 2101 *
2066 * @param peer_idx index of the peer that is about to sample 2102 * @param peer_idx index of the peer that is about to sample
2067 */ 2103 */
2068static void compute_probabilities (uint32_t peer_idx) 2104static void
2105compute_probabilities (uint32_t peer_idx)
2069{ 2106{
2070 // double probs[num_peers] = { 0 }; 2107 // double probs[num_peers] = { 0 };
2071 double probs[num_peers]; 2108 double probs[num_peers];
@@ -2197,6 +2234,7 @@ static void compute_probabilities (uint32_t peer_idx)
2197 GNUNET_free (probs_as_str); 2234 GNUNET_free (probs_as_str);
2198} 2235}
2199 2236
2237
2200/** 2238/**
2201 * @brief This counts the number of peers in which views a given peer occurs. 2239 * @brief This counts the number of peers in which views a given peer occurs.
2202 * 2240 *
@@ -2206,7 +2244,8 @@ static void compute_probabilities (uint32_t peer_idx)
2206 * 2244 *
2207 * @return the number of occurrences 2245 * @return the number of occurrences
2208 */ 2246 */
2209static uint32_t count_peer_in_views_2 (uint32_t peer_idx) 2247static uint32_t
2248count_peer_in_views_2 (uint32_t peer_idx)
2210{ 2249{
2211 uint32_t i, j; 2250 uint32_t i, j;
2212 uint32_t count = 0; 2251 uint32_t count = 0;
@@ -2228,7 +2267,9 @@ static uint32_t count_peer_in_views_2 (uint32_t peer_idx)
2228 return count; 2267 return count;
2229} 2268}
2230 2269
2231static uint32_t cumulated_view_sizes () 2270
2271static uint32_t
2272cumulated_view_sizes ()
2232{ 2273{
2233 uint32_t i; 2274 uint32_t i;
2234 2275
@@ -2240,7 +2281,9 @@ static uint32_t cumulated_view_sizes ()
2240 return view_sizes; 2281 return view_sizes;
2241} 2282}
2242 2283
2243static void count_peer_in_views (uint32_t *count_peers) 2284
2285static void
2286count_peer_in_views (uint32_t *count_peers)
2244{ 2287{
2245 uint32_t i, j; 2288 uint32_t i, j;
2246 2289
@@ -2258,7 +2301,9 @@ static void count_peer_in_views (uint32_t *count_peers)
2258 } 2301 }
2259} 2302}
2260 2303
2261void compute_diversity () 2304
2305void
2306compute_diversity ()
2262{ 2307{
2263 uint32_t i; 2308 uint32_t i;
2264 /* ith entry represents the numer of occurrences in other peer's views */ 2309 /* ith entry represents the numer of occurrences in other peer's views */
@@ -2301,7 +2346,9 @@ void compute_diversity ()
2301 GNUNET_free (deviation); 2346 GNUNET_free (deviation);
2302} 2347}
2303 2348
2304void print_view_sizes () 2349
2350void
2351print_view_sizes ()
2305{ 2352{
2306 uint32_t i; 2353 uint32_t i;
2307 2354
@@ -2315,15 +2362,19 @@ void print_view_sizes ()
2315 } 2362 }
2316} 2363}
2317 2364
2318void all_views_updated_cb () 2365
2366void
2367all_views_updated_cb ()
2319{ 2368{
2320 compute_diversity (); 2369 compute_diversity ();
2321 print_view_sizes (); 2370 print_view_sizes ();
2322} 2371}
2323 2372
2324void view_update_cb (void *cls, 2373
2325 uint64_t view_size, 2374void
2326 const struct GNUNET_PeerIdentity *peers) 2375view_update_cb (void *cls,
2376 uint64_t view_size,
2377 const struct GNUNET_PeerIdentity *peers)
2327{ 2378{
2328 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2329 "View was updated (%" PRIu64 ")\n", view_size); 2380 "View was updated (%" PRIu64 ")\n", view_size);
@@ -2372,6 +2423,7 @@ void view_update_cb (void *cls,
2372 all_views_updated_cb (); 2423 all_views_updated_cb ();
2373} 2424}
2374 2425
2426
2375static void 2427static void
2376pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) 2428pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
2377{ 2429{
@@ -2380,7 +2432,9 @@ pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
2380 GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer); 2432 GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer);
2381} 2433}
2382 2434
2383void write_final_stats (void) 2435
2436void
2437write_final_stats (void)
2384{ 2438{
2385 uint32_t i; 2439 uint32_t i;
2386 2440
@@ -2416,6 +2470,7 @@ void write_final_stats (void)
2416 } 2470 }
2417} 2471}
2418 2472
2473
2419/** 2474/**
2420 * Continuation called by #GNUNET_STATISTICS_get() functions. 2475 * Continuation called by #GNUNET_STATISTICS_get() functions.
2421 * 2476 *
@@ -2448,7 +2503,7 @@ post_test_shutdown_ready_cb (void *cls,
2448 GNUNET_break (0); 2503 GNUNET_break (0);
2449 } 2504 }
2450 2505
2451 if ((NULL != rps_peer->stat_op)&& 2506 if ((NULL != rps_peer->stat_op) &&
2452 (GNUNET_YES == check_statistics_collect_completed_single_peer ( 2507 (GNUNET_YES == check_statistics_collect_completed_single_peer (
2453 rps_peer)) ) 2508 rps_peer)) )
2454 { 2509 {
@@ -2470,6 +2525,7 @@ post_test_shutdown_ready_cb (void *cls,
2470 } 2525 }
2471} 2526}
2472 2527
2528
2473/** 2529/**
2474 * @brief Converts string representation to the corresponding #STAT_TYPE enum. 2530 * @brief Converts string representation to the corresponding #STAT_TYPE enum.
2475 * 2531 *
@@ -2477,7 +2533,8 @@ post_test_shutdown_ready_cb (void *cls,
2477 * 2533 *
2478 * @return corresponding enum 2534 * @return corresponding enum
2479 */ 2535 */
2480enum STAT_TYPE stat_str_2_type (const char *stat_str) 2536enum STAT_TYPE
2537stat_str_2_type (const char *stat_str)
2481{ 2538{
2482 if (0 == strncmp ("# rounds blocked - no pull replies", stat_str, strlen ( 2539 if (0 == strncmp ("# rounds blocked - no pull replies", stat_str, strlen (
2483 "# rounds blocked - no pull replies"))) 2540 "# rounds blocked - no pull replies")))
@@ -2571,7 +2628,8 @@ enum STAT_TYPE stat_str_2_type (const char *stat_str)
2571 * 2628 *
2572 * @return string representation that matches statistics value 2629 * @return string representation that matches statistics value
2573 */ 2630 */
2574char*stat_type_2_str (enum STAT_TYPE stat_type) 2631char*
2632stat_type_2_str (enum STAT_TYPE stat_type)
2575{ 2633{
2576 switch (stat_type) 2634 switch (stat_type)
2577 { 2635 {
@@ -2630,6 +2688,7 @@ char*stat_type_2_str (enum STAT_TYPE stat_type)
2630 } 2688 }
2631} 2689}
2632 2690
2691
2633/** 2692/**
2634 * Callback function to process statistic values. 2693 * Callback function to process statistic values.
2635 * 2694 *
@@ -2735,7 +2794,9 @@ stat_iterator (void *cls,
2735 return GNUNET_OK; 2794 return GNUNET_OK;
2736} 2795}
2737 2796
2738void post_profiler (struct RPSPeer *rps_peer) 2797
2798void
2799post_profiler (struct RPSPeer *rps_peer)
2739{ 2800{
2740 if (COLLECT_STATISTICS != cur_test_run.have_collect_statistics) 2801 if (COLLECT_STATISTICS != cur_test_run.have_collect_statistics)
2741 { 2802 {
@@ -2808,7 +2869,7 @@ run (void *cls,
2808 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n"); 2869 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n");
2809 2870
2810 /* Check whether we timed out */ 2871 /* Check whether we timed out */
2811 if ((n_peers != num_peers)|| 2872 if ((n_peers != num_peers) ||
2812 (NULL == peers) || 2873 (NULL == peers) ||
2813 (0 == links_succeeded) ) 2874 (0 == links_succeeded) )
2814 { 2875 {
diff --git a/src/rps/test_rps_api.c b/src/rps/test_rps_api.c
index 6fca7ea12..06dad2887 100644
--- a/src/rps/test_rps_api.c
+++ b/src/rps/test_rps_api.c
@@ -83,4 +83,5 @@ main (int argc, char *argv[])
83 return check (); 83 return check ();
84} 84}
85 85
86
86/* end of test_rps_api.c */ 87/* end of test_rps_api.c */
diff --git a/src/rps/test_service_rps_custommap.c b/src/rps/test_service_rps_custommap.c
index 6f6f6b0d3..05590b097 100644
--- a/src/rps/test_service_rps_custommap.c
+++ b/src/rps/test_service_rps_custommap.c
@@ -123,4 +123,5 @@ main (int argc, char *argv[])
123 return check (); 123 return check ();
124} 124}
125 125
126
126/* end of test_service_rps_custommap.c */ 127/* end of test_service_rps_custommap.c */
diff --git a/src/rps/test_service_rps_sampler_elem.c b/src/rps/test_service_rps_sampler_elem.c
index 706abf4f9..8fef5adaf 100644
--- a/src/rps/test_service_rps_sampler_elem.c
+++ b/src/rps/test_service_rps_sampler_elem.c
@@ -209,4 +209,5 @@ main (int argc, char *argv[])
209 return check (); 209 return check ();
210} 210}
211 211
212
212/* end of test_service_rps_peers.c */ 213/* end of test_service_rps_peers.c */
diff --git a/src/rps/test_service_rps_view.c b/src/rps/test_service_rps_view.c
index 5b668efe1..5a8c00849 100644
--- a/src/rps/test_service_rps_view.c
+++ b/src/rps/test_service_rps_view.c
@@ -141,4 +141,5 @@ main ()
141 return check (); 141 return check ();
142} 142}
143 143
144
144/* end of test_service_rps_view.c */ 145/* end of test_service_rps_view.c */