GNUnet  0.11.x
Data Structures | Functions
cadet_api_list_tunnels.c File Reference

cadet api: client implementation of cadet service More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_cadet_service.h"
#include "cadet.h"
#include "cadet_protocol.h"
Include dependency graph for cadet_api_list_tunnels.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_CADET_ListTunnels
 Operation handle. More...


static void handle_get_tunnels (void *cls, const struct GNUNET_CADET_LocalInfoTunnel *info)
 Process a local reply about info on all tunnels, pass info to the user. More...
static void handle_get_tunnels_end (void *cls, const struct GNUNET_MessageHeader *msg)
 Process a local reply about info on all tunnels, pass info to the user. More...
static void reconnect (void *cls)
 Reconnect to the service and try again. More...
static void error_handler (void *cls, enum GNUNET_MQ_Error error)
 Function called on connection trouble. 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

cadet api: client implementation of cadet service

Bartlomiej Polot
Christian Grothoff

Definition in file cadet_api_list_tunnels.c.

Function Documentation

◆ handle_get_tunnels()

static void handle_get_tunnels ( void *  cls,
const struct GNUNET_CADET_LocalInfoTunnel info 

Process a local reply about info on all tunnels, pass info to the user.

clsa struct GNUNET_CADET_ListTunnels *
infoMessage itself.

Definition at line 78 of file cadet_api_list_tunnels.c.

80 {
81  struct GNUNET_CADET_ListTunnels *lt = cls;
84  td.peer = info->destination;
85  td.channels = ntohl (info->channels);
86  td.connections = ntohl (info->connections);
87 = ntohs (info->estate);
88  td.cstate = ntohs (info->cstate);
89  lt->tunnels_cb (lt->tunnels_cb_cls,
90  &td);
91 }
void * tunnels_cb_cls
Info callback closure for tunnels_cb.
GNUNET_CADET_TunnelsCB tunnels_cb
Monitor callback.
uint16_t cstate
Connection state.
Definition: cadet.h:489
uint16_t estate
Encryption state.
Definition: cadet.h:484
struct GNUNET_PeerIdentity destination
ID of the destination of the tunnel (can be local peer).
Definition: cadet.h:474
uint32_t connections
Number of connections.
Definition: cadet.h:479
uint32_t channels
Number of channels.
Definition: cadet.h:469
Details about a tunnel managed by CADET.
struct GNUNET_PeerIdentity peer
Target of the tunnel.

References GNUNET_CADET_LocalInfoTunnel::channels, GNUNET_CADET_TunnelDetails::channels, GNUNET_CADET_LocalInfoTunnel::connections, GNUNET_CADET_TunnelDetails::connections, GNUNET_CADET_LocalInfoTunnel::cstate, GNUNET_CADET_TunnelDetails::cstate, GNUNET_CADET_LocalInfoTunnel::destination, GNUNET_CADET_LocalInfoTunnel::estate, GNUNET_CADET_TunnelDetails::estate, GNUNET_CADET_TunnelDetails::peer, GNUNET_CADET_ListTunnels::tunnels_cb, and GNUNET_CADET_ListTunnels::tunnels_cb_cls.

◆ handle_get_tunnels_end()

static void handle_get_tunnels_end ( void *  cls,
const struct GNUNET_MessageHeader msg 

Process a local reply about info on all tunnels, pass info to the user.

clsa struct GNUNET_CADET_ListTunnels *
messageMessage itself.

Definition at line 101 of file cadet_api_list_tunnels.c.

103 {
104  struct GNUNET_CADET_ListTunnels *lt = cls;
106  (void) msg;
108  lt->tunnels_cb (lt->tunnels_cb_cls,
109  NULL);
111 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
void * GNUNET_CADET_list_tunnels_cancel(struct GNUNET_CADET_ListTunnels *lt)
Cancel a monitor request.

References GNUNET_CADET_list_tunnels_cancel(), msg, GNUNET_CADET_ListTunnels::tunnels_cb, and GNUNET_CADET_ListTunnels::tunnels_cb_cls.

Here is the call graph for this function:

◆ reconnect()

static void reconnect ( void *  cls)

Reconnect to the service and try again.

clsa struct GNUNET_CADET_ListTunnels operation

Definition at line 151 of file cadet_api_list_tunnels.c.

152 {
153  struct GNUNET_CADET_ListTunnels *lt = cls;
158  lt),
159  GNUNET_MQ_hd_fixed_size (get_tunnels_end,
161  struct GNUNET_MessageHeader,
162  lt),
164  };
165  struct GNUNET_MessageHeader *msg;
166  struct GNUNET_MQ_Envelope *env;
168  lt->reconnect_task = NULL;
169  lt->mq = GNUNET_CLIENT_connect (lt->cfg,
170  "cadet",
171  handlers,
172  &error_handler,
173  lt);
174  if (NULL == lt->mq)
175  return;
176  env = GNUNET_MQ_msg (msg,
178  GNUNET_MQ_send (lt->mq,
179  env);
180 }
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static void error_handler(void *cls, enum GNUNET_MQ_Error error)
Function called on connection trouble.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static void get_tunnels(void *cls)
Call CADET's meta API, get all tunnels known to a peer.
Definition: gnunet-cadet.c:620
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1064
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:355
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
Local information about all tunnels of service.
End of local information about all tunnels of service.
Request local information about all tunnels of service.
struct GNUNET_MQ_Handle * mq
Message queue to talk to CADET service.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task to reconnect.
Message to inform the client about one of the tunnels in the service.
Definition: cadet.h:459
Message handler for a specific message type.
Header for all communications.

References GNUNET_CADET_ListTunnels::cfg, env, error_handler(), get_tunnels(), GNUNET_CLIENT_connect(), GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS, GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS_END, GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_msg, GNUNET_MQ_send(), handlers, GNUNET_CADET_ListTunnels::mq, msg, and GNUNET_CADET_ListTunnels::reconnect_task.

Referenced by error_handler(), and GNUNET_CADET_list_tunnels().

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

◆ error_handler()

static void error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 

Function called on connection trouble.


clsa struct GNUNET_CADET_ListTunnels
errorerror code from MQ

Definition at line 130 of file cadet_api_list_tunnels.c.

132 {
133  struct GNUNET_CADET_ListTunnels *lt = cls;
135  GNUNET_MQ_destroy (lt->mq);
136  lt->mq = NULL;
140  &reconnect,
141  lt);
142 }
static void reconnect(void *cls)
Reconnect to the service and try again.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
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
struct GNUNET_TIME_Relative GNUNET_TIME_randomized_backoff(struct GNUNET_TIME_Relative rt, struct GNUNET_TIME_Relative threshold)
Randomized exponential back-off, starting at 1 ms and going up by a factor of 2+r,...
Definition: time.c:635
One minute.
struct GNUNET_TIME_Relative backoff
Backoff for reconnect attempts.

References GNUNET_CADET_ListTunnels::backoff, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_randomized_backoff(), GNUNET_TIME_UNIT_MINUTES, GNUNET_CADET_ListTunnels::mq, reconnect(), and GNUNET_CADET_ListTunnels::reconnect_task.

Referenced by reconnect().

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