/** * Initialize the DHT subsystem. * * @param c Configuration. */ void GCD_init (const struct GNUNET_CONFIGURATION_Handle *c) { LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n"); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (c, "CADET", "DHT_REPLICATION_LEVEL", &dht_replication_level)) { GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING, "CADET", "DHT_REPLICATION_LEVEL", "USING DEFAULT"); dht_replication_level = 3; } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (c, "CADET", "ID_ANNOUNCE_TIME", &id_announce_time)) { GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "CADET", "ID_ANNOUNCE_TIME", "MISSING"); GNUNET_SCHEDULER_shutdown (); return; } dht_handle = GNUNET_DHT_connect (c, 64); if (NULL == dht_handle) { GNUNET_break (0); } announce_delay = GNUNET_TIME_UNIT_SECONDS; announce_id_task = GNUNET_SCHEDULER_add_now (&announce_id, NULL); get_requests = GNUNET_CONTAINER_multihashmap32_create (32); }
/** * Initializes the cache * * @param size the size of the cache */ void GST_cache_init (unsigned int size) { if (0 == size) return; cache_size = size; cache = GNUNET_CONTAINER_multihashmap32_create (cache_size); }
/** * Callback called when a client connects to the service. * * @param cls closure for the service * @param client the new client that connected to the service * @param mq the message queue used to send messages to the client * @return @a c */ static void * client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq) { struct CadetClient *c; c = GNUNET_new (struct CadetClient); c->client = client; c->mq = mq; c->id = next_client_id++; /* overflow not important: just for debug */ c->own_channels = GNUNET_CONTAINER_multihashmap32_create (32); c->incoming_channels = GNUNET_CONTAINER_multihashmap32_create (32); GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, c); GNUNET_STATISTICS_update (stats, "# clients", +1, GNUNET_NO); return c; }
/** * Create a tunnel to @a destionation. Must only be called * from within #GCP_get_tunnel(). * * @param destination where to create the tunnel to * @return new tunnel to @a destination */ struct CadetTunnel * GCT_create_tunnel (struct CadetPeer *destination) { struct CadetTunnel *t; t = GNUNET_new (struct CadetTunnel); t->destination = destination; t->channels = GNUNET_CONTAINER_multihashmap32_create (8); (void) GCP_iterate_paths (destination, &consider_path_cb, t); t->maintain_connections_task = GNUNET_SCHEDULER_add_now (&maintain_connections_cb, t); return t; }
/** * Associate the assoc_data in mq with a unique request id. * * @param mq message queue, id will be unique for the queue * @param assoc_data to associate */ uint32_t GNUNET_MQ_assoc_add (struct GNUNET_MQ_Handle *mq, void *assoc_data) { uint32_t id; if (NULL == mq->assoc_map) { mq->assoc_map = GNUNET_CONTAINER_multihashmap32_create (8); mq->assoc_id = 1; } id = mq->assoc_id++; GNUNET_CONTAINER_multihashmap32_put (mq->assoc_map, id, assoc_data, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); return id; }