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

Functions

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

Author
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 
)
static

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

Parameters
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;
83
84 td.peer = info->destination;
85 td.channels = ntohl (info->channels);
86 td.connections = ntohl (info->connections);
87 td.estate = ntohs (info->estate);
88 td.cstate = ntohs (info->cstate);
90 &td);
91}
#define info
void * tunnels_cb_cls
Info callback closure for tunnels_cb.
GNUNET_CADET_TunnelsCB tunnels_cb
Monitor callback.
Details about a tunnel managed by CADET.
struct GNUNET_PeerIdentity peer
Target of the tunnel.

References GNUNET_CADET_TunnelDetails::channels, GNUNET_CADET_TunnelDetails::connections, GNUNET_CADET_TunnelDetails::cstate, GNUNET_CADET_TunnelDetails::estate, info, 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 
)
static

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

Parameters
clsa struct GNUNET_CADET_ListTunnels *
msgMessage itself.

Definition at line 101 of file cadet_api_list_tunnels.c.

103{
104 struct GNUNET_CADET_ListTunnels *lt = cls;
105
106 (void) msg;
107
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)
static

Reconnect to the service and try again.

Parameters
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,
162 lt),
164 };
166 struct GNUNET_MQ_Envelope *env;
167
168 lt->reconnect_task = NULL;
169 lt->mq = GNUNET_CLIENT_connect (lt->cfg,
170 "cadet",
171 handlers,
173 lt);
174 if (NULL == lt->mq)
175 return;
178 GNUNET_MQ_send (lt->mq,
179 env);
180}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
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 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:1060
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:305
#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:76
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS
Local information about all tunnels of service.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS_END
End of local information about all tunnels of service.
#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_REQUEST_INFO_TUNNELS
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:458
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 
)
static

Function called on connection trouble.

Reconnects.

Parameters
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;
134
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:700
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:1277
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:834
#define GNUNET_TIME_UNIT_MINUTES
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: