GNUnet  0.10.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__)

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 143 of file transport_api_manipulation.c.

References GNUNET_assert, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, GNUNET_TRANSPORT_ManipulationHandle::mq, reconnect(), GNUNET_TRANSPORT_ManipulationHandle::reconnect_delay, and GNUNET_TRANSPORT_ManipulationHandle::reconnect_task.

Referenced by GNUNET_TRANSPORT_manipulation_disconnect(), and mq_error_handler().

144 {
145  GNUNET_assert(NULL == h->reconnect_task);
146  if (NULL != h->mq)
147  {
148  GNUNET_MQ_destroy(h->mq);
149  h->mq = NULL;
150  }
151  h->reconnect_task =
153  &reconnect,
154  h);
156 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TIME_Relative reconnect_delay
Delay until we try to reconnect.
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:1237
struct GNUNET_MQ_Handle * mq
My client connection to the transport service.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static void reconnect(void *cls)
Try again to connect to transport service.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the task trying to reconnect to the service.
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 90 of file transport_api_manipulation.c.

References disconnect_and_schedule_reconnect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_YES, h, LOG, and GNUNET_TRANSPORT_ManipulationHandle::reconnecting.

Referenced by reconnect().

92 {
94 
96  "Error receiving from transport service, disconnecting temporarily.\n");
99 }
Handle for the transport service (includes all of the state for the transport service).
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.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
#define LOG(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
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 108 of file transport_api_manipulation.c.

References GNUNET_TRANSPORT_ManipulationHandle::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, LOG, GNUNET_TRANSPORT_ManipulationHandle::mq, mq_error_handler(), GNUNET_TRANSPORT_ManipulationHandle::reconnect_task, and GNUNET_TRANSPORT_ManipulationHandle::reconnecting.

Referenced by disconnect_and_schedule_reconnect(), and GNUNET_TRANSPORT_manipulation_connect().

109 {
113  };
114  struct GNUNET_MQ_Envelope *env;
115  struct StartMessage *s;
116 
117  h->reconnect_task = NULL;
119  "Connecting to transport service.\n");
120  GNUNET_assert(NULL == h->mq);
121  h->reconnecting = GNUNET_NO;
122  h->mq = GNUNET_CLIENT_connect(h->cfg,
123  "transport",
124  handlers,
126  h);
127  if (NULL == h->mq)
128  return;
129  env = GNUNET_MQ_msg(s,
131  GNUNET_MQ_send(h->mq,
132  env);
133 }
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:900
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_NO
Definition: gnunet_common.h:78
Handle for the transport service (includes all of the state for the transport service).
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
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...
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
struct GNUNET_MQ_Handle * mq
My client connection to the transport service.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_START
Message from the core saying that the transport server should start giving it messages.
Message handler for a specific message type.
const struct GNUNET_CONFIGURATION_Handle * cfg
My configuration.
Message from the transport service to the library asking to check if both processes agree about this ...
Definition: transport.h:91
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define 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:351
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the task trying to reconnect to the service.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
Here is the call graph for this function:
Here is the caller graph for this function: