GNUnet  0.11.x
Data Structures | Typedefs | Functions | Variables
gnunet-service-fs_cadet.h File Reference

non-anonymous file-transfer More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  CadetQueryMessage
 Query from one peer, asking the other for CHK-data. More...
struct  CadetReplyMessage
 Reply to a CadetQueryMessage. More...


typedef 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. 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...
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...
void GSF_cadet_query_cancel (struct GSF_CadetRequest *sr)
 Cancel an active request; must not be called after 'proc' was called. More...
void GSF_cadet_start_server (void)
 Initialize subsystem for non-anonymous file-sharing. More...
void GSF_cadet_stop_server (void)
 Shutdown subsystem for non-anonymous file-sharing. More...


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

Christian Grothoff

Definition in file gnunet-service-fs_cadet.h.

Typedef Documentation

◆ GSF_CadetReplyProcessor

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

typetype of the block, ANY on error
expirationexpiration time for the block
data_sizenumber of bytes in data, 0 on error
datareply block data, NULL on error

Definition at line 44 of file gnunet-service-fs_cadet.h.

Function Documentation

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

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
handle to cancel the operation

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

635 {
636  struct CadetHandle *mh;
637  struct GSF_CadetRequest *sr;
640  "Preparing to send query for %s via cadet to %s\n",
641  GNUNET_h2s (query),
642  GNUNET_i2s (target));
643  mh = get_cadet (target);
644  sr = GNUNET_new (struct GSF_CadetRequest);
645  sr->mh = mh;
646  sr->proc = proc;
647  sr->proc_cls = proc_cls;
648  sr->type = type;
649  sr->query = *query;
650  GNUNET_CONTAINER_DLL_insert (mh->pending_head, mh->pending_tail, sr);
652  return sr;
653 }
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.
static struct CadetHandle * get_cadet(const struct GNUNET_PeerIdentity *target)
Get (or create) a cadet to talk to the given peer.
#define GNUNET_log(kind,...)
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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.
Handle for a cadet to another peer.
Handle for a request that is going out via cadet API.
void * proc_cls
Closure for proc.
enum GNUNET_BLOCK_Type type
Desired type for the reply.
struct CadetHandle * mh
Which cadet is this request associated with?
GSF_CadetReplyProcessor proc
Function to call with the result.
struct GNUNET_HashCode query
Query to transmit to the other peer.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model

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(), GSF_CadetRequest::type, and type.

Referenced by cadet_reply_proc(), and GSF_cadet_lookup_().

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.

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

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

706 {
707  struct CadetHandle *mh = value;
710  "Timeout on cadet channel to %s\n",
711  GNUNET_i2s (&mh->target));
712  if (NULL != mh->channel)
713  {
714  struct GNUNET_CADET_Channel *channel = mh->channel;
716  mh->channel = NULL;
718  }
719  if (NULL != mh->reset_task)
720  {
721  GNUNET_SCHEDULER_cancel (mh->reset_task);
722  mh->reset_task = NULL;
723  }
724  return GNUNET_YES;
725 }
static char * value
Value of the record to add/remove.
Definition: gnunet_common.h:97
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
Definition: cadet_api.c:837
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
Opaque handle to a channel.
Definition: cadet.h:117

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().

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

srrequest to cancel

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

664 {
665  struct CadetHandle *mh = sr->mh;
668  p = sr->proc;
669  sr->proc = NULL;
670  if (NULL != p)
671  {
672  /* signal failure / cancellation to callback */
674  }
676  "Cancelled query for %s via cadet to %s\n",
677  GNUNET_h2s (&sr->query),
678  GNUNET_i2s (&sr->mh->target));
679  if (GNUNET_YES == sr->was_transmitted)
680  GNUNET_assert (
681  GNUNET_OK ==
682  GNUNET_CONTAINER_multihashmap_remove (mh->waiting_map, &sr->query, sr));
683  else
684  GNUNET_CONTAINER_DLL_remove (mh->pending_head, mh->pending_tail, sr);
685  GNUNET_free (sr);
686  if ((0 == GNUNET_CONTAINER_multihashmap_size (mh->waiting_map)) &&
687  (NULL == mh->pending_head))
689  &cadet_timeout,
690  mh);
691 }
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
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.
static void cadet_timeout(void *cls)
Task called when it is time to destroy an inactive cadet channel.
Definition: gnunet_common.h:95
Any type of block, used as a wildcard when searching.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
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.
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.
#define GNUNET_free(ptr)
Wrapper around free.
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:1269
One second.
Absolute time zero.
struct GNUNET_PeerIdentity target
Which peer does this cadet go to?
int was_transmitted
Did we transmit this request already? GNUNET_YES if we are in the 'waiting_map', GNUNET_NO if we are ...

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_cadet_start_server()

void GSF_cadet_start_server ( void  )

Initialize subsystem for non-anonymous file-sharing.

Definition at line 484 of file gnunet-service-fs_cadet_server.c.

485 {
489  struct CadetQueryMessage,
490  NULL),
492  };
493  struct GNUNET_HashCode port;
495  if (GNUNET_YES !=
497  "fs",
499  &sc_count_max))
500  return;
502  "Initializing cadet FS server with a limit of %llu connections\n",
503  sc_count_max);
506  GNUNET_assert (NULL != cadet_handle);
509  &port);
511  &port,
512  &connect_cb,
513  NULL,
515  &disconnect_cb,
516  handlers);
517 }
static uint16_t port
Port number.
Definition: gnunet-bcd.c:83
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static struct GNUNET_CADET_Handle * cadet_handle
The handle to cadet.
const struct GNUNET_CONFIGURATION_Handle * GSF_cfg
Our configuration.
struct GNUNET_CONTAINER_MultiPeerMap * cadet_map
Map from peer identities to 'struct CadetHandles' 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.
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 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 long long sc_count_max
Maximum allowed number of cadet clients.
static struct GNUNET_CADET_Port * cadet_port
Listen port for incoming requests.
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:41
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.
Definition: cadet_api.c:910
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.
Definition: cadet_api.c:970
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_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
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_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
P2P request for content (one FS to another via a cadet).
Query from one peer, asking the other for CHK-data.
A 512-bit hashcode.
Message handler for a specific message type.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_cadet_stop_server()

void GSF_cadet_stop_server ( void  )

Shutdown subsystem for non-anonymous file-sharing.

Definition at line 524 of file gnunet-service-fs_cadet_server.c.

525 {
528  NULL);
530  cadet_map = NULL;
531  if (NULL != cadet_port)
532  {
534  cadet_port = NULL;
535  }
536  if (NULL != cadet_handle)
537  {
539  cadet_handle = NULL;
540  }
541  GNUNET_assert (NULL == sc_head);
542  GNUNET_assert (0 == sc_count);
543 }
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 unsigned int sc_count
Number of active cadet clients in the 'sc_*'-DLL.
static struct CadetClient * sc_head
Head of DLL of cadet clients.
void GNUNET_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
Definition: cadet_api.c:775
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port().
Definition: cadet_api.c:808
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.

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().

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.

Cadet channel for creating outbound channels.

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

Referenced by get_cadet(), get_channel(), new_sub(), reset_cadet(), run(), and shutdown_task().

◆ cadet_map

struct GNUNET_CONTAINER_MultiPeerMap* cadet_map

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

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

Referenced by disconnect_cb(), get_cadet(), GSF_cadet_start_server(), and GSF_cadet_stop_server().