static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer) { die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); /* Connect to ATS scheduling */ sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL); if (sched_ats == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS scheduling!\n"); ret = 1; end (); return; } /* Set up peer */ if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p.id.hashPubKey)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); ret = GNUNET_SYSERR; end (); return; } GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p.id))); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", GNUNET_i2s_full(&p.id)); /* Prepare ATS Information */ test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE); test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN); test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); test_ats_info[1].value = htonl(1); test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); test_ats_info[1].value = htonl(10); test_ats_count = 2; /* Adding address without session */ test_session = &test_addr; create_test_address (&test_addr, "test", &test_addr, "test", strlen ("test") + 1); test_hello_address.peer = p.id; test_hello_address.transport_name = test_addr.plugin; test_hello_address.address = test_addr.addr; test_hello_address.address_length = test_addr.addr_len; GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session, test_ats_info, test_ats_count); /* Request address */ GNUNET_ATS_suggest_address (sched_ats, &p.id); }
/** * Method called to retrieve information about each tunnel the mesh peer * is aware of. * * @param cls Closure (unused). * @param initiator Peer that started the tunnel (owner). * @param tunnel_number Tunnel number. * @param peers Array of peer identities that participate in the tunnel. * @param npeers Number of peers in peers. */ static void tunnels_callback (void *cls, const struct GNUNET_PeerIdentity *initiator, unsigned int tunnel_number, const struct GNUNET_PeerIdentity *peers, unsigned int npeers) { unsigned int i; fprintf (stdout, "Tunnel %s [%u]: %u peers\n", GNUNET_i2s_full (initiator), tunnel_number, npeers); for (i = 0; i < npeers; i++) fprintf (stdout, " * %s\n", GNUNET_i2s_full (&peers[i])); fprintf (stdout, "\n"); }
/** * @brief Restore the peers on disk to #valid_peers. */ static void restore_valid_peers () { off_t file_size; uint32_t num_peers; struct GNUNET_DISK_FileHandle *fh; char *buf; ssize_t size_read; char *iter_buf; char *str_repr; const struct GNUNET_PeerIdentity *peer; if (0 == strncmp ("DISABLE", filename_valid_peers, 7)) { return; } if (GNUNET_OK != GNUNET_DISK_file_test (filename_valid_peers)) { return; } fh = GNUNET_DISK_file_open (filename_valid_peers, GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE); GNUNET_assert (NULL != fh); GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_handle_size (fh, &file_size)); num_peers = file_size / 53; buf = GNUNET_malloc (file_size); size_read = GNUNET_DISK_file_read (fh, buf, file_size); GNUNET_assert (size_read == file_size); LOG (GNUNET_ERROR_TYPE_DEBUG, "Restoring %" PRIu32 " peers from file `%s'\n", num_peers, filename_valid_peers); for (iter_buf = buf; iter_buf < buf + file_size - 1; iter_buf += 53) { str_repr = GNUNET_strndup (iter_buf, 53); peer = s2i_full (str_repr); GNUNET_free (str_repr); add_valid_peer (peer); LOG (GNUNET_ERROR_TYPE_DEBUG, "Restored valid peer %s from disk\n", GNUNET_i2s_full (peer)); } iter_buf = NULL; GNUNET_free (buf); LOG (GNUNET_ERROR_TYPE_DEBUG, "num_peers: %" PRIu32 ", _size (valid_peers): %u\n", num_peers, GNUNET_CONTAINER_multipeermap_size (valid_peers)); if (num_peers != GNUNET_CONTAINER_multipeermap_size (valid_peers)) { LOG (GNUNET_ERROR_TYPE_WARNING, "Number of restored peers does not match file size. Have probably duplicates.\n"); } GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh)); LOG (GNUNET_ERROR_TYPE_DEBUG, "Restored %u valid peers from disk\n", GNUNET_CONTAINER_multipeermap_size (valid_peers)); }
/** * @brief Iterator function for #store_valid_peers. * * Implements #GNUNET_CONTAINER_PeerMapIterator. * Writes single peer to disk. * * @param cls the file handle to write to. * @param peer current peer * @param value unused * * @return #GNUNET_YES if we should continue to * iterate, * #GNUNET_NO if not. */ static int store_peer_presistently_iterator (void *cls, const struct GNUNET_PeerIdentity *peer, void *value) { const struct GNUNET_DISK_FileHandle *fh = cls; char peer_string[128]; int size; ssize_t ret; if (NULL == peer) { return GNUNET_YES; } size = GNUNET_snprintf (peer_string, sizeof (peer_string), "%s\n", GNUNET_i2s_full (peer)); GNUNET_assert (53 == size); ret = GNUNET_DISK_file_write (fh, peer_string, size); GNUNET_assert (size == ret); return GNUNET_YES; }
/** * Method called to retrieve information about a specific tunnel the mesh peer * has established, o`r is trying to establish. * * @param cls Closure. * @param peer Peer towards whom the tunnel is directed. * @param n_channels Number of channels. * @param n_connections Number of connections. * @param channels Channels. * @param connections Connections. * @param estate Encryption status. * @param cstate Connectivity status. */ void tunnel_callback (void *cls, const struct GNUNET_PeerIdentity *peer, unsigned int n_channels, unsigned int n_connections, uint32_t *channels, struct GNUNET_HashCode *connections, unsigned int estate, unsigned int cstate) { unsigned int i; if (NULL != peer) { FPRINTF (stdout, "Tunnel %s\n", GNUNET_i2s_full (peer)); FPRINTF (stdout, "- %u channels\n", n_channels); for (i = 0; i < n_channels; i++) FPRINTF (stdout, " %u\n", channels[i]); FPRINTF (stdout, "- %u connections\n", n_connections); for (i = 0; i < n_connections; i++) FPRINTF (stdout, " %s\n", GNUNET_h2s_full (&connections[i])); FPRINTF (stdout, "- enc state: %u\n", estate); FPRINTF (stdout, "- con state: %u\n", cstate); } if (GNUNET_YES != monitor_connections) { GNUNET_SCHEDULER_shutdown(); } return; }
int NetworkManager::incomeMsg (const struct GNUNET_PeerIdentity * other, const struct GNUNET_MessageHeader * message) { const char* key = GNUNET_i2s_full (other); QString peerIdStr(key); if(!theApp->models()->networkModel()) return GNUNET_OK; Peer* peer = theApp->models()->networkModel()->getPeer(peerIdStr); if(peer == NULL) return GNUNET_OK; unsigned int size; unsigned int type; size = ntohs(message->size); type = ntohs(message->type); QTime time = QTime::currentTime(); peer->addIncomingTraffic(size); return GNUNET_OK; }
/** * 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) { static uint64_t num_peers; rps_handle = GNUNET_RPS_connect (cfg); if (NULL == peer_id) { /* Request n PeerIDs */ /* If number was specified use it, else request single peer. */ num_peers = (NULL == args[0]) ? 1 : atoi (args[0]); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting %u PeerIDs\n", num_peers); req_handle = GNUNET_RPS_request_peers (rps_handle, num_peers, reply_handle, NULL); shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_shutdown, NULL); } else { /* Seed PeerID */ GNUNET_RPS_seed_ids (rps_handle, 1, peer_id); FPRINTF (stdout, "Seeded PeerID %s\n", GNUNET_i2s_full (peer_id)); ret = 0; GNUNET_SCHEDULER_add_now (do_shutdown, NULL); } }
/** * Method called to inform about the egos of this peer. * * When used with #GNUNET_IDENTITY_connect, this function is * initially called for all egos and then again whenever a * ego's name changes or if it is deleted. At the end of * the initial pass over all egos, the function is once called * with 'NULL' for @a ego. That does NOT mean that the callback won't * be invoked in the future or that there was an error. * * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get, * this function is only called ONCE, and 'NULL' being passed in * @a ego does indicate an error (i.e. name is taken or no default * value is known). If @a ego is non-NULL and if '*ctx' * is set in those callbacks, the value WILL be passed to a subsequent * call to the identity callback of #GNUNET_IDENTITY_connect (if * that one was not NULL). * * When an identity is renamed, this function is called with the * (known) @a ego but the NEW @a name. * * When an identity is deleted, this function is called with the * (known) ego and "NULL" for the @a name. In this case, * the @a ego is henceforth invalid (and the @a ctx should also be * cleaned up). * * @param cls closure * @param ego ego handle * @param ctx context for application to store data for this ego * (during the lifetime of this process, initially NULL) * @param name name assigned by the user for this ego, * NULL if the user just deleted the ego and it * must thus no longer be used */ static void identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name) { const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key; struct GNUNET_GNSRECORD_Data rd; char *rd_string; char *peername; if (NULL == name) return; if (NULL == ego) { if (NULL == qe) { fprintf (stderr, "Failed to find master-zone ego\n"); GNUNET_SCHEDULER_shutdown (); return; } GNUNET_IDENTITY_disconnect (identity); identity = NULL; return; } GNUNET_assert (NULL != name); if (0 != strcmp (name, "master-zone")) { fprintf (stderr, "Unexpected name %s\n", name); return; } zone_key = GNUNET_IDENTITY_ego_get_private_key (ego); rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; peername = GNUNET_strdup (GNUNET_i2s_full (&id)); GNUNET_asprintf (&rd_string, "6 %s %s", peername, "www"); GNUNET_free (peername); GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_string_to_value (GNUNET_GNSRECORD_TYPE_VPN, rd_string, (void**) &rd.data, &rd.data_size)); rd.record_type = GNUNET_GNSRECORD_TYPE_VPN; qe = GNUNET_NAMESTORE_records_store (namestore, zone_key, "www", 1, &rd, &commence_testing, NULL); GNUNET_free ((void**)rd.data); GNUNET_free (rd_string); }
/** * Function called for peers that we know about. * * @param peer id of the peer, NULL for last call * @param hello hello message for the peer (can be NULL) * @param err_msg NULL if successful, otherwise contains error message */ void NetworkManager::peerinfoProcessor(const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg) { if(peer == NULL) { qWarning() << QString("Got a NULL peer in peerinfoProcessor. %1").arg(err_msg ? err_msg : ""); return; } const char* key = GNUNET_i2s_full (peer); QString peerIdStr(key); if(!theApp->models()->networkModel()) { qWarning() << tr("Got a info about a peer while the network model was not created"); return; } //If is myself, update my Hello string to display to the user. if(theApp->gnunet()->myPublicKeyStr() == peerIdStr) { if(!hello) { qWarning() << tr("Got a info about myself without a hello"); return; } //Save my hello URL char *uri = GNUNET_HELLO_compose_uri(hello, &m_gnunetTransportPlugins->GPI_plugins_find); setMyHelloStr(QString(uri)); return; } Peer* newPeer = NULL; //See if peer already exists.If not, create a new one. if(!theApp->models()->networkModel()->contains(peerIdStr)) { newPeer = theApp->models()->networkModel()->addNewPeer(peer, peerIdStr); } else { newPeer =theApp->models()->networkModel()->getPeer(peerIdStr); } Q_ASSERT(newPeer); if(hello){ GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &peerAddressCallback, newPeer); } }
/** * Handler for client's SHOW_TUNNEL request. * * @param cls Identification of the client. * @param msg The actual message. */ static void handle_show_tunnel (void *cls, const struct GNUNET_CADET_LocalInfo *msg) { struct CadetClient *c = cls; struct GNUNET_MQ_Envelope *env; struct GNUNET_CADET_LocalInfoTunnel *resp; struct CadetTunnel *t; struct CadetPeer *p; unsigned int ch_n; unsigned int c_n; p = GCP_get (&msg->peer, GNUNET_NO); t = GCP_get_tunnel (p, GNUNET_NO); if (NULL == t) { /* We don't know the tunnel */ struct GNUNET_MQ_Envelope *env; struct GNUNET_CADET_LocalInfoTunnel *warn; LOG (GNUNET_ERROR_TYPE_INFO, "Tunnel to %s unknown\n", GNUNET_i2s_full (&msg->peer)); env = GNUNET_MQ_msg (warn, GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL); warn->destination = msg->peer; GNUNET_MQ_send (c->mq, env); GNUNET_SERVICE_client_continue (c->client); return; } /* Initialize context */ ch_n = GCT_count_channels (t); c_n = GCT_count_any_connections (t); env = GNUNET_MQ_msg_extra (resp, c_n * sizeof (struct GNUNET_CADET_ConnectionTunnelIdentifier) + ch_n * sizeof (struct GCT_ChannelTunnelNumber), GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL); resp->destination = msg->peer; /* Do not reorder! #iter_channel needs counters in HBO! */ GCT_iterate_connections (t, &iter_connection, resp); GCT_iterate_channels (t, &iter_channel, resp); resp->connections = htonl (resp->connections); resp->channels = htonl (resp->channels); resp->cstate = htons (GCT_get_cstate (t)); resp->estate = htons (GCT_get_estate (t)); GNUNET_MQ_send (c->mq, env); GNUNET_SERVICE_client_continue (c->client); }
/** * Get the filename under which we would store the GNUNET_HELLO_Message * for the given host and protocol. * * @param id peer for which we need the filename for the HELLO * @return filename of the form DIRECTORY/HOSTID */ static char * get_host_filename (const struct GNUNET_PeerIdentity *id) { char *fn; if (NULL == networkIdDirectory) return NULL; GNUNET_asprintf (&fn, "%s%s%s", networkIdDirectory, DIR_SEPARATOR_STR, GNUNET_i2s_full (id)); return fn; }
static int check_blacklist_config (char *cfg_file, struct GNUNET_PeerIdentity *peer, struct GNUNET_PeerIdentity *bl_peer) { struct GNUNET_CONFIGURATION_Handle *cfg; char *section; char *peer_str; cfg = GNUNET_CONFIGURATION_create (); if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cfg_file)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Could not load configuration `%s'\n", cfg_file); GNUNET_CONFIGURATION_destroy (cfg); return GNUNET_SYSERR; } peer_str = GNUNET_strdup (GNUNET_i2s_full(peer)); GNUNET_asprintf (§ion, "transport-blacklist-%s", peer_str); if (GNUNET_NO == GNUNET_CONFIGURATION_have_value (cfg, section, GNUNET_i2s_full(bl_peer))) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Configuration `%s' does not have blacklisting section for peer `%s' blacklisting `%s'\n", cfg_file, peer_str, GNUNET_i2s_full(bl_peer)); GNUNET_CONFIGURATION_destroy (cfg); GNUNET_free (section); GNUNET_free (peer_str); return GNUNET_SYSERR; } GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Configuration `%s' does have blacklisting section for peer `%s' blacklisting `%s'\n", cfg_file, peer_str, GNUNET_i2s_full(bl_peer)); GNUNET_CONFIGURATION_destroy (cfg); GNUNET_free (section); GNUNET_free (peer_str); return GNUNET_OK; }
/** * Method called to retrieve information about all peers in MESH, called * once per peer. * * After last peer has been reported, an additional call with NULL is done. * * @param cls Closure. * @param peer Peer, or NULL on "EOF". * @param tunnel Do we have a tunnel towards this peer? * @param n_paths Number of known paths towards this peer. * @param best_path How long is the best path? * (0 = unknown, 1 = ourselves, 2 = neighbor) */ static void peers_callback (void *cls, const struct GNUNET_PeerIdentity *peer, int tunnel, unsigned int n_paths, unsigned int best_path) { if (NULL == peer) { if (GNUNET_YES != monitor_connections) { GNUNET_SCHEDULER_shutdown(); } return; } FPRINTF (stdout, "%s tunnel: %c, paths: %u\n", GNUNET_i2s_full (peer), tunnel ? 'Y' : 'N', n_paths); }
/** * Function called to notify transport users that another * peer connected to us. * * @param cls closure * @param peer the peer that connected */ static void notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) { if (0 != memcmp (&pid, peer, sizeof(struct GNUNET_PeerIdentity))) return; ret = 0; if (try_connect) { /* all done, terminate instantly */ FPRINTF (stdout, _("Successfully connected to `%s'\n"), GNUNET_i2s_full (peer)); ret = 0; if (GNUNET_SCHEDULER_NO_TASK != op_timeout) { GNUNET_SCHEDULER_cancel (op_timeout); op_timeout = GNUNET_SCHEDULER_NO_TASK; } if (GNUNET_SCHEDULER_NO_TASK != end) GNUNET_SCHEDULER_cancel (end); end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL ); return; } if (benchmark_send) { if (GNUNET_SCHEDULER_NO_TASK != op_timeout) { GNUNET_SCHEDULER_cancel (op_timeout); op_timeout = GNUNET_SCHEDULER_NO_TASK; } if (verbosity > 0) FPRINTF (stdout, _("Successfully connected to `%s', starting to send benchmark data in %u Kb blocks\n"), GNUNET_i2s (&pid), BLOCKSIZE); start_time = GNUNET_TIME_absolute_get (); if (NULL == th) th = GNUNET_TRANSPORT_notify_transmit_ready (handle, peer, BLOCKSIZE * 1024, GNUNET_TIME_UNIT_FOREVER_REL, &transmit_data, NULL); else GNUNET_break(0); return; } }
/** * A fuction to update every sampler in the given list * * @param sampler the sampler to update. * @param id the PeerID that is put in the sampler */ void RPS_sampler_update (struct RPS_Sampler *sampler, const struct GNUNET_PeerIdentity *id) { uint32_t i; to_file (sampler->file_name, "Got %s", GNUNET_i2s_full (id)); for (i = 0 ; i < sampler->sampler_size ; i++) { RPS_sampler_elem_next (sampler->sampler_elements[i], id); } }
/** * Callback called on receipt of reply. * Prints replied PeerIDs. * * @param cls closure * @param n number of peers * @param recv_peers the received peers */ static void reply_handle (void *cls, uint64_t n, const struct GNUNET_PeerIdentity *recv_peers) { uint64_t i; req_handle = NULL; for (i = 0; i < n; i++) { FPRINTF (stdout, "%s\n", GNUNET_i2s_full (&recv_peers[i])); } ret = 0; GNUNET_SCHEDULER_cancel (shutdown_task); GNUNET_SCHEDULER_add_now (do_shutdown, NULL); }
/** * Method called whenever a given peer has a QoS status change. * * @param address the address * @param bandwidth_in available amount of inbound bandwidth * @param bandwidth_out available amount of outbound bandwidth * @param ats performance data for the address (as far as known) * @param ats_count number of performance records in 'ats' */ void NetworkManager::peerATSstatusChange (const struct GNUNET_HELLO_Address *address, int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, const struct GNUNET_ATS_Information *ats, uint32_t ats_count) { const char* key = GNUNET_i2s_full (&address->peer); QString peerId(key); if(!theApp->models()->networkModel()){ qWarning() << "Recivied a peerATSstatus without network Model"; return; } Peer *peer = theApp->models()->networkModel()->getPeer(peerId); if (NULL == peer) { qWarning() << "Recivied a peerATSstatus, but the peer do not exist : " << peerId; return; } //TODO:: See what ATS can give to us GNUNET_ATS_Information * atsinfo = new GNUNET_ATS_Information[ats_count]; for(unsigned int i = 0 ; i < ats_count ; i++){ memcpy(&atsinfo[i], &ats[i], sizeof(GNUNET_ATS_Information)); qWarning() << QString("ATS - Type : %1 , Value: %2 ").arg( GNUNET_ATS_print_property_type(ntohl(atsinfo[i].type))).arg(atsinfo[i].value); } delete[] atsinfo; unsigned int bandIn = (unsigned int)ntohl(bandwidth_in.value__); unsigned int bandOut = (unsigned int)ntohl(bandwidth_out.value__); peer->setATSInfo(bandIn,bandOut); }
/** * Method called to retrieve information about all tunnels in MESH. * * @param cls Closure. * @param peer Destination peer. * @param channels Number of channels. * @param connections Number of connections. * @param estate Encryption state. * @param cstate Connectivity state. */ void tunnels_callback (void *cls, const struct GNUNET_PeerIdentity *peer, unsigned int channels, unsigned int connections, uint16_t estate, uint16_t cstate) { if (NULL == peer) { if (GNUNET_YES != monitor_connections) { GNUNET_SCHEDULER_shutdown(); } return; } FPRINTF (stdout, "%s [ENC: %u, CON: %u] CHs: %u, CONNs: %u\n", GNUNET_i2s_full (peer), estate, cstate, channels, connections); }
void NetworkManager::notifyConnect(const struct GNUNET_PeerIdentity *peerIdent) { const char* key = GNUNET_i2s_full (peerIdent); QString peerIdStr(key); if(!theApp->models()->networkModel()) { qWarning() << tr("Tried to add a peer while the network model was not created"); return; } //Do not show my own. if(theApp->gnunet()->myPublicKeyStr() == peerIdStr) { //Call peerinfo iterate to get my own hello, to create my share-link. GNUNET_PEERINFO_iterate (m_peerInfo, false, peerIdent, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), &peerinfoProcessorCallback, this); return; } Peer* peer = theApp->models()->networkModel()->getPeer(peerIdStr); //If peer do not exist, create it. if(peer == NULL) peer = theApp->models()->networkModel()->addNewPeer(peerIdent,peerIdStr); //Just set as connected if the previous status was disconnected if(!peer->isConnected()) setConnectedPeers(++m_connectedPeers); peer->setConnected(true); }
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *mycfg, struct GNUNET_TESTING_Peer *peer) { die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); stats = GNUNET_STATISTICS_create ("ats", mycfg); GNUNET_STATISTICS_watch (stats, "ats", "# addresses", &stat_cb, NULL); /* Connect to ATS scheduling */ sched_ats = GNUNET_ATS_scheduling_init (mycfg, &address_suggest_cb, NULL); if (sched_ats == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS scheduling!\n"); GNUNET_SCHEDULER_add_now (&end_badly, NULL); return; } /* Set up peer */ memset (&p.id, '1', sizeof (p.id)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", GNUNET_i2s_full(&p.id)); /* Prepare ATS Information */ test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE); test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN); test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); test_ats_info[1].value = htonl(1); test_ats_count = 2; /* Adding address without session */ test_session = NULL; create_test_address (&test_addr, "test", test_session, "test", strlen ("test") + 1); test_hello_address.peer = p.id; test_hello_address.transport_name = test_addr.plugin; test_hello_address.address = test_addr.addr; test_hello_address.address_length = test_addr.addr_len; /* Adding address */ GNUNET_ATS_address_add (sched_ats, &test_hello_address, NULL, test_ats_info, test_ats_count); }
static void operation_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct PeerResolutionContext *cur; struct PeerResolutionContext *next; op_timeout = GNUNET_SCHEDULER_NO_TASK; if ((try_connect) || (benchmark_send) || (benchmark_receive)) { FPRINTF (stdout, _("Failed to connect to `%s'\n"), GNUNET_i2s_full (&pid)); if (GNUNET_SCHEDULER_NO_TASK != end) GNUNET_SCHEDULER_cancel (end); end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL ); ret = 1; return; } if (iterate_connections) { next = rc_head; while (NULL != (cur = next)) { next = cur->next; FPRINTF (stdout, _("Failed to resolve address for peer `%s'\n"), GNUNET_i2s (&cur->addrcp->peer)); GNUNET_CONTAINER_DLL_remove(rc_head, rc_tail, cur); GNUNET_TRANSPORT_address_to_string_cancel (cur->asc); GNUNET_free(cur->transport); GNUNET_free(cur->addrcp); GNUNET_free(cur); } FPRINTF (stdout, "%s", _("Failed to list connections, timeout occured\n") ); if (GNUNET_SCHEDULER_NO_TASK != end) GNUNET_SCHEDULER_cancel (end); end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL ); ret = 1; return; } }
/** * Function to call with a binary address * * @param peer identity of the peer * @param address binary address (NULL on disconnect) */ void NetworkManager::gotActiveAddress(const struct GNUNET_PeerIdentity *peerIdent, const struct GNUNET_HELLO_Address *address) { if (address == NULL) { qDebug() << tr("Peer removed because dont have an active address"); notifyDisconnect(peerIdent); return; } //We have an address so is connected notifyConnect(peerIdent); if(!theApp->models()->networkModel()) { qWarning() << tr("Got an active address for a peer while the network model was not created"); return; } const char* key = GNUNET_i2s_full (peerIdent); QString peerIdStr(key); Peer* peer = theApp->models()->networkModel()->getPeer(peerIdStr); if(peer == NULL) { qDebug() << "Received a address to a peer that do not exist"; } QString peerTransportName((char *)address->transport_name); peer->setTransportName(peerTransportName); }
void start_cb(struct PeerContext *p, void *cls) { started++; GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Peer %u (`%s') started\n", p->no, GNUNET_i2s_full (&p->id)); if (started != 2) return; char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); GNUNET_free(sender_c); cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, NULL ); }
/** * Function called to notify transport users that another * peer disconnected from us. * * @param peer the peer that disconnected */ void NetworkManager::notifyDisconnect(const struct GNUNET_PeerIdentity *peerIdent) { //struct GNUNET_CRYPTO_HashAsciiEncoded enc; const char* key = GNUNET_i2s_full (peerIdent); QString peerIdStr(key); if(!theApp->models() || !theApp->models()->networkModel()) { qWarning() << tr("Tried to remove a peer while the network model was not created"); return; } Peer* peer = theApp->models()->networkModel()->getPeer(peerIdStr); if(peer == NULL) return; peer->setConnected(false); setConnectedPeers(--m_connectedPeers); }
/** * Convert the 'value' of a record to a string. * * @param cls closure, unused * @param type type of the record * @param data value in binary encoding * @param data_size number of bytes in @a data * @return NULL on error, otherwise human-readable representation of the value */ static char * gns_value_to_string (void *cls, uint32_t type, const void *data, size_t data_size) { const char *cdata; switch (type) { case GNUNET_GNSRECORD_TYPE_PKEY: if (data_size != sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)) return NULL; return GNUNET_CRYPTO_ecdsa_public_key_to_string (data); case GNUNET_GNSRECORD_TYPE_NICK: return GNUNET_strndup (data, data_size); case GNUNET_GNSRECORD_TYPE_LEHO: return GNUNET_strndup (data, data_size); case GNUNET_GNSRECORD_TYPE_GNS2DNS: { char *ns; char *ip; size_t off; char *nstr; off = 0; ns = GNUNET_DNSPARSER_parse_name (data, data_size, &off); ip = GNUNET_DNSPARSER_parse_name (data, data_size, &off); if ( (NULL == ns) || (NULL == ip) || (off != data_size) ) { GNUNET_break_op (0); GNUNET_free_non_null (ns); GNUNET_free_non_null (ip); return NULL; } GNUNET_asprintf (&nstr, "%s@%s", ns, ip); GNUNET_free_non_null (ns); GNUNET_free_non_null (ip); return nstr; } case GNUNET_GNSRECORD_TYPE_VPN: { const struct GNUNET_TUN_GnsVpnRecord *vpn; char* vpn_str; cdata = data; if ( (data_size <= sizeof (struct GNUNET_TUN_GnsVpnRecord)) || ('\0' != cdata[data_size - 1]) ) return NULL; /* malformed */ vpn = data; GNUNET_asprintf (&vpn_str, "%u %s %s", (unsigned int) ntohs (vpn->proto), (const char*) GNUNET_i2s_full (&vpn->peer), (const char*) &vpn[1]); return vpn_str; } case GNUNET_GNSRECORD_TYPE_BOX: { const struct GNUNET_GNSRECORD_BoxRecord *box; uint32_t rt; char *box_str; char *ival; if (data_size < sizeof (struct GNUNET_GNSRECORD_BoxRecord)) return NULL; /* malformed */ box = data; rt = ntohl (box->record_type); ival = GNUNET_GNSRECORD_value_to_string (rt, &box[1], data_size - sizeof (struct GNUNET_GNSRECORD_BoxRecord)); if (NULL == ival) return NULL; /* malformed */ GNUNET_asprintf (&box_str, "%u %u %u %s", (unsigned int) ntohs (box->protocol), (unsigned int) ntohs (box->service), (unsigned int) rt, ival); GNUNET_free (ival); return box_str; } default: return NULL; } }
/** * Initiate transport service. * * @param cls closure * @param server the initialized server * @param c configuration to use */ static void run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { char *keyfile; struct GNUNET_CRYPTO_EddsaPrivateKey *pk; long long unsigned int max_fd_cfg; int max_fd_rlimit; int max_fd; int friend_only; /* setup globals */ GST_cfg = c; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, "PEER", "PRIVATE_KEY", &keyfile)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Transport service is lacking key configuration settings. Exiting.\n")); GNUNET_SCHEDULER_shutdown (); return; } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (c, "transport", "HELLO_EXPIRATION", &hello_expiration)) { hello_expiration = GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION; } GST_server = server; pk = GNUNET_CRYPTO_eddsa_key_create_from_file (keyfile); GNUNET_free (keyfile); GNUNET_assert (NULL != pk); GST_my_private_key = pk; GST_stats = GNUNET_STATISTICS_create ("transport", GST_cfg); GST_peerinfo = GNUNET_PEERINFO_connect (GST_cfg); GNUNET_CRYPTO_eddsa_key_get_public (GST_my_private_key, &GST_my_identity.public_key); GNUNET_assert(NULL != GST_my_private_key); GNUNET_log(GNUNET_ERROR_TYPE_INFO, "My identity is `%4s'\n", GNUNET_i2s_full (&GST_my_identity)); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); if (NULL == GST_peerinfo) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Could not access PEERINFO service. Exiting.\n")); GNUNET_SCHEDULER_shutdown (); return; } max_fd_rlimit = 0; max_fd_cfg = 0; #if HAVE_GETRLIMIT struct rlimit r_file; if (0 == getrlimit (RLIMIT_NOFILE, &r_file)) { max_fd_rlimit = r_file.rlim_cur; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Maximum number of open files was: %u/%u\n", r_file.rlim_cur, r_file.rlim_max); } max_fd_rlimit = (9 * max_fd_rlimit) / 10; /* Keep 10% for rest of transport */ #endif GNUNET_CONFIGURATION_get_value_number (GST_cfg, "transport", "MAX_FD", &max_fd_cfg); if (max_fd_cfg > max_fd_rlimit) max_fd = max_fd_cfg; else max_fd = max_fd_rlimit; if (max_fd < DEFAULT_MAX_FDS) max_fd = DEFAULT_MAX_FDS; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Limiting number of sockets to %u: validation %u, neighbors: %u\n", max_fd, (max_fd / 3), (max_fd / 3) * 2); friend_only = GNUNET_CONFIGURATION_get_value_yesno (GST_cfg, "topology", "FRIENDS-ONLY"); if (GNUNET_SYSERR == friend_only) friend_only = GNUNET_NO; /* According to topology defaults */ /* start subsystems */ GST_blacklist_start (GST_server, GST_cfg, &GST_my_identity); GST_is = GNUNET_ATS_scanner_init (); GST_ats_connect = GNUNET_ATS_connectivity_init (GST_cfg); GST_ats = GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, NULL); GST_ats_init (); GST_manipulation_init (); GST_plugins_load (&GST_manipulation_recv, &plugin_env_address_change_notification, &plugin_env_session_start, &plugin_env_session_end); GST_hello_start (friend_only, &process_hello_update, NULL); GST_neighbours_start ((max_fd / 3) * 2); GST_clients_start (GST_server); GST_validation_start ((max_fd / 3)); }
/** * Convert the 'value' of a record to a string. * * @param cls closure, unused * @param type type of the record * @param data value in binary encoding * @param data_size number of bytes in @a data * @return NULL on error, otherwise human-readable representation of the value */ static char * gns_value_to_string (void *cls, uint32_t type, const void *data, size_t data_size) { const char *cdata; switch (type) { case GNUNET_GNSRECORD_TYPE_PKEY: if (data_size != sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)) return NULL; return GNUNET_CRYPTO_ecdsa_public_key_to_string (data); case GNUNET_GNSRECORD_TYPE_NICK: return GNUNET_strndup (data, data_size); case GNUNET_GNSRECORD_TYPE_LEHO: return GNUNET_strndup (data, data_size); case GNUNET_GNSRECORD_TYPE_GNS2DNS: { char *ns; char *ip; size_t off; char *nstr; off = 0; ns = GNUNET_DNSPARSER_parse_name (data, data_size, &off); ip = GNUNET_DNSPARSER_parse_name (data, data_size, &off); if ( (NULL == ns) || (NULL == ip) || (off != data_size) ) { GNUNET_break_op (0); GNUNET_free_non_null (ns); GNUNET_free_non_null (ip); return NULL; } GNUNET_asprintf (&nstr, "%s@%s", ns, ip); GNUNET_free_non_null (ns); GNUNET_free_non_null (ip); return nstr; } case GNUNET_GNSRECORD_TYPE_VPN: { struct GNUNET_TUN_GnsVpnRecord vpn; char* vpn_str; cdata = data; if ( (data_size <= sizeof (vpn)) || ('\0' != cdata[data_size - 1]) ) return NULL; /* malformed */ /* need to memcpy for alignment */ memcpy (&vpn, data, sizeof (vpn)); GNUNET_asprintf (&vpn_str, "%u %s %s", (unsigned int) ntohs (vpn.proto), (const char*) GNUNET_i2s_full (&vpn.peer), (const char*) &cdata[sizeof (vpn)]); return vpn_str; } case GNUNET_GNSRECORD_TYPE_BOX: { struct GNUNET_GNSRECORD_BoxRecord box; uint32_t rt; char *box_str; char *ival; cdata = data; if (data_size < sizeof (struct GNUNET_GNSRECORD_BoxRecord)) return NULL; /* malformed */ memcpy (&box, data, sizeof (box)); rt = ntohl (box.record_type); ival = GNUNET_GNSRECORD_value_to_string (rt, &cdata[sizeof (box)], data_size - sizeof (box)); if (NULL == ival) return NULL; /* malformed */ GNUNET_asprintf (&box_str, "%u %u %u %s", (unsigned int) ntohs (box.protocol), (unsigned int) ntohs (box.service), (unsigned int) rt, ival); GNUNET_free (ival); return box_str; } case GNUNET_GNSRECORD_TYPE_REVERSE: { struct GNUNET_GNSRECORD_ReverseRecord rev; char *rev_str; char *pkey_str; if (data_size < sizeof (struct GNUNET_GNSRECORD_ReverseRecord)) return NULL; /* malformed */ memcpy (&rev, data, sizeof (rev)); cdata = data; pkey_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&rev.pkey); GNUNET_asprintf (&rev_str, "%s %s %"SCNu64, &cdata[sizeof (rev)], pkey_str, rev.expiration.abs_value_us); GNUNET_free (pkey_str); return rev_str; } default: return NULL; } }
/** * Start a peer with the given configuration * @param tth the testing handle * @param cfgname configuration file * @param peer_id a unique number to identify the peer * @param rec receive callback * @param nc connect callback * @param nd disconnect callback * @param start_cb start callback * @param cb_cls closure for callback * @return the peer context */ struct PeerContext * GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, const char *cfgname, int peer_id, GNUNET_TRANSPORT_ReceiveCallback rec, GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyDisconnect nd, GNUNET_TRANSPORT_TESTING_start_cb start_cb, void *cb_cls) { char *emsg = NULL; struct GNUNET_PeerIdentity *dummy; GNUNET_assert (NULL != tth); GNUNET_assert (NULL != tth->tl_system); if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO) { GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", "File not found: `%s' \n", cfgname); return NULL; } struct PeerContext *p = GNUNET_new (struct PeerContext); GNUNET_CONTAINER_DLL_insert (tth->p_head, tth->p_tail, p); /* Create configuration and call testing lib to modify it */ p->cfg = GNUNET_CONFIGURATION_create (); GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); if (GNUNET_SYSERR == GNUNET_TESTING_configuration_create (tth->tl_system, p->cfg)) { GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", "Testing library failed to create unique configuration based on `%s'\n", cfgname); GNUNET_free (p); return NULL; } p->no = peer_id; /* Configure peer with configuration */ p->peer = GNUNET_TESTING_peer_configure (tth->tl_system, p->cfg, p->no, NULL, &emsg); if (NULL == p->peer) { GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", "Testing library failed to create unique configuration based on `%s': `%s'\n", cfgname, emsg); GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); GNUNET_free_non_null (emsg); return NULL; } GNUNET_free_non_null (emsg); if (GNUNET_OK != GNUNET_TESTING_peer_start (p->peer)) { GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", "Testing library failed to create unique configuration based on `%s'\n", cfgname); GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); return NULL; } memset(&dummy, '\0', sizeof (dummy)); GNUNET_TESTING_peer_get_identity (p->peer, &p->id); if (0 == memcmp (&dummy, &p->id, sizeof (struct GNUNET_PeerIdentity))) { GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", "Testing library failed to obtain peer identity for peer %u\n", p->no); GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); return NULL; } else { GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", "Peer %u configured with identity `%s'\n", p->no, GNUNET_i2s_full (&p->id)); } p->tth = tth; p->nc = nc; p->nd = nd; p->rec = rec; p->start_cb = start_cb; if (cb_cls != NULL) p->cb_cls = cb_cls; else p->cb_cls = p; p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, ¬ify_receive, ¬ify_connect, ¬ify_disconnect); if (NULL == p->th) { GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", "Failed to connect to transport service for peer `%s': `%s'\n", cfgname, emsg); GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); return NULL; } p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p); GNUNET_assert (p->ghh != NULL); return p; }
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer) { char *quota_str; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_OUT", "a_str)) { fprintf (stderr, "Cannot load WAN outbound quota from configuration, exit!\n"); ret = 1; return; } if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str, &wan_quota_out)) { fprintf (stderr, "Cannot load WAN outbound quota from configuration, exit!\n"); ret = 1; GNUNET_free (quota_str); return; } GNUNET_free (quota_str); quota_str = NULL; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_IN", "a_str)) { fprintf (stderr, "Cannot load WAN inbound quota from configuration, exit!\n"); ret = 1; return; } if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str, &wan_quota_in)) { fprintf (stderr, "Cannot load WAN inbound quota from configuration, exit!\n"); GNUNET_free (quota_str); ret = 1; return; } GNUNET_free (quota_str); quota_str = NULL; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN inbound quota: %llu\n", wan_quota_in); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN outbound quota: %llu\n", wan_quota_out); die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); /* Connect to ATS scheduling */ sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL); if (sched_ats == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS scheduling!\n"); ret = 1; end (); return; } perf_ats = GNUNET_ATS_performance_init (cfg, NULL, NULL); if (perf_ats == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS performance!\n"); ret = 1; end (); return; } /* Set up peer 0 */ if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p[0].id.hashPubKey)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); ret = GNUNET_SYSERR; end (); return; } GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p[0].id))); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", GNUNET_i2s(&p[0].id)); /* Set up peer 0 */ if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID1, &p[1].id.hashPubKey)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); ret = GNUNET_SYSERR; end (); return; } GNUNET_assert (0 == strcmp (PEERID1, GNUNET_i2s_full (&p[1].id))); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", GNUNET_i2s(&p[1].id)); /* Prepare ATS Information */ test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE); test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN); test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); test_ats_info[1].value = htonl(1); test_ats_count = 2; /* Adding address with session */ test_session[0] = &test_addr[0]; create_test_address (&test_addr[0], "test0", test_session[0], "test0", strlen ("test0") + 1); test_hello_address[0].peer = p[0].id; test_hello_address[0].transport_name = test_addr[0].plugin; test_hello_address[0].address = test_addr[0].addr; test_hello_address[0].address_length = test_addr[0].addr_len; GNUNET_ATS_address_add (sched_ats, &test_hello_address[0], test_session[0], test_ats_info, test_ats_count); /* Adding address with session */ test_session[1] = &test_addr[1]; create_test_address (&test_addr[1], "test1", test_session[1], "test1", strlen ("test1") + 1); test_hello_address[1].peer = p[1].id; test_hello_address[1].transport_name = test_addr[0].plugin; test_hello_address[1].address = test_addr[0].addr; test_hello_address[1].address_length = test_addr[0].addr_len; GNUNET_ATS_address_add (sched_ats, &test_hello_address[1], test_session[1], test_ats_info, test_ats_count); /* Change bandwidth preference */ GNUNET_ATS_change_preference (perf_ats, &p[0].id, GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END); GNUNET_ATS_change_preference (perf_ats, &p[1].id, GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END); /* Change latency preference */ GNUNET_ATS_change_preference (perf_ats, &p[0].id, GNUNET_ATS_PREFERENCE_LATENCY,(double) 10, GNUNET_ATS_PREFERENCE_END); GNUNET_ATS_change_preference (perf_ats, &p[1].id, GNUNET_ATS_PREFERENCE_LATENCY,(double) 100, GNUNET_ATS_PREFERENCE_END); GNUNET_SCHEDULER_add_delayed (SLEEP, &sleep_task, NULL); }