/** * Callback invoked from identity service with ego information. * An @a ego of NULL means the ego was not found. * * @param cls closure with the configuration * @param ego an ego known to identity service, or NULL */ static void identity_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego) { const struct GNUNET_CONFIGURATION_Handle *cfg = cls; el = NULL; if (NULL == ego) { if (NULL != ego_name) { fprintf (stderr, _("Ego `%s' not known to identity service\n"), ego_name); } GNUNET_SCHEDULER_shutdown (); ret = -1; return; } zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego); GNUNET_free_non_null (ego_name); ego_name = NULL; GNUNET_CLIENT_service_test ("namestore", cfg, GNUNET_TIME_UNIT_SECONDS, &testservice_task, (void *) cfg); }
static void runner6 (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing v6 service\n"); GNUNET_SERVER_add_handlers (server, myhandlers); GNUNET_CLIENT_service_test ("test_service6", cfg, GNUNET_TIME_UNIT_SECONDS, &ready6, (void *) cfg); }
/** * Main function that will be run by the scheduler. * * @param cls closure * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param my_cfg configuration */ static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *my_cfg) { cfg = (struct GNUNET_CONFIGURATION_Handle *) my_cfg; GNUNET_CLIENT_service_test ("ats", cfg, TIMEOUT, &testservice_ats, (void *) cfg); }
/** * Main function that will be run. * * @param cls closure * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param cfg configuration */ static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { if ( (NULL != args[0]) && (NULL == uri) ) uri = GNUNET_strdup (args[0]); GNUNET_CLIENT_service_test ("identity", cfg, GNUNET_TIME_UNIT_SECONDS, &testservice_id_task, (void *) cfg); }
/** * Main function that will be run by the scheduler. * * @param cls closure * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param cfg configuration */ static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *mycfg) { cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg; if (test_configuration) { do_test_configuration (cfg); return; } GNUNET_CLIENT_service_test ("transport", cfg, GNUNET_TIME_UNIT_SECONDS, &testservice_task, (void *) cfg); }
/** * Main function that will be run by the scheduler. * * @param cls closure * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param cfg configuration */ static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { set_value = GNUNET_NO; if (NULL != args[0]) { if (1 != SSCANF (args[0], "%llu", &set_val)) { FPRINTF (stderr, _("Invalid argument `%s'\n"), args[0]); ret = 1; return; } set_value = GNUNET_YES; } if (NULL != remote_host) GNUNET_CLIENT_service_test ("resolver", cfg, GNUNET_TIME_UNIT_SECONDS, &resolver_test_task, (void *) cfg); else GNUNET_SCHEDULER_add_now (&main_task, (void *) cfg); }
static void do_test (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_CLIENT_service_test ("do-nothing", cfg, TIMEOUT, &do_nothing_restarted_notify_task, NULL); }
/** * Handle network size estimate clients. * * @param cls closure * @param c configuration to use * @param service the initialized service */ static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service) { struct GNUNET_MQ_MessageHandler core_handlers[] = { GNUNET_MQ_hd_fixed_size (p2p_estimate, GNUNET_MESSAGE_TYPE_NSE_P2P_FLOOD, struct GNUNET_NSE_FloodMessage, NULL), GNUNET_MQ_handler_end () }; char *proof; struct GNUNET_CRYPTO_EddsaPrivateKey *pk; cfg = c; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, "NSE", "INTERVAL", &gnunet_nse_interval)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "NSE", "INTERVAL"); GNUNET_SCHEDULER_shutdown (); return; } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, "NSE", "WORKDELAY", &proof_find_delay)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "NSE", "WORKDELAY"); GNUNET_SCHEDULER_shutdown (); return; } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "NSE", "WORKBITS", &nse_work_required)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "NSE", "WORKBITS"); GNUNET_SCHEDULER_shutdown (); return; } if (nse_work_required >= sizeof (struct GNUNET_HashCode) * 8) { GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "NSE", "WORKBITS", _("Value is too large.\n")); GNUNET_SCHEDULER_shutdown (); return; } #if ENABLE_NSE_HISTOGRAM { char *histogram_dir; char *histogram_fn; if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "HISTOGRAM_DIR", &histogram_dir)) { GNUNET_assert (0 < GNUNET_asprintf (&histogram_fn, "%s/timestamps", histogram_dir)); GNUNET_free (histogram_dir); histogram = GNUNET_BIO_write_open (histogram_fn); if (NULL == histogram) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to open histogram file `%s'\n", histogram_fn); GNUNET_free (histogram_fn); } logger_test = GNUNET_CLIENT_service_test ("testbed-logger", cfg, GNUNET_TIME_UNIT_SECONDS, &status_cb, NULL); } #endif GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); pk = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg); GNUNET_assert (NULL != pk); my_private_key = pk; GNUNET_CRYPTO_eddsa_key_get_public (my_private_key, &my_identity.public_key); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "PROOFFILE", &proof)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "NSE", "PROOFFILE"); GNUNET_free (my_private_key); my_private_key = NULL; GNUNET_SCHEDULER_shutdown (); return; } if ((GNUNET_YES != GNUNET_DISK_file_test (proof)) || (sizeof (my_proof) != GNUNET_DISK_fn_read (proof, &my_proof, sizeof (my_proof)))) my_proof = 0; GNUNET_free (proof); proof_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, &find_proof, NULL); peers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_YES); nc = GNUNET_notification_context_create (1); /* Connect to core service and register core handlers */ core_api = GNUNET_CORE_connect (cfg, /* Main configuration */ NULL, /* Closure passed to functions */ &core_init, /* Call core_init once connected */ &handle_core_connect, /* Handle connects */ &handle_core_disconnect, /* Handle disconnects */ core_handlers); /* Register these handlers */ if (NULL == core_api) { GNUNET_SCHEDULER_shutdown (); return; } stats = GNUNET_STATISTICS_create ("nse", cfg); }
/** * Request for a service to be started. * * @param h handle to ARM * @param service_name name of the service * @param std_inheritance inheritance of std streams * @param timeout how long to wait before failing for good * @param cont callback to invoke after request is sent or not sent * @param cont_cls closure for callback */ void GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h, const char *service_name, enum GNUNET_OS_InheritStdioFlags std_inheritance, struct GNUNET_TIME_Relative timeout, GNUNET_ARM_ResultCallback cont, void *cont_cls) { struct ARMControlMessage *cm; size_t slen; LOG (GNUNET_ERROR_TYPE_DEBUG, "Asked to start service `%s' within %s\n", service_name, GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_NO)); if (0 == strcasecmp ("arm", service_name)) { /* Possible cases: * 1) We're connected to ARM already. Invoke the callback immediately. * 2) We're not connected to ARM. * Cancel any reconnection attempts temporarily, then perform * a service test. */ if (GNUNET_NO == h->currently_down) { LOG (GNUNET_ERROR_TYPE_DEBUG, "ARM is already running\n"); if (NULL != cont) cont (cont_cls, GNUNET_ARM_REQUEST_SENT_OK, "arm", GNUNET_ARM_RESULT_IS_STARTED_ALREADY); } else if (GNUNET_NO == h->service_test_is_active) { if (NULL != h->cth) { GNUNET_CLIENT_notify_transmit_ready_cancel (h->cth); h->cth = NULL; } if (NULL != h->client) { GNUNET_CLIENT_disconnect (h->client); h->client = NULL; } if (GNUNET_SCHEDULER_NO_TASK != h->reconnect_task) { GNUNET_SCHEDULER_cancel (h->reconnect_task); h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; } LOG (GNUNET_ERROR_TYPE_DEBUG, "Not connected to ARM, will do a service test\n"); slen = strlen ("arm") + 1; cm = GNUNET_malloc (sizeof (struct ARMControlMessage) + slen); cm->h = h; cm->result_cont = cont; cm->cont_cls = cont_cls; cm->timeout = GNUNET_TIME_relative_to_absolute (timeout); cm->std_inheritance = std_inheritance; memcpy (&cm[1], service_name, slen); h->service_test_is_active = GNUNET_YES; GNUNET_CLIENT_service_test ("arm", h->cfg, timeout, &arm_service_report, cm); } else { /* Service test is already running - tell user to chill out and try * again later. */ LOG (GNUNET_ERROR_TYPE_DEBUG, "Service test is already in progress, we're busy\n"); if (NULL != cont) cont (cont_cls, GNUNET_ARM_REQUEST_BUSY, NULL, 0); } return; } change_service (h, service_name, timeout, cont, cont_cls, GNUNET_MESSAGE_TYPE_ARM_START); }