43#define IDLE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2)
157 sc->timeout_task = NULL;
161 "Timeout for inactive cadet client %p\n",
175 if (NULL !=
sc->timeout_task)
199 "Write pending, waiting for it to complete\n");
204 "Finished processing cadet request from client %p, ready to receive the next one\n",
253 "Have no answer and the query was NULL\n");
258 "Have no answer for query `%s'\n",
263 "# queries received via CADET not answered"),
272 "Performing on-demand encoding for query %s\n",
288 "On-demand encoding request failed\n");
301 "Starting transmission of %u byte reply of type %d for query `%s' via cadet to %p\n",
340 "Received query for `%s' via cadet from client %p\n",
360 "Queueing request with datastore failed (queue full?)\n");
387 "# cadet client connections rejected"),
405 "Accepting inbound cadet connection from `%s' as client %p\n",
430 "Terminating cadet connection with client %p\n",
435 if (NULL !=
sc->terminate_task)
437 if (NULL !=
sc->timeout_task)
441 while (NULL != (wqi =
sc->wqi_head))
501 "Initializing cadet FS server with a limit of %llu connections\n",
struct GNUNET_MQ_MessageHandlers handlers[]
struct GNUNET_MQ_Handle * mq
struct GNUNET_MQ_Envelope * env
#define gettext_noop(String)
static uint16_t port
Port number.
static unsigned int replication
Desired replication level.
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_TIME_Relative expiration
User supplied expiration value.
static unsigned int anonymity
static uint32_t type
Type string converted to DNS type value.
static struct GNUNET_FS_SearchContext * sc
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
const struct GNUNET_CONFIGURATION_Handle * GSF_cfg
Our configuration.
struct GNUNET_DATASTORE_Handle * GSF_dsh
Our connection to the datastore.
unsigned int GSF_datastore_queue_size
Size of the datastore queue we assume for common requests.
shared data structures of gnunet-service-fs.c
non-anonymous file-transfer
struct GNUNET_CONTAINER_MultiPeerMap * cadet_map
Map from peer identities to 'struct CadetHandles' with cadet channels to those peers.
int GSF_cadet_release_clients(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Function called on each active cadets to shut them down.
static void disconnect_cb(void *cls, const struct GNUNET_CADET_Channel *channel)
Function called by cadet when a client disconnects.
static void window_change_cb(void *cls, const struct GNUNET_CADET_Channel *channel, int window_size)
Function called whenever an MQ-channel's transmission window size changes.
static unsigned int sc_count
Number of active cadet clients in the 'sc_*'-DLL.
static void refresh_timeout_task(struct CadetClient *sc)
Reset the timeout for the cadet client (due to activity).
static void handle_datastore_reply(void *cls, const struct GNUNET_HashCode *key, size_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid)
Process a datum that was stored in the datastore.
static struct CadetClient * sc_tail
Tail of DLL of cadet clients.
void GSF_cadet_start_server()
Initialize subsystem for non-anonymous file-sharing.
static unsigned long long sc_count_max
Maximum allowed number of cadet clients.
void GSF_cadet_stop_server()
Shutdown subsystem for non-anonymous file-sharing.
static void handle_request(void *cls, const struct CadetQueryMessage *sqm)
Functions with this signature are called whenever a complete query message is received.
static void timeout_cadet_task(void *cls)
Task run to asynchronously terminate the cadet due to timeout.
#define IDLE_TIMEOUT
After how long do we terminate idle connections?
static void * connect_cb(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *initiator)
Functions of this type are called upon new cadet connection from other peers.
static void continue_writing(void *cls)
Check if we are done with the write queue, and if so tell CADET that we are ready to read more.
static struct GNUNET_CADET_Port * cadet_port
Listen port for incoming requests.
static struct CadetClient * sc_head
Head of DLL of cadet clients.
int GNUNET_FS_handle_on_demand_block(const struct GNUNET_HashCode *key, uint32_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid, GNUNET_DATASTORE_DatumProcessor cont, void *cont_cls)
We've received an on-demand encoded block from the datastore.
indexing for the file-sharing service
struct GNUNET_CADET_Handle * cadet_handle
Handler to CADET.
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Constants for network applications operating on top of the CADET service.
CADET service; establish channels to distant peers.
GNUNET_BLOCK_Type
WARNING: This header is generated! In order to add DHT block types, you must register them in GANA,...
@ GNUNET_BLOCK_TYPE_FS_ONDEMAND
Type of a block representing a block to be encoded on demand from disk.
@ GNUNET_BLOCK_TYPE_ANY
Identifier for any block.
Constants for network protocols.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
#define GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER
Transfer of blocks for non-anonymmous file-sharing.
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.
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.
void GNUNET_DATASTORE_cancel(struct GNUNET_DATASTORE_QueueEntry *qe)
Cancel a datastore operation.
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_get_key(struct GNUNET_DATASTORE_Handle *h, uint64_t next_uid, bool random, const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_DatumProcessor proc, void *proc_cls)
Get a result for a particular key from the datastore.
#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_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.
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).
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
unsigned int GNUNET_MQ_get_length(struct GNUNET_MQ_Handle *mq)
Obtain the current length of the message queue.
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.
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)
#define GNUNET_MESSAGE_TYPE_FS_CADET_QUERY
P2P request for content (one FS to another via a cadet).
#define GNUNET_MESSAGE_TYPE_FS_CADET_REPLY
P2P answer for content (one FS to another via a cadet).
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
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_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
static unsigned int size
Size of the "table".
Struct containing information about a client of the service.
struct GNUNET_SCHEDULER_Task * terminate_task
Task that is scheduled to asynchronously terminate the connection.
struct GNUNET_DATASTORE_QueueEntry * qe
Current active request to the datastore, if we have one pending.
size_t reply_size
Size of the last write that was initiated.
struct WriteQueueItem * wqi_tail
Tail of write queue.
struct CadetClient * prev
Linked list prev.
struct GNUNET_CADET_Channel * channel
Channel for communication.
struct WriteQueueItem * wqi_head
Head of write queue.
struct GNUNET_SCHEDULER_Task * timeout_task
Task that is scheduled to terminate idle connections.
struct CadetClient * next
Linked list next.
Query from one peer, asking the other for CHK-data.
struct GNUNET_HashCode query
Query hash from CHK (hash of encrypted block).
uint32_t type
Block type must be DBLOCK or IBLOCK.
Reply to a CadetQueryMessage.
struct GNUNET_TIME_AbsoluteNBO expiration
Expiration time for the block.
uint32_t type
Block type must be DBLOCK or IBLOCK.
Opaque handle to a channel.
Entry in our priority queue.
Handle to a message queue.
enum GNUNET_MQ_PriorityPreferences priority
Flags that were set for this queue by GNUNET_MQ_set_options().
Message handler for a specific message type.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Time for absolute times used by GNUnet, in microseconds.
A message in the queue to be written to the cadet.
struct WriteQueueItem * next
Kept in a DLL.
size_t msize
Number of bytes of payload, allocated at the end of this struct.
struct WriteQueueItem * prev
Kept in a DLL.