GNUnet 0.22.2
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...
 
static int check_start_burst (void *cls, const struct GNUNET_TRANSPORT_StartBurst *sb)
 
static void handle_start_burst (void *cls, const struct GNUNET_TRANSPORT_StartBurst *sb)
 
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, GNUNET_TRANSPORT_StartBurstNotify sb)
 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...
 
void GNUNET_TRANSPORT_communicator_burst_finished (struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
 The communicator tells the transport service that it finished the burst. 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 822 of file transport_api2_communication.c.

823{
825 { GNUNET_MQ_hd_fixed_size (incoming_ack,
828 ch),
829 GNUNET_MQ_hd_var_size (create_queue,
832 ch),
833 GNUNET_MQ_hd_var_size (send_msg,
836 ch),
838 backchannel_incoming,
841 ch),
846 ch),
849 struct GNUNET_MQ_Envelope *env;
850
851 ch->mq =
852 GNUNET_CLIENT_connect (ch->cfg, "transport", handlers, &error_handler, ch);
853 if (NULL == ch->mq)
854 return;
856 strlen (ch->addr_prefix) + 1,
858 if (NULL != ch->sb)
859 {
860 cam->can_burst = htonl (GNUNET_YES);
861 }
862 cam->cc = htonl ((uint32_t) ch->cc);
863 memcpy (&cam[1], ch->addr_prefix, strlen (ch->addr_prefix) + 1);
865 for (struct GNUNET_TRANSPORT_AddressIdentifier *ai = ch->ai_head; NULL != ai;
866 ai = ai->next)
868 for (struct GNUNET_TRANSPORT_QueueHandle *qh = ch->queue_head; NULL != qh;
869 qh = qh->next)
870 send_add_queue (qh);
871}
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 void start_burst(const char *addr, struct GNUNET_TIME_Relative rtt, struct GNUNET_PeerIdentity *pid)
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:1060
@ GNUNET_YES
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:305
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:61
#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_START_BURST
Burst message we send to another peer for hole punching.
#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
uint32_t can_burst
The communicator can do burst msgs.
Definition: transport.h:277
Message from transport to communicator passing along a backchannel message from the given peer pid.
Definition: transport.h:655
Transport tells communicator that it wants a new queue.
Definition: transport.h:521
Transport informs us about being done with an incoming message.
Definition: transport.h:374
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:563
Message from transport to communicator to start a burst.
Definition: transport.h:680
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::can_burst, 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_MESSAGE_TYPE_TRANSPORT_START_BURST, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_YES, handlers, GNUNET_CADET_Channel::mq, GNUNET_TRANSPORT_AddressIdentifier::next, send_add_address(), send_add_queue(), and start_burst().

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

366{
367 struct GNUNET_MQ_Envelope *env;
369
370 if (NULL == ai->ch->mq)
371 return;
373 strlen (ai->address) + 1,
376 aam->nt = htonl ((uint32_t) ai->nt);
377 memcpy (&aam[1], ai->address, strlen (ai->address) + 1);
379}
#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:620
Add address to the list.
Definition: transport.h:287
struct GNUNET_TIME_RelativeNBO expiration
When does the address expire?
Definition: transport.h:301
uint32_t nt
An enum GNUNET_NetworkType in NBO.
Definition: transport.h:306
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 389 of file transport_api2_communication.c.

390{
391 struct GNUNET_MQ_Envelope *env;
393
394 if (NULL == ai->ch->mq)
395 return;
397 dam->aid = htonl (ai->aid);
399}
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:76
#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:316
uint32_t aid
Address identifier.
Definition: transport.h:325

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

410{
411 struct GNUNET_MQ_Envelope *env;
413
414 if (NULL == qh->ch->mq)
415 return;
417 "Sending `GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP` message\n");
419 strlen (qh->address) + 1,
421 aqm->qid = htonl (qh->queue_id);
422 aqm->receiver = qh->peer;
423 aqm->nt = htonl ((uint32_t) qh->nt);
424 aqm->mtu = htonl (qh->mtu);
425 aqm->q_len = GNUNET_htonll (qh->q_len);
426 aqm->priority = htonl (qh->priority);
427 aqm->cs = htonl ((uint32_t) qh->cs);
428 memcpy (&aqm[1], qh->address, strlen (qh->address) + 1);
429 GNUNET_MQ_send (qh->ch->mq, env);
430}
#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:401
uint32_t nt
An enum GNUNET_NetworkType in NBO.
Definition: transport.h:420
uint32_t mtu
Maximum transmission unit, in NBO.
Definition: transport.h:425
uint64_t q_len
Queue length, in NBO.
Definition: transport.h:431
uint32_t priority
Priority of the queue in relation to other queues.
Definition: transport.h:436
uint32_t qid
Queue identifier (used to identify the queue).
Definition: transport.h:410
struct GNUNET_PeerIdentity receiver
Receiver that can be addressed via the queue.
Definition: transport.h:415
uint32_t cs
An enum GNUNET_TRANSPORT_ConnectionStatus in NBO.
Definition: transport.h:441
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 440 of file transport_api2_communication.c.

441{
442 struct GNUNET_MQ_Envelope *env;
444
445 if (NULL == qh->ch->mq)
446 return;
448 uqm->qid = htonl (qh->queue_id);
449 uqm->receiver = qh->peer;
450 uqm->nt = htonl ((uint32_t) qh->nt);
451 uqm->mtu = htonl (qh->mtu);
452 uqm->q_len = GNUNET_htonll (qh->q_len);
453 uqm->priority = htonl (qh->priority);
454 uqm->cs = htonl ((uint32_t) qh->cs);
455 GNUNET_MQ_send (qh->ch->mq, env);
456}
#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:465
uint32_t cs
An enum GNUNET_TRANSPORT_ConnectionStatus in NBO.
Definition: transport.h:491
uint32_t nt
An enum GNUNET_NetworkType in NBO.
Definition: transport.h:470
uint32_t priority
Priority of the queue in relation to other queues.
Definition: transport.h:486
uint32_t mtu
Maximum transmission unit, in NBO.
Definition: transport.h:475
uint64_t q_len
Queue length, in NBO.
Definition: transport.h:481
uint32_t qid
Queue identifier (used to identify the queue).
Definition: transport.h:460

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

467{
468 struct GNUNET_MQ_Envelope *env;
470
471 if (NULL == qh->ch->mq)
472 return;
474 dqm->qid = htonl (qh->queue_id);
475 dqm->receiver = qh->peer;
476 GNUNET_MQ_send (qh->ch->mq, env);
477}
#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:499
struct GNUNET_PeerIdentity receiver
Receiver that can be addressed via the queue.
Definition: transport.h:513
uint32_t qid
Address identifier.
Definition: transport.h:508

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

490{
491 struct FlowControl *fcn;
492 struct AckPending *apn;
493
494 for (struct FlowControl *fc = ch->fc_head; NULL != fc; fc = fcn)
495 {
496 fcn = fc->next;
497 GNUNET_CONTAINER_DLL_remove (ch->fc_head, ch->fc_tail, fc);
498 fc->cb (fc->cb_cls, GNUNET_SYSERR);
499 GNUNET_free (fc);
500 }
501 for (struct AckPending *ap = ch->ap_head; NULL != ap; ap = apn)
502 {
503 apn = ap->next;
504 GNUNET_CONTAINER_DLL_remove (ch->ap_head, ch->ap_tail, ap);
505 GNUNET_free (ap);
506 }
507 if (NULL == ch->mq)
508 return;
510 ch->mq = NULL;
511}
#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:700
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 518 of file transport_api2_communication.c.

519{
521
523 "MQ failure %d, reconnecting to transport service.\n",
524 error);
525 disconnect (ch);
526 /* TODO: maybe do this with exponential backoff/delay */
527 reconnect (ch);
528}
@ 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 539 of file transport_api2_communication.c.

542{
544
545 for (struct FlowControl *fc = ch->fc_head; NULL != fc; fc = fc->next)
546 {
547 if ((fc->id == incoming_ack->fc_id) &&
548 (0 == memcmp (&fc->sender,
549 &incoming_ack->sender,
550 sizeof(struct GNUNET_PeerIdentity))))
551 {
553 "Done with message with flow control id %" PRIu64
554 " for sender %s from sender %s\n",
555 incoming_ack->fc_id,
556 GNUNET_i2s (&fc->sender),
557 GNUNET_i2s (&incoming_ack->sender));
558 GNUNET_CONTAINER_DLL_remove (ch->fc_head, ch->fc_tail, fc);
559 fc->cb (fc->cb_cls, GNUNET_OK);
560 GNUNET_free (fc);
561 return;
562 }
563 }
565 "Message with flow control id %" PRIu64
566 " from sender %s not found\n",
567 incoming_ack->fc_id,
568 GNUNET_i2s (&incoming_ack->sender));
569 GNUNET_break (0);
570 disconnect (ch);
571 /* TODO: maybe do this with exponential backoff/delay */
572 reconnect (ch);
573}
@ 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:393
uint64_t fc_id
Which message is being ACKed?
Definition: transport.h:388

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

586{
587 (void) cls;
589 return GNUNET_OK;
590}
#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 600 of file transport_api2_communication.c.

601{
603 const char *addr = (const char *) &cq[1];
605 struct GNUNET_MQ_Envelope *env;
606 int ret = ch->mq_init (ch->mq_init_cls, &cq->receiver, addr);
607
608 if (GNUNET_NO == ret)
609 {
611 "Address `%s' is already (being) connected to.\n",
612 addr);
614 }
615 else if (GNUNET_SYSERR == ret)
616 {
618 "Address `%s' invalid for this communicator\n",
619 addr);
621 }
622 else
623 {
625 }
626 cqr->request_id = cq->request_id;
628}
static int ret
Final status code.
Definition: gnunet-arm.c:93
@ GNUNET_NO
#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:545
uint32_t request_id
Unique ID for the request.
Definition: transport.h:555
uint32_t request_id
Unique ID for the request.
Definition: transport.h:530
struct GNUNET_PeerIdentity receiver
Receiver that can be addressed via the queue.
Definition: transport.h:535

References ch, env, GNUNET_ERROR_TYPE_DEBUG, 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 640 of file transport_api2_communication.c.

641{
642 (void) cls;
644 return GNUNET_OK;
645}
#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 658 of file transport_api2_communication.c.

663{
664 struct GNUNET_MQ_Envelope *env;
666
668 ack->status = htonl (status);
669 ack->mid = mid;
670 ack->qid = qid;
671 ack->receiver = *receiver;
673}
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:592
uint32_t status
Success (GNUNET_OK), failure (GNUNET_SYSERR).
Definition: transport.h:601
uint64_t mid
Message ID of the original message.
Definition: transport.h:606
uint32_t qid
Queue ID for the queue which was used to send the message.
Definition: transport.h:611
struct GNUNET_PeerIdentity receiver
Receiver identifier.
Definition: transport.h:616

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

684{
685 struct AckPending *ap = cls;
686
687 GNUNET_assert (NULL != ap);
688 GNUNET_assert (NULL != ap->ch->ap_head);
690 send_ack (ap->ch, GNUNET_OK, &ap->receiver, ap->mid, ap->qid);
691 GNUNET_free (ap);
692}
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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.
struct AckPending * ap_head
DLL of messages awaiting transmission confirmation (ack).
struct AckPending * ap_tail
DLL of messages awaiting transmission confirmation (ack).
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 GNUNET_TRANSPORT_CommunicatorHandle::ap_head, GNUNET_TRANSPORT_CommunicatorHandle::ap_tail, AckPending::ch, GNUNET_assert, 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 702 of file transport_api2_communication.c.

703{
705 const struct GNUNET_MessageHeader *mh;
706 struct GNUNET_MQ_Envelope *env;
707 struct AckPending *ap;
709
710 for (qh = ch->queue_head; NULL != qh; qh = qh->next)
711 if ((qh->queue_id == ntohl (smt->qid)) &&
712 (0 == memcmp (&qh->peer,
713 &smt->receiver,
714 sizeof(struct GNUNET_PeerIdentity))))
715 break;
716 if (NULL == qh)
717 {
718 /* queue is already gone, tell transport this one failed */
720 "Transmission failed, queue no longer exists.\n");
721 send_ack (ch, GNUNET_NO, &smt->receiver, smt->mid, smt->qid);
722 return;
723 }
724 ap = GNUNET_new (struct AckPending);
725 ap->ch = ch;
726 ap->receiver = smt->receiver;
727 ap->mid = smt->mid;
728 ap->qid = smt->qid;
729 GNUNET_CONTAINER_DLL_insert (ch->ap_head, ch->ap_tail, ap);
730 mh = (const struct GNUNET_MessageHeader *) &smt[1];
733 GNUNET_MQ_send (qh->mq, env);
734}
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:550
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:655
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:572
uint64_t mid
Message ID, used for flow control.
Definition: transport.h:577
struct GNUNET_PeerIdentity receiver
Receiver identifier.
Definition: transport.h:582
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 746 of file transport_api2_communication.c.

749{
750 (void) cls;
752 return GNUNET_OK;
753}

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

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

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

◆ check_start_burst()

static int check_start_burst ( void *  cls,
const struct GNUNET_TRANSPORT_StartBurst sb 
)
static

Definition at line 780 of file transport_api2_communication.c.

782{
783 const char *addr_str = (const char *) &sb[1];
784 (void) cls;
785
787 "check_start_burst %s %lu\n",
788 addr_str,
789 strlen (addr_str));
791 return GNUNET_OK;
792}

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_check_zero_termination, GNUNET_OK, and GNUNET_TRANSPORT_CommunicatorHandle::sb.

◆ handle_start_burst()

static void handle_start_burst ( void *  cls,
const struct GNUNET_TRANSPORT_StartBurst sb 
)
static

Definition at line 796 of file transport_api2_communication.c.

798{
800 const char *addr = (const char *) &sb[1];
802
804 "Calling communicator to start burst to %s is %s rtt %lu\n",
805 addr,
806 NULL == sb ? "not possible" : "possible",
807 (unsigned long) rtt.rel_value_us);
808
809 if (NULL != ch->sb)
810 ch->sb (addr, GNUNET_TIME_relative_ntoh (sb->rtt), (struct
812 sb->pid);
813}
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:630
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
GNUNET_TRANSPORT_StartBurstNotify sb
Function to start a burst, requested by the transport service.
struct GNUNET_TIME_RelativeNBO rtt
Definition: transport.h:691
struct GNUNET_PeerIdentity pid
Target peer.
Definition: transport.h:689

References ch, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_TIME_relative_ntoh(), GNUNET_TRANSPORT_StartBurst::pid, GNUNET_TIME_Relative::rel_value_us, GNUNET_TRANSPORT_StartBurst::rtt, and GNUNET_TRANSPORT_CommunicatorHandle::sb.

Here is the call graph for this function: