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

implementation of the gnunet_transport_communication_service.h API More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_transport_communication_service.h"
#include "gnunet_ats_transport_service.h"
#include "transport.h"
Include dependency graph for transport_api2_communication.c:

Go to the source code of this file.

Data Structures

struct  FlowControl
 Information we track per packet to enable flow control. More...
 
struct  AckPending
 Information we track per message to tell the transport about success or failures. More...
 
struct  GNUNET_TRANSPORT_CommunicatorHandle
 Opaque handle to the transport service for communicators. More...
 
struct  GNUNET_TRANSPORT_QueueHandle
 Handle returned to identify the internal data structure the transport API has created to manage a message queue to a particular peer. More...
 
struct  GNUNET_TRANSPORT_AddressIdentifier
 Internal representation of an address a communicator is currently providing for the transport service. More...
 

Macros

#define DEFAULT_MAX_QUEUE_LENGTH   16
 How many messages do we keep at most in the queue to the transport service before we start to drop (default, can be changed via the configuration file). More...
 

Functions

static void reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
 (re)connect our communicator to the transport service More...
 
static void send_add_address (struct GNUNET_TRANSPORT_AddressIdentifier *ai)
 Send message to the transport service about address ai being now available. More...
 
static void send_del_address (struct GNUNET_TRANSPORT_AddressIdentifier *ai)
 Send message to the transport service about address ai being no longer available. More...
 
static void send_add_queue (struct GNUNET_TRANSPORT_QueueHandle *qh)
 Send message to the transport service about queue qh being now available. More...
 
static void send_update_queue (struct GNUNET_TRANSPORT_QueueHandle *qh)
 Send message to the transport service about queue qh updated. More...
 
static void send_del_queue (struct GNUNET_TRANSPORT_QueueHandle *qh)
 Send message to the transport service about queue qh being no longer available. More...
 
static void disconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
 Disconnect from the transport service. More...
 
static void error_handler (void *cls, enum GNUNET_MQ_Error error)
 Function called on MQ errors. More...
 
static void handle_incoming_ack (void *cls, const struct GNUNET_TRANSPORT_IncomingMessageAck *incoming_ack)
 Transport service acknowledged a message we gave it (with flow control enabled). More...
 
static int check_create_queue (void *cls, const struct GNUNET_TRANSPORT_CreateQueue *cq)
 Transport service wants us to create a queue. More...
 
static void handle_create_queue (void *cls, const struct GNUNET_TRANSPORT_CreateQueue *cq)
 Transport service wants us to create a queue. More...
 
static int check_send_msg (void *cls, const struct GNUNET_TRANSPORT_SendMessageTo *smt)
 Transport service wants us to send a message. More...
 
static void send_ack (struct GNUNET_TRANSPORT_CommunicatorHandle *ch, int status, const struct GNUNET_PeerIdentity *receiver, uint64_t mid)
 Notify transport service about status of a message with mid sent to receiver. More...
 
static void send_ack_cb (void *cls)
 Message queue transmission by communicator was successful, notify transport service. More...
 
static void handle_send_msg (void *cls, const struct GNUNET_TRANSPORT_SendMessageTo *smt)
 Transport service wants us to send a message. More...
 
static int check_backchannel_incoming (void *cls, const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *bi)
 Transport service gives us backchannel message. More...
 
static void handle_backchannel_incoming (void *cls, const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *bi)
 Transport service gives us backchannel message. More...
 
struct GNUNET_TRANSPORT_CommunicatorHandleGNUNET_TRANSPORT_communicator_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *config_section, const char *addr_prefix, enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc, GNUNET_TRANSPORT_CommunicatorMqInit mq_init, void *mq_init_cls, GNUNET_TRANSPORT_CommunicatorNotify notify_cb, void *notify_cb_cls)
 Connect to the transport service. More...
 
void GNUNET_TRANSPORT_communicator_disconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
 Disconnect from the transport service. More...
 
int GNUNET_TRANSPORT_communicator_receive (struct GNUNET_TRANSPORT_CommunicatorHandle *ch, const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *msg, struct GNUNET_TIME_Relative expected_addr_validity, GNUNET_TRANSPORT_MessageCompletedCallback cb, void *cb_cls)
 Notify transport service that the communicator has received a message. More...
 
struct GNUNET_TRANSPORT_QueueHandleGNUNET_TRANSPORT_communicator_mq_add (struct GNUNET_TRANSPORT_CommunicatorHandle *ch, const struct GNUNET_PeerIdentity *peer, const char *address, uint32_t mtu, uint64_t q_len, uint32_t priority, enum GNUNET_NetworkType nt, enum GNUNET_TRANSPORT_ConnectionStatus cs, struct GNUNET_MQ_Handle *mq)
 Notify transport service that an MQ became available due to an "inbound" connection or because the communicator discovered the presence of another peer. More...
 
void GNUNET_TRANSPORT_communicator_mq_update (struct GNUNET_TRANSPORT_CommunicatorHandle *ch, const struct GNUNET_TRANSPORT_QueueHandle *u_qh, uint64_t q_len, uint32_t priority)
 Notify transport service that an MQ was updated. More...
 
void GNUNET_TRANSPORT_communicator_mq_del (struct GNUNET_TRANSPORT_QueueHandle *qh)
 Notify transport service that an MQ became unavailable due to a disconnect or timeout. More...
 
struct GNUNET_TRANSPORT_AddressIdentifierGNUNET_TRANSPORT_communicator_address_add (struct GNUNET_TRANSPORT_CommunicatorHandle *ch, const char *address, enum GNUNET_NetworkType nt, struct GNUNET_TIME_Relative expiration)
 Notify transport service about an address that this communicator provides for this peer. More...
 
void GNUNET_TRANSPORT_communicator_address_remove (struct GNUNET_TRANSPORT_AddressIdentifier *ai)
 Notify transport service about an address that this communicator no longer provides for this peer. More...
 
void GNUNET_TRANSPORT_communicator_address_remove_all (struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
 Notify transport service that this communicator no longer provides all its addresses for this peer. More...
 
void GNUNET_TRANSPORT_communicator_notify (struct GNUNET_TRANSPORT_CommunicatorHandle *ch, const struct GNUNET_PeerIdentity *pid, const char *comm, const struct GNUNET_MessageHeader *header)
 The communicator asks the transport service to route a message via a different path to another communicator service at another peer. More...
 

Detailed Description

implementation of the gnunet_transport_communication_service.h API

Author
Christian Grothoff

Definition in file transport_api2_communication.c.

Macro Definition Documentation

◆ DEFAULT_MAX_QUEUE_LENGTH

#define DEFAULT_MAX_QUEUE_LENGTH   16

How many messages do we keep at most in the queue to the transport service before we start to drop (default, can be changed via the configuration file).

Definition at line 39 of file transport_api2_communication.c.

Referenced by GNUNET_TRANSPORT_communicator_connect().

Function Documentation

◆ reconnect()

static void reconnect ( struct GNUNET_TRANSPORT_CommunicatorHandle ch)
static

(re)connect our communicator to the transport service

Parameters
chhandle to reconnect

Definition at line 753 of file transport_api2_communication.c.

References GNUNET_TRANSPORT_CommunicatorHandle::addr_prefix, ai, GNUNET_TRANSPORT_CommunicatorHandle::ai_head, GNUNET_TRANSPORT_CommunicatorHandle::cc, GNUNET_TRANSPORT_CommunicatorHandle::cfg, env, error_handler(), GNUNET_CLIENT_connect(), GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING, GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK, GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TRANSPORT_CommunicatorHandle::mq, GNUNET_TRANSPORT_QueueHandle::next, GNUNET_TRANSPORT_AddressIdentifier::next, GNUNET_TRANSPORT_CommunicatorHandle::queue_head, send_add_address(), send_add_queue(), and send_msg().

Referenced by error_handler(), GNUNET_TRANSPORT_communicator_connect(), and handle_incoming_ack().

754 {
756  { GNUNET_MQ_hd_fixed_size (incoming_ack,
758  struct GNUNET_TRANSPORT_IncomingMessageAck,
759  ch),
760  GNUNET_MQ_hd_var_size (create_queue,
762  struct GNUNET_TRANSPORT_CreateQueue,
763  ch),
766  struct GNUNET_TRANSPORT_SendMessageTo,
767  ch),
769  backchannel_incoming,
771  struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming,
772  ch),
774  struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam;
775  struct GNUNET_MQ_Envelope *env;
776 
777  ch->mq =
778  GNUNET_CLIENT_connect (ch->cfg, "transport", handlers, &error_handler, ch);
779  if (NULL == ch->mq)
780  return;
781  env = GNUNET_MQ_msg_extra (cam,
782  strlen (ch->addr_prefix) + 1,
784  cam->cc = htonl ((uint32_t) ch->cc);
785  memcpy (&cam[1], ch->addr_prefix, strlen (ch->addr_prefix) + 1);
786  GNUNET_MQ_send (ch->mq, env);
787  for (struct GNUNET_TRANSPORT_AddressIdentifier *ai = ch->ai_head; NULL != ai;
788  ai = ai->next)
790  for (struct GNUNET_TRANSPORT_QueueHandle *qh = ch->queue_head; NULL != qh;
791  qh = qh->next)
792  send_add_queue (qh);
793 }
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG
transport tells communicator it wants to transmit
static void send_add_queue(struct GNUNET_TRANSPORT_QueueHandle *qh)
Send message to the transport service about queue qh being now available.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE
transport tells communicator it wants a queue
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:1063
struct GNUNET_TRANSPORT_QueueHandle * next
Kept in a DLL.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
struct GNUNET_TRANSPORT_AddressIdentifier * next
Kept in a DLL.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING
Transport signalling incoming backchannel message to a communicator.
struct GNUNET_TRANSPORT_QueueHandle * queue_head
DLL of queues we offer.
static void error_handler(void *cls, enum GNUNET_MQ_Error error)
Function called on MQ errors.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK
transport acknowledges processing an incoming message
const char * addr_prefix
Address prefix to use.
Message handler for a specific message type.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static void send_msg(void *cls)
Function called to notify a client about the socket begin ready to queue more data.
struct GNUNET_MQ_Handle * mq
Queue to talk to the transport service.
struct GNUNET_TRANSPORT_AddressIdentifier * ai_head
Head of DLL of addresses this communicator offers to the transport service.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR
Message sent to indicate to the transport which address prefix is supported by a communicator.
static void send_add_address(struct GNUNET_TRANSPORT_AddressIdentifier *ai)
Send message to the transport service about address ai being now available.
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
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc
Characteristics of the communicator.
Handle returned to identify the internal data structure the transport API has created to manage a mes...
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
Internal representation of an address a communicator is currently providing for the transport service...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_add_address()

static void send_add_address ( struct GNUNET_TRANSPORT_AddressIdentifier ai)
static

Send message to the transport service about address ai being now available.

Parameters
aiaddress to add

Definition at line 356 of file transport_api2_communication.c.

References GNUNET_TRANSPORT_AddressIdentifier::address, GNUNET_TRANSPORT_AddressIdentifier::ch, env, GNUNET_TRANSPORT_AddressIdentifier::expiration, GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TIME_relative_hton(), GNUNET_TRANSPORT_CommunicatorHandle::mq, and GNUNET_TRANSPORT_AddressIdentifier::nt.

Referenced by GNUNET_TRANSPORT_communicator_address_add(), and reconnect().

357 {
358  struct GNUNET_MQ_Envelope *env;
359  struct GNUNET_TRANSPORT_AddAddressMessage *aam;
360 
361  if (NULL == ai->ch->mq)
362  return;
363  env = GNUNET_MQ_msg_extra (aam,
364  strlen (ai->address) + 1,
366  aam->expiration = GNUNET_TIME_relative_hton (ai->expiration);
367  aam->nt = htonl ((uint32_t) ai->nt);
368  memcpy (&aam[1], ai->address, strlen (ai->address) + 1);
369  GNUNET_MQ_send (ai->ch->mq, env);
370 }
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Transport handle where the address was added.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
struct GNUNET_TIME_Relative expiration
When does the address expire? (Expected lifetime of the address.)
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:625
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
Queue to talk to the transport service.
enum GNUNET_NetworkType nt
Network type for the address.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS
inform transport to add an address of this peer
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_del_address()

static void send_del_address ( struct GNUNET_TRANSPORT_AddressIdentifier ai)
static

Send message to the transport service about address ai being no longer available.

Parameters
aiaddress to delete

Definition at line 380 of file transport_api2_communication.c.

References GNUNET_TRANSPORT_AddressIdentifier::aid, GNUNET_TRANSPORT_AddressIdentifier::ch, env, GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS, GNUNET_MQ_msg, GNUNET_MQ_send(), and GNUNET_TRANSPORT_CommunicatorHandle::mq.

Referenced by GNUNET_TRANSPORT_communicator_address_remove().

381 {
382  struct GNUNET_MQ_Envelope *env;
383  struct GNUNET_TRANSPORT_DelAddressMessage *dam;
384 
385  if (NULL == ai->ch->mq)
386  return;
388  dam->aid = htonl (ai->aid);
389  GNUNET_MQ_send (ai->ch->mq, env);
390 }
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Transport handle where the address was added.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS
inform transport to delete an address of this peer
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
Queue to talk to the transport service.
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
uint32_t aid
Internal UUID for the address used in communication with the transport service.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_add_queue()

static void send_add_queue ( struct GNUNET_TRANSPORT_QueueHandle qh)
static

Send message to the transport service about queue qh being now available.

Parameters
qhqueue to add

Definition at line 400 of file transport_api2_communication.c.

References GNUNET_TRANSPORT_QueueHandle::address, GNUNET_TRANSPORT_QueueHandle::ch, GNUNET_TRANSPORT_QueueHandle::cs, env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_htonll(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TRANSPORT_CommunicatorHandle::mq, GNUNET_TRANSPORT_QueueHandle::mtu, GNUNET_TRANSPORT_QueueHandle::nt, GNUNET_TRANSPORT_QueueHandle::peer, GNUNET_TRANSPORT_QueueHandle::priority, GNUNET_TRANSPORT_QueueHandle::q_len, and GNUNET_TRANSPORT_QueueHandle::queue_id.

Referenced by GNUNET_TRANSPORT_communicator_mq_add(), and reconnect().

401 {
402  struct GNUNET_MQ_Envelope *env;
403  struct GNUNET_TRANSPORT_AddQueueMessage *aqm;
404 
405  if (NULL == qh->ch->mq)
406  return;
408  "Sending `GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP` message\n");
409  env = GNUNET_MQ_msg_extra (aqm,
410  strlen (qh->address) + 1,
412  aqm->qid = htonl (qh->queue_id);
413  aqm->receiver = qh->peer;
414  aqm->nt = htonl ((uint32_t) qh->nt);
415  aqm->mtu = htonl (qh->mtu);
416  aqm->q_len = GNUNET_htonll (qh->q_len);
417  aqm->priority = htonl (qh->priority);
418  aqm->cs = htonl ((uint32_t) qh->cs);
419  memcpy (&aqm[1], qh->address, strlen (qh->address) + 1);
420  GNUNET_MQ_send (qh->ch->mq, env);
421 }
enum GNUNET_NetworkType nt
Network type of the communciation queue.
char * address
Address used by the communication queue.
uint32_t queue_id
ID for this queue when talking to the transport service.
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Handle this queue belongs to.
enum GNUNET_TRANSPORT_ConnectionStatus cs
Communication status of the queue.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP
inform transport that a queue was setup to talk to some peer
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:36
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
Queue to talk to the transport service.
struct GNUNET_PeerIdentity peer
Which peer we can communciate with.
#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:355
uint32_t mtu
Maximum transmission unit for the queue.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_update_queue()

static void send_update_queue ( struct GNUNET_TRANSPORT_QueueHandle qh)
static

Send message to the transport service about queue qh updated.

Parameters
qhqueue to add

Definition at line 431 of file transport_api2_communication.c.

References GNUNET_TRANSPORT_QueueHandle::ch, GNUNET_TRANSPORT_QueueHandle::cs, env, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_UPDATE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_TRANSPORT_CommunicatorHandle::mq, GNUNET_TRANSPORT_QueueHandle::mtu, GNUNET_TRANSPORT_QueueHandle::nt, GNUNET_TRANSPORT_QueueHandle::peer, GNUNET_TRANSPORT_QueueHandle::priority, GNUNET_TRANSPORT_QueueHandle::q_len, and GNUNET_TRANSPORT_QueueHandle::queue_id.

Referenced by GNUNET_TRANSPORT_communicator_mq_update().

432 {
433  struct GNUNET_MQ_Envelope *env;
434  struct GNUNET_TRANSPORT_UpdateQueueMessage *uqm;
435 
436  if (NULL == qh->ch->mq)
437  return;
439  uqm->qid = htonl (qh->queue_id);
440  uqm->receiver = qh->peer;
441  uqm->nt = htonl ((uint32_t) qh->nt);
442  uqm->mtu = htonl (qh->mtu);
443  uqm->q_len = GNUNET_htonll (qh->q_len);
444  uqm->priority = htonl (qh->priority);
445  uqm->cs = htonl ((uint32_t) qh->cs);
446  GNUNET_MQ_send (qh->ch->mq, env);
447 }
enum GNUNET_NetworkType nt
Network type of the communciation queue.
uint32_t queue_id
ID for this queue when talking to the transport service.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_UPDATE
inform transport that a queue was updated
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Handle this queue belongs to.
enum GNUNET_TRANSPORT_ConnectionStatus cs
Communication status of the queue.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:36
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
Queue to talk to the transport service.
struct GNUNET_PeerIdentity peer
Which peer we can communciate with.
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
uint32_t mtu
Maximum transmission unit for the queue.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_del_queue()

static void send_del_queue ( struct GNUNET_TRANSPORT_QueueHandle qh)
static

Send message to the transport service about queue qh being no longer available.

Parameters
qhqueue to delete

Definition at line 457 of file transport_api2_communication.c.

References GNUNET_TRANSPORT_QueueHandle::ch, env, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_TRANSPORT_CommunicatorHandle::mq, GNUNET_TRANSPORT_QueueHandle::peer, and GNUNET_TRANSPORT_QueueHandle::queue_id.

Referenced by GNUNET_TRANSPORT_communicator_mq_del().

458 {
459  struct GNUNET_MQ_Envelope *env;
460  struct GNUNET_TRANSPORT_DelQueueMessage *dqm;
461 
462  if (NULL == qh->ch->mq)
463  return;
465  dqm->qid = htonl (qh->queue_id);
466  dqm->receiver = qh->peer;
467  GNUNET_MQ_send (qh->ch->mq, env);
468 }
uint32_t queue_id
ID for this queue when talking to the transport service.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Handle this queue belongs to.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
Queue to talk to the transport service.
struct GNUNET_PeerIdentity peer
Which peer we can communciate with.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN
inform transport that a queue was torn down
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ disconnect()

static void disconnect ( struct GNUNET_TRANSPORT_CommunicatorHandle ch)
static

Disconnect from the transport service.

Purges all flow control entries as we will no longer receive the ACKs. Purges the ack pending entries as the transport will no longer expect the confirmations.

Parameters
chservice to disconnect from

Definition at line 480 of file transport_api2_communication.c.

References GNUNET_TRANSPORT_CommunicatorHandle::ap_head, GNUNET_TRANSPORT_CommunicatorHandle::ap_tail, GNUNET_TRANSPORT_CommunicatorHandle::fc_head, GNUNET_TRANSPORT_CommunicatorHandle::fc_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SYSERR, GNUNET_TRANSPORT_CommunicatorHandle::mq, FlowControl::next, and AckPending::next.

Referenced by error_handler(), GNUNET_TRANSPORT_communicator_disconnect(), and handle_incoming_ack().

481 {
482  struct FlowControl *fcn;
483  struct AckPending *apn;
484 
485  for (struct FlowControl *fc = ch->fc_head; NULL != fc; fc = fcn)
486  {
487  fcn = fc->next;
489  fc->cb (fc->cb_cls, GNUNET_SYSERR);
490  GNUNET_free (fc);
491  }
492  for (struct AckPending *ap = ch->ap_head; NULL != ap; ap = apn)
493  {
494  apn = ap->next;
496  GNUNET_free (ap);
497  }
498  if (NULL == ch->mq)
499  return;
500  GNUNET_MQ_destroy (ch->mq);
501  ch->mq = NULL;
502 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Information we track per packet to enable flow control.
struct AckPending * ap_tail
DLL of messages awaiting transmission confirmation (ack).
struct FlowControl * fc_head
DLL of messages awaiting flow control confirmation (ack).
Information we track per message to tell the transport about success or failures. ...
struct GNUNET_MQ_Handle * mq
Queue to talk to the transport service.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
struct FlowControl * fc_tail
DLL of messages awaiting flow control confirmation (ack).
struct AckPending * next
Kept in a DLL.
struct FlowControl * next
Kept in a DLL.
struct AckPending * ap_head
DLL of messages awaiting transmission confirmation (ack).
#define GNUNET_free(ptr)
Wrapper around free.
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 MQ errors.

Definition at line 509 of file transport_api2_communication.c.

References ch, disconnect(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, and reconnect().

Referenced by reconnect().

510 {
512 
514  "MQ failure %d, reconnecting to transport service.\n",
515  error);
516  disconnect (ch);
517  /* TODO: maybe do this with exponential backoff/delay */
518  reconnect (ch);
519 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
Opaque handle to the transport service for communicators.
static void disconnect(struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
Disconnect from the transport service.
static void reconnect(struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
(re)connect our communicator to the transport service
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_incoming_ack()

static void handle_incoming_ack ( void *  cls,
const struct GNUNET_TRANSPORT_IncomingMessageAck *  incoming_ack 
)
static

Transport service acknowledged a message we gave it (with flow control enabled).

Tell the communicator.

Parameters
clsour struct GNUNET_TRANSPORT_CommunicatorHandle *
incoming_ackthe ack

Definition at line 530 of file transport_api2_communication.c.

References ch, disconnect(), GNUNET_TRANSPORT_CommunicatorHandle::fc_head, GNUNET_TRANSPORT_CommunicatorHandle::fc_tail, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_OK, FlowControl::next, and reconnect().

533 {
535 
536  for (struct FlowControl *fc = ch->fc_head; NULL != fc; fc = fc->next)
537  {
538  if ((fc->id == incoming_ack->fc_id) &&
539  (0 == memcmp (&fc->sender,
540  &incoming_ack->sender,
541  sizeof(struct GNUNET_PeerIdentity))))
542  {
544  fc->cb (fc->cb_cls, GNUNET_OK);
545  GNUNET_free (fc);
546  return;
547  }
548  }
549  GNUNET_break (0);
550  disconnect (ch);
551  /* TODO: maybe do this with exponential backoff/delay */
552  reconnect (ch);
553 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Information we track per packet to enable flow control.
Opaque handle to the transport service for communicators.
static void disconnect(struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
Disconnect from the transport service.
struct FlowControl * fc_head
DLL of messages awaiting flow control confirmation (ack).
static void reconnect(struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
(re)connect our communicator to the transport service
The identity of the host (wraps the signing key of the peer).
struct FlowControl * fc_tail
DLL of messages awaiting flow control confirmation (ack).
struct FlowControl * next
Kept in a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ check_create_queue()

static int check_create_queue ( void *  cls,
const struct GNUNET_TRANSPORT_CreateQueue *  cq 
)
static

Transport service wants us to create a queue.

Check if cq is well-formed.

Parameters
clsour struct GNUNET_TRANSPORT_CommunicatorHandle *
cqthe queue creation request
Returns
GNUNET_OK if smt is well-formed

Definition at line 565 of file transport_api2_communication.c.

References GNUNET_MQ_check_zero_termination, and GNUNET_OK.

566 {
567  (void) cls;
569  return GNUNET_OK;
570 }
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...

◆ handle_create_queue()

static void handle_create_queue ( void *  cls,
const struct GNUNET_TRANSPORT_CreateQueue *  cq 
)
static

Transport service wants us to create a queue.

Tell the communicator.

Parameters
clsour struct GNUNET_TRANSPORT_CommunicatorHandle *
cqthe queue creation request

Definition at line 580 of file transport_api2_communication.c.

References ch, env, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_OK, GNUNET_TRANSPORT_CommunicatorHandle::mq, GNUNET_TRANSPORT_CommunicatorHandle::mq_init, and GNUNET_TRANSPORT_CommunicatorHandle::mq_init_cls.

581 {
583  const char *addr = (const char *) &cq[1];
584  struct GNUNET_TRANSPORT_CreateQueueResponse *cqr;
585  struct GNUNET_MQ_Envelope *env;
586 
587  if (GNUNET_OK != ch->mq_init (ch->mq_init_cls, &cq->receiver, addr))
588  {
590  "Address `%s' invalid for this communicator\n",
591  addr);
593  }
594  else
595  {
597  }
598  cqr->request_id = cq->request_id;
599  GNUNET_MQ_send (ch->mq, env);
600 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK
Response from communicator: will try to create queue.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
Opaque handle to the transport service for communicators.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
Queue to talk to the transport service.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL
Response from communicator: address bogus, will not try to create queue.
#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:355
GNUNET_TRANSPORT_CommunicatorMqInit mq_init
Function to call when the transport service wants us to initiate a communication channel with another...
Here is the call graph for this function:

◆ check_send_msg()

static int check_send_msg ( void *  cls,
const struct GNUNET_TRANSPORT_SendMessageTo *  smt 
)
static

Transport service wants us to send a message.

Check if smt is well-formed.

Parameters
clsour struct GNUNET_TRANSPORT_CommunicatorHandle *
smtthe transmission request
Returns
GNUNET_OK if smt is well-formed

Definition at line 612 of file transport_api2_communication.c.

References GNUNET_MQ_check_boxed_message, and GNUNET_OK.

613 {
614  (void) cls;
616  return GNUNET_OK;
617 }
#define GNUNET_MQ_check_boxed_message(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...

◆ send_ack()

static void send_ack ( struct GNUNET_TRANSPORT_CommunicatorHandle ch,
int  status,
const struct GNUNET_PeerIdentity receiver,
uint64_t  mid 
)
static

Notify transport service about status of a message with mid sent to receiver.

Parameters
chhandle
statusGNUNET_OK on success, GNUNET_SYSERR on failure
receiverwhich peer was the receiver
midmessage that the ack is about

Definition at line 630 of file transport_api2_communication.c.

References env, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_TRANSPORT_CommunicatorHandle::mq, and receiver().

Referenced by handle_send_msg(), and send_ack_cb().

634 {
635  struct GNUNET_MQ_Envelope *env;
636  struct GNUNET_TRANSPORT_SendMessageToAck *ack;
637 
639  ack->status = htonl (status);
640  ack->mid = mid;
641  ack->receiver = *receiver;
642  GNUNET_MQ_send (ch->mq, env);
643 }
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
uint16_t status
See PRISM_STATUS_*-constants.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK
communicator tells transports that message was sent
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
void receiver(void *cls, const void *buf, size_t available, const struct sockaddr *addr, socklen_t addrlen, int errCode)
Callback to read from the SOCKS5 proxy.
Definition: socks.c:329
struct GNUNET_MQ_Handle * mq
Queue to talk to the transport service.
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_ack_cb()

static void send_ack_cb ( void *  cls)
static

Message queue transmission by communicator was successful, notify transport service.

Parameters
clsan struct AckPending *

Definition at line 653 of file transport_api2_communication.c.

References GNUNET_TRANSPORT_CommunicatorHandle::ap_head, GNUNET_TRANSPORT_CommunicatorHandle::ap_tail, AckPending::ch, ch, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_OK, AckPending::mid, AckPending::receiver, and send_ack().

Referenced by handle_send_msg().

654 {
655  struct AckPending *ap = cls;
657 
659  send_ack (ch, GNUNET_OK, &ap->receiver, ap->mid);
660  GNUNET_free (ap);
661 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct GNUNET_PeerIdentity receiver
Which peer is this about?
Opaque handle to the transport service for communicators.
struct AckPending * ap_tail
DLL of messages awaiting transmission confirmation (ack).
Information we track per message to tell the transport about success or failures. ...
static void send_ack(struct GNUNET_TRANSPORT_CommunicatorHandle *ch, int status, const struct GNUNET_PeerIdentity *receiver, uint64_t mid)
Notify transport service about status of a message with mid sent to receiver.
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Communicator this entry belongs to.
uint64_t mid
More-or-less unique ID for the message.
struct AckPending * ap_head
DLL of messages awaiting transmission confirmation (ack).
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_send_msg()

static void handle_send_msg ( void *  cls,
const struct GNUNET_TRANSPORT_SendMessageTo *  smt 
)
static

Transport service wants us to send a message.

Tell the communicator.

Parameters
clsour struct GNUNET_TRANSPORT_CommunicatorHandle *
smtthe transmission request

Definition at line 671 of file transport_api2_communication.c.

References GNUNET_TRANSPORT_CommunicatorHandle::ap_head, GNUNET_TRANSPORT_CommunicatorHandle::ap_tail, AckPending::ch, ch, env, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_MQ_msg_copy(), GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_new, GNUNET_NO, mh, AckPending::mid, GNUNET_TRANSPORT_QueueHandle::mq, GNUNET_TRANSPORT_QueueHandle::next, GNUNET_TRANSPORT_QueueHandle::peer, GNUNET_TRANSPORT_CommunicatorHandle::queue_head, GNUNET_TRANSPORT_QueueHandle::queue_id, AckPending::receiver, send_ack(), and send_ack_cb().

672 {
674  const struct GNUNET_MessageHeader *mh;
675  struct GNUNET_MQ_Envelope *env;
676  struct AckPending *ap;
677  struct GNUNET_TRANSPORT_QueueHandle *qh;
678 
679  for (qh = ch->queue_head; NULL != qh; qh = qh->next)
680  if ((qh->queue_id == smt->qid) &&
681  (0 == memcmp (&qh->peer,
682  &smt->receiver,
683  sizeof(struct GNUNET_PeerIdentity))))
684  break;
685  if (NULL == qh)
686  {
687  /* queue is already gone, tell transport this one failed */
689  "Transmission failed, queue no longer exists.\n");
690  send_ack (ch, GNUNET_NO, &smt->receiver, smt->mid);
691  return;
692  }
693  ap = GNUNET_new (struct AckPending);
694  ap->ch = ch;
695  ap->receiver = smt->receiver;
696  ap->mid = smt->mid;
698  mh = (const struct GNUNET_MessageHeader *) &smt[1];
699  env = GNUNET_MQ_msg_copy (mh);
701  GNUNET_MQ_send (qh->mq, env);
702 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
Definition: mq.c:666
struct GNUNET_PeerIdentity receiver
Which peer is this about?
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static void send_ack_cb(void *cls)
Message queue transmission by communicator was successful, notify transport service.
uint32_t queue_id
ID for this queue when talking to the transport service.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
struct GNUNET_TRANSPORT_QueueHandle * next
Kept in a DLL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_TRANSPORT_QueueHandle * queue_head
DLL of queues we offer.
Opaque handle to the transport service for communicators.
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore...
Definition: mq.c:787
struct AckPending * ap_tail
DLL of messages awaiting transmission confirmation (ack).
Information we track per message to tell the transport about success or failures. ...
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_PeerIdentity peer
Which peer we can communciate with.
The identity of the host (wraps the signing key of the peer).
#define GNUNET_log(kind,...)
static void send_ack(struct GNUNET_TRANSPORT_CommunicatorHandle *ch, int status, const struct GNUNET_PeerIdentity *receiver, uint64_t mid)
Notify transport service about status of a message with mid sent to receiver.
struct GNUNET_MQ_Handle * mq
The queue itself.
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Communicator this entry belongs to.
Header for all communications.
uint64_t mid
More-or-less unique ID for the message.
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
Handle returned to identify the internal data structure the transport API has created to manage a mes...
struct AckPending * ap_head
DLL of messages awaiting transmission confirmation (ack).
Here is the call graph for this function:

◆ check_backchannel_incoming()

static int check_backchannel_incoming ( void *  cls,
const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *  bi 
)
static

Transport service gives us backchannel message.

Check if bi is well-formed.

Parameters
clsour struct GNUNET_TRANSPORT_CommunicatorHandle *
bithe backchannel message
Returns
GNUNET_OK if smt is well-formed

Definition at line 714 of file transport_api2_communication.c.

References GNUNET_MQ_check_boxed_message, and GNUNET_OK.

717 {
718  (void) cls;
720  return GNUNET_OK;
721 }
#define GNUNET_MQ_check_boxed_message(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...

◆ handle_backchannel_incoming()

static void handle_backchannel_incoming ( void *  cls,
const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *  bi 
)
static

Transport service gives us backchannel message.

Handle it.

Parameters
clsour struct GNUNET_TRANSPORT_CommunicatorHandle *
bithe backchannel message

Definition at line 731 of file transport_api2_communication.c.

References _, ch, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_TRANSPORT_CommunicatorHandle::notify_cb, and GNUNET_TRANSPORT_CommunicatorHandle::notify_cb_cls.

734 {
736  if (NULL != ch->notify_cb)
737  ch->notify_cb (ch->notify_cb_cls,
738  &bi->pid,
739  (const struct GNUNET_MessageHeader *) &bi[1]);
740  else
741  GNUNET_log (
743  _ ("Dropped backchanel message: handler not provided by communicator\n"));
744 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
GNUNET_TRANSPORT_CommunicatorNotify notify_cb
Function to call when the transport service receives messages for a communicator (i.e.
Opaque handle to the transport service for communicators.
#define _(String)
GNU gettext support macro.
Definition: platform.h:184
#define GNUNET_log(kind,...)
Header for all communications.