45#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
64#define SET_PEER_FLAG(peer_ctx, mask) ((peer_ctx->peer_flags) |= (mask))
69#define check_peer_flag_set(peer_ctx, mask) \
70 ((peer_ctx->peer_flags) & (mask) ? GNUNET_YES : GNUNET_NO)
75#define UNSET_PEER_FLAG(peer_ctx, mask) ((peer_ctx->peer_flags) &= ~(mask))
80#define check_channel_flag_set(channel_flags, mask) \
81 ((*channel_flags) & (mask) ? GNUNET_YES : GNUNET_NO)
86#define unset_channel_flag(channel_flags, mask) ((*channel_flags) &= ~(mask))
274 struct AttackedPeer *next;
275 struct AttackedPeer *prev;
289#define HISTOGRAM_FILE_SLOTS 32
297#define SIZE_DUMP_FILE (HISTOGRAM_FILE_SLOTS * 5) + 1
361 char *file_name_view_log;
369 char *file_name_observed_log;
522static uint32_t mal_type;
538static uint32_t num_mal_peers;
544static struct AttackedPeer *att_peers_head;
545static struct AttackedPeer *att_peers_tail;
551static struct AttackedPeer *att_peer_index;
562static uint32_t num_attacked_peers;
576static uint32_t push_limit = 10000;
603do_mal_round (
void *cls);
646 if (NULL != peer_map)
675 ctx->peer_id = *peer;
788 if (0 >= iterator_cls->
index)
793 iterator_cls->
index--;
884 "Peer %s is online and valid, calling %i pending operations on it\n",
891 "Removing pending online check for peer %s\n",
971 if (NULL == peer_ctx)
1020 "Trying to establish channel to peer %s\n",
1050 if (NULL == peer_ctx->
mq)
1054 return peer_ctx->
mq;
1074 pending_msg->
ev =
ev;
1125 "Online check for peer %s was successful\n",
1144 "Get informed about peer %s getting online\n",
1161 "# pending online checks",
1209 channel = channel_ctx->
channel;
1282 "Going to remove peer %s\n",
1296 "Removing unsent %s\n",
1308 "# pending online checks",
1322 "Removing pending online check for peer %s\n",
1352 "removing peer from peer_ctx->sub->peer_map failed\n");
1381 struct Sub *sub = cls;
1407 if (0 == strncmp (
"PULL REPLY", pending_msg->
type, 10))
1409 if (0 == strncmp (
"PULL REQUEST", pending_msg->
type, 12))
1411 if (0 == strncmp (
"PUSH", pending_msg->
type, 4))
1413 if ((0 == strncmp (
"PULL REQUEST", pending_msg->
type, 12)) &&
1419 "# pull requests sent (multi-hop peer)",
1448 char peer_string[128];
1459 sizeof(peer_string),
1480 uint32_t number_written_peers;
1492 "Not able to create directory for file `%s'\n",
1499 "Directory for file `%s' exists but is not writable for us\n",
1511 "Not able to write valid peers to file `%s'\n",
1516 "Writing %u valid peers to disk\n",
1518 number_written_peers =
1545 len = strlen (string_repr);
1549 "Not able to convert string representation of PeerID to PeerID\n"
1550 "String representation: %s (len %lu) - too short\n",
1565 "Not able to convert string representation of PeerID to PeerID\n"
1566 "String representation: %s\n",
1610 "Restoring %" PRIu32
" peers from file `%s'\n",
1613 for (iter_buf = buf; iter_buf < buf + file_size - 1; iter_buf += 53)
1620 "Restored valid peer %s from disk\n",
1626 "num_peers: %" PRIu32
", _size (sub->valid_peers): %u\n",
1632 "Number of restored peers does not match file size. Have probably duplicates.\n");
1636 "Restored %u valid peers from disk\n",
1655 "Iteration destroying peers was aborted.\n");
1903 struct Sub *sub = cls;
1906 "New channel was established to us (Peer %s).\n",
1914 channel_ctx->
channel = channel;
1920 "Already got one receive channel. Destroying old one.\n");
2001 "Sending message to %s of type %s\n",
2039 pending_op.
op = peer_op;
2152 "Printing peer list of length %u at %p:\n",
2155 for (i = 0; i < len; i++)
2169 unsigned int *list_size,
2178 "Removing peer %s from list at %p\n",
2182 for (i = 0; i < *list_size; i++)
2186 if (i < *list_size - 1)
2188 memmove (&tmp[i], &tmp[i + 1],
2270 if (NULL == view_array)
2272 if (NULL == cli_ctx->
sub)
2341 "View is too big to send\n");
2346 NULL != cli_ctx_iter;
2347 cli_ctx_iter = cli_ctx_iter->
next)
2387 "Got peer (%s) from biased stream - update all clients\n",
2391 NULL != cli_ctx_iter;
2392 cli_ctx_iter = cli_ctx_iter->
next)
2416 struct Sub *sub = cls;
2424 "Peer in history update not known!\n");
2433 to_file (sub->file_name_view_log,
2454 unsigned int sampler_size;
2459 if (sampler_size > new_size * 4)
2463 else if (sampler_size < new_size)
2489 "Trying to add peers to non-existing peermap.\n");
2523 unsigned int num_peer_ids)
2543 send_size = num_peer_ids;
2546 "Going to send PULL REPLY with %u peers to %s\n",
2580 struct Sub *sub = cls;
2599 struct Sub *sub = cls;
2621 struct Sub *sub = cls;
2624 "Updating samplers with peer %s from insert_in_sampler()\n",
2638 "# observed peers in gossip",
2649 uint32_t num_observed_unique_peers =
2652 "# unique peers in gossip",
2653 num_observed_unique_peers,
2656 to_file (sub->file_name_observed_log,
2657 "%" PRIu32
" %" PRIu32
" %f\n",
2659 num_observed_unique_peers,
2783 "Going to remove send channel to peer %s\n",
2785 #if ENABLE_MALICIOUS
2801 "Peer was removed from our knowledge during cleanup\n");
2814 "Going to remove peer %s\n",
2843 if ((NULL != peer_ctx) &&
2881 uint32_t sampler_size,
2921 "Cadet port `%s' is already in use.\n",
2931 "FILENAME_VALID_PEERS",
2936 "FILENAME_VALID_PEERS");
2940 char *tmp_filename_valid_peers;
2944 sizeof(str_hash),
"%s",
2949 tmp_filename_valid_peers,
3083 sub->file_name_view_log = NULL;
3088 sub->file_name_observed_log = NULL;
3200 if (NULL != cli_ctx->
sub)
3203 cli_ctx->
sub = NULL;
3224 "Received a ns estimate - logest: %f, std_dev: %f (old_size: %u)\n",
3229 estimate = pow (estimate, 1.0 / 3);
3274 double logestimate,
double std_dev)
3282 NULL != cli_ctx_iter;
3283 cli_ctx_iter = cli_ctx_iter->
next)
3285 if (NULL != cli_ctx_iter->
sub)
3306 uint16_t msize = ntohs (
msg->header.
size);
3314 "message says it sends %" PRIu32
" peers, have space for %lu peers\n",
3315 ntohl (
msg->num_peers),
3344 "Client seeded peers:\n");
3350 "Updating samplers with seed %" PRIu32
": %s\n",
3356 if (NULL != cli_ctx->
sub)
3375 uint64_t num_updates;
3377 num_updates = ntohl (
msg->num_updates);
3380 "Client requested %" PRIu64
" updates of view.\n",
3405 "Client does not want to receive updates of view any more.\n");
3433 "Client requested peers from biased stream.\n");
3456 "Client canceled receiving peers from biased stream.\n");
3477 if ((NULL != cli_ctx->
sub) &&
3478 (0 != memcmp (&cli_ctx->
sub->
hash,
3483 "Already have a Sub with different share for this client. Remove old one, add new.\n");
3485 cli_ctx->
sub = NULL;
3507 if (0 != memcmp (&cli_ctx->
sub->
hash, &
msg->hash,
sizeof(
struct
3511 "Share of current sub and request differ!\n");
3514 cli_ctx->
sub = NULL;
3538 "Received CHECK_LIVE (%s)\n",
GNUNET_i2s (peer));
3542 "# pending online checks",
3572 "Received PUSH (%s)\n",
3582 "# push message received (multi-hop peer)",
3588 #if ENABLE_MALICIOUS
3589 struct AttackedPeer *tmp_att_peer;
3591 if ((1 == mal_type) ||
3594 tmp_att_peer =
GNUNET_new (
struct AttackedPeer);
3595 tmp_att_peer->peer_id = *peer;
3596 if (NULL == att_peer_set)
3604 add_peer_array_to_set (peer, 1, att_peer_set);
3613 else if (2 == mal_type)
3652 "# pull request message received",
3660 "# pull request message received (multi-hop peer)",
3666 #if ENABLE_MALICIOUS
3673 else if (2 == mal_type)
3712 if ((ntohs (
msg->header.
size) -
sizeof(
struct
3717 "message says it sends %" PRIu32
" peers, have space for %lu peers\n",
3718 ntohl (
msg->num_peers),
3719 (ntohs (
msg->header.
size) -
sizeof(
struct
3731 "Received a pull reply from a peer (%s) we didn't request one from!\n",
3736 "# unrequested pull replies",
3762 struct AttackedPeer *tmp_att_peer;
3771 "# pull reply messages received",
3777 peer_ctx->peer_id)) )
3780 "# pull reply messages received (multi-hop peer)",
3786 #if ENABLE_MALICIOUS
3797 "PULL REPLY received, got following %u peers:\n",
3798 ntohl (
msg->num_peers));
3800 for (i = 0; i < ntohl (
msg->num_peers); i++)
3807 #if ENABLE_MALICIOUS
3808 if ((NULL != att_peer_set) &&
3809 ((1 == mal_type) || (3 == mal_type) ))
3817 tmp_att_peer =
GNUNET_new (
struct AttackedPeer);
3818 tmp_att_peer->peer_id =
peers[i];
3822 add_peer_array_to_set (&
peers[i], 1, att_peer_set);
3871 unsigned
int spread)
3875 unsigned int rand_delay;
3876 unsigned int max_rand_delay;
3881 "Not accepting spread of 0\n");
3891 / mean.rel_value_us * (2 / spread);
3904 "Returning FOREVER_REL\n");
3928 "Going to send PULL REQUEST to peer %s.\n",
3938 "# pull request send issued",
3946 "# pull request send issued (multi-hop peer)",
3965 "Going to send PUSH to peer %s.\n",
3973 "# push send issued",
3981 "# push send issued (multi-hop peer)",
4001check_client_act_malicious (
void *cls,
4002 const struct GNUNET_RPS_CS_ActMaliciousMessage *
msg)
4005 uint16_t msize = ntohs (
msg->header.
size);
4008 msize -=
sizeof(
struct GNUNET_RPS_CS_ActMaliciousMessage);
4013 "message says it sends %" PRIu32
" peers, have space for %lu peers\n",
4014 ntohl (
msg->num_peers),
4032handle_client_act_malicious (
void *cls,
4034 GNUNET_RPS_CS_ActMaliciousMessage *
msg)
4038 uint32_t num_mal_peers_sent;
4039 uint32_t num_mal_peers_old;
4040 struct Sub *sub = cli_ctx->
sub;
4047 if (NULL == mal_peer_set)
4051 "Now acting malicious type %" PRIu32
", got %" PRIu32
" peers.\n",
4053 ntohl (
msg->num_peers));
4059 num_mal_peers_sent = ntohl (
msg->num_peers);
4060 num_mal_peers_old = num_mal_peers;
4063 num_mal_peers + num_mal_peers_sent);
4069 add_peer_array_to_set (&mal_peers[num_mal_peers_old],
4079 else if ((2 == mal_type) ||
4084 num_mal_peers_sent = ntohl (
msg->num_peers) - 1;
4085 num_mal_peers_old = num_mal_peers;
4089 num_mal_peers + num_mal_peers_sent);
4090 if ((NULL != mal_peers) &&
4091 (0 != num_mal_peers) )
4098 add_peer_array_to_set (&mal_peers[num_mal_peers_old],
4105 &
msg->attacked_peer,
4114 "Attacked peer is %s\n",
4125 else if (0 == mal_type)
4150do_mal_round (
void *cls)
4152 uint32_t num_pushes;
4155 struct AttackedPeer *tmp_att_peer;
4156 struct Sub *sub = cls;
4159 "Going to execute next round maliciously type %" PRIu32
".\n",
4168 num_attacked_peers),
4172 "Going to send %" PRIu32
" pushes\n",
4176 for (i = 0; i < num_pushes; i++)
4178 if (att_peers_tail == att_peer_index)
4179 att_peer_index = att_peers_head;
4181 att_peer_index = att_peer_index->next;
4187 tmp_att_peer = att_peer_index;
4188 for (i = 0; i < num_pushes *
alpha; i++)
4190 if (att_peers_tail == tmp_att_peer)
4191 tmp_att_peer = att_peers_head;
4193 att_peer_index = tmp_att_peer->next;
4200 else if (2 == mal_type)
4225 "Goding to send push to attacked peer (%s)\n",
4234 num_attacked_peers),
4238 "Going to send %" PRIu32
" pushes\n",
4241 for (i = 0; i < num_pushes; i++)
4243 if (att_peers_tail == att_peer_index)
4244 att_peer_index = att_peers_head;
4246 att_peer_index = att_peer_index->next;
4252 tmp_att_peer = att_peer_index;
4253 for (i = 0; i < num_pushes *
alpha; i++)
4255 if (att_peers_tail == tmp_att_peer)
4256 tmp_att_peer = att_peers_head;
4258 att_peer_index = tmp_att_peer->next;
4269 &do_mal_round, sub);
4289 unsigned int *permut;
4290 unsigned int a_peers;
4291 unsigned int b_peers;
4292 uint32_t first_border;
4293 uint32_t second_border;
4296 struct Sub *sub = cls;
4300 "Going to execute next round.\n");
4307 to_file (sub->file_name_view_log,
4308 "___ new round ___");
4316 to_file (sub->file_name_view_log,
4333 "Going to send pushes to %u (ceil (%f * %u)) peers.\n",
4335 for (i = 0; i < a_peers; i++)
4337 peer = view_array[permut[i]];
4344 first_border = a_peers;
4345 second_border = a_peers + b_peers;
4352 "Going to send pulls to %u (ceil (%f * %u)) peers.\n",
4354 for (i = first_border; i < second_border; i++)
4356 peer = view_array[permut[i]];
4379 uint32_t final_size;
4380 uint32_t peers_to_clean_size;
4383 peers_to_clean = NULL;
4384 peers_to_clean_size = 0;
4386 peers_to_clean_size,
4395 to_file (sub->file_name_view_log,
4401 second_border = first_border
4404 final_size = second_border
4407 "first border: %" PRIu32
", second border: %" PRIu32
", final size: %"
4416 for (i = 0; i < first_border; i++)
4430 to_file (sub->file_name_view_log,
4442 for (i = first_border; i < second_border; i++)
4461 to_file (sub->file_name_view_log,
4472 final_size - second_border,
4478 rem_from_list (&peers_to_clean, &peers_to_clean_size, &view_array[i]);
4481 for (i = 0; i < peers_to_clean_size; i++)
4484 to_file (sub->file_name_view_log,
4509 "# rounds blocked - too many pushes, no pull replies",
4518 "# rounds blocked - no pushes, no pull replies",
4536 "Push map size too big for histogram (%u, %u)\n",
4547 "# peers in push map at end of round",
4551 "# peers in pull map at end of round",
4555 "# peers in view at end of round",
4559 "# expected pushes",
4563 "delta expected - received pushes",
4566 view_size_est_need),
4571 "Received %u pushes and %u pulls last round (alpha (%.2f) * view_size (sub->view%u) = %.2f)\n",
4583 "Updating with peer %s from push list\n",
4592 "Updating with peer %s from pull list\n",
4642 unsigned int n_paths,
4643 unsigned int best_path)
4646 struct Sub *sub = cls;
4655 "Got peer_id %s from cadet\n",
4677 struct Sub *sub = cls;
4682 "Got stored, valid peer %s\n",
4703 struct Sub *sub = cls;
4707 "Got peer_id %s from peerinfo\n",
4726 "RPS service is going down\n");
4765 struct AttackedPeer *tmp_att_peer;
4769 if (NULL != mal_peer_set)
4771 if (NULL != att_peer_set)
4773 while (NULL != att_peers_head)
4775 tmp_att_peer = att_peers_head;
4804 "Client connected\n");
4843 "Client disconnected. Destroy its context.\n");
4853 "Error in PEERSTORE monitoring\n");
4861 "Done with initial PEERSTORE iteration during monitoring\n");
4878 long long unsigned int sampler_size;
4893 "STARTING SERVICE (rps) for peer [%s]\n",
4897 "Malicious execution compiled in.\n");
4908 "RPS",
"ROUNDINTERVAL");
4943 strlen (hash_port_string),
4999 GNUNET_MESSAGE_TYPE_RPS_ACT_MALICIOUS,
5000 struct GNUNET_RPS_CS_ActMaliciousMessage,
struct GNUNET_MQ_Handle * mq
struct GNUNET_MessageHeader * msg
static int list
Set if we should print a list of currently running services.
static int ret
Final status code.
static char * peer_id
Option –peer.
static uint64_t timestamp(void)
Get current timestamp.
struct GNUNET_PeerIdentity my_identity
Our peer identity.
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_FS_Handle * ctx
static char * value
Value of the record to add/remove.
static uint32_t type
Type string converted to DNS type value.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
struct GNUNET_CONTAINER_MultiPeerMap * peers
Map from PIDs to struct CadetPeer entries.
static void remove_pending_message(struct PendingMessage *pending_msg, int cancel)
Remove a pending message from the respective DLL.
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 sync_cb(void *cls)
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.
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 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.
static struct GNUNET_PEERSTORE_Monitor * peerstore_notify
Our peerstore notification context.
void process_peerinfo_peers(void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg)
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 struct PeerContext * create_or_get_peer_ctx(struct Sub *sub, const struct GNUNET_PeerIdentity *peer)
Create or get a PeerContext.
void * core_connects(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Callback for core.
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.
static struct GNUNET_PEERSTORE_Handle * peerstore
Handle to the PEERSTORE service.
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 * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Handle client connecting to the service.
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 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 const struct GNUNET_PeerIdentity * get_random_peer_from_peermap(struct GNUNET_CONTAINER_MultiPeerMap *valid_peers)
Get a random peer from peer_map.
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 ()
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.
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 int check_peer_send_intention(const struct PeerContext *peer_ctx)
Check whether other peer has the intention to send/opened channel towars us.
static struct GNUNET_MQ_Handle * get_mq(struct PeerContext *peer_ctx)
Get the message queue (GNUNET_MQ_Handle) of a specific peer.
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.
struct Sub * new_sub(const struct GNUNET_HashCode *hash, uint32_t sampler_size, struct GNUNET_TIME_Relative round_interval)
Create a new Sub.
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 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 void check_peer_online(struct PeerContext *peer_ctx)
Issue a check whether peer is online.
GNUNET_SERVICE_MAIN(GNUNET_OS_project_data_gnunet(), "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 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 struct PeerContext * get_peer_ctx(const struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct GNUNET_PeerIdentity *peer)
Get the PeerContext associated with a peer.
static void error_cb(void *cls)
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.
struct GNUNET_CADET_Channel * get_channel(struct PeerContext *peer_ctx)
Get the channel of a peer.
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 struct ChannelCtx * add_channel_ctx(struct PeerContext *peer_ctx)
Allocate memory for a new channel context and insert it into DLL.
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 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 int destroy_peer(struct PeerContext *peer_ctx)
Remove peer.
static void do_round(void *cls)
Send out PUSHes and PULLs, possibly update #view, samplers.
unsigned int CustomPeerMap_size(const struct CustomPeerMap *c_peer_map)
Get the size of the custom peer map.
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.
struct CustomPeerMap * CustomPeerMap_create(unsigned int len)
Create an empty peermap.
struct GNUNET_PeerIdentity * CustomPeerMap_get_peer_by_index(const struct CustomPeerMap *c_peer_map, uint32_t index)
Get a peer by index.
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.
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.
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.
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"
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.
static unsigned int num_peers
Number of peers.
API to retrieve the current network size estimate.
API to the peerstore service.
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_Handle * GNUNET_CADET_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the MQ-based cadet service.
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Indicate readiness to receive the next message on a channel.
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
struct GNUNET_MQ_Handle * GNUNET_CADET_get_mq(const struct GNUNET_CADET_Channel *channel)
Obtain the message queue for a connected channel.
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.
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_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.
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.
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.
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.
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.
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).
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...
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#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.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value 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_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity 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.
enum GNUNET_GenericReturnValue GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
@ 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.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
void GNUNET_PEERSTORE_monitor_stop(struct GNUNET_PEERSTORE_Monitor *zm)
Stop monitoring.
void GNUNET_PEERSTORE_disconnect(struct GNUNET_PEERSTORE_Handle *h)
Disconnect from the PEERSTORE service.
struct GNUNET_PEERSTORE_Monitor * GNUNET_PEERSTORE_monitor_start(const struct GNUNET_CONFIGURATION_Handle *cfg, int iterate_first, const char *sub_system, const struct GNUNET_PeerIdentity *peer, const char *key, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_SCHEDULER_TaskCallback sync_cb, void *sync_cb_cls, GNUNET_PEERSTORE_Processor callback, void *callback_cls)
Request watching a given key The monitoring can be filtered to contain only records matching peer and...
struct GNUNET_PEERSTORE_Handle * GNUNET_PEERSTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the PEERSTORE service.
void GNUNET_PEERSTORE_monitor_next(struct GNUNET_PEERSTORE_Monitor *zm, uint64_t limit)
Calls the monitor processor specified in GNUNET_PEERSTORE_monitor_start for the next record(s).
#define GNUNET_PEERSTORE_HELLO_KEY
Key used for storing HELLO in the peerstore.
#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_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_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_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).
Handle to a message queue.
Message handler for a specific message type.
Handle for talking with the NSE service.
Handle to the PEERSTORE service.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
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.
struct PendingMessage * next
DLL next, prev.
const char * type
The message type.
struct PendingMessage * 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.