GNUnet  0.11.x
Data Structures | Macros | Typedefs | Enumerations | Functions
CADET service

Confidential Ad-hoc Decentralized End-to-End Transport. More...

Data Structures

struct  GNUNET_CADET_ConnectionTunnelIdentifier
 Hash uniquely identifying a connection below a tunnel. More...
 
struct  GNUNET_CADET_ChannelTunnelNumber
 Number identifying a CADET channel within a tunnel. More...
 
union  GNUNET_CADET_ChannelInfo
 Union to retrieve info about a channel. More...
 
struct  GNUNET_CADET_ChannelInternals
 Internal details about a channel. More...
 
struct  GNUNET_CADET_PeerListEntry
 Information we return per peer. More...
 
struct  GNUNET_CADET_PeerPathDetail
 Detailed information we return per peer. More...
 
struct  GNUNET_CADET_TunnelDetails
 Details about a tunnel managed by CADET. More...
 

Macros

#define GNUNET_CADET_VERSION   0x00000005
 Version number of GNUnet-cadet API. More...
 

Typedefs

typedef void *(* GNUNET_CADET_ConnectEventHandler) (void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *source)
 Method called whenever a peer connects to a port in MQ-based CADET. More...
 
typedef void(* GNUNET_CADET_DisconnectEventHandler) (void *cls, const struct GNUNET_CADET_Channel *channel)
 Function called whenever an MQ-channel is destroyed, unless the destruction was requested by GNUNET_CADET_channel_destroy. More...
 
typedef void(* GNUNET_CADET_WindowSizeEventHandler) (void *cls, const struct GNUNET_CADET_Channel *channel, int window_size)
 Function called whenever an MQ-channel's transmission window size changes. More...
 
typedef void(* GNUNET_CADET_ChannelCB) (void *cls, const struct GNUNET_CADET_ChannelInternals *info)
 Method called to retrieve information about a specific channel the cadet peer is aware of, including all transit nodes. More...
 
typedef void(* GNUNET_CADET_PeersCB) (void *cls, const struct GNUNET_CADET_PeerListEntry *ple)
 Method called to retrieve information about all peers in CADET, called once per peer. More...
 
typedef void(* GNUNET_CADET_PathCB) (void *cls, const struct GNUNET_CADET_PeerPathDetail *ppd)
 Method called to retrieve information about a specific path known to the service. More...
 
typedef void(* GNUNET_CADET_TunnelsCB) (void *cls, const struct GNUNET_CADET_TunnelDetails *td)
 Method called to retrieve information about all tunnels in CADET, called once per tunnel. More...
 

Enumerations

enum  GNUNET_CADET_ChannelInfoOption { GNUNET_CADET_OPTION_PEER = 0x0 }
 

Functions

struct GNUNET_CADET_HandleGNUNET_CADET_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Connect to the MQ-based cadet service. More...
 
void GNUNET_CADET_disconnect (struct GNUNET_CADET_Handle *handle)
 Disconnect from the cadet service. More...
 
struct GNUNET_CADET_PortGNUNET_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 incomming MQ-based channels. More...
 
void GNUNET_CADET_close_port (struct GNUNET_CADET_Port *p)
 Close a port opened with GNUNET_CADET_open_port. More...
 
struct GNUNET_CADET_ChannelGNUNET_CADET_channel_create (struct GNUNET_CADET_Handle *h, void *channel_cls, const struct GNUNET_PeerIdentity *destination, const struct GNUNET_HashCode *port, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
 Create a new channel towards a remote peer. More...
 
void GNUNET_CADET_channel_destroy (struct GNUNET_CADET_Channel *channel)
 Destroy an existing channel. More...
 
struct GNUNET_MQ_HandleGNUNET_CADET_get_mq (const struct GNUNET_CADET_Channel *channel)
 Obtain the message queue for a connected channel. More...
 
void GNUNET_CADET_receive_done (struct GNUNET_CADET_Channel *channel)
 Indicate readiness to receive the next message on a channel. More...
 
const struct GNUNET_HashCodeGC_u2h (uint32_t port)
 Transitional function to convert an unsigned int port to a hash value. More...
 
const union GNUNET_CADET_ChannelInfoGNUNET_CADET_channel_get_info (struct GNUNET_CADET_Channel *channel, enum GNUNET_CADET_ChannelInfoOption option,...)
 Get information about a channel. More...
 
struct GNUNET_CADET_ChannelMonitorGNUNET_CADET_get_channel (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *peer, GNUNET_CADET_ChannelCB callback, void *callback_cls)
 Request information about channels to peer from the local peer. More...
 
void * GNUNET_CADET_get_channel_cancel (struct GNUNET_CADET_ChannelMonitor *cm)
 Cancel a channel monitor request. More...
 
struct GNUNET_CADET_PeersListerGNUNET_CADET_list_peers (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CADET_PeersCB callback, void *callback_cls)
 Request information about peers known to the running cadet service. More...
 
void * GNUNET_CADET_list_peers_cancel (struct GNUNET_CADET_PeersLister *pl)
 Cancel a peer info request. More...
 
struct GNUNET_CADET_GetPathGNUNET_CADET_get_path (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *id, GNUNET_CADET_PathCB callback, void *callback_cls)
 Request information about a peer known to the running cadet peer. More...
 
void * GNUNET_CADET_get_path_cancel (struct GNUNET_CADET_GetPath *gp)
 Cancel gp operation. More...
 
struct GNUNET_CADET_ListTunnelsGNUNET_CADET_list_tunnels (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CADET_TunnelsCB callback, void *callback_cls)
 Request information about tunnels of the running cadet peer. More...
 
void * GNUNET_CADET_list_tunnels_cancel (struct GNUNET_CADET_ListTunnels *lt)
 Cancel a monitor request. More...
 

Detailed Description

Confidential Ad-hoc Decentralized End-to-End Transport.

See also
Documentation
Paper

Macro Definition Documentation

◆ GNUNET_CADET_VERSION

#define GNUNET_CADET_VERSION   0x00000005

Version number of GNUnet-cadet API.

Definition at line 51 of file gnunet_cadet_service.h.

Typedef Documentation

◆ GNUNET_CADET_ConnectEventHandler

typedef void*(* GNUNET_CADET_ConnectEventHandler) (void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *source)

Method called whenever a peer connects to a port in MQ-based CADET.

Parameters
clsClosure from GNUNET_CADET_open_port.
channelNew handle to the channel.
sourcePeer that started this channel.
Returns
Closure for the incoming channel. It's given to:

Definition at line 108 of file gnunet_cadet_service.h.

◆ GNUNET_CADET_DisconnectEventHandler

typedef void(* GNUNET_CADET_DisconnectEventHandler) (void *cls, const struct GNUNET_CADET_Channel *channel)

Function called whenever an MQ-channel is destroyed, unless the destruction was requested by GNUNET_CADET_channel_destroy.

It must NOT call GNUNET_CADET_channel_destroy on the channel.

It should clean up any associated state, including cancelling any pending transmission on this channel.

Parameters
clsChannel closure.
channelConnection to the other end (henceforth invalid).

Definition at line 125 of file gnunet_cadet_service.h.

◆ GNUNET_CADET_WindowSizeEventHandler

typedef void(* GNUNET_CADET_WindowSizeEventHandler) (void *cls, const struct GNUNET_CADET_Channel *channel, int window_size)

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 — FIXME: drop?
window_sizeNew window size. If the is more messages than buffer size this value will be negative. – FIXME: make unsigned, we never call negative?

Definition at line 144 of file gnunet_cadet_service.h.

◆ GNUNET_CADET_ChannelCB

typedef void(* GNUNET_CADET_ChannelCB) (void *cls, const struct GNUNET_CADET_ChannelInternals *info)

Method called to retrieve information about a specific channel the cadet peer is aware of, including all transit nodes.

Parameters
clsClosure.
infointernal details, NULL for end of list

Definition at line 358 of file gnunet_cadet_service.h.

◆ GNUNET_CADET_PeersCB

typedef void(* GNUNET_CADET_PeersCB) (void *cls, const struct GNUNET_CADET_PeerListEntry *ple)

Method called to retrieve information about all peers in CADET, called once per peer.

After last peer has been reported, an additional call with NULL is done.

Parameters
clsClosure.
pleinformation about a peer, or NULL on "EOF".

Definition at line 430 of file gnunet_cadet_service.h.

◆ GNUNET_CADET_PathCB

typedef void(* GNUNET_CADET_PathCB) (void *cls, const struct GNUNET_CADET_PeerPathDetail *ppd)

Method called to retrieve information about a specific path known to the service.

Parameters
clsClosure.
ppddetails about a path to the peer, NULL for end of information

Definition at line 503 of file gnunet_cadet_service.h.

◆ GNUNET_CADET_TunnelsCB

typedef void(* GNUNET_CADET_TunnelsCB) (void *cls, const struct GNUNET_CADET_TunnelDetails *td)

Method called to retrieve information about all tunnels in CADET, called once per tunnel.

After last tunnel has been reported, an additional call with NULL is done.

Parameters
clsClosure.
tdtunnel details, NULL for end of list

Definition at line 581 of file gnunet_cadet_service.h.

Enumeration Type Documentation

◆ GNUNET_CADET_ChannelInfoOption

Enumerator
GNUNET_CADET_OPTION_PEER 

Who is the peer at the other end of the channel.

Only for use in GNUNET_CADET_channel_get_info struct GNUNET_PeerIdentity *peer

Definition at line 281 of file gnunet_cadet_service.h.

282 {
289 };
Who is the peer at the other end of the channel.

Function Documentation

◆ GNUNET_CADET_connect()

struct GNUNET_CADET_Handle* GNUNET_CADET_connect ( const struct GNUNET_CONFIGURATION_Handle cfg)

Connect to the MQ-based cadet service.

Parameters
cfgConfiguration to use.
Returns
Handle to the cadet service NULL on error.

Definition at line 976 of file cadet_api.c.

References GNUNET_CADET_Handle::cfg, GNUNET_CADET_ClientChannelNumber::channel_of_client, GNUNET_CADET_Handle::channels, GNUNET_break, GNUNET_CADET_disconnect(), GNUNET_CADET_LOCAL_CHANNEL_ID_CLI, GNUNET_CONTAINER_multihashmap32_create(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_YES, h, LOG, GNUNET_CADET_Handle::mq, GNUNET_CADET_Handle::next_ccn, GNUNET_CADET_Handle::ports, and reconnect().

Referenced by cadet_connect_adapter(), GSF_cadet_start_server(), and run().

977 {
978  struct GNUNET_CADET_Handle *h;
979 
980  LOG (GNUNET_ERROR_TYPE_DEBUG, "GNUNET_CADET_connect()\n");
981  h = GNUNET_new (struct GNUNET_CADET_Handle);
982  h->cfg = cfg;
985  reconnect (h);
986  if (NULL == h->mq)
987  {
988  GNUNET_break (0);
990  return NULL;
991  }
993  return h;
994 }
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration given by the client, in case of reconnection.
Definition: cadet_api.c:63
void GNUNET_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
Definition: cadet_api.c:841
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
uint32_t channel_of_client
Values for channel numbering.
Definition: cadet.h:111
Opaque handle to the service.
Definition: cadet_api.c:38
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_CADET_ClientChannelNumber next_ccn
child of the next channel to create (to avoid reusing IDs often)
Definition: cadet_api.c:58
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_CONTAINER_MultiHashMap * ports
Ports open.
Definition: cadet_api.c:48
struct GNUNET_MQ_Handle * mq
Message queue.
Definition: cadet_api.c:43
#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI
Minimum value for channel IDs of local clients.
Definition: cadet.h:71
#define LOG(kind,...)
Definition: cadet_api.c:33
static void reconnect(struct GNUNET_CADET_Handle *h)
Reconnect to the service, retransmit all infomation to try to restore the original state...
Definition: cadet_api.c:781
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_CONTAINER_MultiHashMap32 * channels
Channels open.
Definition: cadet_api.c:53
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CADET_disconnect()

void GNUNET_CADET_disconnect ( struct GNUNET_CADET_Handle handle)

Disconnect from the cadet service.

All channels will be destroyed. All channel disconnect callbacks will be called on any still connected peers, notifying about their disconnection. The registered inbound channel cleaner will be called should any inbound channels still exist.

Parameters
handleconnection to cadet to disconnect

Definition at line 841 of file cadet_api.c.

References GNUNET_CADET_Handle::channels, destroy_channel_cb(), destroy_port_cb(), GNUNET_CONTAINER_multihashmap32_destroy(), GNUNET_CONTAINER_multihashmap32_iterate(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_CADET_Handle::mq, GNUNET_CADET_Handle::ports, and GNUNET_CADET_Handle::reconnect_task.

Referenced by cadet_disconnect_adapter(), cleanup(), client_disconnect_cb(), do_shutdown(), GNUNET_CADET_connect(), GSF_cadet_stop_server(), and shutdown_task().

842 {
845  handle);
847  handle->ports = NULL;
850  handle);
852  handle->channels = NULL;
853  if (NULL != handle->mq)
854  {
855  GNUNET_MQ_destroy (handle->mq);
856  handle->mq = NULL;
857  }
858  if (NULL != handle->reconnect_task)
859  {
861  handle->reconnect_task = NULL;
862  }
863  GNUNET_free (handle);
864 }
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiHashMap * ports
Ports open.
Definition: cadet_api.c:48
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_MQ_Handle * mq
Message queue.
Definition: cadet_api.c:43
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
static int destroy_channel_cb(void *cls, uint32_t cid, void *value)
Function called during GNUNET_CADET_disconnect() to destroy all channels that are still open...
Definition: cadet_api.c:737
static int destroy_port_cb(void *cls, const struct GNUNET_HashCode *id, void *value)
Function called during GNUNET_CADET_disconnect() to destroy all ports that are still open...
Definition: cadet_api.c:818
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for trying to reconnect.
Definition: cadet_api.c:68
struct GNUNET_CONTAINER_MultiHashMap32 * channels
Channels open.
Definition: cadet_api.c:53
#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:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CADET_open_port()

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 incomming MQ-based channels.

Parameters
hCADET handle.
portHash identifying the port.
connectsFunction called when an incoming channel is connected.
connects_clsClosure for the connects handler.
window_changesFunction called when the transmit window size changes. Can be NULL.
disconnectsFunction called when a channel is disconnected.
handlersCallbacks for messages we care about, NULL-terminated.
Returns
Port handle, NULL if port is in use
Parameters
hCADET handle.
portHash identifying the port.
connectsFunction called when an incoming channel is connected.
connects_clsClosure for the connects handler.
window_changesFunction called when the transmit window size changes.
disconnectsFunction called when a channel is disconnected.
handlersCallbacks for messages we care about, NULL-terminated.
Returns
Port handle, NULL if port is in use

Definition at line 1010 of file cadet_api.c.

References GNUNET_CADET_Port::cadet, GNUNET_CADET_Port::cls, connects(), GNUNET_CADET_Port::connects, GNUNET_CADET_Port::connects_cls, disconnects(), GNUNET_CADET_Port::disconnects, GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_MQ_copy_handlers(), GNUNET_new, GNUNET_OK, h, GNUNET_CADET_Port::handlers, GNUNET_CADET_Port::id, open_port_cb(), p, port, GNUNET_CADET_Handle::ports, and GNUNET_CADET_Port::window_changes.

Referenced by advertise_dns_exit(), cadet_connect_adapter(), GSF_cadet_start_server(), handle_bob_client_message(), handle_client_listen(), handle_client_register_message(), new_sub(), run(), and store_service().

1017 {
1018  struct GNUNET_CADET_Port *p;
1019 
1020  GNUNET_assert (NULL != connects);
1021  GNUNET_assert (NULL != disconnects);
1023  "Listening to CADET port %s\n",
1024  GNUNET_h2s (port));
1025 
1026  p = GNUNET_new (struct GNUNET_CADET_Port);
1027  p->cadet = h;
1028  p->id = *port;
1030  h->ports,
1031  &p->id,
1032  p,
1034  {
1035  GNUNET_free (p);
1036  return NULL;
1037  }
1038  p->connects = connects;
1039  p->cls = connects_cls;
1041  p->disconnects = disconnects;
1042  p->handlers = GNUNET_MQ_copy_handlers (handlers);
1043 
1044  GNUNET_assert (GNUNET_OK == open_port_cb (h, &p->id, p));
1045  return p;
1046 }
GNUNET_CADET_DisconnectEventHandler disconnects
Handler called when an incoming channel is destroyed.
Definition: cadet_api.c:180
GNUNET_CADET_WindowSizeEventHandler window_changes
Window size change handler.
Definition: cadet_api.c:175
static int open_port_cb(void *cls, const struct GNUNET_HashCode *id, void *value)
Function called during reconnect_cbk() to (re)open all ports that are still open. ...
Definition: cadet_api.c:318
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_HashCode id
Port "number".
Definition: cadet_api.c:150
struct GNUNET_MQ_MessageHandler * GNUNET_MQ_copy_handlers(const struct GNUNET_MQ_MessageHandler *handlers)
Copy an array of handlers.
Definition: mq.c:1214
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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.
GNUNET_CADET_ConnectEventHandler connects
Handler for incoming channels on this port.
Definition: cadet_api.c:165
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
struct GNUNET_CONTAINER_MultiHashMap * ports
Ports open.
Definition: cadet_api.c:48
void * connects(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Definition: 010.c:2
void * cls
Closure for handler.
Definition: cadet_api.c:160
void disconnects(void *cls, const struct GNUNET_PeerIdentity *peer)
Definition: 011.c:2
There must only be one value per key; storing a value should fail if a value under the same key alrea...
struct GNUNET_CADET_Handle * cadet
Handle to the CADET session this port belongs to.
Definition: cadet_api.c:155
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.
void * connects_cls
Closure for connects.
Definition: cadet_api.c:170
static uint16_t port
Port number.
Definition: gnunet-bcd.c:81
struct GNUNET_MQ_MessageHandler * handlers
Payload handlers for incoming channels.
Definition: cadet_api.c:185
#define GNUNET_log(kind,...)
Opaque handle to a port.
Definition: cadet_api.c:145
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CADET_close_port()

void GNUNET_CADET_close_port ( struct GNUNET_CADET_Port p)

Close a port opened with GNUNET_CADET_open_port.

The new_channel callback will no longer be called.

Parameters
pPort handle.

Close a port opened with GNUNET_CADET_open_port.

The new_channel callback will no longer be called.

Parameters
pPort handle.

Definition at line 874 of file cadet_api.c.

References GNUNET_CADET_Port::cadet, env, GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_free_non_null, GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_YES, GNUNET_CADET_Port::handlers, GNUNET_CADET_Port::id, GNUNET_CADET_Handle::mq, msg, GNUNET_CADET_PortMessage::port, and GNUNET_CADET_Handle::ports.

Referenced by cadet_disconnect_adapter(), cb_channel_incoming(), channel_incoming(), cleanup(), client_disconnect_cb(), destroy_port_cb(), destroy_service_session(), destroy_sub(), free_service_record(), GSF_cadet_stop_server(), shutdown_task(), and store_service().

875 {
876  GNUNET_assert (
877  GNUNET_YES ==
879  if (NULL != p->cadet->mq)
880  {
882  struct GNUNET_MQ_Envelope *env;
883 
885  msg->port = p->id;
886  GNUNET_MQ_send (p->cadet->mq, env);
887  }
889  GNUNET_free (p);
890 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
Message for a client to create and destroy channels.
Definition: cadet.h:118
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_HashCode id
Port "number".
Definition: cadet_api.c:150
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct GNUNET_CONTAINER_MultiHashMap * ports
Ports open.
Definition: cadet_api.c:48
struct GNUNET_MQ_Handle * mq
Message queue.
Definition: cadet_api.c:43
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.
struct GNUNET_HashCode port
Port to open/close.
Definition: cadet.h:131
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_CADET_Handle * cadet
Handle to the CADET session this port belongs to.
Definition: cadet_api.c:155
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_CLOSE
Stop listening on a port.
struct GNUNET_MQ_MessageHandler * handlers
Payload handlers for incoming channels.
Definition: cadet_api.c:185
#define GNUNET_YES
Definition: gnunet_common.h:77
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
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CADET_channel_create()

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,
GNUNET_CADET_WindowSizeEventHandler  window_changes,
GNUNET_CADET_DisconnectEventHandler  disconnects,
const struct GNUNET_MQ_MessageHandler handlers 
)

Create a new channel towards a remote peer.

If the destination peer closes the channel after accepting it, disconnects will be called for this channel (unless GNUNET_CADET_channel_destroy() was called on this end first).

Parameters
hCADET handle.
channel_clsClosure for the channel. It's given to:
  • The management handler window_changes.
  • The disconnect handler disconnects
  • Each message type callback in handlers
destinationPeer identity the channel should go to.
portIdentification of the destination port.
window_changesFunction called when the transmit window size changes. Can be NULL if this data is of no interest.
disconnectsFunction called when the channel is disconnected.
handlersCallbacks for messages we care about, NULL-terminated.
Returns
Handle to the channel.

If the destination peer closes the channel after accepting it, disconnects will be called for this channel (unless GNUNET_CADET_channel_destroy() was called on this end first).

Parameters
hCADET handle.
channel_clsClosure for the channel. It's given to:
  • The disconnect handler disconnects
  • Each message type callback in handlers
destinationPeer identity the channel should go to.
portIdentification of the destination port.
window_changesFunction called when the transmit window size changes.
disconnectsFunction called when the channel is disconnected.
handlersCallbacks for messages we care about, NULL-terminated.
Returns
Handle to the channel.

Definition at line 1068 of file cadet_api.c.

References cadet_mq_cancel_impl(), cadet_mq_destroy_impl(), cadet_mq_error_handler(), cadet_mq_send_impl(), GNUNET_CADET_LocalChannelCreateMessage::ccn, GNUNET_CADET_Channel::ccn, ch, create_channel(), GNUNET_CADET_Channel::ctx, disconnects(), GNUNET_CADET_Channel::disconnects, env, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE, GNUNET_MQ_msg, GNUNET_MQ_queue_for_callbacks(), GNUNET_MQ_send(), GNUNET_MQ_set_handlers_closure(), GNUNET_CADET_Handle::mq, GNUNET_CADET_Channel::mq, msg, GNUNET_CADET_Channel::peer, GNUNET_CADET_LocalChannelCreateMessage::peer, port, GNUNET_CADET_LocalChannelCreateMessage::port, and GNUNET_CADET_Channel::window_changes.

Referenced by client_request_complete_alice(), create_channel(), get_cadet(), get_channel(), handle_client_call_message(), handle_client_evaluate(), reset_cadet(), run(), start_test(), try_open_exit(), and warmup().

1075 {
1076  struct GNUNET_CADET_Channel *ch;
1078  struct GNUNET_MQ_Envelope *env;
1079 
1080  GNUNET_assert (NULL != disconnects);
1082  "Creating channel to peer %s at port %s\n",
1083  GNUNET_i2s (destination),
1084  GNUNET_h2s (port));
1085  ch = create_channel (h, NULL);
1086  ch->ctx = channel_cls;
1087  ch->peer = *destination;
1088  ch->window_changes = window_changes;
1089  ch->disconnects = disconnects;
1090 
1091  /* Create MQ for channel */
1095  ch,
1096  handlers,
1098  ch);
1099  GNUNET_MQ_set_handlers_closure (ch->mq, channel_cls);
1100 
1101  /* Request channel creation to service */
1103  msg->ccn = ch->ccn;
1104  msg->port = *port;
1105  msg->peer = *destination;
1106  GNUNET_MQ_send (h->mq, env);
1107  return ch;
1108 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct GNUNET_CADET_ClientChannelNumber ccn
ID of a channel controlled by this client.
Definition: cadet.h:150
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
GNUNET_CADET_DisconnectEventHandler disconnects
Disconnect handler.
Definition: cadet_api.c:128
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void cadet_mq_destroy_impl(struct GNUNET_MQ_Handle *mq, void *impl_state)
Handle destruction of a message queue.
Definition: cadet_api.c:463
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_PeerIdentity peer
Other end of the channel.
Definition: cadet_api.c:85
Opaque handle to a channel.
Definition: cadet_api.c:80
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE
Ask the cadet service to create a new channel.
void GNUNET_MQ_set_handlers_closure(struct GNUNET_MQ_Handle *mq, void *handlers_cls)
Change the closure argument in all of the handlers of the mq.
Definition: mq.c:583
struct GNUNET_CADET_ClientChannelNumber ccn
Local ID of the channel, GNUNET_CADET_LOCAL_CHANNEL_ID_CLI bit is set if outbound.
Definition: cadet_api.c:133
struct GNUNET_MQ_Handle * GNUNET_MQ_queue_for_callbacks(GNUNET_MQ_SendImpl send, GNUNET_MQ_DestroyImpl destroy, GNUNET_MQ_CancelImpl cancel, void *impl_state, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *cls)
Create a message queue for the specified handlers.
Definition: mq.c:552
static struct GNUNET_CADET_Channel * create_channel(struct GNUNET_CADET_Handle *h, const struct GNUNET_CADET_ClientChannelNumber *ccnp)
Create a new channel and insert it in the channel list of the cadet handle.
Definition: cadet_api.c:228
void * ctx
Any data the caller wants to put in here, used for the various callbacks (disconnects, window_changes, handlers).
Definition: cadet_api.c:101
struct GNUNET_MQ_Handle * mq
Message queue.
Definition: cadet_api.c:43
static void cadet_mq_send_impl(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MessageHeader *msg, void *impl_state)
Implement sending functionality of a message queue for us sending messages to a peer.
Definition: cadet_api.c:414
void disconnects(void *cls, const struct GNUNET_PeerIdentity *peer)
Definition: 011.c:2
static void cadet_mq_cancel_impl(struct GNUNET_MQ_Handle *mq, void *impl_state)
Implementation function that cancels the currently sent message.
Definition: cadet_api.c:511
struct GNUNET_MQ_Handle * mq
Message Queue for the channel (which we are implementing).
Definition: cadet_api.c:106
Message for a client to create channels.
Definition: cadet.h:138
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static uint16_t port
Port number.
Definition: gnunet-bcd.c:81
GNUNET_CADET_WindowSizeEventHandler window_changes
Window change handler.
Definition: cadet_api.c:123
#define GNUNET_log(kind,...)
static void cadet_mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
We had an error processing a message we forwarded from a peer to the CADET service.
Definition: cadet_api.c:481
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
struct GNUNET_PeerIdentity peer
Channel's peer.
Definition: cadet.h:155
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_HashCode port
Port of the channel.
Definition: cadet.h:160
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CADET_channel_destroy()

void GNUNET_CADET_channel_destroy ( struct GNUNET_CADET_Channel channel)

Destroy an existing channel.

The existing end callback for the channel will NOT be called. Any pending outgoing messages will be sent but no incoming messages will be accepted and no data callbacks will be called.

Parameters
channelChannel handle, becomes invalid after this call.

Definition at line 903 of file cadet_api.c.

References GNUNET_CADET_Channel::cadet, GNUNET_CADET_Channel::ccn, GNUNET_CADET_LocalChannelDestroyMessage::ccn, destroy_channel(), GNUNET_CADET_Channel::disconnects, env, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_CADET_Handle::mq, and msg.

Referenced by _GSS_operation_destroy(), _GSS_operation_destroy2(), adjust_running_peers(), cadet_mq_error_handler(), cadet_timeout(), cleanup(), client_request_complete_alice(), connect_cb(), destroy_channel(), destroy_line_cadet_channels(), destroy_service_session(), disconnect_cadet_peers(), free_channel_state(), GSF_cadet_release_clients(), reset_cadet(), setup_state_record(), shutdown_task(), timeout_cadet_task(), timeout_request(), and transmit_cryptographic_reply().

904 {
905  struct GNUNET_CADET_Handle *h = channel->cadet;
907  struct GNUNET_MQ_Envelope *env;
908 
909  if (NULL != h->mq)
910  {
912  msg->ccn = channel->ccn;
913  GNUNET_MQ_send (h->mq, env);
914  }
916  "Destroying channel due to GNUNET_CADET_channel_destroy()\n");
917  channel->disconnects = NULL;
918  destroy_channel (channel);
919 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
GNUNET_CADET_DisconnectEventHandler disconnects
Disconnect handler.
Definition: cadet_api.c:128
Message for or to a client to destroy tunnel.
Definition: cadet.h:172
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY
Tell client that a channel was destroyed.
Opaque handle to the service.
Definition: cadet_api.c:38
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_CADET_ClientChannelNumber ccn
Local ID of the channel, GNUNET_CADET_LOCAL_CHANNEL_ID_CLI bit is set if outbound.
Definition: cadet_api.c:133
struct GNUNET_MQ_Handle * mq
Message queue.
Definition: cadet_api.c:43
static void destroy_channel(struct GNUNET_CADET_Channel *ch)
Destroy the specified channel.
Definition: cadet_api.c:270
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_CADET_Handle * cadet
Handle to the cadet this channel belongs to.
Definition: cadet_api.c:90
struct GNUNET_CADET_ClientChannelNumber ccn
ID of a channel controlled by this client.
Definition: cadet.h:182
#define GNUNET_log(kind,...)
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CADET_get_mq()

struct GNUNET_MQ_Handle* GNUNET_CADET_get_mq ( const struct GNUNET_CADET_Channel channel)

Obtain the message queue for a connected channel.

Parameters
channelThe channel handle from which to get the MQ.
Returns
The message queue of the channel.

Obtain the message queue for a connected channel.

Parameters
channelThe channel handle from which to get the MQ.
Returns
NULL if channel is not yet connected.

Definition at line 1119 of file cadet_api.c.

References GNUNET_CADET_Channel::mq.

Referenced by cadet_channel_end_cb(), cb_channel_incoming(), channel_new_cb(), client_request_complete_alice(), continue_writing(), dns_pre_request_handler(), get_mq(), handle_client_call_message(), handle_client_evaluate(), handle_data(), handle_datastore_reply(), inbound_channel(), process_dns_result(), read_stdio(), send_echo(), send_packet_to_cadet_channel(), send_to_channel(), and transmit_pending().

1120 {
1121  return channel->mq;
1122 }
struct GNUNET_MQ_Handle * mq
Message Queue for the channel (which we are implementing).
Definition: cadet_api.c:106
Here is the caller graph for this function:

◆ GNUNET_CADET_receive_done()

void GNUNET_CADET_receive_done ( struct GNUNET_CADET_Channel channel)

Indicate readiness to receive the next message on a channel.

Should only be called once per handler called.

Parameters
channelChannel that will be allowed to call another handler.

Indicate readiness to receive the next message on a channel.

Parameters
chChannel on which to send the ACK.

Definition at line 954 of file cadet_api.c.

References GNUNET_CADET_Channel::cadet, GNUNET_CADET_Channel::ccn, GNUNET_CADET_LocalAck::ccn, GNUNET_CADET_ClientChannelNumber::channel_of_client, env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK, GNUNET_MQ_msg, GNUNET_MQ_send(), LOG, GNUNET_CADET_Handle::mq, and msg.

Referenced by cadet_mq_error_handler(), cb_intersection_element_removed(), continue_writing(), handle_alices_cryptodata_message(), handle_bobs_cryptodata_message(), handle_bobs_cryptodata_multipart(), handle_cadet_audio_message(), handle_cadet_hangup_message(), handle_cadet_pickup_message(), handle_cadet_resume_message(), handle_cadet_ring_message(), handle_cadet_suspend_message(), handle_client_accept(), handle_data(), handle_dns_request(), handle_icmp_back(), handle_icmp_remote(), handle_icmp_service(), handle_intersection_p2p_bf(), handle_intersection_p2p_done(), handle_intersection_p2p_element_info(), handle_peer_check(), handle_peer_pull_reply(), handle_peer_pull_request(), handle_peer_push(), handle_reply(), handle_tcp_back(), handle_tcp_data(), handle_tcp_remote(), handle_tcp_service(), handle_udp_back(), handle_udp_remote(), handle_udp_service(), handle_union_p2p_demand(), handle_union_p2p_done(), handle_union_p2p_elements(), handle_union_p2p_full_done(), handle_union_p2p_full_element(), handle_union_p2p_ibf(), handle_union_p2p_inquiry(), handle_union_p2p_offer(), handle_union_p2p_request_full(), handle_union_p2p_strata_estimator(), ping_handler(), and pong_handler().

955 {
956  struct GNUNET_CADET_LocalAck *msg;
957  struct GNUNET_MQ_Envelope *env;
958 
961  "Sending ACK on channel %X\n",
962  ntohl (channel->ccn.channel_of_client));
963  msg->ccn = channel->ccn;
964  GNUNET_MQ_send (channel->cadet->mq, env);
965 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
Message to allow the client send more data to the service (always service -> client).
Definition: cadet.h:217
uint32_t channel_of_client
Values for channel numbering.
Definition: cadet.h:111
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_CADET_ClientChannelNumber ccn
Local ID of the channel, GNUNET_CADET_LOCAL_CHANNEL_ID_CLI bit is set if outbound.
Definition: cadet_api.c:133
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK
Local ACK for data.
struct GNUNET_MQ_Handle * mq
Message queue.
Definition: cadet_api.c:43
#define LOG(kind,...)
Definition: cadet_api.c:33
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_CADET_ClientChannelNumber ccn
ID of the channel allowed to send more data.
Definition: cadet.h:227
struct GNUNET_CADET_Handle * cadet
Handle to the cadet this channel belongs to.
Definition: cadet_api.c:90
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GC_u2h()

const struct GNUNET_HashCode* GC_u2h ( uint32_t  port)

Transitional function to convert an unsigned int port to a hash value.

WARNING: local static value returned, NOT reentrant! WARNING: do not use this function for new code!

Parameters
portNumerical port (unsigned int format).
Returns
A GNUNET_HashCode usable for the new CADET API.

Definition at line 44 of file cadet_api_helper.c.

References GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_WARNING, and GNUNET_log.

Referenced by main(), start_test(), and warmup().

45 {
46  static struct GNUNET_HashCode hash;
47 
49  "This is a transitional function, use proper crypto hashes as CADET ports\n");
51  sizeof(port),
52  &hash);
53  return &hash;
54 }
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
A 512-bit hashcode.
static uint16_t port
Port number.
Definition: gnunet-bcd.c:81
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CADET_channel_get_info()

const union GNUNET_CADET_ChannelInfo* GNUNET_CADET_channel_get_info ( struct GNUNET_CADET_Channel channel,
enum GNUNET_CADET_ChannelInfoOption  option,
  ... 
)

Get information about a channel.

Parameters
channelChannel handle.
...dependant on option, currently not used
Returns
Union with an answer to the query.
Parameters
channelChannel handle.
optionQuery (GNUNET_CADET_OPTION_*).
...dependant on option, currently not used
Returns
Union with an answer to the query.

Definition at line 932 of file cadet_api.c.

References GNUNET_break, GNUNET_CADET_OPTION_PEER, and GNUNET_CADET_Channel::peer.

935 {
936  switch (option)
937  {
939  return (const union GNUNET_CADET_ChannelInfo *) &channel->peer;
940 
941  default:
942  GNUNET_break (0);
943  return NULL;
944  }
945 }
struct GNUNET_PeerIdentity peer
Other end of the channel.
Definition: cadet_api.c:85
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static char * option
Name of the option.
Definition: gnunet-config.c:38
Union to retrieve info about a channel.
Who is the peer at the other end of the channel.

◆ GNUNET_CADET_get_channel()

struct GNUNET_CADET_ChannelMonitor* GNUNET_CADET_get_channel ( const struct GNUNET_CONFIGURATION_Handle cfg,
struct GNUNET_PeerIdentity peer,
GNUNET_CADET_ChannelCB  callback,
void *  callback_cls 
)

Request information about channels to peer from the local peer.

Parameters
cfgconfiguration to use
peerID of the other end of the channel.
callbackFunction to call with the requested data.
callback_clsClosure for callback.

Request information about channels to peer from the local peer.

Parameters
cfgconfiguration to use
peerID of the other end of the channel.
callbackFunction to call with the requested data.
callback_clsClosure for callback.
Returns
NULL on error

Definition at line 213 of file cadet_api_get_channel.c.

References GNUNET_CADET_ChannelMonitor::cfg, GNUNET_CADET_ChannelMonitor::channel_cb, GNUNET_CADET_ChannelMonitor::channel_cb_cls, GNUNET_break, GNUNET_free, GNUNET_new, GNUNET_CADET_ChannelMonitor::mq, GNUNET_CADET_ChannelMonitor::peer, and reconnect().

217 {
218  struct GNUNET_CADET_ChannelMonitor *cm;
219 
220  if (NULL == callback)
221  {
222  GNUNET_break (0);
223  return NULL;
224  }
226  cm->channel_cb = callback;
227  cm->channel_cb_cls = callback_cls;
228  cm->cfg = cfg;
229  cm->peer = *peer;
230  reconnect (cm);
231  if (NULL == cm->mq)
232  {
233  GNUNET_free (cm);
234  return NULL;
235  }
236  return cm;
237 }
static void reconnect(void *cls)
Reconnect to the service and try again.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void * channel_cb_cls
Info callback closure for channel_cb.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
struct GNUNET_PeerIdentity peer
Peer we want information about.
GNUNET_CADET_ChannelCB channel_cb
Channel callback.
struct GNUNET_MQ_Handle * mq
Message queue to talk to CADET service.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ GNUNET_CADET_get_channel_cancel()

void* GNUNET_CADET_get_channel_cancel ( struct GNUNET_CADET_ChannelMonitor cm)

Cancel a channel monitor request.

The callback will not be called (anymore).

Parameters
hCadet handle.
Returns
Closure that was given to GNUNET_CADET_get_channel().

Definition at line 247 of file cadet_api_get_channel.c.

References GNUNET_CADET_ChannelMonitor::channel_cb_cls, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_CADET_ChannelMonitor::mq, GNUNET_CADET_ChannelMonitor::reconnect_task, and ret.

Referenced by handle_channel_info(), and handle_channel_info_end().

248 {
249  void *ret = cm->channel_cb_cls;
250 
251  if (NULL != cm->mq)
252  GNUNET_MQ_destroy (cm->mq);
253  if (NULL != cm->reconnect_task)
255  GNUNET_free (cm);
256  return ret;
257 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
void * channel_cb_cls
Info callback closure for channel_cb.
struct GNUNET_MQ_Handle * mq
Message queue to talk to CADET service.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
struct GNUNET_SCHEDULER_Task * reconnect_task
Task to reconnect.
#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:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CADET_list_peers()

struct GNUNET_CADET_PeersLister* GNUNET_CADET_list_peers ( const struct GNUNET_CONFIGURATION_Handle cfg,
GNUNET_CADET_PeersCB  callback,
void *  callback_cls 
)

Request information about peers known to the running cadet service.

The callback will be called for every peer known to the service. Only one info request (of any kind) can be active at once.

Parameters
cfgconfiguration to use
callbackFunction to call with the requested data.
callback_clsClosure for callback.
Returns
NULL on error

Definition at line 193 of file cadet_api_list_peers.c.

References GNUNET_CADET_PeersLister::cfg, GNUNET_break, GNUNET_free, GNUNET_new, GNUNET_CADET_PeersLister::mq, GNUNET_CADET_PeersLister::peers_cb, GNUNET_CADET_PeersLister::peers_cb_cls, and reconnect().

Referenced by get_peers().

196 {
197  struct GNUNET_CADET_PeersLister *pl;
198 
199  if (NULL == callback)
200  {
201  GNUNET_break (0);
202  return NULL;
203  }
204  pl = GNUNET_new (struct GNUNET_CADET_PeersLister);
205  pl->peers_cb = callback;
206  pl->peers_cb_cls = callback_cls;
207  pl->cfg = cfg;
208  reconnect (pl);
209  if (NULL == pl->mq)
210  {
211  GNUNET_free (pl);
212  return NULL;
213  }
214  return pl;
215 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
void * peers_cb_cls
Info callback closure for info_cb.
struct GNUNET_MQ_Handle * mq
Message queue to talk to CADET service.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void reconnect(void *cls)
Reconnect to the service and try again.
GNUNET_CADET_PeersCB peers_cb
Monitor callback.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CADET_list_peers_cancel()

void* GNUNET_CADET_list_peers_cancel ( struct GNUNET_CADET_PeersLister pl)

Cancel a peer info request.

The callback will not be called (anymore).

Parameters
ploperation handle
Returns
Closure that was given to GNUNET_CADET_list_peers().

The callback will not be called (anymore).

Parameters
ploperation handle
Returns
Closure given to GNUNET_CADET_get_peers().

Definition at line 225 of file cadet_api_list_peers.c.

References GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_CADET_PeersLister::mq, GNUNET_CADET_PeersLister::peers_cb_cls, GNUNET_CADET_PeersLister::reconnect_task, and ret.

Referenced by handle_get_peers_end(), and shutdown_task().

226 {
227  void *ret = pl->peers_cb_cls;
228 
229  if (NULL != pl->mq)
230  GNUNET_MQ_destroy (pl->mq);
231  if (NULL != pl->reconnect_task)
233  GNUNET_free (pl);
234  return ret;
235 }
struct GNUNET_SCHEDULER_Task * reconnect_task
Task to reconnect.
void * peers_cb_cls
Info callback closure for info_cb.
struct GNUNET_MQ_Handle * mq
Message queue to talk to CADET service.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#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:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CADET_get_path()

struct GNUNET_CADET_GetPath* GNUNET_CADET_get_path ( const struct GNUNET_CONFIGURATION_Handle cfg,
const struct GNUNET_PeerIdentity id,
GNUNET_CADET_PathCB  callback,
void *  callback_cls 
)

Request information about a peer known to the running cadet peer.

Parameters
cfgconfiguration to use
idPeer whose paths we want to examine.
callbackFunction to call with the requested data.
callback_clsClosure for callback.
Returns
NULL on error

Request information about a peer known to the running cadet peer.

Parameters
cfgconfiguration to use
idPeer whose paths to examine.
callbackFunction to call with the requested data.
callback_clsClosure for callback.
Returns
NULL on error

Definition at line 229 of file cadet_api_get_path.c.

References GNUNET_CADET_GetPath::cfg, GNUNET_break, GNUNET_free, GNUNET_new, GNUNET_CADET_GetPath::id, GNUNET_CADET_GetPath::mq, GNUNET_CADET_GetPath::path_cb, GNUNET_CADET_GetPath::path_cb_cls, and reconnect().

Referenced by show_peer().

233 {
234  struct GNUNET_CADET_GetPath *gp;
235 
236  if (NULL == callback)
237  {
238  GNUNET_break (0);
239  return NULL;
240  }
241  gp = GNUNET_new (struct GNUNET_CADET_GetPath);
242  gp->path_cb = callback;
243  gp->path_cb_cls = callback_cls;
244  gp->cfg = cfg;
245  gp->id = *id;
246  reconnect (gp);
247  if (NULL == gp->mq)
248  {
249  GNUNET_free (gp);
250  return NULL;
251  }
252  return gp;
253 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void * path_cb_cls
Closure for path_cb.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
GNUNET_CADET_PathCB path_cb
Monitor callback.
struct GNUNET_MQ_Handle * mq
Message queue to talk to CADET service.
Operation handle.
static void reconnect(void *cls)
Reconnect to the service and try again.
struct GNUNET_PeerIdentity id
Peer we want information about.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CADET_get_path_cancel()

void* GNUNET_CADET_get_path_cancel ( struct GNUNET_CADET_GetPath gp)

Cancel gp operation.

Parameters
gpoperation to cancel
Returns
closure from GNUNET_CADET_get_path().

Definition at line 263 of file cadet_api_get_path.c.

References GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_CADET_GetPath::mq, GNUNET_CADET_GetPath::path_cb_cls, GNUNET_CADET_GetPath::reconnect_task, and ret.

Referenced by handle_get_path_end(), and shutdown_task().

264 {
265  void *ret = gp->path_cb_cls;
266 
267  if (NULL != gp->mq)
268  GNUNET_MQ_destroy (gp->mq);
269  if (NULL != gp->reconnect_task)
271  GNUNET_free (gp);
272  return ret;
273 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_SCHEDULER_Task * reconnect_task
Task to reconnect.
void * path_cb_cls
Closure for path_cb.
struct GNUNET_MQ_Handle * mq
Message queue to talk to CADET service.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#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:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CADET_list_tunnels()

struct GNUNET_CADET_ListTunnels* GNUNET_CADET_list_tunnels ( const struct GNUNET_CONFIGURATION_Handle cfg,
GNUNET_CADET_TunnelsCB  callback,
void *  callback_cls 
)

Request information about tunnels of the running cadet peer.

The callback will be called for every tunnel of the service. Only one info request (of any kind) can be active at once.

Parameters
cfgconfiguration to use
callbackFunction to call with the requested data.
callback_clsClosure for callback.
Returns
NULL on error

Definition at line 194 of file cadet_api_list_tunnels.c.

References GNUNET_CADET_ListTunnels::cfg, GNUNET_break, GNUNET_free, GNUNET_new, GNUNET_CADET_ListTunnels::mq, reconnect(), GNUNET_CADET_ListTunnels::tunnels_cb, and GNUNET_CADET_ListTunnels::tunnels_cb_cls.

Referenced by get_tunnels().

197 {
198  struct GNUNET_CADET_ListTunnels *lt;
199 
200  if (NULL == callback)
201  {
202  GNUNET_break (0);
203  return NULL;
204  }
205  lt = GNUNET_new (struct GNUNET_CADET_ListTunnels);
206  lt->tunnels_cb = callback;
207  lt->tunnels_cb_cls = callback_cls;
208  lt->cfg = cfg;
209  reconnect (lt);
210  if (NULL == lt->mq)
211  {
212  GNUNET_free (lt);
213  return NULL;
214  }
215  return lt;
216 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
struct GNUNET_MQ_Handle * mq
Message queue to talk to CADET service.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void * tunnels_cb_cls
Info callback closure for tunnels_cb.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
static void reconnect(void *cls)
Reconnect to the service and try again.
GNUNET_CADET_TunnelsCB tunnels_cb
Monitor callback.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_CADET_list_tunnels_cancel()

void* GNUNET_CADET_list_tunnels_cancel ( struct GNUNET_CADET_ListTunnels lt)

Cancel a monitor request.

The monitor callback will not be called.

Parameters
ltoperation handle
Returns
Closure given to GNUNET_CADET_list_tunnels(), if any.

The monitor callback will not be called.

Parameters
ltoperation handle
Returns
Closure given to GNUNET_CADET_list_tunnels().

Definition at line 226 of file cadet_api_list_tunnels.c.

References GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_CADET_ListTunnels::mq, GNUNET_CADET_ListTunnels::reconnect_task, ret, and GNUNET_CADET_ListTunnels::tunnels_cb_cls.

Referenced by handle_get_tunnels_end(), and shutdown_task().

227 {
228  void *ret = lt->tunnels_cb_cls;
229 
230  if (NULL != lt->mq)
231  GNUNET_MQ_destroy (lt->mq);
232  if (NULL != lt->reconnect_task)
234  GNUNET_free (lt);
235  return ret;
236 }
struct GNUNET_MQ_Handle * mq
Message queue to talk to CADET service.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
void * tunnels_cb_cls
Info callback closure for tunnels_cb.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task to reconnect.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#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:966
Here is the call graph for this function:
Here is the caller graph for this function: