GNUnet  0.10.x
Data Structures | Macros | Functions | Variables
gnunet-service-fs_cadet_client.c File Reference

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"
Include dependency graph for gnunet-service-fs_cadet_client.c:

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 CadetHandleget_cadet (const struct GNUNET_PeerIdentity *target)
 Get (or create) a cadet to talk to the given peer. More...
 
struct GSF_CadetRequestGSF_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 calld. 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_Handlecadet_handle
 Cadet channel for creating outbound channels. More...
 
struct GNUNET_CONTAINER_MultiPeerMapcadet_map
 Map from peer identities to 'struct CadetHandles' with cadet channels to those peers. More...
 

Detailed Description

non-anonymous file-transfer

Author
Christian Grothoff

TODO:

Definition in file gnunet-service-fs_cadet_client.c.

Macro Definition Documentation

◆ CLIENT_RETRY_TIMEOUT

#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 44 of file gnunet-service-fs_cadet_client.c.

Referenced by get_cadet().

Function Documentation

◆ transmit_pending()

static void transmit_pending ( void *  cls)
static

Transmit pending requests via the cadet.

Parameters
clsstruct CadetHandle to process

Definition at line 549 of file gnunet-service-fs_cadet_client.c.

References CadetHandle::channel, 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_get_length(), GNUNET_MQ_msg, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_OK, GNUNET_YES, GSF_CadetRequest::mh, mq, CadetHandle::pending_head, CadetHandle::pending_tail, GSF_CadetRequest::query, CadetQueryMessage::query, CadetHandle::target, GSF_CadetRequest::type, CadetQueryMessage::type, CadetHandle::waiting_map, and GSF_CadetRequest::was_transmitted.

Referenced by GSF_cadet_query(), reset_cadet(), and window_change_cb().

550 {
551  struct CadetHandle *mh = cls;
553  struct GSF_CadetRequest *sr;
554  struct GNUNET_MQ_Envelope *env;
555  struct CadetQueryMessage *sqm;
556 
557  if ( (0 != GNUNET_MQ_get_length (mq)) ||
558  (NULL == (sr = mh->pending_head)) )
559  return;
561  mh->pending_tail,
562  sr);
565  &sr->query,
566  sr,
570  "Sending query for %s via cadet to %s\n",
571  GNUNET_h2s (&sr->query),
572  GNUNET_i2s (&mh->target));
573  env = GNUNET_MQ_msg (sqm,
575  sqm->type = htonl (sr->type);
576  sqm->query = sr->query;
579  mh);
580  GNUNET_MQ_send (mq,
581  env);
582 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Query from one peer, asking the other for CHK-data.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
Handle for a cadet to another peer.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
uint32_t type
Block type must be DBLOCK or IBLOCK.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_HashCode query
Query to transmit to the other peer.
struct GNUNET_HashCode query
Query hash from CHK (hash of encrypted block).
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...
Definition: mq.c:774
int was_transmitted
Did we transmit this request already? GNUNET_YES if we are in the 'waiting_map', GNUNET_NO if we are ...
unsigned int GNUNET_MQ_get_length(struct GNUNET_MQ_Handle *mq)
Obtain the current length of the message queue.
Definition: mq.c:335
struct GNUNET_PeerIdentity target
Which peer does this cadet go to?
Handle for a request that is going out via cadet API.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
Allow multiple values with the same key.
Handle to a message queue.
Definition: mq.c:85
struct GNUNET_CADET_Channel * channel
Channel to the other peer.
struct GSF_CadetRequest * pending_head
Head of DLL of pending requests on this cadet.
struct GSF_CadetRequest * pending_tail
Tail of DLL of pending requests on this cadet.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
#define GNUNET_MESSAGE_TYPE_FS_CADET_QUERY
P2P request for content (one FS to another via a cadet).
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:80
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
static void transmit_pending(void *cls)
Transmit pending requests via the cadet.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_CONTAINER_MultiHashMap * waiting_map
Map from query to struct GSF_CadetRequests waiting for a reply.
enum GNUNET_BLOCK_Type type
Desired type for the reply.
struct GNUNET_MQ_Handle * GNUNET_CADET_get_mq(const struct GNUNET_CADET_Channel *channel)
Obtain the message queue for a connected peer.
Definition: cadet_api.c:1142
Here is the call graph for this function:
Here is the caller graph for this function:

◆ move_to_pending()

static int move_to_pending ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Iterator called on each entry in a waiting map to move it back to the pending list.

Parameters
clsthe struct CadetHandle
keythe key of the entry in the map (the query)
valuethe struct GSF_CadetRequest to move to pending
Returns
GNUNET_YES (continue to iterate)

Definition at line 184 of file gnunet-service-fs_cadet_client.c.

References GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_NO, GNUNET_YES, GSF_CadetRequest::mh, CadetHandle::pending_head, CadetHandle::pending_tail, value, CadetHandle::waiting_map, and GSF_CadetRequest::was_transmitted.

Referenced by reset_cadet().

187 {
188  struct CadetHandle *mh = cls;
189  struct GSF_CadetRequest *sr = value;
190 
193  key,
194  value));
196  mh->pending_tail,
197  sr);
199  return GNUNET_YES;
200 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
Handle for a cadet to another peer.
#define GNUNET_NO
Definition: gnunet_common.h:81
static char * value
Value of the record to add/remove.
int was_transmitted
Did we transmit this request already? GNUNET_YES if we are in the 'waiting_map', GNUNET_NO if we are ...
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
Handle for a request that is going out via cadet API.
struct GSF_CadetRequest * pending_head
Head of DLL of pending requests on this cadet.
struct GSF_CadetRequest * pending_tail
Tail of DLL of pending requests on this cadet.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_CONTAINER_MultiHashMap * waiting_map
Map from query to struct GSF_CadetRequests waiting for a reply.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_reply()

static int check_reply ( void *  cls,
const struct CadetReplyMessage srm 
)
static

Functions with this signature are called whenever a complete reply is received.

Parameters
clsclosure with the struct CadetHandle
srmthe actual message
Returns
GNUNET_OK on success, GNUNET_SYSERR to stop further processing

Definition at line 212 of file gnunet-service-fs_cadet_client.c.

References GNUNET_OK, and reset_cadet_task().

214 {
215  /* We check later... */
216  return GNUNET_OK;
217 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
Here is the call graph for this function:

◆ reset_cadet_task()

static void reset_cadet_task ( void *  cls)
static

Task called when it is time to reset an cadet.

Parameters
clsthe struct CadetHandle to tear down

Definition at line 534 of file gnunet-service-fs_cadet_client.c.

References GSF_CadetRequest::mh, reset_cadet(), and CadetHandle::reset_task.

Referenced by check_reply(), get_cadet(), and reset_cadet_async().

535 {
536  struct CadetHandle *mh = cls;
537 
538  mh->reset_task = NULL;
539  reset_cadet (mh);
540 }
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
Handle for a cadet to another peer.
struct GNUNET_SCHEDULER_Task * reset_task
Task to reset cadets that had errors (asynchronously, as we may not be able to do it immediately duri...
static void reset_cadet(struct CadetHandle *mh)
We had a serious error, tear down and re-create cadet from scratch.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_cadet_async()

static void reset_cadet_async ( struct CadetHandle mh)
static

We had a serious error, tear down and re-create cadet from scratch, but do so asynchronously.

Parameters
mhcadet to reset

Definition at line 236 of file gnunet-service-fs_cadet_client.c.

References GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), reset_cadet_task(), and CadetHandle::reset_task.

Referenced by handle_reply().

237 {
238  if (NULL != mh->reset_task)
241  mh);
242 }
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
static void reset_cadet_task(void *cls)
Task called when it is time to reset an cadet.
struct GNUNET_SCHEDULER_Task * reset_task
Task to reset cadets that had errors (asynchronously, as we may not be able to do it immediately duri...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_reply()

static int process_reply ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Iterator called on each entry in a waiting map to process a result.

Parameters
clsthe struct HandleReplyClosure
keythe key of the entry in the map (the query)
valuethe struct GSF_CadetRequest to handle result for
Returns
GNUNET_YES (continue to iterate)

Definition at line 288 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().

291 {
292  struct HandleReplyClosure *hrc = cls;
293  struct GSF_CadetRequest *sr = value;
294 
295  sr->proc (sr->proc_cls,
296  hrc->type,
297  hrc->expiration,
298  hrc->data_size,
299  hrc->data);
300  sr->proc = NULL;
302  hrc->found = GNUNET_YES;
303  return GNUNET_YES;
304 }
struct GNUNET_TIME_Absolute expiration
Expiration time for the block.
int found
Did we have a matching query?
const void * data
Reply payload.
static char * value
Value of the record to add/remove.
void * proc_cls
Closure for proc.
Closure for handle_reply().
Handle for a request that is going out via cadet API.
GSF_CadetReplyProcessor proc
Function to call with the result.
#define GNUNET_YES
Definition: gnunet_common.h:80
enum GNUNET_BLOCK_Type type
Type of the block.
size_t data_size
Number of bytes in data.
void GSF_cadet_query_cancel(struct GSF_CadetRequest *sr)
Cancel an active request; must not be called after 'proc' was calld.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_waiting_entry()

static int free_waiting_entry ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Iterator called on each entry in a waiting map to call the 'proc' continuation and release associated resources.

Parameters
clsthe struct CadetHandle
keythe key of the entry in the map (the query)
valuethe struct GSF_CadetRequest to clean up
Returns
GNUNET_YES (continue to iterate)

Definition at line 318 of file gnunet-service-fs_cadet_client.c.

References GNUNET_YES, GSF_cadet_query_cancel(), and value.

Referenced by disconnect_cb().

321 {
322  struct GSF_CadetRequest *sr = value;
323 
325  return GNUNET_YES;
326 }
static char * value
Value of the record to add/remove.
Handle for a request that is going out via cadet API.
#define GNUNET_YES
Definition: gnunet_common.h:80
void GSF_cadet_query_cancel(struct GSF_CadetRequest *sr)
Cancel an active request; must not be called after 'proc' was calld.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_reply()

static void handle_reply ( void *  cls,
const struct CadetReplyMessage srm 
)
static

Functions with this signature are called whenever a complete reply is received.

Parameters
clsclosure with the struct CadetHandle
srmthe actual message

Definition at line 337 of file gnunet-service-fs_cadet_client.c.

References CadetHandle::channel, 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, GSF_CadetRequest::mh, process_reply(), reset_cadet_async(), GNUNET_MessageHeader::size, CadetHandle::target, GSF_CadetRequest::type, CadetReplyMessage::type, HandleReplyClosure::type, and CadetHandle::waiting_map.

339 {
340  struct CadetHandle *mh = cls;
341  struct HandleReplyClosure hrc;
342  uint16_t msize;
343  enum GNUNET_BLOCK_Type type;
344  struct GNUNET_HashCode query;
345 
346  msize = ntohs (srm->header.size) - sizeof (struct CadetReplyMessage);
347  type = (enum GNUNET_BLOCK_Type) ntohl (srm->type);
348  if (GNUNET_YES !=
350  type,
351  &srm[1],
352  msize,
353  &query))
354  {
355  GNUNET_break_op (0);
357  "Received bogus reply of type %u with %u bytes via cadet from peer %s\n",
358  type,
359  msize,
360  GNUNET_i2s (&mh->target));
361  reset_cadet_async (mh);
362  return;
363  }
365  "Received reply `%s' via cadet from peer %s\n",
366  GNUNET_h2s (&query),
367  GNUNET_i2s (&mh->target));
370  gettext_noop ("# replies received via cadet"), 1,
371  GNUNET_NO);
372  hrc.data = &srm[1];
373  hrc.data_size = msize;
375  hrc.type = type;
376  hrc.found = GNUNET_NO;
378  &query,
379  &process_reply,
380  &hrc);
381  if (GNUNET_NO == hrc.found)
382  {
384  gettext_noop ("# replies received via cadet dropped"), 1,
385  GNUNET_NO);
386  }
387 }
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:670
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
Handle for a cadet to another peer.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_FS_CADET_REPLY.
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.
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
#define GNUNET_NO
Definition: gnunet_common.h:81
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
int GNUNET_BLOCK_get_key(struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, const void *block, size_t block_size, struct GNUNET_HashCode *key)
Function called to obtain the key for a block.
Definition: block.c:379
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.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_BLOCK_Context * GSF_block_ctx
Our block context.
Closure for handle_reply().
struct GNUNET_PeerIdentity target
Which peer does this cadet go to?
A 512-bit hashcode.
struct GNUNET_TIME_AbsoluteNBO expiration
Expiration time for the block.
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Send an ack on the channel to confirm the processing of a message.
Definition: cadet_api.c:973
struct GNUNET_CADET_Channel * channel
Channel to the other peer.
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_HashMapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
#define GNUNET_log(kind,...)
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_YES
Definition: gnunet_common.h:80
uint32_t type
Block type must be DBLOCK or IBLOCK.
Reply to a CadetQueryMessage.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_CONTAINER_MultiHashMap * waiting_map
Map from query to struct GSF_CadetRequests waiting for a reply.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

◆ disconnect_cb()

static void disconnect_cb ( void *  cls,
const struct GNUNET_CADET_Channel channel 
)
static

Function called by cadet when a client disconnects.

Cleans up our struct CadetClient of that channel.

Parameters
clsour struct CadetClient
channelchannel of the disconnecting client

Definition at line 398 of file gnunet-service-fs_cadet_client.c.

References CadetHandle::channel, 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(), GSF_CadetRequest::mh, CadetHandle::pending_head, CadetHandle::reset_task, CadetHandle::target, CadetHandle::timeout_task, and CadetHandle::waiting_map.

Referenced by get_cadet(), GNUNET_SERVICE_run_(), GNUNET_SERVICE_start(), and reset_cadet().

400 {
401  struct CadetHandle *mh = cls;
402  struct GSF_CadetRequest *sr;
403 
404  if (NULL == mh->channel)
405  return; /* being destroyed elsewhere */
406  GNUNET_assert (channel == mh->channel);
407  mh->channel = NULL;
408  while (NULL != (sr = mh->pending_head))
410  /* first remove `mh` from the `cadet_map`, so that if the
411  callback from `free_waiting_entry()` happens to re-issue
412  the request, we don't immediately have it back in the
413  `waiting_map`. */
416  &mh->target,
417  mh));
420  mh);
421  if (NULL != mh->timeout_task)
423  if (NULL != mh->reset_task)
425  GNUNET_assert (0 ==
428  GNUNET_free (mh);
429 }
struct GNUNET_CONTAINER_MultiPeerMap * cadet_map
Map from peer identities to 'struct CadetHandles' with cadet channels to those peers.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
Handle for a cadet to another peer.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_HashMapIterator it, void *it_cls)
Iterate over all entries in the map.
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_PeerIdentity target
Which peer does this cadet go to?
struct GNUNET_SCHEDULER_Task * timeout_task
Task to kill inactive cadets (we keep them around for a few seconds to give the application a chance ...
struct GNUNET_SCHEDULER_Task * reset_task
Task to reset cadets that had errors (asynchronously, as we may not be able to do it immediately duri...
Handle for a request that is going out via cadet API.
struct GNUNET_CADET_Channel * channel
Channel to the other peer.
struct GSF_CadetRequest * pending_head
Head of DLL of pending requests on this cadet.
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...
struct GNUNET_CONTAINER_MultiHashMap * waiting_map
Map from query to struct GSF_CadetRequests waiting for a reply.
void GSF_cadet_query_cancel(struct GSF_CadetRequest *sr)
Cancel an active request; must not be called after 'proc' was calld.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ window_change_cb()

static void window_change_cb ( void *  cls,
const struct GNUNET_CADET_Channel channel,
int  window_size 
)
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.

Parameters
clsChannel closure.
channelConnection to the other end (henceforth invalid).
window_sizeNew window size. If the is more messages than buffer size this value will be negative..

Definition at line 447 of file gnunet-service-fs_cadet_client.c.

References GSF_CadetRequest::mh, and transmit_pending().

Referenced by get_cadet(), and reset_cadet().

450 {
451  /* FIXME: for flow control, implement? */
452 #if 0
453  /* Something like this instead of the GNUNET_MQ_notify_sent() in
454  transmit_pending() might be good (once the window change CB works...) */
455  if (0 < window_size) /* test needed? */
457 #endif
458 }
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
static void transmit_pending(void *cls)
Transmit pending requests via the cadet.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_cadet()

static void reset_cadet ( struct CadetHandle mh)
static

We had a serious error, tear down and re-create cadet from scratch.

Parameters
mhcadet to reset

Definition at line 467 of file gnunet-service-fs_cadet_client.c.

References CadetHandle::channel, disconnect_cb(), GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER, GNUNET_CADET_channel_create(), GNUNET_CADET_channel_destroy(), GNUNET_CADET_OPTION_RELIABLE, 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, move_to_pending(), CadetHandle::target, transmit_pending(), CadetHandle::waiting_map, and window_change_cb().

Referenced by reset_cadet_task().

468 {
470  "Resetting cadet channel to %s\n",
471  GNUNET_i2s (&mh->target));
472  if (NULL != mh->channel)
473  {
475  mh->channel = NULL;
476  }
479  mh);
480  {
482  GNUNET_MQ_hd_var_size (reply,
484  struct CadetReplyMessage,
485  mh),
487  };
488  struct GNUNET_HashCode port;
489 
492  &port);
494  mh,
495  &mh->target,
496  &port,
499  &disconnect_cb,
500  handlers);
501  }
502  transmit_pending (mh);
503 }
static void window_change_cb(void *cls, const struct GNUNET_CADET_Channel *channel, int window_size)
Function called whenever an MQ-channel&#39;s transmission window size changes.
#define GNUNET_MESSAGE_TYPE_FS_CADET_REPLY
P2P answer for content (one FS to another via a cadet).
static void disconnect_cb(void *cls, const struct GNUNET_CADET_Channel *channel)
Function called by cadet when a client disconnects.
Enable channel reliability, lost messages will be retransmitted.
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.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_HashMapIterator it, void *it_cls)
Iterate over all entries in the map.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
struct GNUNET_PeerIdentity target
Which peer does this cadet go to?
A 512-bit hashcode.
Message handler for a specific message type.
static uint16_t port
Port number.
Definition: gnunet-bcd.c:79
struct GNUNET_CADET_Channel * channel
Channel to the other peer.
#define GNUNET_log(kind,...)
#define GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER
Transfer of blocks for non-anonymmous file-sharing.
static void transmit_pending(void *cls)
Transmit pending requests via the cadet.
struct GNUNET_CADET_Handle * cadet_handle
Cadet channel for creating outbound channels.
Reply to a CadetQueryMessage.
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
Definition: cadet_api.c:911
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_CONTAINER_MultiHashMap * waiting_map
Map from query to struct GSF_CadetRequests waiting for a reply.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
struct GNUNET_CADET_Channel * GNUNET_CADET_channel_create(struct GNUNET_CADET_Handle *h, void *channel_cls, const struct GNUNET_PeerIdentity *destination, const struct GNUNET_HashCode *port, enum GNUNET_CADET_ChannelOption options, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Create a new channel towards a remote peer.
Definition: cadet_api.c:1088
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cadet_timeout()

static void cadet_timeout ( void *  cls)
static

Task called when it is time to destroy an inactive cadet channel.

Parameters
clsthe struct CadetHandle to tear down

Definition at line 512 of file gnunet-service-fs_cadet_client.c.

References CadetHandle::channel, GNUNET_CADET_channel_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GSF_CadetRequest::mh, CadetHandle::target, and CadetHandle::timeout_task.

Referenced by GSF_cadet_query_cancel().

513 {
514  struct CadetHandle *mh = cls;
515  struct GNUNET_CADET_Channel *tun;
516 
518  "Timeout on cadet channel to %s\n",
519  GNUNET_i2s (&mh->target));
520  mh->timeout_task = NULL;
521  tun = mh->channel;
522  mh->channel = NULL;
523  if (NULL != tun)
525 }
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
Handle for a cadet to another peer.
Opaque handle to a channel.
Definition: cadet_api.c:80
struct GNUNET_PeerIdentity target
Which peer does this cadet go to?
struct GNUNET_SCHEDULER_Task * timeout_task
Task to kill inactive cadets (we keep them around for a few seconds to give the application a chance ...
struct GNUNET_CADET_Channel * channel
Channel to the other peer.
#define GNUNET_log(kind,...)
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
Definition: cadet_api.c:911
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_cadet()

static struct CadetHandle* get_cadet ( const struct GNUNET_PeerIdentity target)
static

Get (or create) a cadet to talk to the given peer.

Parameters
targetpeer we want to communicate with

Definition at line 591 of file gnunet-service-fs_cadet_client.c.

References CadetHandle::channel, CLIENT_RETRY_TIMEOUT, disconnect_cb(), GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER, GNUNET_assert, GNUNET_CADET_channel_create(), GNUNET_CADET_OPTION_RELIABLE, 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, GSF_CadetRequest::mh, reset_cadet_task(), CadetHandle::reset_task, CadetHandle::target, CadetHandle::timeout_task, CadetHandle::waiting_map, and window_change_cb().

Referenced by GSF_cadet_query().

592 {
593  struct CadetHandle *mh;
594 
596  target);
597  if (NULL != mh)
598  {
599  if (NULL != mh->timeout_task)
600  {
602  mh->timeout_task = NULL;
603  }
604  return mh;
605  }
607  "Creating cadet channel to %s\n",
608  GNUNET_i2s (target));
609  mh = GNUNET_new (struct CadetHandle);
612  mh);
614  mh->target = *target;
617  &mh->target,
618  mh,
620  {
622  GNUNET_MQ_hd_var_size (reply,
624  struct CadetReplyMessage,
625  mh),
627  };
628  struct GNUNET_HashCode port;
629 
632  &port);
634  mh,
635  &mh->target,
636  &port,
639  &disconnect_cb,
640  handlers);
641  }
642  return mh;
643 }
static void window_change_cb(void *cls, const struct GNUNET_CADET_Channel *channel, int window_size)
Function called whenever an MQ-channel&#39;s transmission window size changes.
#define GNUNET_MESSAGE_TYPE_FS_CADET_REPLY
P2P answer for content (one FS to another via a cadet).
struct GNUNET_CONTAINER_MultiPeerMap * cadet_map
Map from peer identities to &#39;struct CadetHandles&#39; with cadet channels to those peers.
static void disconnect_cb(void *cls, const struct GNUNET_CADET_Channel *channel)
Function called by cadet when a client disconnects.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
Handle for a cadet to another peer.
Enable channel reliability, lost messages will be retransmitted.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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.
Definition: scheduler.c:1246
#define CLIENT_RETRY_TIMEOUT
After how long do we reset connections without replies?
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
static void reset_cadet_task(void *cls)
Task called when it is time to reset an cadet.
struct GNUNET_PeerIdentity target
Which peer does this cadet go to?
A 512-bit hashcode.
Message handler for a specific message type.
struct GNUNET_SCHEDULER_Task * timeout_task
Task to kill inactive cadets (we keep them around for a few seconds to give the application a chance ...
struct GNUNET_SCHEDULER_Task * reset_task
Task to reset cadets that had errors (asynchronously, as we may not be able to do it immediately duri...
There must only be one value per key; storing a value should fail if a value under the same key alrea...
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
static uint16_t port
Port number.
Definition: gnunet-bcd.c:79
struct GNUNET_CADET_Channel * channel
Channel to the other peer.
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
#define GNUNET_log(kind,...)
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
#define GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER
Transfer of blocks for non-anonymmous file-sharing.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_CADET_Handle * cadet_handle
Cadet channel for creating outbound channels.
Reply to a CadetQueryMessage.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_CONTAINER_MultiHashMap * waiting_map
Map from query to struct GSF_CadetRequests waiting for a reply.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
struct GNUNET_CADET_Channel * GNUNET_CADET_channel_create(struct GNUNET_CADET_Handle *h, void *channel_cls, const struct GNUNET_PeerIdentity *destination, const struct GNUNET_HashCode *port, enum GNUNET_CADET_ChannelOption options, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Create a new channel towards a remote peer.
Definition: cadet_api.c:1088
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Parameters
targetpeer that should have the block
queryhash to query for the block
typedesired type for the block
procfunction to call with result
proc_clsclosure for proc
Returns
handle to cancel the operation

Definition at line 657 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, GSF_CadetRequest::mh, CadetHandle::pending_head, CadetHandle::pending_tail, GSF_CadetRequest::proc, GSF_CadetRequest::proc_cls, GSF_CadetRequest::query, transmit_pending(), and GSF_CadetRequest::type.

Referenced by cadet_reply_proc(), and GSF_cadet_lookup_().

662 {
663  struct CadetHandle *mh;
664  struct GSF_CadetRequest *sr;
665 
667  "Preparing to send query for %s via cadet to %s\n",
668  GNUNET_h2s (query),
669  GNUNET_i2s (target));
670  mh = get_cadet (target);
671  sr = GNUNET_new (struct GSF_CadetRequest);
672  sr->mh = mh;
673  sr->proc = proc;
674  sr->proc_cls = proc_cls;
675  sr->type = type;
676  sr->query = *query;
678  mh->pending_tail,
679  sr);
680  transmit_pending (mh);
681  return sr;
682 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
Handle for a cadet to another peer.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_HashCode query
Query to transmit to the other peer.
void * proc_cls
Closure for proc.
Handle for a request that is going out via cadet API.
GSF_CadetReplyProcessor proc
Function to call with the result.
struct GSF_CadetRequest * pending_head
Head of DLL of pending requests on this cadet.
struct GSF_CadetRequest * pending_tail
Tail of DLL of pending requests on this cadet.
#define GNUNET_log(kind,...)
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
static void transmit_pending(void *cls)
Transmit pending requests via the cadet.
struct CadetHandle * mh
Which cadet is this request associated with?
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
enum GNUNET_BLOCK_Type type
Desired type for the reply.
static struct CadetHandle * get_cadet(const struct GNUNET_PeerIdentity *target)
Get (or create) a cadet to talk to the given peer.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_cadet_query_cancel()

void GSF_cadet_query_cancel ( struct GSF_CadetRequest sr)

Cancel an active request; must not be called after 'proc' was calld.

Parameters
srrequest to cancel

Definition at line 692 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, GSF_CadetRequest::mh, p, CadetHandle::pending_head, CadetHandle::pending_tail, GSF_CadetRequest::proc, GSF_CadetRequest::proc_cls, GSF_CadetRequest::query, CadetHandle::target, CadetHandle::timeout_task, CadetHandle::waiting_map, and GSF_CadetRequest::was_transmitted.

Referenced by clean_request(), disconnect_cb(), free_waiting_entry(), GSF_pending_request_cancel_(), and process_reply().

693 {
694  struct CadetHandle *mh = sr->mh;
696 
697  p = sr->proc;
698  sr->proc = NULL;
699  if (NULL != p)
700  {
701  /* signal failure / cancellation to callback */
704  0, NULL);
705  }
707  "Cancelled query for %s via cadet to %s\n",
708  GNUNET_h2s (&sr->query),
709  GNUNET_i2s (&sr->mh->target));
710  if (GNUNET_YES == sr->was_transmitted)
713  &sr->query,
714  sr));
715  else
717  mh->pending_tail,
718  sr);
719  GNUNET_free (sr);
721  (NULL == mh->pending_head) )
723  &cadet_timeout,
724  mh);
725 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
Any type of block, used as a wildcard when searching.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
Handle for a cadet to another peer.
#define GNUNET_TIME_UNIT_SECONDS
One second.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
struct GNUNET_HashCode query
Query to transmit to the other peer.
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.
Definition: scheduler.c:1246
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
int was_transmitted
Did we transmit this request already? GNUNET_YES if we are in the &#39;waiting_map&#39;, GNUNET_NO if we are ...
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
void * proc_cls
Closure for proc.
struct GNUNET_PeerIdentity target
Which peer does this cadet go to?
struct GNUNET_SCHEDULER_Task * timeout_task
Task to kill inactive cadets (we keep them around for a few seconds to give the application a chance ...
GSF_CadetReplyProcessor proc
Function to call with the result.
struct GSF_CadetRequest * pending_head
Head of DLL of pending requests on this cadet.
struct GSF_CadetRequest * pending_tail
Tail of DLL of pending requests on this cadet.
#define GNUNET_log(kind,...)
static void cadet_timeout(void *cls)
Task called when it is time to destroy an inactive cadet channel.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct CadetHandle * mh
Which cadet is this request associated with?
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_CONTAINER_MultiHashMap * waiting_map
Map from query to struct GSF_CadetRequests waiting for a reply.
void(* GSF_CadetReplyProcessor)(void *cls, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute expiration, size_t data_size, const void *data)
Function called with a reply from the cadet.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_cadet_release_clients()

int GSF_cadet_release_clients ( void *  cls,
const struct GNUNET_PeerIdentity key,
void *  value 
)

Function called on each active cadets to shut them down.

Parameters
clsNULL
keytarget peer, unused
valuethe struct CadetHandle to destroy
Returns
GNUNET_YES (continue to iterate)

Definition at line 737 of file gnunet-service-fs_cadet_client.c.

References CadetHandle::channel, GNUNET_CADET_channel_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_SCHEDULER_cancel(), GNUNET_YES, GSF_CadetRequest::mh, CadetHandle::reset_task, CadetHandle::target, and value.

Referenced by GSF_cadet_stop_server().

740 {
741  struct CadetHandle *mh = value;
742 
744  "Timeout on cadet channel to %s\n",
745  GNUNET_i2s (&mh->target));
746  if (NULL != mh->channel)
747  {
748  struct GNUNET_CADET_Channel *channel = mh->channel;
749 
750  mh->channel = NULL;
752  }
753  if (NULL != mh->reset_task)
754  {
756  mh->reset_task = NULL;
757  }
758  return GNUNET_YES;
759 }
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
Handle for a cadet to another peer.
Opaque handle to a channel.
Definition: cadet_api.c:80
static char * value
Value of the record to add/remove.
struct GNUNET_PeerIdentity target
Which peer does this cadet go to?
struct GNUNET_SCHEDULER_Task * reset_task
Task to reset cadets that had errors (asynchronously, as we may not be able to do it immediately duri...
struct GNUNET_CADET_Channel * channel
Channel to the other peer.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:80
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
Definition: cadet_api.c:911
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ cadet_handle

struct GNUNET_CADET_Handle* cadet_handle

Cadet channel for creating outbound channels.

Definition at line 153 of file gnunet-service-fs_cadet_client.c.

◆ cadet_map

struct GNUNET_CONTAINER_MultiPeerMap* cadet_map

Map from peer identities to 'struct CadetHandles' with cadet channels to those peers.

Definition at line 159 of file gnunet-service-fs_cadet_client.c.

Referenced by GSF_cadet_start_server(), and GSF_cadet_stop_server().