"Failed to write string to buffer (size: %i)\n",
size);
return;
- } */
-
- size = strlen (line) * sizeof(char);
+ } */size = strlen (line) * sizeof(char);
size2 = GNUNET_DISK_file_write (f, line, size);
if (size != size2)
}
}
+
/**
* This function is used to facilitate writing important information to disk
*/
* @return #GNUNET_YES if so
* #GNUNET_NO otherwise
*/
-static int check_statistics_collect_completed_single_peer (
+static int
+check_statistics_collect_completed_single_peer (
const struct RPSPeer *rps_peer)
{
if (cur_test_run.stat_collect_flags !=
* @return #GNUNET_YES if so
* #GNUNET_NO otherwise
*/
-static int check_statistics_collect_completed ()
+static int
+check_statistics_collect_completed ()
{
uint32_t i;
}
}
/* If we do not collect statistics, shut down directly */
- if ((NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics)||
+ if ((NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics) ||
(GNUNET_YES == check_statistics_collect_completed ()) )
{
GNUNET_SCHEDULER_shutdown ();
unsigned int amount;
unsigned int i;
- if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test))
+ if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
{
return;
}
GNUNET_RPS_seed_ids (peer->rps_handle, amount, ids_to_seed);
}
+
/**
* Get the id of peer i.
*/
(void) op;
- if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test))
+ if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
{
return;
}
- if ((NULL == pinfo)||(NULL != emsg))
+ if ((NULL == pinfo) || (NULL != emsg))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg);
GNUNET_TESTBED_operation_done (entry->op);
GNUNET_assert (NULL != ca_result);
- if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test))
+ if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
{
return;
}
return h;
}
+
/**
* Called to open a connection to the peer's statistics
*
return peer->stats_h;
}
+
/**
* Called to disconnect from peer's statistics service
*
peer->stats_h = NULL;
}
+
/**
* Called after successfully opening a connection to a peer's statistics
* service; we register statistics monitoring for CORE and NSE here.
return evaluate ();
}
+
static int
no_eval (void)
{
return 0;
}
+
/**
* Initialise given RPSPeer
*/
-static void default_init_peer (struct RPSPeer *rps_peer)
+static void
+default_init_peer (struct RPSPeer *rps_peer)
{
rps_peer->num_ids_to_request = 1;
}
+
/**
* Callback to call on receipt of a reply
*
rps_peer->num_recv_ids++;
}
- if ((0 == evaluate ())&&(HAVE_QUICK_QUIT == cur_test_run.have_quick_quit))
+ if ((0 == evaluate ()) && (HAVE_QUICK_QUIT == cur_test_run.have_quick_quit))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test succeeded before timeout\n");
GNUNET_assert (NULL != post_test_task);
}
}
+
/**
* Request random peers.
*/
struct RPSPeer *rps_peer;
struct PendingReply *pending_rep;
- if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test))
+ if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
return;
rps_peer = pending_req->rps_peer;
GNUNET_assert (1 <= rps_peer->num_pending_reqs);
rps_peer->num_pending_reqs--;
}
+
static void
cancel_pending_req (struct PendingRequest *pending_req)
{
GNUNET_free (pending_req);
}
+
static void
cancel_request (struct PendingReply *pending_rep)
{
GNUNET_free (pending_rep);
}
+
/**
* Cancel a request.
*/
struct RPSPeer *rps_peer = cls;
struct PendingReply *pending_rep;
- if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test))
+ if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
return;
pending_rep = rps_peer->pending_rep_head;
GNUNET_assert (1 <= rps_peer->num_pending_reps);
}
}
+
void
cancel_pending_req_rep (struct RPSPeer *rps_peer)
{
GNUNET_assert (0 == rps_peer->num_pending_reps);
}
+
/***********************************
* MALICIOUS
***********************************/
/**
* Initialise only non-mal RPSPeers
*/
-static void mal_init_peer (struct RPSPeer *rps_peer)
+static void
+mal_init_peer (struct RPSPeer *rps_peer)
{
if (rps_peer->index >= round (portion * num_peers))
rps_peer->num_ids_to_request = 1;
#endif /* ENABLE_MALICIOUS */
}
+
static void
mal_cb (struct RPSPeer *rps_peer)
{
uint32_t num_mal_peers;
- if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test))
+ if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
{
return;
}
static void
single_req_cb (struct RPSPeer *rps_peer)
{
- if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test))
+ if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
{
return;
}
schedule_missing_requests (rps_peer);
}
+
/***********************************
* DELAYED_REQUESTS
***********************************/
static void
delay_req_cb (struct RPSPeer *rps_peer)
{
- if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test))
+ if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
{
return;
}
schedule_missing_requests (rps_peer);
}
+
/***********************************
* SEED
***********************************/
static void
seed_cb (struct RPSPeer *rps_peer)
{
- if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test))
+ if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
{
return;
}
seed_peers, rps_peer);
}
+
/***********************************
* SEED_BIG
***********************************/
static void
seed_big_cb (struct RPSPeer *rps_peer)
{
- if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test))
+ if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
{
return;
}
seed_peers_big, rps_peer);
}
+
/***********************************
* SINGLE_PEER_SEED
***********************************/
// TODO
}
+
/***********************************
* SEED_REQUEST
***********************************/
static void
seed_req_cb (struct RPSPeer *rps_peer)
{
- if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test))
+ if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
{
return;
}
schedule_missing_requests (rps_peer);
}
+
// TODO start big mal
/***********************************
static void
req_cancel_cb (struct RPSPeer *rps_peer)
{
- if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test))
+ if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
{
return;
}
cancel_request_cb, rps_peer);
}
+
/***********************************
* CHURN
***********************************/
static void
churn_test_cb (struct RPSPeer *rps_peer)
{
- if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test))
+ if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
{
return;
}
/* Start churn */
- if ((HAVE_CHURN == cur_test_run.have_churn)&&(NULL == churn_task))
+ if ((HAVE_CHURN == cur_test_run.have_churn) && (NULL == churn_task))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting churn task\n");
schedule_missing_requests (rps_peer);
}
+
/***********************************
* SUB
***********************************/
rps_peer);
}
+
/***********************************
* PROFILER
***********************************/
// FIXME
struct OpListEntry *entry = cls;
- if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test))
+ if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
{
return;
}
// run_round ();
}
+
/**
* @brief Set the rps-service up or down for a specific peer
*
double portion_go_online;
double portion_go_offline;
- if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test))
+ if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
{
return;
}
/**
* Initialise given RPSPeer
*/
-static void profiler_init_peer (struct RPSPeer *rps_peer)
+static void
+profiler_init_peer (struct RPSPeer *rps_peer)
{
if (num_peers - 1 == rps_peer->index)
rps_peer->num_ids_to_request = cur_test_run.num_requests;
static void
profiler_cb (struct RPSPeer *rps_peer)
{
- if ((GNUNET_YES == in_shutdown)||(GNUNET_YES == post_test))
+ if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
{
return;
}
/* Start churn */
- if ((HAVE_CHURN == cur_test_run.have_churn)&&(NULL == churn_task))
+ if ((HAVE_CHURN == cur_test_run.have_churn) && (NULL == churn_task))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting churn task\n");
schedule_missing_requests (rps_peer);
}
+
/**
* Function called from #profiler_eval with a filename.
*
return GNUNET_OK;
}
+
/**
* This is run after the test finished.
*
*
* @return
*/
-static int is_in_view (uint32_t a, uint32_t b)
+static int
+is_in_view (uint32_t a, uint32_t b)
{
uint32_t i;
return GNUNET_NO;
}
-static uint32_t get_idx_of_pid (const struct GNUNET_PeerIdentity *pid)
+
+static uint32_t
+get_idx_of_pid (const struct GNUNET_PeerIdentity *pid)
{
uint32_t i;
GNUNET_assert (0);
}
+
/**
* @brief Counts number of peers in view of a that have b in their view
*
*
* @return
*/
-static uint32_t count_containing_views (uint32_t a, uint32_t b)
+static uint32_t
+count_containing_views (uint32_t a, uint32_t b)
{
uint32_t i;
uint32_t peer_idx;
return count;
}
+
/**
* @brief Computes the probability for each other peer to be selected by the
* sampling process based on the views of all peers
*
* @param peer_idx index of the peer that is about to sample
*/
-static void compute_probabilities (uint32_t peer_idx)
+static void
+compute_probabilities (uint32_t peer_idx)
{
// double probs[num_peers] = { 0 };
double probs[num_peers];
GNUNET_free (probs_as_str);
}
+
/**
* @brief This counts the number of peers in which views a given peer occurs.
*
*
* @return the number of occurrences
*/
-static uint32_t count_peer_in_views_2 (uint32_t peer_idx)
+static uint32_t
+count_peer_in_views_2 (uint32_t peer_idx)
{
uint32_t i, j;
uint32_t count = 0;
return count;
}
-static uint32_t cumulated_view_sizes ()
+
+static uint32_t
+cumulated_view_sizes ()
{
uint32_t i;
return view_sizes;
}
-static void count_peer_in_views (uint32_t *count_peers)
+
+static void
+count_peer_in_views (uint32_t *count_peers)
{
uint32_t i, j;
}
}
-void compute_diversity ()
+
+void
+compute_diversity ()
{
uint32_t i;
/* ith entry represents the numer of occurrences in other peer's views */
GNUNET_free (deviation);
}
-void print_view_sizes ()
+
+void
+print_view_sizes ()
{
uint32_t i;
}
}
-void all_views_updated_cb ()
+
+void
+all_views_updated_cb ()
{
compute_diversity ();
print_view_sizes ();
}
-void view_update_cb (void *cls,
- uint64_t view_size,
- const struct GNUNET_PeerIdentity *peers)
+
+void
+view_update_cb (void *cls,
+ uint64_t view_size,
+ const struct GNUNET_PeerIdentity *peers)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"View was updated (%" PRIu64 ")\n", view_size);
all_views_updated_cb ();
}
+
static void
pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
{
GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer);
}
-void write_final_stats (void)
+
+void
+write_final_stats (void)
{
uint32_t i;
}
}
+
/**
* Continuation called by #GNUNET_STATISTICS_get() functions.
*
GNUNET_break (0);
}
- if ((NULL != rps_peer->stat_op)&&
+ if ((NULL != rps_peer->stat_op) &&
(GNUNET_YES == check_statistics_collect_completed_single_peer (
rps_peer)) )
{
}
}
+
/**
* @brief Converts string representation to the corresponding #STAT_TYPE enum.
*
*
* @return corresponding enum
*/
-enum STAT_TYPE stat_str_2_type (const char *stat_str)
+enum STAT_TYPE
+stat_str_2_type (const char *stat_str)
{
if (0 == strncmp ("# rounds blocked - no pull replies", stat_str, strlen (
"# rounds blocked - no pull replies")))
*
* @return string representation that matches statistics value
*/
-char*stat_type_2_str (enum STAT_TYPE stat_type)
+char*
+stat_type_2_str (enum STAT_TYPE stat_type)
{
switch (stat_type)
{
}
}
+
/**
* Callback function to process statistic values.
*
return GNUNET_OK;
}
-void post_profiler (struct RPSPeer *rps_peer)
+
+void
+post_profiler (struct RPSPeer *rps_peer)
{
if (COLLECT_STATISTICS != cur_test_run.have_collect_statistics)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n");
/* Check whether we timed out */
- if ((n_peers != num_peers)||
+ if ((n_peers != num_peers) ||
(NULL == peers) ||
(0 == links_succeeded) )
{