44 #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
63 #define SET_PEER_FLAG(peer_ctx, mask) ((peer_ctx->peer_flags) |= (mask))
68 #define check_peer_flag_set(peer_ctx, mask) \
69 ((peer_ctx->peer_flags) & (mask) ? GNUNET_YES : GNUNET_NO)
74 #define UNSET_PEER_FLAG(peer_ctx, mask) ((peer_ctx->peer_flags) &= ~(mask))
79 #define check_channel_flag_set(channel_flags, mask) \
80 ((*channel_flags) & (mask) ? GNUNET_YES : GNUNET_NO)
85 #define unset_channel_flag(channel_flags, mask) ((*channel_flags) &= ~(mask))
273 struct AttackedPeer *next;
274 struct AttackedPeer *prev;
288 #define HISTOGRAM_FILE_SLOTS 32
296 #define SIZE_DUMP_FILE (HISTOGRAM_FILE_SLOTS * 5) + 1
360 char *file_name_view_log;
368 char *file_name_observed_log;
536 static uint32_t num_mal_peers;
542 static struct AttackedPeer *att_peers_head;
543 static struct AttackedPeer *att_peers_tail;
549 static struct AttackedPeer *att_peer_index;
560 static uint32_t num_attacked_peers;
574 static uint32_t push_limit = 10000;
601 do_mal_round (
void *cls);
786 if (0 >= iterator_cls->
index)
791 iterator_cls->
index--;
882 "Peer %s is online and valid, calling %i pending operations on it\n",
889 "Removing pending online check for peer %s\n",
969 if (NULL == peer_ctx)
1018 "Trying to establish channel to peer %s\n",
1048 if (NULL == peer_ctx->
mq)
1052 return peer_ctx->
mq;
1072 pending_msg->
ev =
ev;
1123 "Online check for peer %s was successful\n",
1142 "Get informed about peer %s getting online\n",
1159 "# pending online checks",
1207 channel = channel_ctx->
channel;
1280 "Going to remove peer %s\n",
1294 "Removing unsent %s\n",
1306 "# pending online checks",
1320 "Removing pending online check for peer %s\n",
1350 "removing peer from peer_ctx->sub->peer_map failed\n");
1379 struct Sub *sub = cls;
1405 if (0 == strncmp (
"PULL REPLY", pending_msg->
type, 10))
1407 if (0 == strncmp (
"PULL REQUEST", pending_msg->
type, 12))
1409 if (0 == strncmp (
"PUSH", pending_msg->
type, 4))
1411 if ((0 == strncmp (
"PULL REQUEST", pending_msg->
type, 12)) &&
1417 "# pull requests sent (multi-hop peer)",
1446 char peer_string[128];
1457 sizeof(peer_string),
1478 uint32_t number_written_peers;
1490 "Not able to create directory for file `%s'\n",
1497 "Directory for file `%s' exists but is not writable for us\n",
1509 "Not able to write valid peers to file `%s'\n",
1514 "Writing %u valid peers to disk\n",
1516 number_written_peers =
1543 len = strlen (string_repr);
1547 "Not able to convert string representation of PeerID to PeerID\n"
1548 "String representation: %s (len %lu) - too short\n",
1563 "Not able to convert string representation of PeerID to PeerID\n"
1564 "String representation: %s\n",
1608 "Restoring %" PRIu32
" peers from file `%s'\n",
1611 for (iter_buf =
buf; iter_buf <
buf + file_size - 1; iter_buf += 53)
1618 "Restored valid peer %s from disk\n",
1624 "num_peers: %" PRIu32
", _size (sub->valid_peers): %u\n",
1630 "Number of restored peers does not match file size. Have probably duplicates.\n");
1634 "Restored %u valid peers from disk\n",
1653 "Iteration destroying peers was aborted.\n");
1901 struct Sub *sub = cls;
1904 "New channel was established to us (Peer %s).\n",
1912 channel_ctx->
channel = channel;
1918 "Already got one receive channel. Destroying old one.\n");
1999 "Sending message to %s of type %s\n",
2037 pending_op.
op = peer_op;
2150 "Printing peer list of length %u at %p:\n",
2153 for (i = 0; i <
len; i++)
2167 unsigned int *list_size,
2176 "Removing peer %s from list at %p\n",
2180 for (i = 0; i < *list_size; i++)
2184 if (i < *list_size - 1)
2186 memmove (&tmp[i], &tmp[i + 1],
2268 if (NULL == view_array)
2270 if (NULL == cli_ctx->
sub)
2339 "View is too big to send\n");
2344 NULL != cli_ctx_iter;
2345 cli_ctx_iter = cli_ctx_iter->
next)
2385 "Got peer (%s) from biased stream - update all clients\n",
2389 NULL != cli_ctx_iter;
2390 cli_ctx_iter = cli_ctx_iter->
next)
2414 struct Sub *sub = cls;
2422 "Peer in history update not known!\n");
2431 to_file (sub->file_name_view_log,
2452 unsigned int sampler_size;
2457 if (sampler_size > new_size * 4)
2461 else if (sampler_size < new_size)
2469 #if ENABLE_MALICIOUS
2487 "Trying to add peers to non-existing peermap.\n");
2521 unsigned int num_peer_ids)
2541 send_size = num_peer_ids;
2544 "Going to send PULL REPLY with %u peers to %s\n",
2578 struct Sub *sub = cls;
2597 struct Sub *sub = cls;
2619 struct Sub *sub = cls;
2622 "Updating samplers with peer %s from insert_in_sampler()\n",
2636 "# observed peers in gossip",
2647 uint32_t num_observed_unique_peers =
2650 "# unique peers in gossip",
2651 num_observed_unique_peers,
2654 to_file (sub->file_name_observed_log,
2655 "%" PRIu32
" %" PRIu32
" %f\n",
2657 num_observed_unique_peers,
2781 "Going to remove send channel to peer %s\n",
2783 #if ENABLE_MALICIOUS
2799 "Peer was removed from our knowledge during cleanup\n");
2812 "Going to remove peer %s\n",
2841 if ((NULL != peer_ctx) &&
2879 uint32_t sampler_size,
2919 "Cadet port `%s' is already in use.\n",
2929 "FILENAME_VALID_PEERS",
2934 "FILENAME_VALID_PEERS");
2938 char *tmp_filename_valid_peers;
2942 sizeof(str_hash),
"%s",
2947 tmp_filename_valid_peers,
3081 sub->file_name_view_log = NULL;
3086 sub->file_name_observed_log = NULL;
3198 if (NULL != cli_ctx->
sub)
3201 cli_ctx->
sub = NULL;
3222 "Received a ns estimate - logest: %f, std_dev: %f (old_size: %u)\n",
3227 estimate = pow (estimate, 1.0 / 3);
3272 double logestimate,
double std_dev)
3280 NULL != cli_ctx_iter;
3281 cli_ctx_iter = cli_ctx_iter->
next)
3283 if (NULL != cli_ctx_iter->
sub)
3304 uint16_t msize = ntohs (
msg->header.
size);
3312 "message says it sends %" PRIu32
" peers, have space for %lu peers\n",
3313 ntohl (
msg->num_peers),
3342 "Client seeded peers:\n");
3348 "Updating samplers with seed %" PRIu32
": %s\n",
3354 if (NULL != cli_ctx->
sub)
3373 uint64_t num_updates;
3375 num_updates = ntohl (
msg->num_updates);
3378 "Client requested %" PRIu64
" updates of view.\n",
3403 "Client does not want to receive updates of view any more.\n");
3431 "Client requested peers from biased stream.\n");
3454 "Client canceled receiving peers from biased stream.\n");
3475 if ((NULL != cli_ctx->
sub) &&
3476 (0 != memcmp (&cli_ctx->
sub->
hash,
3481 "Already have a Sub with different share for this client. Remove old one, add new.\n");
3483 cli_ctx->
sub = NULL;
3505 if (0 != memcmp (&cli_ctx->
sub->
hash, &
msg->hash,
sizeof(
struct
3509 "Share of current sub and request differ!\n");
3512 cli_ctx->
sub = NULL;
3540 "# pending online checks",
3570 "Received PUSH (%s)\n",
3580 "# push message received (multi-hop peer)",
3586 #if ENABLE_MALICIOUS
3587 struct AttackedPeer *tmp_att_peer;
3592 tmp_att_peer =
GNUNET_new (
struct AttackedPeer);
3593 tmp_att_peer->peer_id = *
peer;
3594 if (NULL == att_peer_set)
3602 add_peer_array_to_set (
peer, 1, att_peer_set);
3650 "# pull request message received",
3658 "# pull request message received (multi-hop peer)",
3664 #if ENABLE_MALICIOUS
3710 if ((ntohs (
msg->header.
size) -
sizeof(
struct
3715 "message says it sends %" PRIu32
" peers, have space for %lu peers\n",
3716 ntohl (
msg->num_peers),
3717 (ntohs (
msg->header.
size) -
sizeof(
struct
3729 "Received a pull reply from a peer (%s) we didn't request one from!\n",
3734 "# unrequested pull replies",
3759 #if ENABLE_MALICIOUS
3760 struct AttackedPeer *tmp_att_peer;
3769 "# pull reply messages received",
3775 peer_ctx->peer_id)) )
3778 "# pull reply messages received (multi-hop peer)",
3784 #if ENABLE_MALICIOUS
3795 "PULL REPLY received, got following %u peers:\n",
3796 ntohl (
msg->num_peers));
3798 for (i = 0; i < ntohl (
msg->num_peers); i++)
3805 #if ENABLE_MALICIOUS
3806 if ((NULL != att_peer_set) &&
3815 tmp_att_peer =
GNUNET_new (
struct AttackedPeer);
3816 tmp_att_peer->peer_id =
peers[i];
3820 add_peer_array_to_set (&
peers[i], 1, att_peer_set);
3869 unsigned
int spread)
3873 unsigned int rand_delay;
3874 unsigned int max_rand_delay;
3879 "Not accepting spread of 0\n");
3889 / mean.rel_value_us * (2 / spread);
3902 "Returning FOREVER_REL\n");
3926 "Going to send PULL REQUEST to peer %s.\n",
3936 "# pull request send issued",
3944 "# pull request send issued (multi-hop peer)",
3963 "Going to send PUSH to peer %s.\n",
3971 "# push send issued",
3979 "# push send issued (multi-hop peer)",
3987 #if ENABLE_MALICIOUS
3999 check_client_act_malicious (
void *cls,
4000 const struct GNUNET_RPS_CS_ActMaliciousMessage *
msg)
4003 uint16_t msize = ntohs (
msg->header.
size);
4006 msize -=
sizeof(
struct GNUNET_RPS_CS_ActMaliciousMessage);
4011 "message says it sends %" PRIu32
" peers, have space for %lu peers\n",
4012 ntohl (
msg->num_peers),
4030 handle_client_act_malicious (
void *cls,
4032 GNUNET_RPS_CS_ActMaliciousMessage *
msg)
4036 uint32_t num_mal_peers_sent;
4037 uint32_t num_mal_peers_old;
4038 struct Sub *sub = cli_ctx->
sub;
4045 if (NULL == mal_peer_set)
4049 "Now acting malicious type %" PRIu32
", got %" PRIu32
" peers.\n",
4051 ntohl (
msg->num_peers));
4057 num_mal_peers_sent = ntohl (
msg->num_peers);
4058 num_mal_peers_old = num_mal_peers;
4061 num_mal_peers + num_mal_peers_sent);
4067 add_peer_array_to_set (&mal_peers[num_mal_peers_old],
4082 num_mal_peers_sent = ntohl (
msg->num_peers) - 1;
4083 num_mal_peers_old = num_mal_peers;
4087 num_mal_peers + num_mal_peers_sent);
4088 if ((NULL != mal_peers) &&
4089 (0 != num_mal_peers) )
4096 add_peer_array_to_set (&mal_peers[num_mal_peers_old],
4103 &
msg->attacked_peer,
4112 "Attacked peer is %s\n",
4148 do_mal_round (
void *cls)
4150 uint32_t num_pushes;
4153 struct AttackedPeer *tmp_att_peer;
4154 struct Sub *sub = cls;
4157 "Going to execute next round maliciously type %" PRIu32
".\n",
4166 num_attacked_peers),
4170 "Going to send %" PRIu32
" pushes\n",
4174 for (i = 0; i < num_pushes; i++)
4176 if (att_peers_tail == att_peer_index)
4177 att_peer_index = att_peers_head;
4179 att_peer_index = att_peer_index->next;
4185 tmp_att_peer = att_peer_index;
4186 for (i = 0; i < num_pushes *
alpha; i++)
4188 if (att_peers_tail == tmp_att_peer)
4189 tmp_att_peer = att_peers_head;
4191 att_peer_index = tmp_att_peer->next;
4223 "Goding to send push to attacked peer (%s)\n",
4232 num_attacked_peers),
4236 "Going to send %" PRIu32
" pushes\n",
4239 for (i = 0; i < num_pushes; i++)
4241 if (att_peers_tail == att_peer_index)
4242 att_peer_index = att_peers_head;
4244 att_peer_index = att_peer_index->next;
4250 tmp_att_peer = att_peer_index;
4251 for (i = 0; i < num_pushes *
alpha; i++)
4253 if (att_peers_tail == tmp_att_peer)
4254 tmp_att_peer = att_peers_head;
4256 att_peer_index = tmp_att_peer->next;
4267 &do_mal_round, sub);
4287 unsigned int *permut;
4288 unsigned int a_peers;
4289 unsigned int b_peers;
4290 uint32_t first_border;
4291 uint32_t second_border;
4294 struct Sub *sub = cls;
4298 "Going to execute next round.\n");
4305 to_file (sub->file_name_view_log,
4306 "___ new round ___");
4314 to_file (sub->file_name_view_log,
4331 "Going to send pushes to %u (ceil (%f * %u)) peers.\n",
4333 for (i = 0; i < a_peers; i++)
4335 peer = view_array[permut[i]];
4342 first_border = a_peers;
4343 second_border = a_peers + b_peers;
4350 "Going to send pulls to %u (ceil (%f * %u)) peers.\n",
4352 for (i = first_border; i < second_border; i++)
4354 peer = view_array[permut[i]];
4377 uint32_t final_size;
4378 uint32_t peers_to_clean_size;
4381 peers_to_clean = NULL;
4382 peers_to_clean_size = 0;
4384 peers_to_clean_size,
4393 to_file (sub->file_name_view_log,
4399 second_border = first_border
4402 final_size = second_border
4405 "first border: %" PRIu32
", second border: %" PRIu32
", final size: %"
4414 for (i = 0; i < first_border; i++)
4428 to_file (sub->file_name_view_log,
4440 for (i = first_border; i < second_border; i++)
4459 to_file (sub->file_name_view_log,
4470 final_size - second_border,
4476 rem_from_list (&peers_to_clean, &peers_to_clean_size, &view_array[i]);
4479 for (i = 0; i < peers_to_clean_size; i++)
4482 to_file (sub->file_name_view_log,
4507 "# rounds blocked - too many pushes, no pull replies",
4516 "# rounds blocked - no pushes, no pull replies",
4534 "Push map size too big for histogram (%u, %u)\n",
4545 "# peers in push map at end of round",
4549 "# peers in pull map at end of round",
4553 "# peers in view at end of round",
4557 "# expected pushes",
4561 "delta expected - received pushes",
4564 view_size_est_need),
4569 "Received %u pushes and %u pulls last round (alpha (%.2f) * view_size (sub->view%u) = %.2f)\n",
4581 "Updating with peer %s from push list\n",
4590 "Updating with peer %s from pull list\n",
4640 unsigned int n_paths,
4641 unsigned int best_path)
4644 struct Sub *sub = cls;
4653 "Got peer_id %s from cadet\n",
4675 struct Sub *sub = cls;
4680 "Got stored, valid peer %s\n",
4700 const char *err_msg)
4702 struct Sub *sub = cls;
4710 "Got peer_id %s from peerinfo\n",
4729 "RPS service is going down\n");
4767 #if ENABLE_MALICIOUS
4768 struct AttackedPeer *tmp_att_peer;
4772 if (NULL != mal_peer_set)
4774 if (NULL != att_peer_set)
4776 while (NULL != att_peers_head)
4778 tmp_att_peer = att_peers_head;
4807 "Client connected\n");
4846 "Client disconnected. Destroy its context.\n");
4865 long long unsigned int sampler_size;
4880 "STARTING SERVICE (rps) for peer [%s]\n",
4882 #if ENABLE_MALICIOUS
4884 "Malicious execution compiled in.\n");
4895 "RPS",
"ROUNDINTERVAL");
4930 strlen (hash_port_string),
4975 #
if ENABLE_MALICIOUS
4977 GNUNET_MESSAGE_TYPE_RPS_ACT_MALICIOUS,
4978 struct GNUNET_RPS_CS_ActMaliciousMessage,
struct GNUNET_MQ_Handle * mq
struct GNUNET_MessageHeader * msg
static int ret
Return value of the commandline.
static int list
Set if we should print a list of currently running services.
static struct GNUNET_CONTAINER_MultiPeerMap * ids
GNUNET_PeerIdentity -> CadetPeer.
static struct CadetPeer * peers
Operation to get peer ids.
static char * peer_id
Option –peer.
static struct GNUNET_PeerIdentity * peer_ids
static unsigned int num_peers
struct GNUNET_HashCode key
The key used in the DHT.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static char * value
Value of the record to add/remove.
static struct GNUNET_CONTAINER_MultiPeerMap * peer_map
Peermap to get the index of a given peer ID quick.
static unsigned int mal_type
Type of malicious peer to test.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static struct GNUNET_PeerIdentity my_identity
Identity of this peer.
static void remove_pending_message(struct PendingMessage *pending_msg, int cancel)
Remove a pending message from the respective DLL.
static struct GNUNET_PEERINFO_Handle * peerinfo_handle
Handler to PEERINFO.
static struct PeerContext * get_peer_ctx(const struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct GNUNET_PeerIdentity *peer)
Get the PeerContext associated with a peer.
struct ClientContext * cli_ctx_tail
struct GNUNET_CONTAINER_MultiPeerMap * map_single_hop
PeerMap to keep track of connected peers.
static void clean_peer(struct Sub *sub, const struct GNUNET_PeerIdentity *peer)
Remove data that is not needed anymore.
static void send_pull_reply(struct PeerContext *peer_ctx, const struct GNUNET_PeerIdentity *peer_ids, unsigned int num_peer_ids)
Send a PULL REPLY to peer_id.
static void mq_online_check_successful(void *cls)
This is called in response to the first message we sent as a online check.
static int check_operation_scheduled(const struct PeerContext *peer_ctx, const PeerOp peer_op)
Check whether function of type PeerOp was already scheduled.
static void handle_client_stream_cancel(void *cls, const struct GNUNET_MessageHeader *msg)
Handles the cancellation of the stream of biased peer ids.
static int valid_peer_iterator(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Iterator over #valid_peers hash map entries.
void core_init(void *cls, const struct GNUNET_PeerIdentity *my_identity)
Callback on initialisation of Core.
static void destroy_channel_cb(void *cls)
Destroy a cadet channel.
struct ClientContext * cli_ctx_head
DLL with all clients currently connected to us.
static void handle_client_view_cancel(void *cls, const struct GNUNET_MessageHeader *msg)
Handle the cancellation of the view updates.
static void destroy_cli_ctx(struct ClientContext *cli_ctx)
Destroy the context for a (connected) client.
static void handle_client_view_request(void *cls, const struct GNUNET_RPS_CS_DEBUG_ViewRequest *msg)
Handle RPS request from the client.
void process_peerinfo_peers(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg)
Iterator over peers from peerinfo.
static const struct GNUNET_PeerIdentity * s2i_full(const char *string_repr)
Convert string representation of peer id to peer id.
static void handle_client_stream_request(void *cls, const struct GNUNET_RPS_CS_DEBUG_StreamRequest *msg)
Handle RPS request for biased stream from the client.
static void handle_peer_push(void *cls, const struct GNUNET_MessageHeader *msg)
Handle a PUSH message from another peer.
static struct GNUNET_PEERINFO_NotifyContext * peerinfo_notify_handle
Handle for cancellation of iteration over peers.
static int check_sending_channel_needed(const struct PeerContext *peer_ctx)
Checks if there is a sending channel and if it is needed.
static struct GNUNET_PeerIdentity own_identity
Our own identity.
static int check_peer_pull_reply(void *cls, const struct GNUNET_RPS_P2P_PullReplyMessage *msg)
Check whether we sent a corresponding request and whether this reply is the first one.
static void store_valid_peers(const struct Sub *sub)
Store the peers currently in #valid_peers to disk.
static int add_valid_peer(const struct GNUNET_PeerIdentity *peer, struct GNUNET_CONTAINER_MultiPeerMap *valid_peers)
Add a given peer to valid peers.
static int get_rand_peer_iterator(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Iterator function for get_random_peer_from_peermap.
static void handle_client_start_sub(void *cls, const struct GNUNET_RPS_CS_SubStartMessage *msg)
Create and start a Sub.
static void adapt_sizes(struct Sub *sub, double logestimate, double std_dev)
Update sizes in sampler and view on estimate update from nse service.
#define SET_PEER_FLAG(peer_ctx, mask)
Set a peer flag of given peer context.
static void set_peer_online(struct PeerContext *peer_ctx)
Set the peer flag to living and call the pending operations on this peer.
static struct GNUNET_NSE_Handle * nse
Handler to NSE.
GNUNET_SERVICE_MAIN("rps", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(client_seed, GNUNET_MESSAGE_TYPE_RPS_CS_SEED, struct GNUNET_RPS_CS_SeedMessage, NULL), GNUNET_MQ_hd_fixed_size(client_view_request, GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_REQUEST, struct GNUNET_RPS_CS_DEBUG_ViewRequest, NULL), GNUNET_MQ_hd_fixed_size(client_view_cancel, GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_CANCEL, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_fixed_size(client_stream_request, GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_REQUEST, struct GNUNET_RPS_CS_DEBUG_StreamRequest, NULL), GNUNET_MQ_hd_fixed_size(client_stream_cancel, GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_CANCEL, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_fixed_size(client_start_sub, GNUNET_MESSAGE_TYPE_RPS_CS_SUB_START, struct GNUNET_RPS_CS_SubStartMessage, NULL), GNUNET_MQ_hd_fixed_size(client_stop_sub, GNUNET_MESSAGE_TYPE_RPS_CS_SUB_STOP, struct GNUNET_RPS_CS_SubStopMessage, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
static int peermap_clear_iterator(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator over hash map entries.
struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
static struct Sub * msub
Main Sub.
static void handle_peer_pull_reply(void *cls, const struct GNUNET_RPS_P2P_PullReplyMessage *msg)
Handle PULL REPLY message from another peer.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static void send_pull_request(struct PeerContext *peer_ctx)
Send single pull request.
#define HISTOGRAM_FILE_SLOTS
This number determines the number of slots for files that represent histograms.
struct GNUNET_CADET_Channel * get_channel(struct PeerContext *peer_ctx)
Get the channel of a peer.
static int check_removable(const struct PeerContext *peer_ctx)
Check if peer is removable.
#define check_peer_flag_set(peer_ctx, mask)
Get peer flag of given peer context.
static int store_peer_presistently_iterator(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Iterator function for store_valid_peers.
void init_peer_cb(void *cls, const struct GNUNET_PeerIdentity *peer, int tunnel, unsigned int n_paths, unsigned int best_path)
This is called from GNUNET_CADET_get_peers().
static void send_push(struct PeerContext *peer_ctx)
Send single push.
static void shutdown_task(void *cls)
Task run during shutdown.
static void destroy_channel(struct ChannelCtx *channel_ctx)
Callback for scheduler to destroy a channel.
static void insert_in_view_op(void *cls, const struct GNUNET_PeerIdentity *peer)
Insert PeerID in #view.
static void send_message(struct PeerContext *peer_ctx, struct GNUNET_MQ_Envelope *ev, const char *type)
Send a message to another peer.
#define UNSET_PEER_FLAG(peer_ctx, mask)
Unset flag of given peer context.
static void handle_peer_check(void *cls, const struct GNUNET_MessageHeader *msg)
Handle a CHECK_LIVE message from another peer.
static void insert_in_pull_map(void *cls, const struct GNUNET_PeerIdentity *peer)
Insert PeerID in #pull_map.
static struct PendingMessage * insert_pending_message(struct PeerContext *peer_ctx, struct GNUNET_MQ_Envelope *ev, const char *type)
Add an envelope to a message passed to mq to list of pending messages.
static int check_client_seed(void *cls, const struct GNUNET_RPS_CS_SeedMessage *msg)
This function is called, when the client seeds peers.
static struct GNUNET_TIME_Relative compute_rand_delay(struct GNUNET_TIME_Relative mean, unsigned int spread)
Compute a random delay.
static int check_peer_flag(const struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags)
Check whether flags on a peer are set.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
Handle random peer sampling clients.
struct GNUNET_CADET_Handle * cadet_handle
Handler to CADET.
static void nse_callback(void *cls, struct GNUNET_TIME_Absolute timestamp, double logestimate, double std_dev)
Function called by NSE.
static void peers_terminate(struct Sub *sub)
Delete storage of peers that was created with #initialise_peers ()
struct Sub * new_sub(const struct GNUNET_HashCode *hash, uint32_t sampler_size, struct GNUNET_TIME_Relative round_interval)
Create a new Sub.
static int insert_in_view(struct Sub *sub, const struct GNUNET_PeerIdentity *peer)
Insert PeerID in #view.
static int issue_peer_online_check(struct Sub *sub, const struct GNUNET_PeerIdentity *peer)
Try connecting to a peer to see whether it is online.
static float beta
Percentage of total peer number in the view to send random PULLs to.
void * core_connects(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Callback for core.
static const struct GNUNET_PeerIdentity * get_random_peer_from_peermap(struct GNUNET_CONTAINER_MultiPeerMap *valid_peers)
Get a random peer from peer_map.
static void remove_channel_ctx(struct ChannelCtx *channel_ctx)
Free memory and NULL pointers.
static void got_peer(struct Sub *sub, const struct GNUNET_PeerIdentity *peer)
This is called on peers from external sources (cadet, peerinfo, ...) If the peer is not known,...
static int destroy_sending_channel(struct PeerContext *peer_ctx)
Destroy the send channel of a peer e.g.
static struct PeerContext * create_peer_ctx(struct Sub *sub, const struct GNUNET_PeerIdentity *peer)
Create a new PeerContext and insert it into the peer map.
static int check_peer_send_intention(const struct PeerContext *peer_ctx)
Check whether other peer has the intention to send/opened channel towars us.
static float alpha
Percentage of total peer number in the view to send random PUSHes to.
static int check_peer_known(const struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct GNUNET_PeerIdentity *peer)
Check whether we have information about the given peer.
static void indicate_sending_intention(struct PeerContext *peer_ctx)
Indicate that we want to send to the other peer.
static void send_view(const struct ClientContext *cli_ctx, const struct GNUNET_PeerIdentity *view_array, uint64_t view_size)
Send view to client.
static int valid_peers_iterator(void *cls, const struct GNUNET_PeerIdentity *peer)
Iterator function over stored, valid peers.
static void handle_client_stop_sub(void *cls, const struct GNUNET_RPS_CS_SubStopMessage *msg)
Destroy the Sub.
static struct PeerContext * create_or_get_peer_ctx(struct Sub *sub, const struct GNUNET_PeerIdentity *peer)
Create or get a PeerContext.
static void schedule_channel_destruction(struct ChannelCtx *channel_ctx)
Schedule the destruction of a channel for immediately afterwards.
static void clients_notify_view_update(const struct Sub *sub)
sends updates to clients that are interested
static void handle_peer_pull_request(void *cls, const struct GNUNET_MessageHeader *msg)
Handle PULL REQUEST request message from another peer.
static int insert_peer(struct Sub *sub, const struct GNUNET_PeerIdentity *peer)
Add peer to known peers.
static void check_peer_online(struct PeerContext *peer_ctx)
Issue a check whether peer is online.
static void hist_update(const struct GNUNET_PeerIdentity *ids, uint32_t num_peers, void *cls)
Put random peer from sampler into the view as history update.
void core_disconnects(void *cls, const struct GNUNET_PeerIdentity *peer, void *peer_cls)
Callback for core.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Handle client connecting to the service.
struct GNUNET_CORE_Handle * core_handle
Handle to CORE.
static int check_connected(struct PeerContext *peer_ctx)
Check whether we have a connection to this peer.
static int get_valid_peers(struct GNUNET_CONTAINER_MultiPeerMap *valid_peers, PeersIterator iterator, void *it_cls)
Get all currently known, valid peer ids.
static void send_stream_peers(const struct ClientContext *cli_ctx, uint64_t num_peers, const struct GNUNET_PeerIdentity *peers)
Send peer from biased stream to client.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls)
Callback called when a client disconnected from the service.
static void restore_valid_peers(const struct Sub *sub)
Restore the peers on disk to #valid_peers.
static void handle_client_seed(void *cls, const struct GNUNET_RPS_CS_SeedMessage *msg)
Handle seed from the client.
static void resize_wrapper(struct RPS_Sampler *sampler, uint32_t new_size)
Wrapper around RPS_sampler_resize()
static void cleanup_destroyed_channel(void *cls, const struct GNUNET_CADET_Channel *channel)
This is called when a channel is destroyed.
static void mq_notify_sent_cb(void *cls)
This is called once a message is sent.
static void clients_notify_stream_peer(const struct Sub *sub, uint64_t num_peers, const struct GNUNET_PeerIdentity *peers)
sends updates to clients that are interested
static void * handle_inbound_channel(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *initiator)
Handle the channel a peer opens to us.
static void print_peer_list(struct GNUNET_PeerIdentity *list, unsigned int len)
Print peerlist to log.
static void rem_from_list(struct GNUNET_PeerIdentity **peer_list, unsigned int *list_size, const struct GNUNET_PeerIdentity *peer)
Remove peer from list.
static void destroy_sub(struct Sub *sub)
Destroy Sub.
static int schedule_operation(struct PeerContext *peer_ctx, const PeerOp peer_op, void *cls)
Schedule a operation on given peer.
static int check_sending_channel_exists(const struct PeerContext *peer_ctx)
Check whether a sending channel towards the given peer exists.
static const uint32_t num_valid_peers_max
Maximum number of valid peers to keep.
static void insert_in_sampler(void *cls, const struct GNUNET_PeerIdentity *peer)
Update sampler with given PeerID.
static void remove_peer(struct Sub *sub, const struct GNUNET_PeerIdentity *peer)
remove peer from our knowledge, the view, push and pull maps and samplers.
static int check_peer_valid(const struct GNUNET_CONTAINER_MultiPeerMap *valid_peers, const struct GNUNET_PeerIdentity *peer)
Check whether peer is actually a peer.
static struct GNUNET_MQ_Handle * get_mq(struct PeerContext *peer_ctx)
Get the message queue (GNUNET_MQ_Handle) of a specific peer.
static struct ChannelCtx * add_channel_ctx(struct PeerContext *peer_ctx)
Allocate memory for a new channel context and insert it into DLL.
static int destroy_peer(struct PeerContext *peer_ctx)
Remove peer.
static void do_round(void *cls)
Send out PUSHes and PULLs, possibly update #view, samplers.
struct CustomPeerMap * CustomPeerMap_create(unsigned int len)
Create an empty peermap.
unsigned int CustomPeerMap_size(const struct CustomPeerMap *c_peer_map)
Get the size of the custom peer map.
struct GNUNET_PeerIdentity * CustomPeerMap_get_peer_by_index(const struct CustomPeerMap *c_peer_map, uint32_t index)
Get a peer by index.
int CustomPeerMap_contains_peer(const struct CustomPeerMap *c_peer_map, const struct GNUNET_PeerIdentity *peer)
Check whether custom peer map contains a peer.
int CustomPeerMap_put(const struct CustomPeerMap *c_peer_map, const struct GNUNET_PeerIdentity *peer)
Insert peer into the custom peer map.
int CustomPeerMap_remove_peer(const struct CustomPeerMap *c_peer_map, const struct GNUNET_PeerIdentity *peer)
Remove peer from custom peer map.
void CustomPeerMap_destroy(struct CustomPeerMap *c_peer_map)
Destroy peermap.
void CustomPeerMap_clear(const struct CustomPeerMap *c_peer_map)
Clear the custom peer map.
utilities for managing (information about) peers
struct RPS_Sampler * RPS_sampler_init(size_t init_size, struct GNUNET_TIME_Relative max_round_interval)
Initialise a tuple of sampler elements.
void RPS_sampler_update(struct RPS_Sampler *sampler, const struct GNUNET_PeerIdentity *id)
Update every sampler element of this sampler with given peer.
void RPS_sampler_reinitialise_by_value(struct RPS_Sampler *sampler, const struct GNUNET_PeerIdentity *id)
Reinitialise all previously initialised sampler elements with the given value.
void RPS_sampler_resize(struct RPS_Sampler *sampler, unsigned int new_size)
Grow or shrink the size of the sampler.
struct RPS_SamplerRequestHandle * RPS_sampler_get_n_rand_peers(struct RPS_Sampler *sampler, uint32_t num_peers, RPS_sampler_n_rand_peers_ready_cb cb, void *cls)
Get n random peers out of the sampled peers.
void RPS_sampler_destroy(struct RPS_Sampler *sampler)
Cleans the samplers.
unsigned int RPS_sampler_get_size(struct RPS_Sampler *sampler)
Get the size of the sampler.
uint32_t RPS_sampler_count_id(struct RPS_Sampler *sampler, const struct GNUNET_PeerIdentity *id)
Counts how many Samplers currently hold a given PeerID.
void View_clear(struct View *view)
Clear the view.
int View_contains_peer(const struct View *view, const struct GNUNET_PeerIdentity *peer)
Check whether view contains a peer.
int View_put(struct View *view, const struct GNUNET_PeerIdentity *peer)
Insert peer into the view.
const struct GNUNET_PeerIdentity * View_get_as_array(const struct View *view)
Get the view as an array.
unsigned int View_size(const struct View *view)
Get the size of the view.
void View_destroy(struct View *view)
Destroy view.
void View_change_len(struct View *view, uint32_t len)
Change length of view.
int View_remove_peer(struct View *view, const struct GNUNET_PeerIdentity *peer)
Remove peer from view.
struct View * View_create(uint32_t len)
Create an empty view.
wrapper around the "local view"
static struct GNUNET_DISK_FileHandle * fh
File handle to STDIN, for reading restart/quit commands.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
Constants for network applications operating on top of the CADET service.
CADET service; establish channels to distant peers.
Core service; the main API for encrypted P2P communications.
API to retrieve the current network size estimate.
Maintain the list of currently known hosts.
API to create, modify and access statistics.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
#define GNUNET_APPLICATION_PORT_RPS
Transfer of blocks for random peer sampling.
struct GNUNET_CADET_Channel * GNUNET_CADET_channel_create(struct GNUNET_CADET_Handle *h, void *channel_cls, const struct GNUNET_PeerIdentity *destination, const struct GNUNET_HashCode *port, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Create a new channel towards a remote peer.
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Send an ack on the channel to confirm the processing of a message.
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
void GNUNET_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port.
struct GNUNET_MQ_Handle * GNUNET_CADET_get_mq(const struct GNUNET_CADET_Channel *channel)
Obtain the message queue for a connected peer.
struct GNUNET_CADET_Handle * GNUNET_CADET_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the MQ-based cadet service.
struct GNUNET_CADET_Port * GNUNET_CADET_open_port(struct GNUNET_CADET_Handle *h, const struct GNUNET_HashCode *port, GNUNET_CADET_ConnectEventHandler connects, void *connects_cls, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Open a port to receive incoming MQ-based channels.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
#define GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE
Maximum message size that can be sent on CADET.
struct GNUNET_CORE_Handle * GNUNET_CORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Connect to the core service.
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
unsigned int * GNUNET_CRYPTO_random_permute(enum GNUNET_CRYPTO_Quality mode, unsigned int n)
Get an array with a random permutation of the numbers 0...n-1.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
Retrieve the identity of the host's peer.
@ GNUNET_CRYPTO_QUALITY_STRONG
High-quality operations are desired.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory).
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_handle_size(struct GNUNET_DISK_FileHandle *fh, off_t *size)
Get the size of an open file.
@ GNUNET_DISK_OPEN_READ
Open the file for reading.
@ GNUNET_DISK_OPEN_WRITE
Open the file for writing.
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_NONE
Nobody is allowed to do anything to the file.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_contains(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Check if the map contains any value under the given key (including values that are NULL).
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
int GNUNET_CONTAINER_multipeermap_remove_all(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Remove all entries for the given key from the map.
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
static int iterator(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator over hash map entries.
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
#define GNUNET_log(kind,...)
void * cls
Closure for mv and cb.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a string representing a public key to a public key.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
const char * GNUNET_error_type_to_string(enum GNUNET_ErrorType kind)
Convert error type to string.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_MAX_MALLOC_CHECKED
Maximum allocation with GNUNET_malloc macro.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_msg_header(type)
Allocate a GNUNET_MQ_Envelope, where the message only consists of a header.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_NSE_disconnect(struct GNUNET_NSE_Handle *h)
Disconnect from network size estimation service.
#define GNUNET_NSE_log_estimate_to_n(loge)
Convert the logarithmic estimated returned to the 'GNUNET_NSE_Callback' into an absolute estimate in ...
struct GNUNET_NSE_Handle * GNUNET_NSE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_NSE_Callback func, void *func_cls)
Connect to the network size estimation service.
struct GNUNET_PEERINFO_NotifyContext * GNUNET_PEERINFO_notify(const struct GNUNET_CONFIGURATION_Handle *cfg, int include_friend_only, GNUNET_PEERINFO_Processor callback, void *callback_cls)
Call a method whenever our known information about peers changes.
struct GNUNET_PEERINFO_Handle * GNUNET_PEERINFO_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the peerinfo service.
void GNUNET_PEERINFO_notify_cancel(struct GNUNET_PEERINFO_NotifyContext *nc)
Stop notifying about changes.
void GNUNET_PEERINFO_disconnect(struct GNUNET_PEERINFO_Handle *h)
Disconnect from the peerinfo service.
#define GNUNET_MESSAGE_TYPE_RPS_CS_SUB_START
RPS client-service message to start a sub sampler.
#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_CANCEL
Cancel getting biased stream.
#define GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE
RPS check liveliness message to check liveliness of other peer.
#define GNUNET_MESSAGE_TYPE_RPS_PP_PUSH
RPS PUSH message to push own ID to another peer.
#define GNUNET_MESSAGE_TYPE_RPS_CS_SUB_STOP
RPS client-service message to stop a sub sampler.
#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_CANCEL
Cancel getting updates of the view.
#define GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REPLY
RPS PULL REPLY message which contains the view of the other peer.
#define GNUNET_MESSAGE_TYPE_RPS_CS_SEED
RPS CS SEED Message for the Client to seed peers into rps.
#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_REQUEST
Request biased input stream.
#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_REPLY
Send update of the view.
#define GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST
RPS PULL REQUEST message to request the local view of another peer.
#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_REQUEST
Request updates of the view.
#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_REPLY
Send peer of biased stream.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_saturating_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Saturating multiply relative time by a given factor.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Add relative times together.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Divide relative time by a given factor.
static unsigned int size
Size of the "table".
int close_all_files()
Close all files that were opened with get_file_handle.
Some utils facilitating the view into the internals for the sampler needed for evaluation.
#define to_file(file_name,...)
This function is used to facilitate writing important information to disk.
example IPC messages between RPS API and GNS service
int(* PeersIterator)(void *cls, const struct GNUNET_PeerIdentity *peer)
Iterator over valid peers.
void(* PeerOp)(void *cls, const struct GNUNET_PeerIdentity *peer)
Functions of this type can be used to be stored at a peer for later execution.
Peers_PeerFlags
Different flags indicating the status of another peer.
@ Peers_TO_DESTROY
We set this bit when we are going to destroy the channel to this peer.
@ Peers_ONLINE
We set this bit when we know the peer is online.
@ Peers_PULL_REPLY_PENDING
If we are waiting for a reply from that peer (sent a pull request).
struct PeerContext * peer_ctx
The peer context associated with the channel.
struct GNUNET_CADET_Channel * channel
The channel itself.
struct GNUNET_SCHEDULER_Task * destruction_task
When channel destruction needs to be delayed (because it is called from within the cadet routine of a...
Struct used to store the context of a connected client.
struct ClientContext * prev
struct ClientContext * next
DLL.
struct GNUNET_SERVICE_Client * client
The client handle to send the reply to.
struct Sub * sub
The Sub this context belongs to.
int8_t stream_update
Whether this client wants to receive stream updates.
struct GNUNET_MQ_Handle * mq
The message queue to communicate with the client.
int64_t view_updates_left
How many updates this client expects to receive.
Peer map to store peers with specialised use-cases (push_list, pull_list, view, .....
Opaque handle to a channel.
Opaque handle to the service.
Internal representation of the hash map.
Context for the core service connection.
Handle used to access files (and pipes).
A HELLO message is used to exchange information about transports with other peers.
Handle to a message queue.
Message handler for a specific message type.
Handle for talking with the NSE service.
Handle to the peerinfo service.
Context for the info handler.
The identity of the host (wraps the signing key of the peer).
Message from service to client containing peer from biased stream.
uint64_t num_peers
Number of peers.
Message from client to service indicating that clients wants to get stream of biased peers.
Message from service to client containing current update of view.
uint64_t num_peers
Number of peers in the view.
Message from client to service indicating that clients wants to get updates of the view.
Message from client to service with seed of peers.
Message from client to service telling it to start a new sub.
Message from client to service telling it to stop a new sub.
P2P Message to send PeerIDs to other peer.
uint32_t num_peers
Number of PeerIDs sent.
Entry in list of pending tasks.
Handle to a client that is connected to a service.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
The closure to get_rand_peer_iterator.
uint32_t index
The index of the peer to return.
const struct GNUNET_PeerIdentity * peer
Pointer to peer to return.
Struct used to keep track of other peer's status.
uint32_t round_pull_req
This is pobably followed by 'statistical' data (when we first saw it, how did we get its ID,...
uint32_t peer_flags
Flags indicating status of peer.
struct GNUNET_TIME_Absolute last_keepalive
Last time we received a keepalive message.
struct PeerPendingOp * pending_ops
Array of pending operations on this peer.
struct GNUNET_TIME_Absolute last_message_recv
Last time we received something from that peer.
struct PendingMessage * pending_messages_tail
struct PendingMessage * online_check_pending
Handle to the callback given to cadet_ntfy_tmt_rdy()
struct ChannelCtx * send_channel_ctx
Channel open to client.
struct Sub * sub
The Sub this context belongs to.
struct ChannelCtx * recv_channel_ctx
Channel open from client.
unsigned int num_pending_ops
Number of pending operations.
struct GNUNET_MQ_Handle * mq
Message queue open to client.
struct PendingMessage * pending_messages_head
DLL with all messages that are yet to be sent.
struct GNUNET_PeerIdentity peer_id
Identity of the peer.
Pending operation on peer consisting of callback and closure.
Closure to valid_peer_iterator.
PeersIterator iterator
Iterator function.
void * cls
Closure to iterator.
List containing all messages that are yet to be send.
const char * type
The message type.
struct PendingMessage * prev
This is a doubly-linked list.
struct PendingMessage * next
DLL next, prev.
struct GNUNET_MQ_Envelope * ev
The envelope to the corresponding message.
struct PeerContext * peer_ctx
The corresponding context.
Closure to _get_n_rand_peers_ready_cb()
Sampler with its own array of SamplerElements.
Closure used to pass the client and the id to the callback that replies to a client's request.
struct ClientContext * cli_ctx
The client handle to send the reply to.
struct ReplyCls * next
DLL.
uint32_t id
The identifier of the request.
struct RPS_SamplerRequestHandle * req_handle
The handle to the request.
struct RPS_Sampler * sampler
Sampler used for the Brahms protocol itself.
uint32_t push_delta[32]
Histogram of deltas between the expected and actual number of received pushes.
struct GNUNET_HashCode hash
Hash of the shared value that defines Subs.
unsigned int view_size_est_need
This is the estimate used as view size.
struct GNUNET_CONTAINER_MultiPeerMap * valid_peers
Hashmap of valid peers.
uint32_t push_recv[32]
This array accumulates the number of received pushes per round.
struct CustomPeerMap * pull_map
List to store peers received through pulls temporary.
struct GNUNET_CONTAINER_MultiPeerMap * peer_map
Set of all peers to keep track of them.
uint32_t pull_delays[32]
Number of pull replies with this delay measured in rounds.
unsigned int sampler_size_est_need
The size of sampler we need to be able to satisfy the Brahms protocol's need of random peers.
uint32_t num_rounds
Counts the executed rounds.
struct GNUNET_SCHEDULER_Task * do_round_task
Identifier for the main task that runs periodically.
unsigned int view_size_est_min
This is the minimum estimate used as view size.
char * filename_valid_peers
Filename of the file that stores the valid peers persistently.
struct CustomPeerMap * push_map
List to store peers received through pushes temporary.
unsigned int sampler_size_est_min
This is the minimum estimate used as sampler size.
struct GNUNET_CONTAINER_MultiPeerMap * observed_unique_peers
Multipeermap (ab-) used to count unique peer_ids.
uint32_t num_observed_peers
Count the observed peers.
struct GNUNET_CADET_Port * cadet_port
Port to communicate to other peers.
struct View * view
The view.
struct GNUNET_TIME_Relative round_interval
Time interval the do_round task runs in.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.