GNUnet 0.21.1
Transport Next Generation service

Low-level communication with other peers. More...

Collaboration diagram for Transport Next Generation service:

Data Structures

struct  GNUNET_TRANSPORT_MonitorInformation
 Information about another peer's address. More...
 

Macros

#define GNUNET_TRANSPORT_COMMUNICATION_VERSION   0x00000000
 Version number of the transport communication API. More...
 
#define GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED   UINT64_MAX
 Queue length. More...
 
#define GNUNET_TRANSPORT_CORE_VERSION   0x00000000
 Version number of the transport API. More...
 
#define GNUNET_TRANSPORT_MONITOR_VERSION   0x00000000
 Version number of the transport API. More...
 

Typedefs

typedef int(* GNUNET_TRANSPORT_CommunicatorMqInit) (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
 Function called by the transport service to initialize a message queue given address information about another peer. More...
 
typedef void(* GNUNET_TRANSPORT_CommunicatorNotify) (void *cls, const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *msg)
 Function called when the transport service has received a backchannel message for this communicator (!) via a different return path. More...
 
typedef void(* GNUNET_TRANSPORT_MessageCompletedCallback) (void *cls, int success)
 Function called to notify communicator that we have received and processed the message. More...
 
typedef void *(* GNUNET_TRANSPORT_NotifyConnect) (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
 Function called to notify transport users that another peer connected to us. More...
 
typedef void(* GNUNET_TRANSPORT_NotifyDisconnect) (void *cls, const struct GNUNET_PeerIdentity *peer, void *handler_cls)
 Function called to notify transport users that another peer disconnected from us. More...
 
typedef void(* GNUNET_TRANSPORT_MonitorCallback) (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_MonitorInformation *mi)
 Function to call with information about a peer. More...
 

Enumerations

enum  GNUNET_TRANSPORT_CommunicatorCharacteristics { GNUNET_TRANSPORT_CC_UNKNOWN = 0 , GNUNET_TRANSPORT_CC_RELIABLE = 1 , GNUNET_TRANSPORT_CC_UNRELIABLE = 2 }
 What characteristics does this communicator have? More...
 
enum  GNUNET_TRANSPORT_ConnectionStatus { GNUNET_TRANSPORT_CS_DOWN = -1 , GNUNET_TRANSPORT_CS_OUTBOUND = 0 , GNUNET_TRANSPORT_CS_INBOUND = 1 }
 Possible states of a connection. More...
 

Functions

struct GNUNET_TRANSPORT_ApplicationHandleGNUNET_TRANSPORT_application_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Initialize the TRANSPORT application client handle. More...
 
void GNUNET_TRANSPORT_application_done (struct GNUNET_TRANSPORT_ApplicationHandle *ch)
 Shutdown TRANSPORT application client. More...
 
struct GNUNET_TRANSPORT_ApplicationSuggestHandleGNUNET_TRANSPORT_application_suggest (struct GNUNET_TRANSPORT_ApplicationHandle *ch, const struct GNUNET_PeerIdentity *peer, enum GNUNET_MQ_PriorityPreferences pk, struct GNUNET_BANDWIDTH_Value32NBO bw)
 An application would like TRANSPORT to connect to a peer. More...
 
void GNUNET_TRANSPORT_application_suggest_cancel (struct GNUNET_TRANSPORT_ApplicationSuggestHandle *sh)
 We no longer care about being connected to a peer. More...
 
void GNUNET_TRANSPORT_application_validate (struct GNUNET_TRANSPORT_ApplicationHandle *ch, const struct GNUNET_PeerIdentity *peer, enum GNUNET_NetworkType nt, const char *addr)
 An application (or a communicator) has received a HELLO (or other address data of another peer) and wants TRANSPORT to validate that the address is correct. More...
 
struct GNUNET_TRANSPORT_CommunicatorHandleGNUNET_TRANSPORT_communicator_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *config_section_name, 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 *handle, 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...
 
struct GNUNET_TRANSPORT_CoreHandleGNUNET_TRANSPORT_core_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *self, const struct GNUNET_MQ_MessageHandler *handlers, void *cls, GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyDisconnect nd)
 Connect to the transport service. More...
 
void GNUNET_TRANSPORT_core_disconnect (struct GNUNET_TRANSPORT_CoreHandle *handle)
 Disconnect from the transport service. More...
 
struct GNUNET_TRANSPORT_MonitorContextGNUNET_TRANSPORT_monitor (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *peer, int one_shot, GNUNET_TRANSPORT_MonitorCallback cb, void *cb_cls)
 Return information about a specific peer or all peers currently known to transport service once or in monitoring mode. More...
 
void GNUNET_TRANSPORT_monitor_cancel (struct GNUNET_TRANSPORT_MonitorContext *mc)
 Cancel request to monitor peers. More...
 

Detailed Description

Low-level communication with other peers.

Communication with other peers.

See also
Documentation

Macro Definition Documentation

◆ GNUNET_TRANSPORT_COMMUNICATION_VERSION

#define GNUNET_TRANSPORT_COMMUNICATION_VERSION   0x00000000

Version number of the transport communication API.

Definition at line 54 of file gnunet_transport_communication_service.h.

◆ GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED

#define GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED   UINT64_MAX

Queue length.

Definition at line 59 of file gnunet_transport_communication_service.h.

◆ GNUNET_TRANSPORT_CORE_VERSION

#define GNUNET_TRANSPORT_CORE_VERSION   0x00000000

Version number of the transport API.

Definition at line 52 of file gnunet_transport_core_service.h.

◆ GNUNET_TRANSPORT_MONITOR_VERSION

#define GNUNET_TRANSPORT_MONITOR_VERSION   0x00000000

Version number of the transport API.

Definition at line 56 of file gnunet_transport_monitor_service.h.

Typedef Documentation

◆ GNUNET_TRANSPORT_CommunicatorMqInit

typedef int(* GNUNET_TRANSPORT_CommunicatorMqInit) (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)

Function called by the transport service to initialize a message queue given address information about another peer.

If and when the communication channel is established, the communicator must call GNUNET_TRANSPORT_communicator_mq_add() to notify the service that the channel is now up. It is the responsibility of the communicator to manage sane retries and timeouts for any peer/address combination provided by the transport service. Timeouts and retries do not need to be signalled to the transport service.

Parameters
clsclosure
peeridentity of the other peer
addresswhere to send the message, human-readable communicator-specific format, 0-terminated, UTF-8
Returns
GNUNET_OK on success, GNUNET_SYSERR if the provided address is invalid, GNUNET_NO if this address is already (beging) connected to.

Definition at line 79 of file gnunet_transport_communication_service.h.

◆ GNUNET_TRANSPORT_CommunicatorNotify

typedef void(* GNUNET_TRANSPORT_CommunicatorNotify) (void *cls, const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *msg)

Function called when the transport service has received a backchannel message for this communicator (!) via a different return path.

Typically used to receive messages of type GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_FC_LIMITS or GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_KX_CONFIRMATION as well as communicator-specific messages to assist with NAT traversal.

Parameters
clsclosure
senderwhich peer sent the notification
msgpayload

Definition at line 131 of file gnunet_transport_communication_service.h.

◆ GNUNET_TRANSPORT_MessageCompletedCallback

typedef void(* GNUNET_TRANSPORT_MessageCompletedCallback) (void *cls, int success)

Function called to notify communicator that we have received and processed the message.

Used for flow control (if supported by the communicator).

Parameters
clsclosure
successGNUNET_SYSERR on failure (try to disconnect/reset connection) GNUNET_OK on success

Definition at line 187 of file gnunet_transport_communication_service.h.

◆ GNUNET_TRANSPORT_NotifyConnect

typedef void *(* GNUNET_TRANSPORT_NotifyConnect) (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)

Function called to notify transport users that another peer connected to us.

Parameters
clsclosure
peerthe identity of the peer that connected; this pointer will remain valid until the disconnect, hence applications do not necessarily have to make a copy of the value if they only need it until disconnect
mqmessage queue to use to transmit to peer
Returns
closure to use in MQ handlers

Definition at line 73 of file gnunet_transport_core_service.h.

◆ GNUNET_TRANSPORT_NotifyDisconnect

typedef void(* GNUNET_TRANSPORT_NotifyDisconnect) (void *cls, const struct GNUNET_PeerIdentity *peer, void *handler_cls)

Function called to notify transport users that another peer disconnected from us.

The message queue that was given to the connect notification will be destroyed and must not be used henceforth.

Parameters
clsclosure from GNUNET_TRANSPORT_core_connect
peerthe peer that disconnected
handlers_clsclosure of the handlers, was returned from the connect notification callback

Definition at line 90 of file gnunet_transport_core_service.h.

◆ GNUNET_TRANSPORT_MonitorCallback

typedef void(* GNUNET_TRANSPORT_MonitorCallback) (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_MonitorInformation *mi)

Function to call with information about a peer.

If one_shot was set to GNUNET_YES to iterate over all peers once, a final call with NULL for peer and address will follow when done. In this case state and timeout do not contain valid values.

The #GNUNET_TRANSPORT_monitor_peers_cancel() call MUST not be called from within this function!

Parameters
clsclosure
peerpeer this update is about, NULL if this is the final last callback for a iteration operation
mimonitoring data on the peer

Definition at line 127 of file gnunet_transport_monitor_service.h.

Enumeration Type Documentation

◆ GNUNET_TRANSPORT_CommunicatorCharacteristics

What characteristics does this communicator have?

FIXME: may want to distinguish bi-directional as well, should we define a bit for that? Needed in DV logic (handle_dv_learn)!

Enumerator
GNUNET_TRANSPORT_CC_UNKNOWN 

Characteristics are unknown (e.g.

DV).

GNUNET_TRANSPORT_CC_RELIABLE 

Transmission is reliabile (with ACKs), e.g.

TCP/HTTP/HTTPS.

GNUNET_TRANSPORT_CC_UNRELIABLE 

Transmission is unreliable (e.g.

UDP)

Definition at line 97 of file gnunet_transport_communication_service.h.

98{
103
108
113};
@ GNUNET_TRANSPORT_CC_RELIABLE
Transmission is reliabile (with ACKs), e.g.
@ GNUNET_TRANSPORT_CC_UNRELIABLE
Transmission is unreliable (e.g.
@ GNUNET_TRANSPORT_CC_UNKNOWN
Characteristics are unknown (e.g.

◆ GNUNET_TRANSPORT_ConnectionStatus

Possible states of a connection.

Enumerator
GNUNET_TRANSPORT_CS_DOWN 

Connection is down.

GNUNET_TRANSPORT_CS_OUTBOUND 

this is an outbound connection (transport initiated)

GNUNET_TRANSPORT_CS_INBOUND 

this is an inbound connection (communicator initiated)

Definition at line 234 of file gnunet_transport_communication_service.h.

235{
240
245
250};
@ GNUNET_TRANSPORT_CS_INBOUND
this is an inbound connection (communicator initiated)
@ GNUNET_TRANSPORT_CS_DOWN
Connection is down.
@ GNUNET_TRANSPORT_CS_OUTBOUND
this is an outbound connection (transport initiated)

Function Documentation

◆ GNUNET_TRANSPORT_application_init()

struct GNUNET_TRANSPORT_ApplicationHandle * GNUNET_TRANSPORT_application_init ( const struct GNUNET_CONFIGURATION_Handle cfg)

Initialize the TRANSPORT application client handle.

Parameters
cfgconfiguration to use
Returns
ats application handle, NULL on error

Initialize the TRANSPORT application client handle.

Parameters
cfgconfiguration to use
Returns
transport application handle, NULL on error

Definition at line 219 of file transport_api2_application.c.

221{
223
225 ch->cfg = cfg;
227 reconnect (ch);
228 return ch;
229}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
@ GNUNET_YES
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Handle to the TRANSPORT subsystem for application management.
static void reconnect(struct GNUNET_TRANSPORT_ApplicationHandle *ch)
Re-establish the connection to the TRANSPORT service.

References cfg, ch, GNUNET_CONTAINER_multipeermap_create(), GNUNET_new, GNUNET_YES, and reconnect().

Referenced by connect_peers_run(), DHTU_gnunet_init(), GNUNET_TRANSPORT_TESTING_restart_peer(), GNUNET_TRANSPORT_TESTING_start_peer(), run(), and start_peer_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_application_done()

void GNUNET_TRANSPORT_application_done ( struct GNUNET_TRANSPORT_ApplicationHandle ch)

Shutdown TRANSPORT application client.

Parameters
chhandle to destroy

Shutdown TRANSPORT application client.

Parameters
chhandle to release

Definition at line 257 of file transport_api2_application.c.

259{
260 if (NULL != ch->mq)
261 {
263 ch->mq = NULL;
264 }
265 if (NULL != ch->task)
266 {
268 ch->task = NULL;
269 }
272 NULL);
274 GNUNET_free (ch);
275}
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
struct GNUNET_MQ_Handle * mq
Message Queue for the channel (which we are implementing).
Definition: cadet.h:142
static int free_sug_handle(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Function called to free all struct GNUNET_TRANSPORT_ApplicationSuggestHandles in the map.

References ch, free_sug_handle(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), and GNUNET_CADET_Channel::mq.

Referenced by cleaning_task(), DHTU_gnunet_done(), do_shutdown(), GNUNET_TRANSPORT_TESTING_restart_peer(), GNUNET_TRANSPORT_TESTING_stop_peer(), shutdown_rest(), and stop_peer_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_application_suggest()

struct GNUNET_TRANSPORT_ApplicationSuggestHandle * GNUNET_TRANSPORT_application_suggest ( struct GNUNET_TRANSPORT_ApplicationHandle ch,
const struct GNUNET_PeerIdentity peer,
enum GNUNET_MQ_PriorityPreferences  pk,
struct GNUNET_BANDWIDTH_Value32NBO  bw 
)

An application would like TRANSPORT to connect to a peer.

Parameters
chhandle
peeridentity of the peer we need an address for
pkwhat kind of application will the application require (can be GNUNET_MQ_PRIO_BACKGROUND, we will still try to connect)
bwdesired bandwidth, can be zero (we will still try to connect)
Returns
suggest handle, NULL if a request is already pending

Definition at line 289 of file transport_api2_application.c.

294{
296
298 s->ch = ch;
299 s->id = *peer;
300 s->pk = pk;
301 s->bw = bw;
303 ch->sug_requests,
304 &s->id,
305 s,
308 "Requesting TRANSPORT to suggest address for `%s'\n",
309 GNUNET_i2s (peer));
310 if (NULL == ch->mq)
311 return s;
313 return s;
314}
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
@ GNUNET_OK
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_DEBUG
Handle for TRANSPORT address suggestion requests.
enum GNUNET_MQ_PriorityPreferences pk
What preference is being expressed?
struct GNUNET_TRANSPORT_ApplicationHandle * ch
Connecitivity handle this suggestion handle belongs to.
struct GNUNET_BANDWIDTH_Value32NBO bw
How much bandwidth does the client expect?
struct GNUNET_PeerIdentity id
ID of the peer for which address suggestion was requested.
static int transmit_suggestion(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Transmit request for an address suggestion.
#define LOG(kind,...)

References GNUNET_TRANSPORT_ApplicationSuggestHandle::bw, ch, GNUNET_TRANSPORT_ApplicationSuggestHandle::ch, GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_new, GNUNET_OK, GNUNET_TRANSPORT_ApplicationSuggestHandle::id, LOG, GNUNET_CADET_Channel::mq, pk, GNUNET_TRANSPORT_ApplicationSuggestHandle::pk, and transmit_suggestion().

Referenced by attempt_connect(), consider_peer_activate(), GCP_set_hello(), gnunet_drop(), gnunet_hold(), GNUNET_TRANSPORT_TESTING_connect_peers(), and notify_disconnect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_application_suggest_cancel()

void GNUNET_TRANSPORT_application_suggest_cancel ( struct GNUNET_TRANSPORT_ApplicationSuggestHandle sh)

We no longer care about being connected to a peer.

Parameters
shhandle to stop

Definition at line 323 of file transport_api2_application.c.

325{
327 struct GNUNET_MQ_Envelope *ev;
329
331 "Telling TRANSPORT we no longer care for an address for `%s'\n",
332 GNUNET_i2s (&sh->id));
334 GNUNET_OK ==
335 GNUNET_CONTAINER_multipeermap_remove (ch->sug_requests, &sh->id, sh));
336 if (NULL == ch->mq)
337 {
338 GNUNET_free (sh);
339 return;
340 }
342 m->pk = htonl ((uint32_t) sh->pk);
343 m->bw = sh->bw;
344 m->peer = sh->id;
345 GNUNET_MQ_send (ch->mq, ev);
346 GNUNET_free (sh);
347}
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static struct GNUNET_IDENTITY_Handle * sh
Handle to IDENTITY service.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
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_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL
Type of the 'struct ExpressPreferenceMessage' send by clients to TRANSPORT to abandon bandwidth prefe...
Application client to TRANSPORT service: we would like to have address suggestions for this peer.
Definition: transport.h:774

References ch, GNUNET_assert, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_OK, LOG, m, GNUNET_CADET_Channel::mq, and sh.

Referenced by attempt_connect(), consider_peer_activate(), core_disconnect_cb(), destroy_peer(), free_peer(), GCP_set_hello(), gnunet_drop(), gnunet_hold(), GNUNET_TRANSPORT_TESTING_connect_peers_cancel(), and notify_connect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_application_validate()

void GNUNET_TRANSPORT_application_validate ( struct GNUNET_TRANSPORT_ApplicationHandle ch,
const struct GNUNET_PeerIdentity peer,
enum GNUNET_NetworkType  nt,
const char *  addr 
)

An application (or a communicator) has received a HELLO (or other address data of another peer) and wants TRANSPORT to validate that the address is correct.

The result is NOT returned, in fact TRANSPORT may do nothing (i.e. if it has too many active validations or recently tried this one already). If the addr validates, TRANSPORT will persist the address with PEERSTORE.

Parameters
chhandle
peeridentity of the peer we have an address for
ntnetwork type of addr (as claimed by the other peer); used by TRANSPORT to avoid trying addr's that really cannot work due to network type mismatches
addraddress to validate

Definition at line 366 of file transport_api2_application.c.

371{
372 struct GNUNET_MQ_Envelope *ev;
374 size_t alen;
375
376 if (NULL == ch->mq)
377 {
378 GNUNET_log (
380 "Address validation for %s:%s skipped as transport is not connected\n",
382 addr);
383 return;
384 }
385 alen = strlen (addr) + 1;
386 ev =
388 alen,
390 m->peer = *peer;
391 m->nt = htonl ((uint32_t) nt);
392 memcpy (&m[1], addr, alen);
393 GNUNET_MQ_send (ch->mq, ev);
394}
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_WARNING
#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_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION
Type of the 'struct RequestHelloValidationMessage' send by clients to TRANSPORT to trigger validation...
We got an address of another peer, TRANSPORT service should validate it.
Definition: transport.h:805
struct GNUNET_PeerIdentity peer
Peer to the address is presumably for.
Definition: transport.h:820

References ch, GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), m, GNUNET_CADET_Channel::mq, nt, and RequestHelloValidationMessage::peer.

Referenced by connect_peers_run(), gnunet_try_connect(), and sock_read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_communicator_connect()

struct GNUNET_TRANSPORT_CommunicatorHandle * GNUNET_TRANSPORT_communicator_connect ( const struct GNUNET_CONFIGURATION_Handle cfg,
const char *  config_section_name,
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.

Parameters
cfgconfiguration to use
config_section_namesection of the configuration to use for options
addr_prefixaddress prefix for addresses supported by this communicator, could be NULL for incoming-only communicators
ccwhat characteristics does the communicator have?
mq_initfunction to call to initialize a message queue given the address of another peer, can be NULL if the communicator only supports receiving messages
mq_init_clsclosure for mq_init
notify_cbfunction to pass backchannel messages to communicator
notify_cb_clsclosure for notify_cb
Returns
NULL on error

Definition at line 827 of file transport_api2_communication.c.

836{
838
840 ch->cfg = cfg;
841 ch->config_section = config_section;
842 ch->addr_prefix = addr_prefix;
843 ch->mq_init = mq_init;
844 ch->mq_init_cls = mq_init_cls;
845 ch->notify_cb = notify_cb;
846 ch->notify_cb_cls = notify_cb_cls;
847 ch->cc = cc;
848 reconnect (ch);
849 if (GNUNET_OK !=
852 "MAX_QUEUE_LENGTH",
853 &ch->max_queue_length))
854 ch->max_queue_length = DEFAULT_MAX_QUEUE_LENGTH;
855 if (NULL == ch->mq)
856 {
857 GNUNET_free (ch);
858 return NULL;
859 }
860 return ch;
861}
static void notify_cb(void *cls, const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *msg)
Function called when the transport service has received a backchannel message for this communicator (...
static int mq_init(void *cls, const struct GNUNET_PeerIdentity *peer_id, const char *address)
Function called by the transport service to initialize a message queue given address information abou...
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
Opaque handle to the transport service for communicators.
enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc
Characteristics of the communicator.
const char * addr_prefix
Address prefix to use.
const char * config_section
Config section to use.
static void reconnect(struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
(re)connect our communicator to the transport service
#define DEFAULT_MAX_QUEUE_LENGTH
How many messages do we keep at most in the queue to the transport service before we start to drop (d...

References GNUNET_TRANSPORT_CommunicatorHandle::addr_prefix, GNUNET_TRANSPORT_CommunicatorHandle::cc, cfg, ch, GNUNET_TRANSPORT_CommunicatorHandle::config_section, DEFAULT_MAX_QUEUE_LENGTH, GNUNET_CONFIGURATION_get_value_number(), GNUNET_free, GNUNET_new, GNUNET_OK, GNUNET_CADET_Channel::mq, mq_init(), GNUNET_TRANSPORT_CommunicatorHandle::mq_init_cls, notify_cb(), GNUNET_TRANSPORT_CommunicatorHandle::notify_cb_cls, and reconnect().

Referenced by init_socket(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_communicator_disconnect()

void GNUNET_TRANSPORT_communicator_disconnect ( struct GNUNET_TRANSPORT_CommunicatorHandle ch)

Disconnect from the transport service.

Parameters
chhandle returned from connect

Definition at line 870 of file transport_api2_communication.c.

872{
873 disconnect (ch);
874 while (NULL != ch->ai_head)
875 {
876 GNUNET_break (0); /* communicator forgot to remove address, warn! */
878 }
879 GNUNET_free (ch);
880}
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.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
static void disconnect(struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
Disconnect from the transport service.

References ch, disconnect(), GNUNET_break, GNUNET_free, and GNUNET_TRANSPORT_communicator_address_remove().

Referenced by do_shutdown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_communicator_receive()

int GNUNET_TRANSPORT_communicator_receive ( struct GNUNET_TRANSPORT_CommunicatorHandle handle,
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.

Parameters
handleconnection to transport service
senderpresumed sender of the message (details to be checked by higher layers)
msgthe message
expected_addr_validityhow long does the communicator believe it will continue to be able to receive messages from the same address on which it received this message?
cbfunction to call once handling the message is done, NULL if flow control is not supported by this communicator
cb_clsclosure for cb
Returns
GNUNET_OK if all is well, GNUNET_NO if the message was immediately dropped due to memory limitations (communicator should try to apply back pressure), GNUNET_SYSERR if the message could not be delivered because the transport service is not yet up

Definition at line 887 of file transport_api2_communication.c.

894{
895 struct GNUNET_MQ_Envelope *env;
897 uint16_t msize;
898
899
901 "communicator receive\n");
902
903 if (NULL == ch->mq)
904 return GNUNET_SYSERR;
905 if ((NULL == cb) && (GNUNET_MQ_get_length (ch->mq) >= ch->max_queue_length))
906 {
907 GNUNET_log (
909 "Dropping message: transport is too slow, queue length %llu exceeded\n",
910 ch->max_queue_length);
911 return GNUNET_NO;
912 }
913
914 msize = ntohs (msg->size);
915 env =
917 if (NULL == env)
918 {
919 GNUNET_break (0);
920 return GNUNET_SYSERR;
921 }
923 GNUNET_TIME_relative_hton (expected_addr_validity);
924 im->sender = *sender;
925 // FIXME: this is expensive, would be better if we would
926 // re-design the API to allow us to create the envelope first,
927 // and then have the application fill in the body so we do
928 // not have to memcpy()
929 memcpy (&im[1], msg, msize);
930 im->fc_on = htonl (GNUNET_NO);
931 if (NULL != cb)
932 {
933 struct FlowControl *fc;
934
935 im->fc_on = htonl (GNUNET_YES);
936 im->fc_id = ch->fc_gen++;
937 fc = GNUNET_new (struct FlowControl);
938 fc->sender = *sender;
939 fc->id = im->fc_id;
940 fc->cb = cb;
941 fc->cb_cls = cb_cls;
942 GNUNET_CONTAINER_DLL_insert (ch->fc_head, ch->fc_tail, fc);
944 "Created flow control id %" PRIu64 " for sender %s\n",
945 fc->id,
946 GNUNET_i2s (&fc->sender));
947 }
949 return GNUNET_OK;
950}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
@ GNUNET_NO
@ GNUNET_SYSERR
unsigned int GNUNET_MQ_get_length(struct GNUNET_MQ_Handle *mq)
Obtain the current length of the message queue.
Definition: mq.c:293
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG
inform transport about an incoming message
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:618
Information we track per packet to enable flow control.
GNUNET_TRANSPORT_MessageCompletedCallback cb
Function to call once the message was processed.
struct GNUNET_PeerIdentity sender
Which peer is this about?
uint64_t id
More-or-less unique ID for the message.
void * cb_cls
Closure for cb.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
Inform transport about an incoming message.
Definition: transport.h:328
struct GNUNET_TIME_RelativeNBO expected_address_validity
How long does the communicator believe the address on which the message was received to remain valid?
Definition: transport.h:348
struct GNUNET_PeerIdentity sender
Sender identifier.
Definition: transport.h:353
uint32_t fc_on
Do we use flow control or not?
Definition: transport.h:337
uint64_t fc_id
64-bit number to identify the matching ACK.
Definition: transport.h:342

References FlowControl::cb, FlowControl::cb_cls, ch, env, GNUNET_TRANSPORT_IncomingMessage::expected_address_validity, GNUNET_TRANSPORT_IncomingMessage::fc_id, GNUNET_TRANSPORT_IncomingMessage::fc_on, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG, GNUNET_MQ_get_length(), GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_relative_hton(), GNUNET_YES, FlowControl::id, GNUNET_CADET_Channel::mq, msg, GNUNET_TRANSPORT_IncomingMessage::sender, FlowControl::sender, and GNUNET_MessageHeader::size.

Referenced by pass_plaintext_to_core(), recv_from_streams(), and select_read_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_communicator_mq_add()

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.

Parameters
chconnection to transport service
peerpeer with which we can now communicate
addressaddress in human-readable format, 0-terminated, UTF-8
mtumaximum message size supported by queue, 0 if sending is not supported, SIZE_MAX for no MTU
q_lennumber of messages that can be send through this queue
priorityqueue priority. Queues with highest priority should be used
ntwhich network type does the address belong to?
cswhat is the connection status of the queue?
mqmessage queue of the peer
Returns
API handle identifying the new MQ

Definition at line 957 of file transport_api2_communication.c.

967{
969
970 // Do not notify the service if there is no intial capacity.
971 GNUNET_assert (0 < q_len);
972
974 qh->ch = ch;
975 qh->peer = *peer;
977 qh->nt = nt;
978 qh->mtu = mtu;
979 qh->q_len = q_len;
980 qh->priority = priority;
981 qh->cs = cs;
982 qh->mq = mq;
983 qh->queue_id = ch->queue_gen++;
984 GNUNET_CONTAINER_DLL_insert (ch->queue_head, ch->queue_tail, qh);
985 send_add_queue (qh);
986 return qh;
987}
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
static char * address
GNS address for this phone.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
Handle returned to identify the internal data structure the transport API has created to manage a mes...
enum GNUNET_TRANSPORT_ConnectionStatus cs
Communication status of the queue.
struct GNUNET_MQ_Handle * mq
The queue itself.
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.
static void send_add_queue(struct GNUNET_TRANSPORT_QueueHandle *qh)
Send message to the transport service about queue qh being now available.

References address, GNUNET_TRANSPORT_QueueHandle::address, ch, GNUNET_TRANSPORT_QueueHandle::ch, GNUNET_TRANSPORT_QueueHandle::cs, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_strdup, mq, GNUNET_TRANSPORT_QueueHandle::mq, GNUNET_TRANSPORT_QueueHandle::mtu, nt, GNUNET_TRANSPORT_QueueHandle::nt, GNUNET_TRANSPORT_QueueHandle::peer, GNUNET_TRANSPORT_QueueHandle::priority, GNUNET_TRANSPORT_QueueHandle::q_len, GNUNET_TRANSPORT_QueueHandle::queue_id, and send_add_queue().

Referenced by add_acks(), setup_peer_mq(), setup_queue(), setup_receiver_mq(), and try_handle_plaintext().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_communicator_mq_update()

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.

Parameters
chconnection to transport service
u_qhthe queue to update
q_lennumber of messages that can be send through this queue
priorityqueue priority. Queues with highest priority should be used

Definition at line 991 of file transport_api2_communication.c.

996{
998
999 for (qh = ch->queue_head; NULL != qh; qh = qh->next)
1000 {
1001 if (u_qh == qh)
1002 break;
1003 }
1004 GNUNET_assert (NULL != qh);
1005 qh->q_len = q_len;
1006 qh->priority = priority;
1007 send_update_queue (qh);
1008}
struct GNUNET_TRANSPORT_QueueHandle * next
Kept in a DLL.
static void send_update_queue(struct GNUNET_TRANSPORT_QueueHandle *qh)
Send message to the transport service about queue qh updated.

References ch, GNUNET_assert, GNUNET_TRANSPORT_QueueHandle::next, GNUNET_TRANSPORT_QueueHandle::priority, GNUNET_TRANSPORT_QueueHandle::q_len, and send_update_queue().

Referenced by add_acks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_communicator_mq_del()

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.

Parameters
qhhandle for the queue that must be invalidated

Definition at line 1018 of file transport_api2_communication.c.

1019{
1021
1022 send_del_queue (qh);
1023 GNUNET_CONTAINER_DLL_remove (ch->queue_head, ch->queue_tail, qh);
1024 GNUNET_MQ_destroy (qh->mq);
1025 GNUNET_free (qh->address);
1026 GNUNET_free (qh);
1027}
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static void send_del_queue(struct GNUNET_TRANSPORT_QueueHandle *qh)
Send message to the transport service about queue qh being no longer available.

References GNUNET_TRANSPORT_QueueHandle::address, ch, GNUNET_TRANSPORT_QueueHandle::ch, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_TRANSPORT_QueueHandle::mq, and send_del_queue().

Referenced by peer_destroy(), queue_destroy(), and receiver_destroy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_communicator_address_add()

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.

Parameters
chconnection to transport service
addressour address in human-readable format, 0-terminated, UTF-8
ntwhich network type does the address belong to?
expirationwhen does the communicator forsee this address expiring?

Definition at line 1040 of file transport_api2_communication.c.

1045{
1047
1049 ai->ch = ch;
1051 ai->nt = nt;
1053 ai->aid = ch->aid_gen++;
1054 GNUNET_CONTAINER_DLL_insert (ch->ai_head, ch->ai_tail, ai);
1056 return ai;
1057}
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
static struct GNUNET_TIME_Relative expiration
User supplied expiration value.
Internal representation of an address a communicator is currently providing for the transport service...
struct GNUNET_TIME_Relative expiration
When does the address expire? (Expected lifetime of the address.)
enum GNUNET_NetworkType nt
Network type for the address.
uint32_t aid
Internal UUID for the address used in communication with the transport service.
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Transport handle where the address was added.
static void send_add_address(struct GNUNET_TRANSPORT_AddressIdentifier *ai)
Send message to the transport service about address ai being now available.

References address, GNUNET_TRANSPORT_AddressIdentifier::address, ai, GNUNET_TRANSPORT_AddressIdentifier::aid, ch, GNUNET_TRANSPORT_AddressIdentifier::ch, expiration, GNUNET_TRANSPORT_AddressIdentifier::expiration, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_strdup, nt, GNUNET_TRANSPORT_AddressIdentifier::nt, and send_add_address().

Referenced by nat_address_cb(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_communicator_address_remove()

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.

Parameters
aiaddress that is no longer provided

Definition at line 1067 of file transport_api2_communication.c.

1069{
1071
1073 GNUNET_CONTAINER_DLL_remove (ch->ai_head, ch->ai_tail, ai);
1075 GNUNET_free (ai);
1076 ai = NULL;
1077}
static void send_del_address(struct GNUNET_TRANSPORT_AddressIdentifier *ai)
Send message to the transport service about address ai being no longer available.

References GNUNET_TRANSPORT_AddressIdentifier::address, ai, ch, GNUNET_TRANSPORT_AddressIdentifier::ch, GNUNET_CONTAINER_DLL_remove, GNUNET_free, and send_del_address().

Referenced by do_shutdown(), GNUNET_TRANSPORT_communicator_address_remove_all(), GNUNET_TRANSPORT_communicator_disconnect(), and nat_address_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_communicator_address_remove_all()

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.

Parameters
chThe communicator handle.

Definition at line 1086 of file transport_api2_communication.c.

1088{
1089 struct GNUNET_TRANSPORT_AddressIdentifier *ai = ch->ai_head;
1090 while (NULL != ai)
1091 {
1092 struct GNUNET_TRANSPORT_AddressIdentifier *ai_next = ai->next;
1094 ai = ai_next;
1095 }
1096}
struct GNUNET_TRANSPORT_AddressIdentifier * next
Kept in a DLL.

References ai, ch, GNUNET_TRANSPORT_communicator_address_remove(), and GNUNET_TRANSPORT_AddressIdentifier::next.

Referenced by do_shutdown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_communicator_notify()

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.

This must only be done for special control traffic (as there is no flow control for this API), such as acknowledgements, and generally only be done if the communicator is uni-directional (i.e. cannot send the message back itself).

While backchannel messages are signed and encrypted, communicators must protect against replay attacks when using this backchannel communication!

Parameters
chhandle of this communicator
pidpeer to send the message to
commname of the communicator to send the message to
headerheader of the message to transmit and pass via the notify-API to pid's communicator comm

Definition at line 1103 of file transport_api2_communication.c.

1108{
1109 struct GNUNET_MQ_Envelope *env;
1111 size_t slen = strlen (comm) + 1;
1112 uint16_t mlen = ntohs (header->size);
1113
1114 GNUNET_assert (mlen + slen + sizeof(*cb) < UINT16_MAX);
1115 env =
1117 slen + mlen,
1119 cb->pid = *pid;
1120 memcpy (&cb[1], header, mlen);
1121 memcpy (((char *) &cb[1]) + mlen, comm, slen);
1122 GNUNET_MQ_send (ch->mq, env);
1123}
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL
Tell transport that it should assist with exchanging a message between communicators.
Message from communicator to transport service asking for transmission of a backchannel message with ...
Definition: transport.h:621
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL.
Definition: transport.h:625
struct GNUNET_PeerIdentity pid
Target peer.
Definition: transport.h:635

References ch, env, GNUNET_assert, GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TRANSPORT_CommunicatorBackchannel::header, GNUNET_CADET_Channel::mq, pid, GNUNET_TRANSPORT_CommunicatorBackchannel::pid, and GNUNET_MessageHeader::size.

Referenced by consider_ss_ack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_core_connect()

struct GNUNET_TRANSPORT_CoreHandle * GNUNET_TRANSPORT_core_connect ( const struct GNUNET_CONFIGURATION_Handle cfg,
const struct GNUNET_PeerIdentity self,
const struct GNUNET_MQ_MessageHandler handlers,
void *  cls,
GNUNET_TRANSPORT_NotifyConnect  nc,
GNUNET_TRANSPORT_NotifyDisconnect  nd 
)

Connect to the transport service.

Note that the connection may complete (or fail) asynchronously.

Parameters
cfgconfiguration to use
selfour own identity (API should check that it matches the identity found by transport), or NULL (no check)
handlersarray of message handlers; note that the closures provided will be ignored and replaced with the respective return value from nc
handlersarray with handlers to call when we receive messages, or NULL
clsclosure for the nc, nd and neb callbacks
ncfunction to call on connect events, or NULL
ndfunction to call on disconnect events, or NULL
nebfunction to call if we have excess bandwidth to a peer, or NULL
Returns
NULL on error

Referenced by GNUNET_TRANSPORT_TESTING_restart_peer(), GNUNET_TRANSPORT_TESTING_start_peer(), GSC_KX_init(), run(), and start_peer_run().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_core_disconnect()

void GNUNET_TRANSPORT_core_disconnect ( struct GNUNET_TRANSPORT_CoreHandle handle)

Disconnect from the transport service.

Parameters
handlehandle returned from connect

Referenced by GNUNET_TRANSPORT_TESTING_restart_peer(), GNUNET_TRANSPORT_TESTING_stop_peer(), GSC_KX_done(), shutdown_task(), and stop_peer_run().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_monitor()

struct GNUNET_TRANSPORT_MonitorContext * GNUNET_TRANSPORT_monitor ( const struct GNUNET_CONFIGURATION_Handle cfg,
const struct GNUNET_PeerIdentity peer,
int  one_shot,
GNUNET_TRANSPORT_MonitorCallback  cb,
void *  cb_cls 
)

Return information about a specific peer or all peers currently known to transport service once or in monitoring mode.

To obtain information about a specific peer, a peer identity can be passed. To obtain information about all peers currently known to transport service, NULL can be passed as peer identity.

For each peer, the callback is called with information about the address used to communicate with this peer, the state this peer is currently in and the the current timeout for this state.

Upon completion, the #GNUNET_TRANSPORT_PeerIterateCallback is called one more time with NULL. After this, the operation must no longer be explicitly canceled.

The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called in the the peer_callback!

Parameters
cfgconfiguration to use
peera specific peer identity to obtain information for, NULL for all peers
one_shotGNUNET_YES to return the current state and then end (with NULL+NULL), GNUNET_NO to monitor peers continuously
cbfunction to call with the results
cb_clsclosure for mc

Definition at line 254 of file transport_api2_monitor.c.

259{
261
263 mc->cfg = cfg;
264 if (NULL != peer)
265 mc->peer = *peer;
266 mc->one_shot = one_shot;
267 mc->cb = cb;
268 mc->cb_cls = cb_cls;
269 reconnect (mc);
270 if (NULL == mc->mq)
271 {
272 GNUNET_free (mc);
273 return NULL;
274 }
275 return mc;
276}
static struct GNUNET_TESTBED_Controller * mc
Handle to the master controller.
Opaque handle to the transport service for monitors.
GNUNET_TRANSPORT_MonitorCallback cb
Function to call with monitor data.
int one_shot
GNUNET_YES to return the current state and then end.
struct GNUNET_PeerIdentity peer
Peer we monitor, all zeros for "all".
static void reconnect(struct GNUNET_TRANSPORT_MonitorContext *mc)
(re)connect our monitor to the transport service

References GNUNET_TRANSPORT_MonitorContext::cb, GNUNET_TRANSPORT_MonitorContext::cb_cls, cfg, GNUNET_free, GNUNET_new, mc, GNUNET_TRANSPORT_MonitorContext::one_shot, GNUNET_TRANSPORT_MonitorContext::peer, and reconnect().

Here is the call graph for this function:

◆ GNUNET_TRANSPORT_monitor_cancel()

void GNUNET_TRANSPORT_monitor_cancel ( struct GNUNET_TRANSPORT_MonitorContext mc)

Cancel request to monitor peers.

Parameters
mchandle for the request to cancel
pmchandle for the request to cancel

Definition at line 285 of file transport_api2_monitor.c.

286{
287 disconnect (mc);
288 GNUNET_free (mc);
289}
static void disconnect(struct GNUNET_TRANSPORT_MonitorContext *mc)
Disconnect from the transport service.

References disconnect(), GNUNET_free, and mc.

Referenced by handle_monitor_end().

Here is the call graph for this function:
Here is the caller graph for this function: