GNUnet 0.21.1
transport_api2_communication.c File Reference

implementation of the gnunet_transport_communication_service.h API More...

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, uint32_t qid)
 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 a 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 38 of file transport_api2_communication.c.

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 783 of file transport_api2_communication.c.

784{
786 { GNUNET_MQ_hd_fixed_size (incoming_ack,
789 ch),
790 GNUNET_MQ_hd_var_size (create_queue,
793 ch),
794 GNUNET_MQ_hd_var_size (send_msg,
797 ch),
799 backchannel_incoming,
802 ch),
805 struct GNUNET_MQ_Envelope *env;
806
807 ch->mq =
808 GNUNET_CLIENT_connect (ch->cfg, "transport", handlers, &error_handler, ch);
809 if (NULL == ch->mq)
810 return;
812 strlen (ch->addr_prefix) + 1,
814 cam->cc = htonl ((uint32_t) ch->cc);
815 memcpy (&cam[1], ch->addr_prefix, strlen (ch->addr_prefix) + 1);
817 for (struct GNUNET_TRANSPORT_AddressIdentifier *ai = ch->ai_head; NULL != ai;
818 ai = ai->next)
820 for (struct GNUNET_TRANSPORT_QueueHandle *qh = ch->queue_head; NULL != qh;
821 qh = qh->next)
822 send_add_queue (qh);
823}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
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:1057
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:304
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#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:63
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK
transport acknowledges processing an incoming message
#define GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR
Message sent to indicate to the transport which address prefix is supported by a communicator.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE
transport tells communicator it wants a queue
#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING
Transport signalling incoming backchannel message to a communicator.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG
transport tells communicator it wants to transmit
struct GNUNET_MQ_Handle * mq
Message Queue for the channel (which we are implementing).
Definition: cadet.h:142
Message handler for a specific message type.
Internal representation of an address a communicator is currently providing for the transport service...
struct GNUNET_TRANSPORT_AddressIdentifier * next
Kept in a DLL.
uint32_t cc
NBO encoding of enum GNUNET_TRANSPORT_CommunicatorCharacteristics
Definition: transport.h:272
Message from transport to communicator passing along a backchannel message from the given peer pid.
Definition: transport.h:650
Transport tells communicator that it wants a new queue.
Definition: transport.h:516
Transport informs us about being done with an incoming message.
Definition: transport.h:369
Handle returned to identify the internal data structure the transport API has created to manage a mes...
Inform communicator about transport's desire to send a message.
Definition: transport.h:558
static void error_handler(void *cls, enum GNUNET_MQ_Error error)
Function called on MQ errors.
static void send_add_address(struct GNUNET_TRANSPORT_AddressIdentifier *ai)
Send message to the transport service about address ai being now available.
static void send_add_queue(struct GNUNET_TRANSPORT_QueueHandle *qh)
Send message to the transport service about queue qh being now available.

References ai, GNUNET_TRANSPORT_CommunicatorAvailableMessage::cc, ch, 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(), handlers, GNUNET_CADET_Channel::mq, GNUNET_TRANSPORT_AddressIdentifier::next, send_add_address(), and send_add_queue().

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

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 360 of file transport_api2_communication.c.

361{
362 struct GNUNET_MQ_Envelope *env;
364
365 if (NULL == ai->ch->mq)
366 return;
368 strlen (ai->address) + 1,
371 aam->nt = htonl ((uint32_t) ai->nt);
372 memcpy (&aam[1], ai->address, strlen (ai->address) + 1);
374}
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS
inform transport to add an address of this peer
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:618
Add address to the list.
Definition: transport.h:282
struct GNUNET_TIME_RelativeNBO expiration
When does the address expire?
Definition: transport.h:296
uint32_t nt
An enum GNUNET_NetworkType in NBO.
Definition: transport.h:301
struct GNUNET_TIME_Relative expiration
When does the address expire? (Expected lifetime of the address.)
enum GNUNET_NetworkType nt
Network type for the address.
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Transport handle where the address was added.
struct GNUNET_MQ_Handle * mq
Queue to talk to the transport service.

References GNUNET_TRANSPORT_AddressIdentifier::address, ai, GNUNET_TRANSPORT_AddressIdentifier::ch, env, GNUNET_TRANSPORT_AddAddressMessage::expiration, 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, GNUNET_TRANSPORT_AddAddressMessage::nt, and GNUNET_TRANSPORT_AddressIdentifier::nt.

Referenced by GNUNET_TRANSPORT_communicator_address_add(), and reconnect().

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 384 of file transport_api2_communication.c.

385{
386 struct GNUNET_MQ_Envelope *env;
388
389 if (NULL == ai->ch->mq)
390 return;
392 dam->aid = htonl (ai->aid);
394}
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS
inform transport to delete an address of this peer
uint32_t aid
Internal UUID for the address used in communication with the transport service.
Remove address from the list.
Definition: transport.h:311
uint32_t aid
Address identifier.
Definition: transport.h:320

References ai, GNUNET_TRANSPORT_DelAddressMessage::aid, 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().

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 404 of file transport_api2_communication.c.

405{
406 struct GNUNET_MQ_Envelope *env;
408
409 if (NULL == qh->ch->mq)
410 return;
412 "Sending `GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP` message\n");
414 strlen (qh->address) + 1,
416 aqm->qid = htonl (qh->queue_id);
417 aqm->receiver = qh->peer;
418 aqm->nt = htonl ((uint32_t) qh->nt);
419 aqm->mtu = htonl (qh->mtu);
420 aqm->q_len = GNUNET_htonll (qh->q_len);
421 aqm->priority = htonl (qh->priority);
422 aqm->cs = htonl ((uint32_t) qh->cs);
423 memcpy (&aqm[1], qh->address, strlen (qh->address) + 1);
424 GNUNET_MQ_send (qh->ch->mq, env);
425}
#define GNUNET_log(kind,...)
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP
inform transport that a queue was setup to talk to some peer
Add queue to the transport.
Definition: transport.h:396
uint32_t nt
An enum GNUNET_NetworkType in NBO.
Definition: transport.h:415
uint32_t mtu
Maximum transmission unit, in NBO.
Definition: transport.h:420
uint64_t q_len
Queue length, in NBO.
Definition: transport.h:426
uint32_t priority
Priority of the queue in relation to other queues.
Definition: transport.h:431
uint32_t qid
Queue identifier (used to identify the queue).
Definition: transport.h:405
struct GNUNET_PeerIdentity receiver
Receiver that can be addressed via the queue.
Definition: transport.h:410
uint32_t cs
An enum GNUNET_TRANSPORT_ConnectionStatus in NBO.
Definition: transport.h:436
enum GNUNET_TRANSPORT_ConnectionStatus cs
Communication status of the queue.
uint32_t queue_id
ID for this queue when talking to the transport service.
uint32_t mtu
Maximum transmission unit for the queue.
char * address
Address used by the communication queue.
enum GNUNET_NetworkType nt
Network type of the communication queue.
struct GNUNET_PeerIdentity peer
Which peer we can communciate with.
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Handle this queue belongs to.

References GNUNET_TRANSPORT_QueueHandle::address, GNUNET_TRANSPORT_QueueHandle::ch, GNUNET_TRANSPORT_AddQueueMessage::cs, 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_AddQueueMessage::mtu, GNUNET_TRANSPORT_QueueHandle::mtu, GNUNET_TRANSPORT_AddQueueMessage::nt, GNUNET_TRANSPORT_QueueHandle::nt, GNUNET_TRANSPORT_QueueHandle::peer, GNUNET_TRANSPORT_AddQueueMessage::priority, GNUNET_TRANSPORT_QueueHandle::priority, GNUNET_TRANSPORT_AddQueueMessage::q_len, GNUNET_TRANSPORT_QueueHandle::q_len, GNUNET_TRANSPORT_AddQueueMessage::qid, GNUNET_TRANSPORT_QueueHandle::queue_id, and GNUNET_TRANSPORT_AddQueueMessage::receiver.

Referenced by GNUNET_TRANSPORT_communicator_mq_add(), and reconnect().

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 435 of file transport_api2_communication.c.

436{
437 struct GNUNET_MQ_Envelope *env;
439
440 if (NULL == qh->ch->mq)
441 return;
443 uqm->qid = htonl (qh->queue_id);
444 uqm->receiver = qh->peer;
445 uqm->nt = htonl ((uint32_t) qh->nt);
446 uqm->mtu = htonl (qh->mtu);
447 uqm->q_len = GNUNET_htonll (qh->q_len);
448 uqm->priority = htonl (qh->priority);
449 uqm->cs = htonl ((uint32_t) qh->cs);
450 GNUNET_MQ_send (qh->ch->mq, env);
451}
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_UPDATE
inform transport that a queue was updated
struct GNUNET_PeerIdentity receiver
Receiver that can be addressed via the queue.
Definition: transport.h:460
uint32_t cs
An enum GNUNET_TRANSPORT_ConnectionStatus in NBO.
Definition: transport.h:486
uint32_t nt
An enum GNUNET_NetworkType in NBO.
Definition: transport.h:465
uint32_t priority
Priority of the queue in relation to other queues.
Definition: transport.h:481
uint32_t mtu
Maximum transmission unit, in NBO.
Definition: transport.h:470
uint64_t q_len
Queue length, in NBO.
Definition: transport.h:476
uint32_t qid
Queue identifier (used to identify the queue).
Definition: transport.h:455

References GNUNET_TRANSPORT_QueueHandle::ch, GNUNET_TRANSPORT_UpdateQueueMessage::cs, 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_UpdateQueueMessage::mtu, GNUNET_TRANSPORT_QueueHandle::mtu, GNUNET_TRANSPORT_UpdateQueueMessage::nt, GNUNET_TRANSPORT_QueueHandle::nt, GNUNET_TRANSPORT_QueueHandle::peer, GNUNET_TRANSPORT_UpdateQueueMessage::priority, GNUNET_TRANSPORT_QueueHandle::priority, GNUNET_TRANSPORT_UpdateQueueMessage::q_len, GNUNET_TRANSPORT_QueueHandle::q_len, GNUNET_TRANSPORT_UpdateQueueMessage::qid, GNUNET_TRANSPORT_QueueHandle::queue_id, and GNUNET_TRANSPORT_UpdateQueueMessage::receiver.

Referenced by GNUNET_TRANSPORT_communicator_mq_update().

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 461 of file transport_api2_communication.c.

462{
463 struct GNUNET_MQ_Envelope *env;
465
466 if (NULL == qh->ch->mq)
467 return;
469 dqm->qid = htonl (qh->queue_id);
470 dqm->receiver = qh->peer;
471 GNUNET_MQ_send (qh->ch->mq, env);
472}
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN
inform transport that a queue was torn down
Remove queue, it is no longer available.
Definition: transport.h:494
struct GNUNET_PeerIdentity receiver
Receiver that can be addressed via the queue.
Definition: transport.h:508
uint32_t qid
Address identifier.
Definition: transport.h:503

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, GNUNET_TRANSPORT_DelQueueMessage::qid, GNUNET_TRANSPORT_QueueHandle::queue_id, and GNUNET_TRANSPORT_DelQueueMessage::receiver.

Referenced by GNUNET_TRANSPORT_communicator_mq_del().

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 484 of file transport_api2_communication.c.

485{
486 struct FlowControl *fcn;
487 struct AckPending *apn;
488
489 for (struct FlowControl *fc = ch->fc_head; NULL != fc; fc = fcn)
490 {
491 fcn = fc->next;
492 GNUNET_CONTAINER_DLL_remove (ch->fc_head, ch->fc_tail, fc);
493 fc->cb (fc->cb_cls, GNUNET_SYSERR);
494 GNUNET_free (fc);
495 }
496 for (struct AckPending *ap = ch->ap_head; NULL != ap; ap = apn)
497 {
498 apn = ap->next;
499 GNUNET_CONTAINER_DLL_remove (ch->ap_head, ch->ap_tail, ap);
500 GNUNET_free (ap);
501 }
502 if (NULL == ch->mq)
503 return;
505 ch->mq = NULL;
506}
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
@ GNUNET_SYSERR
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683
Information we track per message to tell the transport about success or failures.
struct AckPending * next
Kept in a DLL.
Information we track per packet to enable flow control.
struct FlowControl * next
Kept in a DLL.

References ch, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SYSERR, GNUNET_CADET_Channel::mq, FlowControl::next, and AckPending::next.

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

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 513 of file transport_api2_communication.c.

514{
516
518 "MQ failure %d, reconnecting to transport service.\n",
519 error);
520 disconnect (ch);
521 /* TODO: maybe do this with exponential backoff/delay */
522 reconnect (ch);
523}
@ GNUNET_ERROR_TYPE_INFO
Opaque handle to the transport service for communicators.
static void reconnect(struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
(re)connect our communicator to the transport service
static void disconnect(struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
Disconnect from the transport service.

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

Referenced by reconnect().

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 534 of file transport_api2_communication.c.

537{
539
540 for (struct FlowControl *fc = ch->fc_head; NULL != fc; fc = fc->next)
541 {
542 if ((fc->id == incoming_ack->fc_id) &&
543 (0 == memcmp (&fc->sender,
544 &incoming_ack->sender,
545 sizeof(struct GNUNET_PeerIdentity))))
546 {
548 "Done with message with flow control id %" PRIu64
549 " for sender %s from sender %s\n",
550 incoming_ack->fc_id,
551 GNUNET_i2s (&fc->sender),
552 GNUNET_i2s (&incoming_ack->sender));
553 GNUNET_CONTAINER_DLL_remove (ch->fc_head, ch->fc_tail, fc);
554 fc->cb (fc->cb_cls, GNUNET_OK);
555 GNUNET_free (fc);
556 return;
557 }
558 }
560 "Message with flow control id %" PRIu64
561 " from sender %s not found\n",
562 incoming_ack->fc_id,
563 GNUNET_i2s (&incoming_ack->sender));
564 GNUNET_break (0);
565 disconnect (ch);
566 /* TODO: maybe do this with exponential backoff/delay */
567 reconnect (ch);
568}
@ GNUNET_OK
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_PeerIdentity sender
Sender identifier of the original message.
Definition: transport.h:388
uint64_t fc_id
Which message is being ACKed?
Definition: transport.h:383

References ch, disconnect(), GNUNET_TRANSPORT_IncomingMessageAck::fc_id, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_OK, reconnect(), and GNUNET_TRANSPORT_IncomingMessageAck::sender.

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 580 of file transport_api2_communication.c.

581{
582 (void) cls;
584 return GNUNET_OK;
585}
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...

References GNUNET_MQ_check_zero_termination, and GNUNET_OK.

◆ 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 595 of file transport_api2_communication.c.

596{
598 const char *addr = (const char *) &cq[1];
600 struct GNUNET_MQ_Envelope *env;
601 int ret = ch->mq_init (ch->mq_init_cls, &cq->receiver, addr);
602
603 if (GNUNET_NO == ret)
604 {
606 "Address `%s' is already (beging) connected to.\n",
607 addr);
609 }
610 else if (GNUNET_SYSERR == ret)
611 {
613 "Address `%s' invalid for this communicator\n",
614 addr);
616 }
617 else
618 {
620 }
621 cqr->request_id = cq->request_id;
623}
static int ret
Final status code.
Definition: gnunet-arm.c:94
@ GNUNET_NO
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL
Response from communicator: address bogus, will not try to create queue.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK
Response from communicator: will try to create queue.
Communicator tells transport how queue creation went down.
Definition: transport.h:540
uint32_t request_id
Unique ID for the request.
Definition: transport.h:550
uint32_t request_id
Unique ID for the request.
Definition: transport.h:525
struct GNUNET_PeerIdentity receiver
Receiver that can be addressed via the queue.
Definition: transport.h:530

References ch, env, GNUNET_ERROR_TYPE_DEBUG, 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_NO, GNUNET_SYSERR, GNUNET_CADET_Channel::mq, GNUNET_TRANSPORT_CreateQueue::receiver, GNUNET_TRANSPORT_CreateQueue::request_id, GNUNET_TRANSPORT_CreateQueueResponse::request_id, and ret.

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 635 of file transport_api2_communication.c.

636{
637 (void) cls;
639 return GNUNET_OK;
640}
#define GNUNET_MQ_check_boxed_message(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...

References GNUNET_MQ_check_boxed_message, and GNUNET_OK.

◆ send_ack()

static void send_ack ( struct GNUNET_TRANSPORT_CommunicatorHandle ch,
int  status,
const struct GNUNET_PeerIdentity receiver,
uint64_t  mid,
uint32_t  qid 
)
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 653 of file transport_api2_communication.c.

658{
659 struct GNUNET_MQ_Envelope *env;
661
663 ack->status = htonl (status);
664 ack->mid = mid;
665 ack->qid = qid;
666 ack->receiver = *receiver;
668}
static int status
The program status; 0 for success.
Definition: gnunet-nse.c:39
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK
communicator tells transports that message was sent
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:330
Inform transport that message was sent.
Definition: transport.h:587
uint32_t status
Success (GNUNET_OK), failure (GNUNET_SYSERR).
Definition: transport.h:596
uint64_t mid
Message ID of the original message.
Definition: transport.h:601
uint32_t qid
Queue ID for the queue which was used to send the message.
Definition: transport.h:606
struct GNUNET_PeerIdentity receiver
Receiver identifier.
Definition: transport.h:611

References ch, env, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_TRANSPORT_SendMessageToAck::mid, GNUNET_CADET_Channel::mq, GNUNET_TRANSPORT_SendMessageToAck::qid, receiver(), GNUNET_TRANSPORT_SendMessageToAck::receiver, status, and GNUNET_TRANSPORT_SendMessageToAck::status.

Referenced by handle_send_msg(), and send_ack_cb().

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 678 of file transport_api2_communication.c.

679{
680 struct AckPending *ap = cls;
682
683 if (NULL != ch->ap_head && NULL != ap)
684 GNUNET_CONTAINER_DLL_remove (ch->ap_head, ch->ap_tail, ap);
685 if (NULL != ap)
686 {
687 send_ack (ch, GNUNET_OK, &ap->receiver, ap->mid, ap->qid);
688 GNUNET_free (ap);
689 }
690}
uint64_t mid
More-or-less unique ID for the message.
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Communicator this entry belongs to.
struct GNUNET_PeerIdentity receiver
Which peer is this about?
uint32_t qid
Queue ID of the queue which will be used for the message.
static void send_ack(struct GNUNET_TRANSPORT_CommunicatorHandle *ch, int status, const struct GNUNET_PeerIdentity *receiver, uint64_t mid, uint32_t qid)
Notify transport service about status of a message with mid sent to receiver.

References ch, AckPending::ch, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_OK, AckPending::mid, AckPending::qid, AckPending::receiver, and send_ack().

Referenced by handle_send_msg().

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 700 of file transport_api2_communication.c.

701{
703 const struct GNUNET_MessageHeader *mh;
704 struct GNUNET_MQ_Envelope *env;
705 struct AckPending *ap;
707
708 for (qh = ch->queue_head; NULL != qh; qh = qh->next)
709 if ((qh->queue_id == ntohl (smt->qid)) &&
710 (0 == memcmp (&qh->peer,
711 &smt->receiver,
712 sizeof(struct GNUNET_PeerIdentity))))
713 break;
714 if (NULL == qh)
715 {
716 /* queue is already gone, tell transport this one failed */
718 "Transmission failed, queue no longer exists.\n");
719 send_ack (ch, GNUNET_NO, &smt->receiver, smt->mid, smt->qid);
720 return;
721 }
722 ap = GNUNET_new (struct AckPending);
723 ap->ch = ch;
724 ap->receiver = smt->receiver;
725 ap->mid = smt->mid;
726 ap->qid = smt->qid;
727 GNUNET_CONTAINER_DLL_insert (ch->ap_head, ch->ap_tail, ap);
728 mh = (const struct GNUNET_MessageHeader *) &smt[1];
731 GNUNET_MQ_send (qh->mq, env);
732}
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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:533
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:638
Header for all communications.
struct GNUNET_MQ_Handle * mq
The queue itself.
struct GNUNET_TRANSPORT_QueueHandle * next
Kept in a DLL.
uint32_t qid
Which queue should we use?
Definition: transport.h:567
uint64_t mid
Message ID, used for flow control.
Definition: transport.h:572
struct GNUNET_PeerIdentity receiver
Receiver identifier.
Definition: transport.h:577
static void send_ack_cb(void *cls)
Message queue transmission by communicator was successful, notify transport service.

References ch, AckPending::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, GNUNET_TRANSPORT_SendMessageTo::mid, AckPending::mid, GNUNET_TRANSPORT_QueueHandle::mq, GNUNET_TRANSPORT_QueueHandle::next, GNUNET_TRANSPORT_QueueHandle::peer, GNUNET_TRANSPORT_SendMessageTo::qid, AckPending::qid, GNUNET_TRANSPORT_QueueHandle::queue_id, GNUNET_TRANSPORT_SendMessageTo::receiver, AckPending::receiver, send_ack(), and send_ack_cb().

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 744 of file transport_api2_communication.c.

747{
748 (void) cls;
750 return GNUNET_OK;
751}

References GNUNET_MQ_check_boxed_message, and GNUNET_OK.

◆ 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 761 of file transport_api2_communication.c.

764{
766 if (NULL != ch->notify_cb)
767 ch->notify_cb (ch->notify_cb_cls,
768 &bi->pid,
769 (const struct GNUNET_MessageHeader *) &bi[1]);
770 else
771 GNUNET_log (
773 _ ("Dropped backchanel message: handler not provided by communicator\n"));
774}
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
struct GNUNET_PeerIdentity pid
Origin peer.
Definition: transport.h:665

References _, ch, GNUNET_ERROR_TYPE_INFO, GNUNET_log, and GNUNET_TRANSPORT_CommunicatorBackchannelIncoming::pid.