non-anonymous file-transfer More...
#include "platform.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_cadet.h"
Go to the source code of this file.
Data Structures | |
struct | GSF_CadetRequest |
Handle for a request that is going out via cadet API. More... | |
struct | CadetHandle |
Handle for a cadet to another peer. More... | |
struct | HandleReplyClosure |
Closure for handle_reply(). More... | |
Macros | |
#define | CLIENT_RETRY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
After how long do we reset connections without replies? More... | |
Functions | |
static void | transmit_pending (void *cls) |
Transmit pending requests via the cadet. More... | |
static int | move_to_pending (void *cls, const struct GNUNET_HashCode *key, void *value) |
Iterator called on each entry in a waiting map to move it back to the pending list. More... | |
static int | check_reply (void *cls, const struct CadetReplyMessage *srm) |
Functions with this signature are called whenever a complete reply is received. More... | |
static void | reset_cadet_task (void *cls) |
Task called when it is time to reset an cadet. More... | |
static void | reset_cadet_async (struct CadetHandle *mh) |
We had a serious error, tear down and re-create cadet from scratch, but do so asynchronously. More... | |
static int | process_reply (void *cls, const struct GNUNET_HashCode *key, void *value) |
Iterator called on each entry in a waiting map to process a result. More... | |
static int | free_waiting_entry (void *cls, const struct GNUNET_HashCode *key, void *value) |
Iterator called on each entry in a waiting map to call the 'proc' continuation and release associated resources. More... | |
static void | handle_reply (void *cls, const struct CadetReplyMessage *srm) |
Functions with this signature are called whenever a complete reply is received. 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... | |
static void | reset_cadet (struct CadetHandle *mh) |
We had a serious error, tear down and re-create cadet from scratch. More... | |
static void | cadet_timeout (void *cls) |
Task called when it is time to destroy an inactive cadet channel. More... | |
static struct CadetHandle * | get_cadet (const struct GNUNET_PeerIdentity *target) |
Get (or create) a cadet to talk to the given peer. More... | |
struct GSF_CadetRequest * | GSF_cadet_query (const struct GNUNET_PeerIdentity *target, const struct GNUNET_HashCode *query, enum GNUNET_BLOCK_Type type, GSF_CadetReplyProcessor proc, void *proc_cls) |
Look for a block by directly contacting a particular peer. More... | |
void | GSF_cadet_query_cancel (struct GSF_CadetRequest *sr) |
Cancel an active request; must not be called after 'proc' was called. More... | |
int | GSF_cadet_release_clients (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Function called on each active cadets to shut them down. More... | |
Variables | |
struct GNUNET_CADET_Handle * | cadet_handle |
Cadet channel for creating outbound channels. More... | |
struct GNUNET_CONTAINER_MultiPeerMap * | cadet_map |
Map from peer identities to 'struct CadetHandles' with cadet channels to those peers. More... | |
non-anonymous file-transfer
TODO:
Definition in file gnunet-service-fs_cadet_client.c.
#define CLIENT_RETRY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
After how long do we reset connections without replies?
Definition at line 42 of file gnunet-service-fs_cadet_client.c.
|
static |
Transmit pending requests via the cadet.
cls | struct CadetHandle to process |
Definition at line 526 of file gnunet-service-fs_cadet_client.c.
References env, GNUNET_assert, GNUNET_CADET_get_mq(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_FS_CADET_QUERY, GNUNET_MQ_env_set_options(), GNUNET_MQ_get_length(), GNUNET_MQ_msg, GNUNET_MQ_notify_sent(), GNUNET_MQ_PREF_CORK_ALLOWED, GNUNET_MQ_PREF_GOODPUT, GNUNET_MQ_PREF_OUT_OF_ORDER, GNUNET_MQ_send(), GNUNET_OK, GNUNET_YES, mh, mq, CadetQueryMessage::query, GSF_CadetRequest::query, transmit_pending(), CadetQueryMessage::type, GSF_CadetRequest::type, and GSF_CadetRequest::was_transmitted.
Referenced by GSF_cadet_query(), reset_cadet(), transmit_pending(), and window_change_cb().
|
static |
Iterator called on each entry in a waiting map to move it back to the pending list.
cls | the struct CadetHandle |
key | the key of the entry in the map (the query) |
value | the struct GSF_CadetRequest to move to pending |
Definition at line 181 of file gnunet-service-fs_cadet_client.c.
References GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_NO, GNUNET_YES, key, mh, value, and GSF_CadetRequest::was_transmitted.
Referenced by reset_cadet().
|
static |
Functions with this signature are called whenever a complete reply is received.
cls | closure with the struct CadetHandle |
srm | the actual message |
Definition at line 204 of file gnunet-service-fs_cadet_client.c.
References GNUNET_OK.
|
static |
Task called when it is time to reset an cadet.
cls | the struct CadetHandle to tear down |
Definition at line 511 of file gnunet-service-fs_cadet_client.c.
References mh, and reset_cadet().
Referenced by get_cadet(), and reset_cadet_async().
|
static |
We had a serious error, tear down and re-create cadet from scratch, but do so asynchronously.
mh | cadet to reset |
Definition at line 227 of file gnunet-service-fs_cadet_client.c.
References GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), mh, and reset_cadet_task().
Referenced by handle_reply().
|
static |
Iterator called on each entry in a waiting map to process a result.
cls | the struct HandleReplyClosure |
key | the key of the entry in the map (the query) |
value | the struct GSF_CadetRequest to handle result for |
Definition at line 277 of file gnunet-service-fs_cadet_client.c.
References HandleReplyClosure::data, HandleReplyClosure::data_size, HandleReplyClosure::expiration, HandleReplyClosure::found, GNUNET_YES, GSF_cadet_query_cancel(), GSF_CadetRequest::proc, GSF_CadetRequest::proc_cls, HandleReplyClosure::type, and value.
Referenced by handle_reply().
|
static |
Iterator called on each entry in a waiting map to call the 'proc' continuation and release associated resources.
cls | the struct CadetHandle |
key | the key of the entry in the map (the query) |
value | the struct GSF_CadetRequest to clean up |
Definition at line 305 of file gnunet-service-fs_cadet_client.c.
References GNUNET_YES, GSF_cadet_query_cancel(), and value.
Referenced by disconnect_cb().
|
static |
Functions with this signature are called whenever a complete reply is received.
cls | closure with the struct CadetHandle |
srm | the actual message |
Definition at line 322 of file gnunet-service-fs_cadet_client.c.
References HandleReplyClosure::data, HandleReplyClosure::data_size, CadetReplyMessage::expiration, HandleReplyClosure::expiration, HandleReplyClosure::found, gettext_noop, GNUNET_BLOCK_get_key(), GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_ntoh(), GNUNET_YES, GSF_block_ctx, GSF_stats, CadetReplyMessage::header, mh, process_reply(), reset_cadet_async(), GNUNET_MessageHeader::size, type, CadetReplyMessage::type, and HandleReplyClosure::type.
|
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 382 of file gnunet-service-fs_cadet_client.c.
References cadet_map, free_waiting_entry(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_free, GNUNET_OK, GNUNET_SCHEDULER_cancel(), GSF_cadet_query_cancel(), and mh.
Referenced by get_cadet(), GNUNET_SERVICE_register_(), GNUNET_SERVICE_run_(), GNUNET_SERVICE_start(), and reset_cadet().
|
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 428 of file gnunet-service-fs_cadet_client.c.
References mh, and transmit_pending().
Referenced by get_cadet(), and reset_cadet().
|
static |
We had a serious error, tear down and re-create cadet from scratch.
mh | cadet to reset |
Definition at line 448 of file gnunet-service-fs_cadet_client.c.
References cadet_handle, disconnect_cb(), GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER, GNUNET_CADET_channel_create(), GNUNET_CADET_channel_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_FS_CADET_REPLY, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, handlers, mh, move_to_pending(), port, transmit_pending(), and window_change_cb().
Referenced by reset_cadet_task().
|
static |
Task called when it is time to destroy an inactive cadet channel.
cls | the struct CadetHandle to tear down |
Definition at line 489 of file gnunet-service-fs_cadet_client.c.
References GNUNET_CADET_channel_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, and mh.
Referenced by GSF_cadet_query_cancel().
|
static |
Get (or create) a cadet to talk to the given peer.
target | peer we want to communicate with |
Definition at line 565 of file gnunet-service-fs_cadet_client.c.
References cadet_handle, cadet_map, CLIENT_RETRY_TIMEOUT, disconnect_cb(), GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER, GNUNET_assert, GNUNET_CADET_channel_create(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_get(), GNUNET_CONTAINER_multipeermap_put(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_FS_CADET_REPLY, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_new, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, handlers, mh, port, reset_cadet_task(), CadetHandle::target, and window_change_cb().
Referenced by GSF_cadet_query().
struct GSF_CadetRequest * GSF_cadet_query | ( | const struct GNUNET_PeerIdentity * | target, |
const struct GNUNET_HashCode * | query, | ||
enum GNUNET_BLOCK_Type | type, | ||
GSF_CadetReplyProcessor | proc, | ||
void * | proc_cls | ||
) |
Look for a block by directly contacting a particular peer.
target | peer that should have the block |
query | hash to query for the block |
type | desired type for the block |
proc | function to call with result |
proc_cls | closure for proc |
Definition at line 628 of file gnunet-service-fs_cadet_client.c.
References get_cadet(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_new, mh, GSF_CadetRequest::mh, GSF_CadetRequest::proc, GSF_CadetRequest::proc_cls, GSF_CadetRequest::query, transmit_pending(), type, and GSF_CadetRequest::type.
Referenced by cadet_reply_proc(), and GSF_cadet_lookup_().
void GSF_cadet_query_cancel | ( | struct GSF_CadetRequest * | sr | ) |
Cancel an active request; must not be called after 'proc' was called.
sr | request to cancel |
Definition at line 661 of file gnunet-service-fs_cadet_client.c.
References cadet_timeout(), GNUNET_assert, GNUNET_BLOCK_TYPE_ANY, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_UNIT_SECONDS, GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_YES, mh, GSF_CadetRequest::mh, p, GSF_CadetRequest::proc, GSF_CadetRequest::proc_cls, GSF_CadetRequest::query, CadetHandle::target, and GSF_CadetRequest::was_transmitted.
Referenced by clean_request(), disconnect_cb(), free_waiting_entry(), GSF_pending_request_cancel_(), and process_reply().
int GSF_cadet_release_clients | ( | void * | cls, |
const struct GNUNET_PeerIdentity * | key, | ||
void * | value | ||
) |
Function called on each active cadets to shut them down.
cls | NULL |
key | target peer, unused |
value | the struct CadetHandle to destroy |
Definition at line 701 of file gnunet-service-fs_cadet_client.c.
References GNUNET_CADET_channel_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_SCHEDULER_cancel(), GNUNET_YES, mh, and value.
Referenced by GSF_cadet_stop_server().
struct GNUNET_CADET_Handle* cadet_handle |
Cadet channel for creating outbound channels.
Cadet channel for creating outbound channels.
Definition at line 150 of file gnunet-service-fs_cadet_client.c.
Referenced by get_cadet(), and reset_cadet().
struct GNUNET_CONTAINER_MultiPeerMap* cadet_map |
Map from peer identities to 'struct CadetHandles' with cadet channels to those peers.
Definition at line 156 of file gnunet-service-fs_cadet_client.c.
Referenced by disconnect_cb(), get_cadet(), GSF_cadet_start_server(), and GSF_cadet_stop_server().