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 "transport.h"
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_CommunicatorHandle * | GNUNET_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_QueueHandle * | GNUNET_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_AddressIdentifier * | GNUNET_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... | |
implementation of the gnunet_transport_communication_service.h API
Definition in file transport_api2_communication.c.
#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.
|
static |
(re)connect our communicator to the transport service
ch | handle to reconnect |
Definition at line 822 of file transport_api2_communication.c.
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().
|
static |
Send message to the transport service about address ai being now available.
ai | address to add |
Definition at line 365 of file transport_api2_communication.c.
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().
|
static |
Send message to the transport service about address ai being no longer available.
ai | address to delete |
Definition at line 389 of file transport_api2_communication.c.
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().
|
static |
Send message to the transport service about queue qh being now available.
qh | queue to add |
Definition at line 409 of file transport_api2_communication.c.
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().
|
static |
Send message to the transport service about queue qh updated.
qh | queue to add |
Definition at line 440 of file transport_api2_communication.c.
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().
|
static |
Send message to the transport service about queue qh being no longer available.
qh | queue to delete |
Definition at line 466 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, GNUNET_TRANSPORT_DelQueueMessage::qid, GNUNET_TRANSPORT_QueueHandle::queue_id, and GNUNET_TRANSPORT_DelQueueMessage::receiver.
Referenced by GNUNET_TRANSPORT_communicator_mq_del().
|
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.
ch | service to disconnect from |
Definition at line 489 of file transport_api2_communication.c.
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().
|
static |
Function called on MQ errors.
Definition at line 518 of file transport_api2_communication.c.
References ch, disconnect(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, and reconnect().
Referenced by reconnect().
|
static |
Transport service acknowledged a message we gave it (with flow control enabled).
Tell the communicator.
cls | our struct GNUNET_TRANSPORT_CommunicatorHandle * |
incoming_ack | the ack |
Definition at line 539 of file transport_api2_communication.c.
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.
|
static |
Transport service wants us to create a queue.
Check if cq is well-formed.
cls | our struct GNUNET_TRANSPORT_CommunicatorHandle * |
cq | the queue creation request |
Definition at line 585 of file transport_api2_communication.c.
References GNUNET_MQ_check_zero_termination, and GNUNET_OK.
|
static |
Transport service wants us to create a queue.
Tell the communicator.
cls | our struct GNUNET_TRANSPORT_CommunicatorHandle * |
cq | the queue creation request |
Definition at line 600 of file transport_api2_communication.c.
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.
|
static |
Transport service wants us to send a message.
Check if smt is well-formed.
cls | our struct GNUNET_TRANSPORT_CommunicatorHandle * |
smt | the transmission request |
Definition at line 640 of file transport_api2_communication.c.
References GNUNET_MQ_check_boxed_message, and GNUNET_OK.
|
static |
Notify transport service about status of a message with mid sent to receiver.
ch | handle |
status | GNUNET_OK on success, GNUNET_SYSERR on failure |
receiver | which peer was the receiver |
mid | message that the ack is about |
Definition at line 658 of file transport_api2_communication.c.
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().
|
static |
Message queue transmission by communicator was successful, notify transport service.
cls | an struct AckPending * |
Definition at line 683 of file transport_api2_communication.c.
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().
|
static |
Transport service wants us to send a message.
Tell the communicator.
cls | our struct GNUNET_TRANSPORT_CommunicatorHandle * |
smt | the transmission request |
Definition at line 702 of file transport_api2_communication.c.
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().
|
static |
Transport service gives us backchannel message.
Check if bi is well-formed.
cls | our struct GNUNET_TRANSPORT_CommunicatorHandle * |
bi | the backchannel message |
Definition at line 746 of file transport_api2_communication.c.
References GNUNET_MQ_check_boxed_message, and GNUNET_OK.
|
static |
Transport service gives us backchannel message.
Handle it.
cls | our struct GNUNET_TRANSPORT_CommunicatorHandle * |
bi | the backchannel message |
Definition at line 763 of file transport_api2_communication.c.
References _, ch, GNUNET_ERROR_TYPE_INFO, GNUNET_log, and GNUNET_TRANSPORT_CommunicatorBackchannelIncoming::pid.
|
static |
Definition at line 780 of file transport_api2_communication.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_check_zero_termination, GNUNET_OK, and GNUNET_TRANSPORT_CommunicatorHandle::sb.
|
static |
Definition at line 796 of file transport_api2_communication.c.
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.