GNUnet  0.11.x
Data Structures | Macros | Typedefs | Enumerations | Functions
TRANSPORT service

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

Data Structures

struct  GNUNET_TRANSPORT_MonitorInformation
 Information about another peer's address. More...
 
struct  GNUNET_TRANSPORT_SessionInfo
 Information about a plugin's session. 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_HELLO_VERSION   0x00000000
 Version number of the transport API. More...
 
#define GNUNET_TRANSPORT_MANIPULATION_VERSION   0x00000003
 Version number of the transport API. More...
 
#define GNUNET_TRANSPORT_MONITOR_VERSION   0x00000000
 Version number of the transport API. More...
 
#define GNUNET_TRANSPORT_VERSION   0x00000003
 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_HelloUpdateCallback) (void *cls, const struct GNUNET_MessageHeader *hello)
 Function called whenever there is an update to the HELLO of this peer. More...
 
typedef void(* GNUNET_TRANSPORT_AddressCallback) (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address, enum GNUNET_NetworkType nt, struct GNUNET_TIME_Absolute expiration)
 Function with addresses found in a HELLO. 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...
 
typedef void(* GNUNET_TRANSPORT_AddressToStringCallback) (void *cls, const char *address, int res)
 Function to call with a textual representation of an address. More...
 
typedef void(* GNUNET_TRANSPORT_PeerIterateCallback) (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout)
 Function to call with information about a peer. More...
 
typedef int(* GNUNET_TRANSPORT_BlacklistCallback) (void *cls, const struct GNUNET_PeerIdentity *pid)
 Function that decides if a connection is acceptable or not. More...
 
typedef void(* GNUNET_TRANSPORT_SessionMonitorCallback) (void *cls, struct GNUNET_TRANSPORT_PluginSession *session, void **session_ctx, const struct GNUNET_TRANSPORT_SessionInfo *info)
 Function called by the plugin with information about the current sessions managed by the plugin (for monitoring). 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_NotifyExcessBandwidth) (void *cls, const struct GNUNET_PeerIdentity *neighbour, void *handlers_cls)
 Function called if we have "excess" bandwidth to 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...
 
enum  GNUNET_TRANSPORT_AddressClass {
  GNUNET_TRANSPORT_AC_NONE = 0 , GNUNET_TRANSPORT_AC_OTHER = 1 , GNUNET_TRANSPORT_AC_GLOBAL = 2 , GNUNET_TRANSPORT_AC_GLOBAL_PRIVATE = 4 ,
  GNUNET_TRANSPORT_AC_LAN = 8 , GNUNET_TRANSPORT_AC_WLAN = 16 , GNUNET_TRANSPORT_AC_BT = 32 , GNUNET_TRANSPORT_AC_ANY = 65535
}
 Some addresses contain sensitive information or are not suitable for global distribution. More...
 
enum  GNUNET_TRANSPORT_PeerState {
  GNUNET_TRANSPORT_PS_NOT_CONNECTED = 0 , GNUNET_TRANSPORT_PS_INIT_ATS , GNUNET_TRANSPORT_PS_SYN_SENT , GNUNET_TRANSPORT_PS_SYN_RECV_ATS ,
  GNUNET_TRANSPORT_PS_SYN_RECV_ACK , GNUNET_TRANSPORT_PS_CONNECTED , GNUNET_TRANSPORT_PS_RECONNECT_ATS , GNUNET_TRANSPORT_PS_RECONNECT_SENT ,
  GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT , GNUNET_TRANSPORT_PS_DISCONNECT , GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED
}
 Possible state of a neighbour. More...
 
enum  GNUNET_TRANSPORT_SessionState {
  GNUNET_TRANSPORT_SS_INIT , GNUNET_TRANSPORT_SS_HANDSHAKE , GNUNET_TRANSPORT_SS_UP , GNUNET_TRANSPORT_SS_UPDATE ,
  GNUNET_TRANSPORT_SS_DONE
}
 Possible states of a session in a plugin. More...
 

Functions

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_HelloGetHandleGNUNET_TRANSPORT_hello_get (const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_TRANSPORT_AddressClass ac, GNUNET_TRANSPORT_HelloUpdateCallback rec, void *rec_cls)
 Obtain updates on changes to the HELLO message for this peer. More...
 
void GNUNET_TRANSPORT_hello_get_cancel (struct GNUNET_TRANSPORT_HelloGetHandle *ghh)
 Stop receiving updates about changes to our HELLO message. More...
 
int GNUNET_TRANSPORT_hello_parse (const struct GNUNET_MessageHeader *hello, GNUNET_TRANSPORT_AddressCallback cb, void *cb_cls)
 Parse a HELLO message that we have received into its constituent addresses. More...
 
struct GNUNET_TRANSPORT_ManipulationHandleGNUNET_TRANSPORT_manipulation_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Connect to the transport service. More...
 
void GNUNET_TRANSPORT_manipulation_disconnect (struct GNUNET_TRANSPORT_ManipulationHandle *handle)
 Disconnect from the transport service. More...
 
void GNUNET_TRANSPORT_manipulation_set (struct GNUNET_TRANSPORT_ManipulationHandle *handle, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_ATS_Properties *prop, struct GNUNET_TIME_Relative delay_in, struct GNUNET_TIME_Relative delay_out)
 Set transport metrics for a peer and a direction. 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...
 
struct GNUNET_TRANSPORT_OfferHelloHandleGNUNET_TRANSPORT_offer_hello (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_MessageHeader *hello, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
 Offer the transport service the HELLO of another peer. More...
 
void GNUNET_TRANSPORT_offer_hello_cancel (struct GNUNET_TRANSPORT_OfferHelloHandle *ohh)
 Cancel the request to transport to offer the HELLO message. More...
 
struct GNUNET_TRANSPORT_AddressToStringContextGNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_HELLO_Address *address, int numeric, struct GNUNET_TIME_Relative timeout, GNUNET_TRANSPORT_AddressToStringCallback aluc, void *aluc_cls)
 Convert a binary address into a human readable address. More...
 
void GNUNET_TRANSPORT_address_to_string_cancel (struct GNUNET_TRANSPORT_AddressToStringContext *alc)
 Cancel request for address conversion. More...
 
const char * GNUNET_TRANSPORT_ps2s (enum GNUNET_TRANSPORT_PeerState state)
 Convert a transport state to a human readable string. More...
 
int GNUNET_TRANSPORT_is_connected (enum GNUNET_TRANSPORT_PeerState state)
 Check if a state is defined as connected. More...
 
struct GNUNET_TRANSPORT_PeerMonitoringContextGNUNET_TRANSPORT_monitor_peers (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *peer, int one_shot, GNUNET_TRANSPORT_PeerIterateCallback peer_callback, void *peer_callback_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_peers_cancel (struct GNUNET_TRANSPORT_PeerMonitoringContext *pic)
 Cancel request to monitor peers. More...
 
struct GNUNET_TRANSPORT_BlacklistGNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_TRANSPORT_BlacklistCallback cb, void *cb_cls)
 Install a blacklist callback. More...
 
void GNUNET_TRANSPORT_blacklist_cancel (struct GNUNET_TRANSPORT_Blacklist *br)
 Abort the blacklist. More...
 
struct GNUNET_TRANSPORT_PluginMonitorGNUNET_TRANSPORT_monitor_plugins (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_TRANSPORT_SessionMonitorCallback cb, void *cb_cls)
 Install a plugin session state monitor callback. More...
 
void GNUNET_TRANSPORT_monitor_plugins_cancel (struct GNUNET_TRANSPORT_PluginMonitor *pm)
 Cancel monitoring the plugin session state. 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, GNUNET_TRANSPORT_NotifyExcessBandwidth neb)
 Connect to the transport service. More...
 
struct GNUNET_MQ_HandleGNUNET_TRANSPORT_core_get_mq (struct GNUNET_TRANSPORT_CoreHandle *handle, const struct GNUNET_PeerIdentity *peer)
 Checks if a given peer is connected to us and get the message queue. More...
 

Detailed Description

Low-level communication with other peers.

Low-level P2P IO.

address information

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 51 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 56 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 48 of file gnunet_transport_core_service.h.

◆ GNUNET_TRANSPORT_HELLO_VERSION

#define GNUNET_TRANSPORT_HELLO_VERSION   0x00000000

Version number of the transport API.

Definition at line 52 of file gnunet_transport_hello_service.h.

◆ GNUNET_TRANSPORT_MANIPULATION_VERSION

#define GNUNET_TRANSPORT_MANIPULATION_VERSION   0x00000003

Version number of the transport API.

Definition at line 53 of file gnunet_transport_manipulation_service.h.

◆ GNUNET_TRANSPORT_MONITOR_VERSION

#define GNUNET_TRANSPORT_MONITOR_VERSION   0x00000000

Version number of the transport API.

Definition at line 53 of file gnunet_transport_monitor_service.h.

◆ GNUNET_TRANSPORT_VERSION

#define GNUNET_TRANSPORT_VERSION   0x00000003

Version number of the transport API.

Definition at line 51 of file gnunet_transport_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

Definition at line 76 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 128 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 183 of file gnunet_transport_communication_service.h.

◆ GNUNET_TRANSPORT_NotifyConnect [1/2]

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 69 of file gnunet_transport_core_service.h.

◆ GNUNET_TRANSPORT_NotifyDisconnect [1/2]

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 86 of file gnunet_transport_core_service.h.

◆ GNUNET_TRANSPORT_HelloUpdateCallback

typedef void(* GNUNET_TRANSPORT_HelloUpdateCallback) (void *cls, const struct GNUNET_MessageHeader *hello)

Function called whenever there is an update to the HELLO of this peer.

Parameters
clsclosure
helloour updated HELLO

Definition at line 120 of file gnunet_transport_hello_service.h.

◆ GNUNET_TRANSPORT_AddressCallback

typedef void(* GNUNET_TRANSPORT_AddressCallback) (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address, enum GNUNET_NetworkType nt, struct GNUNET_TIME_Absolute expiration)

Function with addresses found in a HELLO.

Parameters
clsclosure
peeridentity of the peer
addressthe address (UTF-8, 0-terminated)
ntnetwork type of the address
expirationwhen does this address expire?

Definition at line 166 of file gnunet_transport_hello_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 124 of file gnunet_transport_monitor_service.h.

◆ GNUNET_TRANSPORT_AddressToStringCallback

typedef void(* GNUNET_TRANSPORT_AddressToStringCallback) (void *cls, const char *address, int res)

Function to call with a textual representation of an address.

This function will be called several times with different possible textual representations, and a last time with address being NULL to signal the end of the iteration. Note that address NULL always is the last call, regardless of the value in res.

Parameters
clsclosure
addressNULL on end of iteration, otherwise 0-terminated printable UTF-8 string, in particular an empty string if res is GNUNET_NO
resresult of the address to string conversion: if GNUNET_OK: conversion successful if GNUNET_NO: address was invalid (or not supported) if GNUNET_SYSERR: communication error (IPC error)

Definition at line 118 of file gnunet_transport_service.h.

◆ GNUNET_TRANSPORT_PeerIterateCallback

typedef void(* GNUNET_TRANSPORT_PeerIterateCallback) (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout)

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
addressaddress, NULL if this is the final callback for iteration op
statecurrent state this peer is in
state_timeouttimeout for the current state of the peer

Definition at line 330 of file gnunet_transport_service.h.

◆ GNUNET_TRANSPORT_BlacklistCallback

typedef int(* GNUNET_TRANSPORT_BlacklistCallback) (void *cls, const struct GNUNET_PeerIdentity *pid)

Function that decides if a connection is acceptable or not.

Parameters
clsclosure
pidpeer to approve or disapproave
Returns
GNUNET_OK if the connection is allowed, GNUNET_SYSERR if not

Definition at line 399 of file gnunet_transport_service.h.

◆ GNUNET_TRANSPORT_SessionMonitorCallback

typedef void(* GNUNET_TRANSPORT_SessionMonitorCallback) (void *cls, struct GNUNET_TRANSPORT_PluginSession *session, void **session_ctx, const struct GNUNET_TRANSPORT_SessionInfo *info)

Function called by the plugin with information about the current sessions managed by the plugin (for monitoring).

Parameters
clsclosure
sessionsession handle this information is about, NULL to indicate that we are "in sync" (initial iteration complete)
session_ctxstorage location where the application can store data; will point to NULL on GNUNET_TRANSPORT_SS_INIT, and must be reset to NULL on GNUNET_TRANSPORT_SS_DONE
infoinformation about the state of the session, NULL if session is also NULL and we are merely signalling that the initial iteration is over; NULL with session being non-NULL if the monitor was being cancelled while sessions were active

Definition at line 547 of file gnunet_transport_service.h.

◆ GNUNET_TRANSPORT_NotifyConnect [2/2]

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 600 of file gnunet_transport_service.h.

◆ GNUNET_TRANSPORT_NotifyDisconnect [2/2]

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 618 of file gnunet_transport_service.h.

◆ GNUNET_TRANSPORT_NotifyExcessBandwidth

typedef void(* GNUNET_TRANSPORT_NotifyExcessBandwidth) (void *cls, const struct GNUNET_PeerIdentity *neighbour, void *handlers_cls)

Function called if we have "excess" bandwidth to a peer.

The notification will happen the first time we have excess bandwidth, and then only again after the client has performed some transmission to the peer.

Excess bandwidth is defined as being allowed (by ATS) to send more data, and us reaching the limit of the capacity build-up (which, if we go past it, means we don't use available bandwidth). See also the "max carry" in struct GNUNET_BANDWIDTH_Tracker.

Parameters
clsthe closure
neighbourpeer that we have excess bandwidth to
handlers_clsclosure of the handlers, was returned from the connect notification callback

Definition at line 641 of file gnunet_transport_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 94 of file gnunet_transport_communication_service.h.

95 {
100 
105 
110 };
@ 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 230 of file gnunet_transport_communication_service.h.

231 {
236 
241 
246 };
@ 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)

◆ GNUNET_TRANSPORT_AddressClass

Some addresses contain sensitive information or are not suitable for global distribution.

We use address classes to filter addresses by which domain they make sense to be used in. These are used in a bitmask.

Enumerator
GNUNET_TRANSPORT_AC_NONE 

No address.

GNUNET_TRANSPORT_AC_OTHER 

Addresses that fall into no other category (i.e.

incoming which we cannot use elsewhere).

GNUNET_TRANSPORT_AC_GLOBAL 

Addresses that are global and are insensitive (i.e.

IPv4).

GNUNET_TRANSPORT_AC_GLOBAL_PRIVATE 

Addresses that are global and are sensitive (i.e.

IPv6 with our MAC).

GNUNET_TRANSPORT_AC_LAN 

Addresses useful in the local wired network, i.e.

a MAC. Sensitive, but obvious to people nearby. Useful for broadcasts.

GNUNET_TRANSPORT_AC_WLAN 

Addresses useful in the local wireless network, i.e.

a MAC. Sensitive, but obvious to people nearby. Useful for broadcasts.

GNUNET_TRANSPORT_AC_BT 

Addresses useful in the local bluetooth network.

Sensitive, but obvious to people nearby. Useful for broadcasts.

GNUNET_TRANSPORT_AC_ANY 

Bitmask for "any" address.

Definition at line 61 of file gnunet_transport_hello_service.h.

62 {
67 
73 
79 
85 
92 
99 
105 
110 };
@ GNUNET_TRANSPORT_AC_BT
Addresses useful in the local bluetooth network.
@ GNUNET_TRANSPORT_AC_OTHER
Addresses that fall into no other category (i.e.
@ GNUNET_TRANSPORT_AC_LAN
Addresses useful in the local wired network, i.e.
@ GNUNET_TRANSPORT_AC_GLOBAL
Addresses that are global and are insensitive (i.e.
@ GNUNET_TRANSPORT_AC_NONE
No address.
@ GNUNET_TRANSPORT_AC_GLOBAL_PRIVATE
Addresses that are global and are sensitive (i.e.
@ GNUNET_TRANSPORT_AC_ANY
Bitmask for "any" address.
@ GNUNET_TRANSPORT_AC_WLAN
Addresses useful in the local wireless network, i.e.

◆ GNUNET_TRANSPORT_PeerState

Possible state of a neighbour.

Initially, we are GNUNET_TRANSPORT_PS_NOT_CONNECTED.

Then, there are two main paths. If we receive a SYN message, we give the inbound address to ATS. After the check we ask ATS for a suggestion (#GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS). If ATS makes a suggestion, we send our SYN_ACK and go to #GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK. If we receive a ACK, we go to GNUNET_TRANSPORT_PS_CONNECTED (and notify everyone about the new connection). If the operation times out, we go to GNUNET_TRANSPORT_PS_DISCONNECT.

The other case is where we transmit a SYN message first. We start with GNUNET_TRANSPORT_PS_INIT_ATS. If we get an address, we send the SYN message and go to state #GNUNET_TRANSPORT_PS_CONNECT_SENT. Once we receive a SYN_ACK, we go to GNUNET_TRANSPORT_PS_CONNECTED (and notify everyone about the new connection and send back a ACK). If the operation times out, we go to GNUNET_TRANSPORT_PS_DISCONNECT.

If the session is in trouble (i.e. transport-level disconnect or timeout), we go to GNUNET_TRANSPORT_PS_RECONNECT_ATS where we ask ATS for a new address (we don't notify anyone about the disconnect yet). Once we have a new address, we enter GNUNET_TRANSPORT_PS_RECONNECT_SENT and send a SYN message. If we receive a SYN_ACK, we go to GNUNET_TRANSPORT_PS_CONNECTED and nobody noticed that we had trouble; we also send a ACK at this time just in case. If the operation times out, we go to GNUNET_TRANSPORT_PS_DISCONNECT (and notify everyone about the lost connection).

If ATS decides to switch addresses while we have a normal connection, we go to #GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT and send a SESSION_CONNECT. If we get a ACK back, we switch the primary connection to the suggested alternative from ATS, go back to GNUNET_TRANSPORT_PS_CONNECTED and send a ACK to the other peer just to be sure. If the operation times out we go to GNUNET_TRANSPORT_PS_CONNECTED (and notify ATS that the given alternative address is "invalid").

Once a session is in GNUNET_TRANSPORT_PS_DISCONNECT, it is cleaned up and then goes to (GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED). If we receive an explicit disconnect request, we can go from any state to GNUNET_TRANSPORT_PS_DISCONNECT, possibly after generating disconnect notifications.

Note that it is quite possible that while we are in any of these states, we could receive a 'SYN' request from the other peer. We then enter a 'weird' state where we pursue our own primary state machine (as described above), but with the 'send_connect_ack' flag set to 1. If our state machine allows us to send a 'SYN_ACK' (because we have an acceptable address), we send the 'SYN_ACK' and set the 'send_connect_ack' to 2. If we then receive a 'ACK', we go to GNUNET_TRANSPORT_PS_CONNECTED (and reset 'send_connect_ack' to 0).

Enumerator
GNUNET_TRANSPORT_PS_NOT_CONNECTED 

Fresh peer or completely disconnected.

GNUNET_TRANSPORT_PS_INIT_ATS 

Asked to initiate connection, trying to get address from ATS.

GNUNET_TRANSPORT_PS_SYN_SENT 

Sent SYN message to other peer, waiting for SYN_ACK.

GNUNET_TRANSPORT_PS_SYN_RECV_ATS 

Received a SYN, asking ATS about address suggestions.

GNUNET_TRANSPORT_PS_SYN_RECV_ACK 

SYN request from other peer was SYN_ACK'ed, waiting for ACK.

GNUNET_TRANSPORT_PS_CONNECTED 

Got our SYN_ACK/ACK, connection is up.

GNUNET_TRANSPORT_PS_RECONNECT_ATS 

Connection got into trouble, rest of the system still believes it to be up, but we're getting a new address from ATS.

GNUNET_TRANSPORT_PS_RECONNECT_SENT 

Sent SYN over new address (either by ATS telling us to switch addresses or from RECONNECT_ATS); if this fails, we need to tell the rest of the system about a disconnect.

GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT 

We have some primary connection, but ATS suggested we switch to some alternative; we now sent a SYN message for the alternative session to the other peer and waiting for a SYN_ACK to make this our primary connection.

GNUNET_TRANSPORT_PS_DISCONNECT 

Disconnect in progress (we're sending the DISCONNECT message to the other peer; after that is finished, the state will be cleaned up).

GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED 

We're finished with the disconnect; and are cleaning up the state now! We put the struct into this state when we are really in the task that calls 'free' on it and are about to remove the record from the map.

We should never find a 'struct NeighbourMapEntry' in this state in the map. Accessing a 'struct NeighbourMapEntry' in this state virtually always means using memory that has been freed (the exception being the cleanup code in free_neighbour()).

Definition at line 215 of file gnunet_transport_service.h.

216 {
221 
226 
231 
236 
241 
246 
252 
259 
267 
273 
284 };
@ GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED
We're finished with the disconnect; and are cleaning up the state now! We put the struct into this st...
@ GNUNET_TRANSPORT_PS_NOT_CONNECTED
Fresh peer or completely disconnected.
@ GNUNET_TRANSPORT_PS_INIT_ATS
Asked to initiate connection, trying to get address from ATS.
@ GNUNET_TRANSPORT_PS_SYN_RECV_ATS
Received a SYN, asking ATS about address suggestions.
@ GNUNET_TRANSPORT_PS_SYN_RECV_ACK
SYN request from other peer was SYN_ACK'ed, waiting for ACK.
@ GNUNET_TRANSPORT_PS_RECONNECT_SENT
Sent SYN over new address (either by ATS telling us to switch addresses or from RECONNECT_ATS); if th...
@ GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT
We have some primary connection, but ATS suggested we switch to some alternative; we now sent a SYN m...
@ GNUNET_TRANSPORT_PS_CONNECTED
Got our SYN_ACK/ACK, connection is up.
@ GNUNET_TRANSPORT_PS_SYN_SENT
Sent SYN message to other peer, waiting for SYN_ACK.
@ GNUNET_TRANSPORT_PS_RECONNECT_ATS
Connection got into trouble, rest of the system still believes it to be up, but we're getting a new a...
@ GNUNET_TRANSPORT_PS_DISCONNECT
Disconnect in progress (we're sending the DISCONNECT message to the other peer; after that is finishe...

◆ GNUNET_TRANSPORT_SessionState

Possible states of a session in a plugin.

Enumerator
GNUNET_TRANSPORT_SS_INIT 

The session was created (first call for each session object).

GNUNET_TRANSPORT_SS_HANDSHAKE 

Initial session handshake is in progress.

GNUNET_TRANSPORT_SS_UP 

Session is fully UP.

GNUNET_TRANSPORT_SS_UPDATE 

This is just an update about the session, the state did not change.

GNUNET_TRANSPORT_SS_DONE 

Session is being torn down and about to disappear.

Last call for each session object.

Definition at line 450 of file gnunet_transport_service.h.

451 {
456 
461 
466 
472 
478 };
@ GNUNET_TRANSPORT_SS_INIT
The session was created (first call for each session object).
@ GNUNET_TRANSPORT_SS_HANDSHAKE
Initial session handshake is in progress.
@ GNUNET_TRANSPORT_SS_DONE
Session is being torn down and about to disappear.
@ GNUNET_TRANSPORT_SS_UP
Session is fully UP.
@ GNUNET_TRANSPORT_SS_UPDATE
This is just an update about the session, the state did not change.

Function Documentation

◆ GNUNET_TRANSPORT_communicator_connect()

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 
)

Connect to the transport service.

Parameters
cfgconfiguration to use
config_sectionsection 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
Parameters
cfgconfiguration to use
config_sectionsection 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?
mtumaximum message size supported by communicator, 0 if sending is not supported, SIZE_MAX for no MTU
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 815 of file transport_api2_communication.c.

824 {
826 
828  ch->cfg = cfg;
829  ch->config_section = config_section;
830  ch->addr_prefix = addr_prefix;
831  ch->mq_init = mq_init;
832  ch->mq_init_cls = mq_init_cls;
833  ch->notify_cb = notify_cb;
834  ch->notify_cb_cls = notify_cb_cls;
835  ch->cc = cc;
836  reconnect (ch);
837  if (GNUNET_OK !=
840  "MAX_QUEUE_LENGTH",
841  &ch->max_queue_length))
842  ch->max_queue_length = DEFAULT_MAX_QUEUE_LENGTH;
843  if (NULL == ch->mq)
844  {
845  GNUNET_free (ch);
846  return NULL;
847  }
848  return ch;
849 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
static int mq_init(void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
Function called by the transport service to initialize a message queue given address information abou...
@ GNUNET_OK
Definition: gnunet_common.h:95
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.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MQ_Handle * mq
Message Queue for the channel (which we are implementing).
Definition: cadet.h:143
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.
GNUNET_TRANSPORT_CommunicatorNotify notify_cb
Function to call when the transport service receives messages for a communicator (i....
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, GNUNET_TRANSPORT_CommunicatorHandle::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 858 of file transport_api2_communication.c.

860 {
861  disconnect (ch);
862  while (NULL != ch->ai_head)
863  {
864  GNUNET_break (0); /* communicator forgot to remove address, warn! */
866  }
867  GNUNET_free (ch);
868 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
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.
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 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.

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
Parameters
chconnection 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 895 of file transport_api2_communication.c.

902 {
903  struct GNUNET_MQ_Envelope *env;
904  struct GNUNET_TRANSPORT_IncomingMessage *im;
905  uint16_t msize;
906 
907  if (NULL == ch->mq)
908  return GNUNET_SYSERR;
909  if ((NULL == cb) && (GNUNET_MQ_get_length (ch->mq) >= ch->max_queue_length))
910  {
911  GNUNET_log (
913  "Dropping message: transport is too slow, queue length %llu exceeded\n",
914  ch->max_queue_length);
915  return GNUNET_NO;
916  }
917 
918  msize = ntohs (msg->size);
919  env =
921  if (NULL == env)
922  {
923  GNUNET_break (0);
924  return GNUNET_SYSERR;
925  }
926  im->expected_address_validity =
927  GNUNET_TIME_relative_hton (expected_addr_validity);
928  im->sender = *sender;
929  // FIXME: this is expensive, would be better if we would
930  // re-design the API to allow us to create the envelope first,
931  // and then have the application fill in the body so we do
932  // not have to memcpy()
933  memcpy (&im[1], msg, msize);
934  im->fc_on = htonl (GNUNET_NO);
935  if (NULL != cb)
936  {
937  struct FlowControl *fc;
938 
939  im->fc_on = htonl (GNUNET_YES);
940  im->fc_id = ch->fc_gen++;
941  fc = GNUNET_new (struct FlowControl);
942  fc->sender = *sender;
943  fc->id = im->fc_id;
944  fc->cb = cb;
945  fc->cb_cls = cb_cls;
946  GNUNET_CONTAINER_DLL_insert (ch->fc_head, ch->fc_tail, fc);
947  }
948  GNUNET_MQ_send (ch->mq, env);
949  return GNUNET_OK;
950 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_log(kind,...)
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_NO
Definition: gnunet_common.h:94
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
@ GNUNET_ERROR_TYPE_WARNING
unsigned int GNUNET_MQ_get_length(struct GNUNET_MQ_Handle *mq)
Obtain the current length of the message queue.
Definition: mq.c:337
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:355
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:52
#define GNUNET_MESSAGE_TYPE_TRANSPORT_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:444
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.

References FlowControl::cb, FlowControl::cb_cls, ch, env, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_WARNING, 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, FlowControl::sender, and GNUNET_MessageHeader::size.

Referenced by pass_plaintext_to_core(), 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

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?
ccwhat characteristics does the communicator have?
cswhat is the connection status of the queue?
mqmessage queue of the peer
Returns
API handle identifying the new MQ

Definition at line 976 of file transport_api2_communication.c.

986 {
987  struct GNUNET_TRANSPORT_QueueHandle *qh;
988 
990  qh->ch = ch;
991  qh->peer = *peer;
992  qh->address = GNUNET_strdup (address);
993  qh->nt = nt;
994  qh->mtu = mtu;
995  qh->q_len = q_len;
996  qh->priority = priority;
997  qh->cs = cs;
998  qh->mq = mq;
999  qh->queue_id = ch->queue_gen++;
1000  GNUNET_CONTAINER_DLL_insert (ch->queue_head, ch->queue_tail, qh);
1001  send_add_queue (qh);
1002  return qh;
1003 }
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
static char * address
GNS address for this phone.
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
#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.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
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_CONTAINER_DLL_insert, GNUNET_new, GNUNET_strdup, mq, GNUNET_TRANSPORT_QueueHandle::mq, GNUNET_TRANSPORT_QueueHandle::mtu, nt, GNUNET_TRANSPORT_QueueHandle::nt, peer, GNUNET_TRANSPORT_QueueHandle::peer, GNUNET_TRANSPORT_QueueHandle::priority, GNUNET_TRANSPORT_QueueHandle::q_len, GNUNET_TRANSPORT_QueueHandle::queue_id, and send_add_queue().

Referenced by 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
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 1016 of file transport_api2_communication.c.

1021 {
1022  struct GNUNET_TRANSPORT_QueueHandle *qh;
1023 
1024  for (qh = ch->queue_head; NULL != qh; qh = qh->next)
1025  {
1026  if (u_qh == qh)
1027  break;
1028  }
1029  GNUNET_assert (NULL != qh);
1030  qh->q_len = q_len;
1031  qh->priority = priority;
1032  send_update_queue (qh);
1033 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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 1043 of file transport_api2_communication.c.

1044 {
1046 
1047  send_del_queue (qh);
1048  GNUNET_CONTAINER_DLL_remove (ch->queue_head, ch->queue_tail, qh);
1049  GNUNET_MQ_destroy (qh->mq);
1050  GNUNET_free (qh->address);
1051  GNUNET_free (qh);
1052 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
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 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 1065 of file transport_api2_communication.c.

1070 {
1072 
1074  ai->ch = ch;
1076  ai->nt = nt;
1078  ai->aid = ch->aid_gen++;
1079  GNUNET_CONTAINER_DLL_insert (ch->ai_head, ch->ai_tail, ai);
1080  send_add_address (ai);
1081  return ai;
1082 }
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
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 1091 of file transport_api2_communication.c.

1093 {
1095 
1096  send_del_address (ai);
1097  GNUNET_CONTAINER_DLL_remove (ch->ai_head, ch->ai_tail, ai);
1098  GNUNET_free (ai->address);
1099  GNUNET_free (ai);
1100 }
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 1108 of file transport_api2_communication.c.

1110 {
1111  for (struct GNUNET_TRANSPORT_AddressIdentifier *ai = ch->ai_head; NULL != ai;
1112  ai = ai->next)
1114 }
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

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).

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

1140 {
1141  struct GNUNET_MQ_Envelope *env;
1142  struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb;
1143  size_t slen = strlen (comm) + 1;
1144  uint16_t mlen = ntohs (header->size);
1145 
1146  GNUNET_assert (mlen + slen + sizeof(*cb) < UINT16_MAX);
1147  env =
1148  GNUNET_MQ_msg_extra (cb,
1149  slen + mlen,
1151  cb->pid = *pid;
1152  memcpy (&cb[1], header, mlen);
1153  memcpy (((char *) &cb[1]) + mlen, comm, slen);
1154  GNUNET_MQ_send (ch->mq, env);
1155 }
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.

References ch, env, GNUNET_assert, GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_CADET_Channel::mq, 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() [1/2]

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(), opstart_get_handle_transport(), 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
handlehandle to the service as returned from GNUNET_TRANSPORT_core_connect()

Definition at line 912 of file transport_api_core.c.

913 {
914  LOG (GNUNET_ERROR_TYPE_DEBUG, "Transport disconnect called!\n");
915  /* this disconnects all neighbours... */
916  if (NULL == handle->reconnect_task)
918  /* and now we stop trying to connect again... */
919  if (NULL != handle->reconnect_task)
920  {
922  handle->reconnect_task = NULL;
923  }
925  handle->neighbours = NULL;
926  GNUNET_free (handle->handlers);
927  handle->handlers = NULL;
929 }
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
@ GNUNET_ERROR_TYPE_DEBUG
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
struct GNUNET_SCHEDULER_Task * reconnect_task
Task to reconnect to the service.
Definition: dns_api.c:81
static void disconnect_and_schedule_reconnect(struct GNUNET_TRANSPORT_CoreHandle *h)
Function that will schedule the job that will try to connect us again to the client.
#define LOG(kind,...)

References disconnect_and_schedule_reconnect(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_SCHEDULER_cancel(), handle, LOG, and GNUNET_DNS_Handle::reconnect_task.

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

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

◆ GNUNET_TRANSPORT_hello_get()

struct GNUNET_TRANSPORT_HelloGetHandle* GNUNET_TRANSPORT_hello_get ( const struct GNUNET_CONFIGURATION_Handle cfg,
enum GNUNET_TRANSPORT_AddressClass  ac,
GNUNET_TRANSPORT_HelloUpdateCallback  rec,
void *  rec_cls 
)

Obtain updates on changes to the HELLO message for this peer.

The callback given in this function is never called synchronously.

Parameters
cfgconfiguration to use
acwhich network type should the addresses from the HELLO belong to?
recfunction to call with the HELLO
rec_clsclosure for rec
Returns
handle to cancel the operation

Obtain updates on changes to the HELLO message for this peer.

The callback given in this function is never called synchronously.

Parameters
cfgconfiguration
acwhich network type should the addresses from the HELLO belong to?
recfunction to call with the HELLO, sender will be our peer identity; message and sender will be NULL on timeout (handshake with transport service pending/failed). cost estimate will be 0.
rec_clsclosure for rec
Returns
handle to cancel the operation

Definition at line 230 of file transport_api_hello_get.c.

234 {
236 
238  ghh->rec = rec;
239  ghh->rec_cls = rec_cls;
240  ghh->cfg = cfg;
241  ghh->ac = ac;
242  reconnect (ghh);
243  if (NULL == ghh->mq)
244  {
245  GNUNET_free (ghh);
246  return NULL;
247  }
248  return ghh;
249 }
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
static struct GNUNET_TRANSPORT_HelloGetHandle * ghh
Handle to get our current HELLO.
Functions to call with this peer's HELLO.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
GNUNET_TRANSPORT_HelloUpdateCallback rec
Callback to call once we got our HELLO.
enum GNUNET_TRANSPORT_AddressClass ac
Type of HELLOs client cares about.
struct GNUNET_MQ_Handle * mq
Transport handle.
static void reconnect(void *cls)
Try again to connect to transport service.

References ac, GNUNET_TRANSPORT_HelloGetHandle::ac, cfg, GNUNET_TRANSPORT_HelloGetHandle::cfg, ghh, GNUNET_free, GNUNET_new, GNUNET_TRANSPORT_HelloGetHandle::mq, GNUNET_TRANSPORT_HelloGetHandle::rec, GNUNET_TRANSPORT_HelloGetHandle::rec_cls, and reconnect().

Referenced by GNUNET_TRANSPORT_TESTING_restart_peer(), GNUNET_TRANSPORT_TESTING_start_peer(), p1_transport_connect_cache_callback(), and run().

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

◆ GNUNET_TRANSPORT_hello_get_cancel()

void GNUNET_TRANSPORT_hello_get_cancel ( struct GNUNET_TRANSPORT_HelloGetHandle ghh)

Stop receiving updates about changes to our HELLO message.

Parameters
ghhhandle to cancel

Definition at line 258 of file transport_api_hello_get.c.

259 {
260  if (NULL != ghh->reconnect_task)
261  {
263  ghh->reconnect_task = NULL;
264  }
265  if (NULL != ghh->mq)
266  {
268  ghh->mq = NULL;
269  }
270  GNUNET_free (ghh);
271 }
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the task trying to reconnect to the service.

References ghh, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_TRANSPORT_HelloGetHandle::mq, and GNUNET_TRANSPORT_HelloGetHandle::reconnect_task.

Referenced by cleanup_occ(), GNUNET_TRANSPORT_TESTING_restart_peer(), GNUNET_TRANSPORT_TESTING_stop_peer(), hello_callback(), hello_update_cb(), and shutdown_task().

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

◆ GNUNET_TRANSPORT_hello_parse()

int GNUNET_TRANSPORT_hello_parse ( const struct GNUNET_MessageHeader hello,
GNUNET_TRANSPORT_AddressCallback  cb,
void *  cb_cls 
)

Parse a HELLO message that we have received into its constituent addresses.

Parameters
hellomessage to parse
cbfunction to call on each address found
cb_clsclosure for cb
Returns
GNUNET_OK if hello was well-formed, GNUNET_SYSERR if not

◆ GNUNET_TRANSPORT_manipulation_connect()

struct GNUNET_TRANSPORT_ManipulationHandle* GNUNET_TRANSPORT_manipulation_connect ( const struct GNUNET_CONFIGURATION_Handle cfg)

Connect to the transport service.

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

Parameters
cfgconfiguration to use
Returns
NULL on error

Definition at line 208 of file transport_api_manipulation.c.

210 {
212 
214  h->cfg = cfg;
216  "Connecting to transport service.\n");
217  reconnect (h);
218  if (NULL == h->mq)
219  {
220  GNUNET_free (h);
221  return NULL;
222  }
223  return h;
224 }
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
Handle for the transport service (includes all of the state for the transport service).
static void reconnect(void *cls)
Try again to connect to transport service.
#define LOG(kind,...)

References cfg, GNUNET_ARM_Handle::cfg, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_new, h, LOG, GNUNET_ARM_Handle::mq, and reconnect().

Referenced by GNUNET_TRANSPORT_TESTING_start_peer(), and run().

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

◆ GNUNET_TRANSPORT_manipulation_disconnect()

void GNUNET_TRANSPORT_manipulation_disconnect ( struct GNUNET_TRANSPORT_ManipulationHandle handle)

Disconnect from the transport service.

Parameters
handlehandle returned from connect
handlehandle to the service as returned from GNUNET_TRANSPORT_manipulation_connect()

Definition at line 233 of file transport_api_manipulation.c.

236 {
237  if (NULL == handle->reconnect_task)
239  /* and now we stop trying to connect again... */
240  if (NULL != handle->reconnect_task)
241  {
243  handle->reconnect_task = NULL;
244  }
246 }
static void disconnect_and_schedule_reconnect(struct GNUNET_TRANSPORT_ManipulationHandle *h)
Function that will schedule the job that will try to connect us again to the client.

References disconnect_and_schedule_reconnect(), GNUNET_free, GNUNET_SCHEDULER_cancel(), handle, and GNUNET_DNS_Handle::reconnect_task.

Referenced by do_shutdown(), GNUNET_TRANSPORT_TESTING_restart_peer(), GNUNET_TRANSPORT_TESTING_stop_peer(), and run().

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

◆ GNUNET_TRANSPORT_manipulation_set()

void GNUNET_TRANSPORT_manipulation_set ( struct GNUNET_TRANSPORT_ManipulationHandle handle,
const struct GNUNET_PeerIdentity peer,
const struct GNUNET_ATS_Properties prop,
struct GNUNET_TIME_Relative  delay_in,
struct GNUNET_TIME_Relative  delay_out 
)

Set transport metrics for a peer and a direction.

Parameters
handletransport handle
peerthe peer to set the metric for
propthe performance metrics to set
delay_ininbound delay to introduce
delay_outoutbound delay to introduce

Note: Delay restrictions in receiving direction will be enforced with one message delay.

Definition at line 175 of file transport_api_manipulation.c.

181 {
182  struct GNUNET_MQ_Envelope *env;
183  struct TrafficMetricMessage *msg;
184 
185  if (NULL == handle->mq)
186  return;
187  env = GNUNET_MQ_msg (msg,
189  msg->reserved = htonl (0);
190  msg->peer = *peer;
191  GNUNET_ATS_properties_hton (&msg->properties,
192  prop);
193  msg->delay_in = GNUNET_TIME_relative_hton (delay_in);
194  msg->delay_out = GNUNET_TIME_relative_hton (delay_out);
196  env);
197 }
static struct GNUNET_TIME_Relative delay_out
Outbound delay to apply to all peers.
static struct GNUNET_TIME_Relative delay_in
Inbound delay to apply to all peers.
void GNUNET_ATS_properties_hton(struct GNUNET_ATS_PropertiesNBO *nbo, const struct GNUNET_ATS_Properties *hbo)
Convert ATS properties from host to network byte order.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC
Message containing traffic metrics for transport service.
struct GNUNET_MQ_Handle * mq
Connection to DNS service, or NULL.
Definition: dns_api.c:61
Message from the library to the transport service asking for binary addresses known for a peer.
Definition: transport.h:494

References delay_in, delay_out, env, GNUNET_ATS_properties_hton(), GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_TIME_relative_hton(), handle, GNUNET_DNS_Handle::mq, msg, and peer.

Referenced by run().

Here is the call graph for this function:
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.
struct GNUNET_MQ_Handle * mq
The message queue to the controller service.
Definition: testbed_api.h:218
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration to use while connecting to controller.
Definition: testbed_api.h:213
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.
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_TESTBED_Controller::cfg, GNUNET_free, GNUNET_new, mc, GNUNET_TESTBED_Controller::mq, GNUNET_TRANSPORT_MonitorContext::one_shot, 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:

◆ GNUNET_TRANSPORT_offer_hello()

struct GNUNET_TRANSPORT_OfferHelloHandle* GNUNET_TRANSPORT_offer_hello ( const struct GNUNET_CONFIGURATION_Handle cfg,
const struct GNUNET_MessageHeader hello,
GNUNET_SCHEDULER_TaskCallback  cont,
void *  cont_cls 
)

Offer the transport service the HELLO of another peer.

Note that the transport service may just ignore this message if the HELLO is malformed or useless due to our local configuration.

Parameters
cfgconfiguration
hellothe hello message
contcontinuation to call when HELLO has been sent, tc reason GNUNET_SCHEDULER_REASON_TIMEOUT for fail tc reasong GNUNET_SCHEDULER_REASON_READ_READY for success
cont_clsclosure for cont
Returns
a struct GNUNET_TRANSPORT_OfferHelloHandle handle or NULL on failure, in case of failure cont will not be called

Definition at line 87 of file transport_api_offer_hello.c.

91 {
94  struct GNUNET_MQ_Envelope *env;
96 
97  if (GNUNET_OK !=
98  GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hello,
99  &peer))
100  {
101  GNUNET_break (0);
102  GNUNET_free (ohh);
103  return NULL;
104  }
105  ohh->mq = GNUNET_CLIENT_connect (cfg,
106  "transport",
107  NULL,
108  NULL,
109  ohh);
110  if (NULL == ohh->mq)
111  {
112  GNUNET_free (ohh);
113  return NULL;
114  }
115  ohh->cont = cont;
116  ohh->cls = cont_cls;
117  GNUNET_break (ntohs (hello->type) == GNUNET_MESSAGE_TYPE_HELLO);
118  env = GNUNET_MQ_msg_copy (hello);
121  ohh);
122  GNUNET_MQ_send (ohh->mq,
123  env);
124  return ohh;
125 }
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:1064
int GNUNET_HELLO_get_id(const struct GNUNET_HELLO_Message *hello, struct GNUNET_PeerIdentity *peer)
Get the peer identity from a HELLO message.
Definition: hello.c:671
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.
Definition: mq.c:787
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
Definition: mq.c:666
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
A HELLO message is used to exchange information about transports with other peers.
The identity of the host (wraps the signing key of the peer).
Entry in linked list for all offer-HELLO requests.
GNUNET_SCHEDULER_TaskCallback cont
Function to call once we are done.
struct GNUNET_MQ_Handle * mq
Transport service handle we use for transmission.
static void finished_hello(void *cls)
Done sending HELLO message to the service, notify application.

References cfg, GNUNET_TRANSPORT_OfferHelloHandle::cls, GNUNET_TRANSPORT_OfferHelloHandle::cont, env, finished_hello(), GNUNET_break, GNUNET_CLIENT_connect(), GNUNET_free, GNUNET_HELLO_get_id(), GNUNET_MESSAGE_TYPE_HELLO, GNUNET_MQ_msg_copy(), GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_new, GNUNET_OK, GNUNET_TRANSPORT_OfferHelloHandle::mq, peer, and GNUNET_MessageHeader::type.

Referenced by attempt_connect_task(), GCP_set_hello(), ip_try_connect(), offer_hello(), send_hello(), and try_connect().

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

◆ GNUNET_TRANSPORT_offer_hello_cancel()

void GNUNET_TRANSPORT_offer_hello_cancel ( struct GNUNET_TRANSPORT_OfferHelloHandle ohh)

Cancel the request to transport to offer the HELLO message.

Parameters
ohhthe struct GNUNET_TRANSPORT_OfferHelloHandle to cancel
ohhthe handle for the operation to cancel

Definition at line 134 of file transport_api_offer_hello.c.

136 {
137  GNUNET_MQ_destroy (ohh->mq);
138  GNUNET_free (ohh);
139 }

References GNUNET_free, GNUNET_MQ_destroy(), and GNUNET_TRANSPORT_OfferHelloHandle::mq.

Referenced by cleaning_task(), cleanup_occ_lp2c(), cleanup_rocc(), destroy_peer(), finished_hello(), free_connect_info(), GCP_set_hello(), GNUNET_TRANSPORT_TESTING_connect_peers_cancel(), libgnunet_plugin_dhtu_gnunet_done(), notify_connect(), offer_hello(), and try_connect().

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

◆ GNUNET_TRANSPORT_address_to_string()

struct GNUNET_TRANSPORT_AddressToStringContext* GNUNET_TRANSPORT_address_to_string ( const struct GNUNET_CONFIGURATION_Handle cfg,
const struct GNUNET_HELLO_Address address,
int  numeric,
struct GNUNET_TIME_Relative  timeout,
GNUNET_TRANSPORT_AddressToStringCallback  aluc,
void *  aluc_cls 
)

Convert a binary address into a human readable address.

Parameters
cfgconfiguration to use
addressaddress to convert (binary format)
numericshould (IP) addresses be displayed in numeric form (otherwise do reverse DNS lookup)
timeouthow long is the lookup allowed to take at most
alucfunction to call with the results
aluc_clsclosure for aluc
Returns
handle to cancel the operation, NULL on error

Definition at line 177 of file transport_api_address_to_string.c.

185 {
189  GNUNET_MQ_hd_var_size (reply,
192  alc),
194  };
195  size_t alen;
196  size_t slen;
197  struct AddressLookupMessage *msg;
198  struct GNUNET_MQ_Envelope *env;
199  char *addrbuf;
200 
201  alen = address->address_length;
202  slen = strlen (address->transport_name) + 1;
203  if ((alen + slen >= GNUNET_MAX_MESSAGE_SIZE
204  - sizeof(struct AddressLookupMessage)) ||
205  (alen >= GNUNET_MAX_MESSAGE_SIZE) ||
206  (slen >= GNUNET_MAX_MESSAGE_SIZE))
207  {
208  GNUNET_break (0);
209  GNUNET_free (alc);
210  return NULL;
211  }
212  alc->cb = aluc;
213  alc->cb_cls = aluc_cls;
214  alc->mq = GNUNET_CLIENT_connect (cfg,
215  "transport",
216  handlers,
218  alc);
219  if (NULL == alc->mq)
220  {
221  GNUNET_break (0);
222  GNUNET_free (alc);
223  return NULL;
224  }
226  "Client tries to resolve for peer `%s' address plugin %s len %u\n",
227  GNUNET_i2s (&address->peer),
228  address->transport_name,
229  (unsigned int) address->address_length);
231  alen + slen,
233  msg->numeric_only = htons ((int16_t) numeric);
234  msg->addrlen = htons ((uint16_t) alen);
236  addrbuf = (char *) &msg[1];
237  GNUNET_memcpy (addrbuf,
238  address->address,
239  alen);
240  GNUNET_memcpy (&addrbuf[alen],
241  address->transport_name,
242  slen);
243  GNUNET_MQ_send (alc->mq,
244  env);
245  return alc;
246 }
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
Definition: gnunet-abd.c:61
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static int numeric
Option -n.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_INFO
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY
Response to the address lookup request.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING
Request to look addresses of peers in server.
Message from the library to the transport service asking for converting a transport address to a huma...
Definition: transport.h:349
Message used to notify the transport API about an address to string conversion.
Definition: transport.h:324
Message handler for a specific message type.
GNUNET_TRANSPORT_AddressToStringCallback cb
Function to call with the human-readable address.
struct GNUNET_MQ_Handle * mq
Connection to the service.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...

References address, GNUNET_TRANSPORT_AddressToStringContext::cb, GNUNET_TRANSPORT_AddressToStringContext::cb_cls, cfg, env, GNUNET_break, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING, GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_TIME_relative_hton(), handlers, GNUNET_TRANSPORT_AddressToStringContext::mq, mq_error_handler(), msg, numeric, and timeout.

Referenced by ats_perf_cb(), ats_perf_mon_cb(), plugin_monitoring_cb(), print_address(), and resolve_peer_address().

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

◆ GNUNET_TRANSPORT_address_to_string_cancel()

void GNUNET_TRANSPORT_address_to_string_cancel ( struct GNUNET_TRANSPORT_AddressToStringContext alc)

Cancel request for address conversion.

Parameters
alcthe context handle

Definition at line 255 of file transport_api_address_to_string.c.

258 {
259  GNUNET_MQ_destroy (alc->mq);
260  GNUNET_free (alc);
261 }

References GNUNET_free, GNUNET_MQ_destroy(), and GNUNET_TRANSPORT_AddressToStringContext::mq.

Referenced by ats_perf_mon_cb(), end(), handle_reply(), mq_error_handler(), operation_timeout(), plugin_monitoring_cb(), and shutdown_task().

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

◆ GNUNET_TRANSPORT_ps2s()

const char* GNUNET_TRANSPORT_ps2s ( enum GNUNET_TRANSPORT_PeerState  state)

Convert a transport state to a human readable string.

Parameters
statethe state

Convert a transport state to a human readable string.

Parameters
statethe state value
Returns
corresponding string

Definition at line 132 of file transport_api_monitor_peers.c.

133 {
134  switch (state)
135  {
137  return "S_NOT_CONNECTED";
138 
140  return "S_INIT_ATS";
141 
143  return "S_SYN_SENT";
144 
146  return "S_SYN_RECV_ATS";
147 
149  return "S_SYN_RECV_ACK";
150 
152  return "S_CONNECTED";
153 
155  return "S_RECONNECT_ATS";
156 
158  return "S_RECONNECT_SENT";
159 
161  return "S_SWITCH_SYN_SENT";
162 
164  return "S_DISCONNECT";
165 
167  return "S_DISCONNECT_FINISHED";
168 
169  default:
170  GNUNET_break (0);
171  return "UNDEFINED";
172  }
173 }
enum State state
current state of profiling

References GNUNET_break, GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_TRANSPORT_PS_DISCONNECT, GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED, GNUNET_TRANSPORT_PS_INIT_ATS, GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TRANSPORT_PS_RECONNECT_ATS, GNUNET_TRANSPORT_PS_RECONNECT_SENT, GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT, GNUNET_TRANSPORT_PS_SYN_RECV_ACK, GNUNET_TRANSPORT_PS_SYN_RECV_ATS, GNUNET_TRANSPORT_PS_SYN_SENT, and state.

Referenced by disconnect_neighbour(), GNUNET_TRANSPORT_is_connected(), GST_neighbours_handle_session_ack(), GST_neighbours_handle_session_syn(), GST_neighbours_handle_session_syn_ack(), GST_neighbours_session_terminated(), master_task(), neighbours_changed_notification(), print_info(), send_peer_information(), set_state_and_timeout(), and switch_address_bl_check_cont().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_is_connected()

int GNUNET_TRANSPORT_is_connected ( enum GNUNET_TRANSPORT_PeerState  state)

Check if a state is defined as connected.

Parameters
statethe state value
Returns
GNUNET_YES or GNUNET_NO

Definition at line 93 of file transport_api_monitor_peers.c.

94 {
95  switch (state)
96  {
102  return GNUNET_NO;
103 
108  return GNUNET_YES;
109 
112  return GNUNET_NO;
113 
114  default:
116  "Unhandled state `%s'\n",
118  GNUNET_break (0);
119  break;
120  }
121  return GNUNET_SYSERR;
122 }
@ GNUNET_ERROR_TYPE_ERROR
const char * GNUNET_TRANSPORT_ps2s(enum GNUNET_TRANSPORT_PeerState state)
Convert peer state to human-readable string.

References GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_NO, GNUNET_SYSERR, GNUNET_TRANSPORT_ps2s(), GNUNET_TRANSPORT_PS_CONNECTED, GNUNET_TRANSPORT_PS_DISCONNECT, GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED, GNUNET_TRANSPORT_PS_INIT_ATS, GNUNET_TRANSPORT_PS_NOT_CONNECTED, GNUNET_TRANSPORT_PS_RECONNECT_ATS, GNUNET_TRANSPORT_PS_RECONNECT_SENT, GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT, GNUNET_TRANSPORT_PS_SYN_RECV_ACK, GNUNET_TRANSPORT_PS_SYN_RECV_ATS, GNUNET_TRANSPORT_PS_SYN_SENT, GNUNET_YES, and state.

Referenced by print_info(), process_peer_iteration_cb(), send_outbound_quota_to_clients(), set_state_and_timeout(), and test_connected().

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

◆ GNUNET_TRANSPORT_monitor_peers()

struct GNUNET_TRANSPORT_PeerMonitoringContext* GNUNET_TRANSPORT_monitor_peers ( const struct GNUNET_CONFIGURATION_Handle cfg,
const struct GNUNET_PeerIdentity peer,
int  one_shot,
GNUNET_TRANSPORT_PeerIterateCallback  peer_callback,
void *  peer_callback_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
peer_callbackfunction to call with the results
peer_callback_clsclosure for peer_callback

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
peer_callbackfunction to call with the results
peer_callback_clsclosure for peer_address_callback

Definition at line 419 of file transport_api_monitor_peers.c.

425 {
428 
429  pal_ctx->cb = peer_callback;
430  pal_ctx->cb_cls = peer_callback_cls;
431  pal_ctx->cfg = cfg;
432  if (NULL != peer)
433  pal_ctx->peer = *peer;
434  pal_ctx->one_shot = one_shot;
435  do_peer_connect (pal_ctx);
436  if (NULL == pal_ctx->mq)
437  {
438  GNUNET_free (pal_ctx);
439  return NULL;
440  }
441  return pal_ctx;
442 }
Context for iterating validation entries.
struct GNUNET_MQ_Handle * mq
Connection to the service.
GNUNET_TRANSPORT_PeerIterateCallback cb
Function to call with the binary address.
struct GNUNET_PeerIdentity peer
Identity of the peer to monitor.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
static void do_peer_connect(void *cls)
Task run to re-establish the connection.

References GNUNET_TRANSPORT_PeerMonitoringContext::cb, GNUNET_TRANSPORT_PeerMonitoringContext::cb_cls, cfg, GNUNET_TRANSPORT_PeerMonitoringContext::cfg, do_peer_connect(), GNUNET_free, GNUNET_new, GNUNET_TRANSPORT_PeerMonitoringContext::mq, GNUNET_TRANSPORT_PeerMonitoringContext::one_shot, peer, and GNUNET_TRANSPORT_PeerMonitoringContext::peer.

Referenced by run().

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

◆ GNUNET_TRANSPORT_monitor_peers_cancel()

void GNUNET_TRANSPORT_monitor_peers_cancel ( struct GNUNET_TRANSPORT_PeerMonitoringContext pic)

Cancel request to monitor peers.

Parameters
pichandle for the request to cancel

Definition at line 451 of file transport_api_monitor_peers.c.

454 {
455  if (NULL != pic->mq)
456  {
457  GNUNET_MQ_destroy (pic->mq);
458  pic->mq = NULL;
459  }
460  if (NULL != pic->reconnect_task)
461  {
462  GNUNET_SCHEDULER_cancel (pic->reconnect_task);
463  pic->reconnect_task = NULL;
464  }
465  GNUNET_free (pic);
466 }
static struct GNUNET_PEERINFO_IteratorContext * pic
Current iterator context (if active, otherwise NULL).

References GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), and pic.

Referenced by handle_response_end(), mq_error_handler(), and shutdown_task().

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

◆ GNUNET_TRANSPORT_blacklist()

struct GNUNET_TRANSPORT_Blacklist* GNUNET_TRANSPORT_blacklist ( const struct GNUNET_CONFIGURATION_Handle cfg,
GNUNET_TRANSPORT_BlacklistCallback  cb,
void *  cb_cls 
)

Install a blacklist callback.

The service will be queried for all existing connections as well as any fresh connections to check if they are permitted. If the blacklisting callback is unregistered, all hosts that were denied in the past will automatically be whitelisted again. Cancelling the blacklist handle is also the only way to re-enable connections from peers that were previously blacklisted.

Parameters
cfgconfiguration to use
cbcallback to invoke to check if connections are allowed
cb_clsclosure for cb
Returns
NULL on error, otherwise handle for cancellation

Definition at line 163 of file transport_api_blacklist.c.

166 {
167  struct GNUNET_TRANSPORT_Blacklist *br;
168 
170  br->cfg = cfg;
171  br->cb = cb;
172  br->cb_cls = cb_cls;
173  reconnect (br);
174  if (NULL == br->mq)
175  {
176  GNUNET_free (br);
177  return NULL;
178  }
179  return br;
180 }
Handle for blacklisting requests.
struct GNUNET_MQ_Handle * mq
Connection to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
GNUNET_TRANSPORT_BlacklistCallback cb
Function to call for determining if a peer is allowed to communicate with us.
static void reconnect(struct GNUNET_TRANSPORT_Blacklist *br)
Establish blacklist connection to transport service.

References GNUNET_TRANSPORT_Blacklist::cb, GNUNET_TRANSPORT_Blacklist::cb_cls, cfg, GNUNET_TRANSPORT_Blacklist::cfg, GNUNET_free, GNUNET_new, GNUNET_TRANSPORT_Blacklist::mq, and reconnect().

Referenced by disconnect_notify(), run(), and setup_ac().

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

◆ GNUNET_TRANSPORT_blacklist_cancel()

void GNUNET_TRANSPORT_blacklist_cancel ( struct GNUNET_TRANSPORT_Blacklist br)

Abort the blacklist.

Note that this function is the only way for removing a peer from the blacklist.

Parameters
brhandle of the request that is to be cancelled

Definition at line 190 of file transport_api_blacklist.c.

191 {
192  GNUNET_MQ_destroy (br->mq);
193  GNUNET_free (br);
194 }

References GNUNET_free, GNUNET_MQ_destroy(), and GNUNET_TRANSPORT_Blacklist::mq.

Referenced by do_shutdown(), shutdown_task(), and whitelist_peers().

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

◆ GNUNET_TRANSPORT_monitor_plugins()

struct GNUNET_TRANSPORT_PluginMonitor* GNUNET_TRANSPORT_monitor_plugins ( const struct GNUNET_CONFIGURATION_Handle cfg,
GNUNET_TRANSPORT_SessionMonitorCallback  cb,
void *  cb_cls 
)

Install a plugin session state monitor callback.

The callback will be notified whenever the session changes.

Parameters
cfgconfiguration to use
cbcallback to invoke on events
cb_clsclosure for cb
Returns
NULL on error, otherwise handle for cancellation

Definition at line 412 of file transport_api_monitor_plugins.c.

415 {
417 
419  pm->cb = cb;
420  pm->cb_cls = cb_cls;
421  pm->cfg = cfg;
423  if (NULL == pm->mq)
424  {
425  GNUNET_free (pm);
426  return NULL;
427  }
429  return pm;
430 }
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
Handle for a plugin session state monitor.
struct GNUNET_CONTAINER_MultiHashMap32 * sessions
Map of session_ids (reduced to 32-bits) to struct GNUNET_TRANSPORT_PluginSession objects.
GNUNET_TRANSPORT_SessionMonitorCallback cb
Callback to call.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
struct GNUNET_MQ_Handle * mq
Connection to the service.
static void do_plugin_connect(void *cls)
Task run to re-establish the connection.

References GNUNET_TRANSPORT_PluginMonitor::cb, GNUNET_TRANSPORT_PluginMonitor::cb_cls, cfg, GNUNET_TRANSPORT_PluginMonitor::cfg, do_plugin_connect(), GNUNET_CONTAINER_multihashmap32_create(), GNUNET_free, GNUNET_new, GNUNET_TRANSPORT_PluginMonitor::mq, pm, and GNUNET_TRANSPORT_PluginMonitor::sessions.

Referenced by run().

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

◆ GNUNET_TRANSPORT_monitor_plugins_cancel()

void GNUNET_TRANSPORT_monitor_plugins_cancel ( struct GNUNET_TRANSPORT_PluginMonitor pm)

Cancel monitoring the plugin session state.

The callback will be called once for each session that is up with the "info" argument being NULL (this is just to enable client-side cleanup).

Parameters
pmhandle of the request that is to be cancelled

The callback will be called once for each session that is up with the information #GNUNET_TRANSPORT_SS_FINI (even though the session may stay up; this is just to enable client-side cleanup).

Parameters
pmhandle of the request that is to be cancelled

Definition at line 442 of file transport_api_monitor_plugins.c.

444 {
445  if (NULL != pm->mq)
446  {
448  pm->mq = NULL;
449  }
450  if (NULL != pm->reconnect_task)
451  {
453  pm->reconnect_task = NULL;
454  }
456  &free_entry,
457  pm);
459  GNUNET_free (pm);
460 }
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task ID for reconnect.
static int free_entry(void *cls, uint32_t key, void *value)
Free the session entry and notify the callback about its demise.

References free_entry(), GNUNET_CONTAINER_multihashmap32_destroy(), GNUNET_CONTAINER_multihashmap32_iterate(), GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_TRANSPORT_PluginMonitor::mq, pm, GNUNET_TRANSPORT_PluginMonitor::reconnect_task, and GNUNET_TRANSPORT_PluginMonitor::sessions.

Referenced by shutdown_task().

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

◆ GNUNET_TRANSPORT_core_connect() [2/2]

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,
GNUNET_TRANSPORT_NotifyExcessBandwidth  neb 
)

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

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)
clsclosure for the callbacks
recreceive function to call
ncfunction to call on connect events
ndfunction to call on disconnect events
nebfunction to call if we have excess bandwidth to a peer
Returns
NULL on error

Definition at line 859 of file transport_api_core.c.

866 {
868  unsigned int i;
869 
871  if (NULL != self)
872  {
873  h->self = *self;
874  h->check_self = GNUNET_YES;
875  }
876  h->cfg = cfg;
877  h->cls = cls;
878  h->nc_cb = nc;
879  h->nd_cb = nd;
880  h->neb_cb = neb;
881  h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
882  if (NULL != handlers)
883  {
884  for (i = 0; NULL != handlers[i].cb; i++)
885  ;
886  h->handlers = GNUNET_new_array (i + 1, struct GNUNET_MQ_MessageHandler);
887  GNUNET_memcpy (h->handlers,
888  handlers,
889  i * sizeof(struct GNUNET_MQ_MessageHandler));
890  }
891  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service\n");
892  reconnect (h);
893  if (NULL == h->mq)
894  {
895  GNUNET_free (h->handlers);
896  GNUNET_free (h);
897  return NULL;
898  }
899  h->neighbours =
901  return h;
902 }
static struct GNUNET_PEERINFO_NotifyContext * nc
Iterator context.
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).
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
Handle for the transport service (includes all of the state for the transport service).
void * cls
Closure for the callbacks.
static void reconnect(void *cls)
Try again to connect to transport service.
#define STARTING_NEIGHBOURS_SIZE
How large to start with for the hashmap of neighbours.

References cfg, GNUNET_ARM_Handle::cfg, GNUNET_TRANSPORT_CoreHandle::cls, GNUNET_CONTAINER_multipeermap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_memcpy, GNUNET_new, GNUNET_new_array, GNUNET_TIME_UNIT_ZERO, GNUNET_YES, h, handlers, LOG, GNUNET_ARM_Handle::mq, nc, reconnect(), and STARTING_NEIGHBOURS_SIZE.

Here is the call graph for this function:

◆ GNUNET_TRANSPORT_core_get_mq()

struct GNUNET_MQ_Handle* GNUNET_TRANSPORT_core_get_mq ( struct GNUNET_TRANSPORT_CoreHandle handle,
const struct GNUNET_PeerIdentity peer 
)

Checks if a given peer is connected to us and get the message queue.

Parameters
handleconnection to transport service
peerthe peer to check
Returns
NULL if disconnected, otherwise message queue for peer

Definition at line 666 of file transport_api2_core.c.

668 {
669  struct Neighbour *n;
670 
671  n = neighbour_find (handle, peer);
672  if (NULL == n)
673  return NULL;
674  return n->mq;
675 }
A connected controller which is not our child.
struct GNUNET_MQ_Handle * mq
Active message queue for the peer.
static struct Neighbour * neighbour_find(struct GNUNET_TRANSPORT_CoreHandle *h, const struct GNUNET_PeerIdentity *peer)
Get the neighbour list entry for the given peer.

References handle, Neighbour::mq, neighbour_find(), and peer.

Referenced by rocc_cache_get_handle_transport_cb().

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