GNUnet 0.21.0
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...
 

Typedefs

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

Functions

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

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

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.

Parameters
clsclosure
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.

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

635{
636 struct CadetHandle *mh;
637 struct GSF_CadetRequest *sr;
638
640 "Preparing to send query for %s via cadet to %s\n",
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 uint32_t type
Type string converted to DNS type value.
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_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_log(kind,...)
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).
@ GNUNET_ERROR_TYPE_DEBUG
#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.

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

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

706{
707 struct CadetHandle *mh = value;
708
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;
715
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.
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
Definition: cadet_api.c:830
@ GNUNET_YES
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
Opaque handle to a channel.
Definition: cadet.h:116

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.

Parameters
srrequest to cancel

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

664{
665 struct CadetHandle *mh = sr->mh;
667
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)
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))
690 mh);
691}
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.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:38
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
enum GNUNET_GenericReturnValue 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.
@ GNUNET_OK
#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:1272
#define GNUNET_TIME_UNIT_SECONDS
One second.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
@ GNUNET_BLOCK_TYPE_ANY
Identifier for any block.
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 483 of file gnunet-service-fs_cadet_server.c.

484{
488 struct CadetQueryMessage,
489 NULL),
491 };
492 struct GNUNET_HashCode port;
493
494 if (GNUNET_YES !=
496 "fs",
497 "MAX_CADET_CLIENTS",
498 &sc_count_max))
499 return;
501 "Initializing cadet FS server with a limit of %llu connections\n",
505 GNUNET_assert (NULL != cadet_handle);
508 &port);
510 &port,
511 &connect_cb,
512 NULL,
515 handlers);
516}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
static uint16_t port
Port number.
Definition: gnunet-bcd.c:147
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 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 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 struct GNUNET_CADET_Port * cadet_port
Listen port for incoming requests.
struct GNUNET_CADET_Handle * cadet_handle
Handler to CADET.
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:40
#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.
Definition: cadet_api.c:894
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:954
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)
#define GNUNET_MESSAGE_TYPE_FS_CADET_QUERY
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 523 of file gnunet-service-fs_cadet_server.c.

524{
527 NULL);
529 cadet_map = NULL;
530 if (NULL != cadet_port)
531 {
533 cadet_port = NULL;
534 }
535 if (NULL != cadet_handle)
536 {
538 cadet_handle = NULL;
539 }
540 GNUNET_assert (NULL == sc_head);
541 GNUNET_assert (0 == sc_count);
542}
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:774
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port.
Definition: cadet_api.c:801
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
extern

Cadet channel for creating outbound channels.

Cadet channel for creating outbound channels.

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

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

◆ cadet_map

struct GNUNET_CONTAINER_MultiPeerMap* cadet_map
extern

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