non-anonymous file-transfer More...
#include "platform.h"
#include "gnunet_constants.h"
#include "gnunet_util_lib.h"
#include "gnunet_cadet_service.h"
#include "gnunet_protocols.h"
#include "gnunet_applications.h"
#include "gnunet-service-fs.h"
#include "gnunet-service-fs_indexing.h"
#include "gnunet-service-fs_cadet.h"
Go to the source code of this file.
Data Structures | |
struct | WriteQueueItem |
A message in the queue to be written to the cadet. More... | |
struct | CadetClient |
Struct containing information about a client of the service. More... | |
Macros | |
#define | IDLE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2) |
After how long do we terminate idle connections? More... | |
Functions | |
static void | timeout_cadet_task (void *cls) |
Task run to asynchronously terminate the cadet due to timeout. More... | |
static void | refresh_timeout_task (struct CadetClient *sc) |
Reset the timeout for the cadet client (due to activity). More... | |
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. More... | |
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. More... | |
static void | handle_request (void *cls, const struct CadetQueryMessage *sqm) |
Functions with this signature are called whenever a complete query message is received. More... | |
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. More... | |
static void | disconnect_cb (void *cls, const struct GNUNET_CADET_Channel *channel) |
Function called by cadet when a client disconnects. More... | |
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. More... | |
void | GSF_cadet_start_server () |
Initialize subsystem for non-anonymous file-sharing. More... | |
void | GSF_cadet_stop_server () |
Shutdown subsystem for non-anonymous file-sharing. More... | |
Variables | |
static struct GNUNET_CADET_Port * | cadet_port |
Listen port for incoming requests. More... | |
static struct CadetClient * | sc_head |
Head of DLL of cadet clients. More... | |
static struct CadetClient * | sc_tail |
Tail of DLL of cadet clients. More... | |
static unsigned int | sc_count |
Number of active cadet clients in the 'sc_*'-DLL. More... | |
static unsigned long long | sc_count_max |
Maximum allowed number of cadet clients. More... | |
non-anonymous file-transfer
TODO:
Definition in file gnunet-service-fs_cadet_server.c.
#define IDLE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2) |
After how long do we terminate idle connections?
Definition at line 43 of file gnunet-service-fs_cadet_server.c.
|
static |
Task run to asynchronously terminate the cadet due to timeout.
cls | the 'struct CadetClient' |
Definition at line 152 of file gnunet-service-fs_cadet_server.c.
References GNUNET_CADET_channel_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and sc.
Referenced by refresh_timeout_task().
|
static |
Reset the timeout for the cadet client (due to activity).
sc | client handle to reset timeout for |
Definition at line 173 of file gnunet-service-fs_cadet_server.c.
References GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), IDLE_TIMEOUT, sc, and timeout_cadet_task().
Referenced by connect_cb(), continue_writing(), and handle_request().
|
static |
Check if we are done with the write queue, and if so tell CADET that we are ready to read more.
cls | where to process the write queue |
Definition at line 190 of file gnunet-service-fs_cadet_server.c.
References GNUNET_CADET_get_mq(), GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_get_length(), mq, refresh_timeout_task(), and sc.
Referenced by handle_datastore_reply(), and handle_request().
|
static |
Process a datum that was stored in the datastore.
cls | closure with the struct CadetClient which sent the query |
key | key for the content |
size | number of bytes in data |
data | content stored |
type | type of the content |
priority | priority of the content |
anonymity | anonymity-level for the content |
replication | replication-level for the content |
expiration | expiration time for the content |
uid | unique identifier for the datum; maybe 0 if no unique identifier is available |
Definition at line 226 of file gnunet-service-fs_cadet_server.c.
References anonymity, continue_writing(), data, env, expiration, CadetReplyMessage::expiration, gettext_noop, GNUNET_BLOCK_TYPE_ANY, GNUNET_BLOCK_TYPE_FS_ONDEMAND, GNUNET_break, GNUNET_CADET_get_mq(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_FS_handle_on_demand_block(), GNUNET_h2s(), GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_FS_CADET_REPLY, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_hton(), GSF_stats, handle_datastore_reply(), key, replication, sc, size, type, and CadetReplyMessage::type.
Referenced by handle_datastore_reply(), and handle_request().
|
static |
Functions with this signature are called whenever a complete query message is received.
cls | closure with the struct CadetClient |
sqm | the actual message |
Definition at line 334 of file gnunet-service-fs_cadet_server.c.
References continue_writing(), gettext_noop, GNUNET_DATASTORE_get_key(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GSF_datastore_queue_size, GSF_dsh, GSF_stats, handle_datastore_reply(), CadetQueryMessage::query, refresh_timeout_task(), sc, and CadetQueryMessage::type.
|
static |
Functions of this type are called upon new cadet connection from other peers.
cls | the closure from GNUNET_CADET_connect |
channel | the channel representing the cadet |
initiator | the identity of the peer who wants to establish a cadet with us; NULL on binding error |
struct CadetClient
) Definition at line 376 of file gnunet-service-fs_cadet_server.c.
References CadetClient::channel, gettext_noop, GNUNET_assert, GNUNET_CADET_channel_destroy(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), GSF_stats, refresh_timeout_task(), sc, sc_count, sc_count_max, sc_head, and sc_tail.
Referenced by GNUNET_SERVICE_register_(), GNUNET_SERVICE_run_(), GNUNET_SERVICE_start(), and GSF_cadet_start_server().
|
static |
Function called by cadet when a client disconnects.
Cleans up our struct CadetClient
of that channel.
cls | our struct CadetClient |
channel | channel of the disconnecting client |
Definition at line 420 of file gnunet-service-fs_cadet_server.c.
References gettext_noop, GNUNET_CONTAINER_DLL_remove, GNUNET_DATASTORE_cancel(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), GSF_stats, sc, sc_count, sc_head, and sc_tail.
Referenced by GSF_cadet_start_server().
|
static |
Function called whenever an MQ-channel's transmission window size changes.
The first callback in an outgoing channel will be with a non-zero value and will mean the channel is connected to the destination.
For an incoming channel it will be called immediately after the GNUNET_CADET_ConnectEventHandler, also with a non-zero value.
cls | Channel closure. |
channel | Connection to the other end (henceforth invalid). |
window_size | New window size. If the is more messages than buffer size this value will be negative.. |
Definition at line 471 of file gnunet-service-fs_cadet_server.c.
Referenced by GSF_cadet_start_server().
void GSF_cadet_start_server | ( | void | ) |
Initialize subsystem for non-anonymous file-sharing.
Definition at line 483 of file gnunet-service-fs_cadet_server.c.
References cadet_handle, cadet_map, cadet_port, connect_cb(), disconnect_cb(), GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER, GNUNET_assert, GNUNET_CADET_connect(), GNUNET_CADET_open_port(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONTAINER_multipeermap_create(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_FS_CADET_QUERY, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_YES, GSF_cfg, handlers, port, request, sc_count_max, and window_change_cb().
Referenced by main_init().
void GSF_cadet_stop_server | ( | void | ) |
Shutdown subsystem for non-anonymous file-sharing.
Definition at line 523 of file gnunet-service-fs_cadet_server.c.
References cadet_handle, cadet_map, cadet_port, GNUNET_assert, GNUNET_CADET_close_port(), GNUNET_CADET_disconnect(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GSF_cadet_release_clients(), sc_count, and sc_head.
Referenced by shutdown_task().
|
static |
Listen port for incoming requests.
Definition at line 123 of file gnunet-service-fs_cadet_server.c.
Referenced by create_channel_to_destination(), GNUNET_TUN_compute_service_cadet_port(), GSF_cadet_start_server(), GSF_cadet_stop_server(), and store_service().
|
static |
Head of DLL of cadet clients.
Definition at line 128 of file gnunet-service-fs_cadet_server.c.
Referenced by connect_cb(), disconnect_cb(), and GSF_cadet_stop_server().
|
static |
Tail of DLL of cadet clients.
Definition at line 133 of file gnunet-service-fs_cadet_server.c.
Referenced by connect_cb(), and disconnect_cb().
|
static |
Number of active cadet clients in the 'sc_*'-DLL.
Definition at line 138 of file gnunet-service-fs_cadet_server.c.
Referenced by connect_cb(), disconnect_cb(), and GSF_cadet_stop_server().
|
static |
Maximum allowed number of cadet clients.
Definition at line 143 of file gnunet-service-fs_cadet_server.c.
Referenced by connect_cb(), and GSF_cadet_start_server().