GNUnet  0.11.x
Data Structures | Macros | Functions
transport_api_manipulation.c File Reference

library to access the low-level P2P IO service More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_arm_service.h"
#include "gnunet_hello_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_transport_service.h"
#include "transport.h"
Include dependency graph for transport_api_manipulation.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_TRANSPORT_ManipulationHandle
 Handle for the transport service (includes all of the state for the transport service). More...
 

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "transport-api", __VA_ARGS__)
 

Functions

static void disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_ManipulationHandle *h)
 Function that will schedule the job that will try to connect us again to the client. More...
 
static void mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. More...
 
static void reconnect (void *cls)
 Try again to connect to transport service. More...
 
void GNUNET_TRANSPORT_manipulation_set (struct GNUNET_TRANSPORT_ManipulationHandle *handle, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_ATS_Properties *prop, struct GNUNET_TIME_Relative delay_in, struct GNUNET_TIME_Relative delay_out)
 Set transport metrics for a peer and a direction. More...
 
struct GNUNET_TRANSPORT_ManipulationHandleGNUNET_TRANSPORT_manipulation_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Connect to the transport service. More...
 
void GNUNET_TRANSPORT_manipulation_disconnect (struct GNUNET_TRANSPORT_ManipulationHandle *handle)
 Disconnect from the transport service. More...
 

Detailed Description

library to access the low-level P2P IO service

Author
Christian Grothoff

Definition in file transport_api_manipulation.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "transport-api", __VA_ARGS__)

Definition at line 35 of file transport_api_manipulation.c.

Function Documentation

◆ disconnect_and_schedule_reconnect()

static void disconnect_and_schedule_reconnect ( struct GNUNET_TRANSPORT_ManipulationHandle h)
static

Function that will schedule the job that will try to connect us again to the client.

Parameters
htransport service to reconnect

Definition at line 145 of file transport_api_manipulation.c.

147 {
148  GNUNET_assert (NULL == h->reconnect_task);
149  if (NULL != h->mq)
150  {
152  h->mq = NULL;
153  }
154  h->reconnect_task =
155  GNUNET_SCHEDULER_add_delayed (h->reconnect_delay,
156  &reconnect,
157  h);
158  h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
159 }
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
Definition: arm_api.c:147
static void reconnect(void *cls)
Try again to connect to transport service.

References GNUNET_assert, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, h, GNUNET_ARM_Handle::mq, reconnect(), and GNUNET_ARM_Handle::reconnect_task.

Referenced by GNUNET_TRANSPORT_manipulation_disconnect(), and mq_error_handler().

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

◆ mq_error_handler()

static void mq_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.

Not every message queue implementation supports an error handler.

Parameters
clsclosure with the struct GNUNET_TRANSPORT_ManipulationHandle *
errorerror code

Definition at line 92 of file transport_api_manipulation.c.

94 {
96 
98  "Error receiving from transport service, disconnecting temporarily.\n");
99  h->reconnecting = GNUNET_YES;
101 }
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_ERROR_TYPE_DEBUG
Handle for the transport service (includes all of the state for the transport service).
#define LOG(kind,...)
static void disconnect_and_schedule_reconnect(struct GNUNET_TRANSPORT_ManipulationHandle *h)
Function that will schedule the job that will try to connect us again to the client.

References disconnect_and_schedule_reconnect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_YES, h, and LOG.

Referenced by reconnect().

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

◆ reconnect()

static void reconnect ( void *  cls)
static

Try again to connect to transport service.

Parameters
clsthe handle to the transport service

Definition at line 110 of file transport_api_manipulation.c.

111 {
115  };
116  struct GNUNET_MQ_Envelope *env;
117  struct StartMessage *s;
118 
119  h->reconnect_task = NULL;
121  "Connecting to transport service.\n");
122  GNUNET_assert (NULL == h->mq);
123  h->reconnecting = GNUNET_NO;
125  "transport",
126  handlers,
128  h);
129  if (NULL == h->mq)
130  return;
131  env = GNUNET_MQ_msg (s,
133  GNUNET_MQ_send (h->mq,
134  env);
135 }
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
@ GNUNET_NO
Definition: gnunet_common.h:94
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_MESSAGE_TYPE_TRANSPORT_START
Message from the core saying that the transport server should start giving it messages.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
Message handler for a specific message type.
Message from the transport service to the library asking to check if both processes agree about this ...
Definition: transport.h:92
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...

References GNUNET_ARM_Handle::cfg, env, GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_TRANSPORT_START, GNUNET_MQ_handler_end, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, h, handlers, LOG, GNUNET_ARM_Handle::mq, mq_error_handler(), and GNUNET_ARM_Handle::reconnect_task.

Referenced by disconnect_and_schedule_reconnect(), and GNUNET_TRANSPORT_manipulation_connect().

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