99 for (i = 0; i < n; i++)
101 fprintf (stdout,
"%s\n",
128 fprintf (stdout,
"Empty view\n");
131 for (i = 0; i < n; i++)
133 fprintf (stdout,
"%s\n",
166 fprintf (stdout,
"No peer was returned\n");
171 fprintf (stdout,
"%s\n",
200 fprintf (stderr,
"Failed to connect to the rps service\n");
209 if ((NULL ==
args[0]) ||
215 "Requesting %" PRIu64
" PeerIDs\n",
num_peers);
223 if ((NULL ==
args[0]) ||
235 "Requesting continuous view updates\n");
262main (
int argc,
char *
const *argv)
264 const char helpstr[] =
265 "Get random GNUnet peers. If none is specified a single is requested.";
275 "Get updates of view (0 for infinite updates)"),
288 "gnunet-rps [NUMBER_OF_PEERS]",
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
#define gettext_noop(String)
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static void stream_input_handle(void *cls, uint64_t num_peers, const struct GNUNET_PeerIdentity *recv_peers)
Callback called on receipt of peer from biased stream.
static int view_update
Do we want to receive updates of the view? (Option –view)
static int stream_input
Do we want to receive updates of the view? (Option –view)
static void do_shutdown(void *cls)
Task run when user presses CTRL-C to abort.
static struct GNUNET_RPS_Request_Handle * req_handle
Request handle.
static void reply_handle(void *cls, uint64_t n, const struct GNUNET_PeerIdentity *recv_peers)
Callback called on receipt of reply.
static struct GNUNET_RPS_Handle * rps_handle
RPS handle.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run by the scheduler.
static struct GNUNET_PeerIdentity peer_id
PeerID (Option –seed)
static uint64_t num_view_updates
Number of updates we want to receive.
int main(int argc, char *const *argv)
The main function to rps.
static void view_update_handle(void *cls, uint64_t n, const struct GNUNET_PeerIdentity *recv_peers)
Callback called on receipt view update.
static unsigned int num_peers
Number of peers.
#define GNUNET_GETOPT_option_base32_auto(shortName, name, argumentHelp, description, val)
Allow user to specify a binary value using Crockford Base32 encoding where the size of the binary val...
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
#define GNUNET_log(kind,...)
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
void GNUNET_RPS_request_cancel(struct GNUNET_RPS_Request_Handle *rh)
Cancel an issued request.
struct GNUNET_RPS_Handle * GNUNET_RPS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the rps service.
struct GNUNET_RPS_StreamRequestHandle * GNUNET_RPS_stream_request(struct GNUNET_RPS_Handle *rps_handle, GNUNET_RPS_NotifyReadyCB stream_input_cb, void *cls)
Request biased stream of peers that are being put into the sampler.
void GNUNET_RPS_view_request(struct GNUNET_RPS_Handle *rps_handle, uint32_t num_updates, GNUNET_RPS_NotifyReadyCB view_update_cb, void *cls)
Request updates of view.
void GNUNET_RPS_seed_ids(struct GNUNET_RPS_Handle *h, uint32_t n, const struct GNUNET_PeerIdentity *ids)
Seed rps service with peerIDs.
void GNUNET_RPS_disconnect(struct GNUNET_RPS_Handle *h)
Disconnect from the rps service.
struct GNUNET_RPS_Request_Handle * GNUNET_RPS_request_peers(struct GNUNET_RPS_Handle *rps_handle, uint32_t num_req_peers, GNUNET_RPS_NotifyReadyCB ready_cb, void *cls)
Request n random peers.
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,...
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.
Definition of a command line option.
The identity of the host (wraps the signing key of the peer).
Handler to handle requests from a client.
Handler for a single request from a client.