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_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, 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_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_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_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 72 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 124 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 179 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 125 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 329 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 397 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 544 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 596 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 613 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 635 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 (i.e.

DV).

GNUNET_TRANSPORT_CC_RELIABLE 

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

TCP/HTTP/HTTPS.

GNUNET_TRANSPORT_CC_UNRELIABLE 

Transmission is unreliable (i.e.

UDP)

Definition at line 90 of file gnunet_transport_communication_service.h.

91 {
96 
101 
106 };
Transmission is reliabile (with ACKs), i.e.

◆ 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 225 of file gnunet_transport_communication_service.h.

226 {
231 
236 
241 };
this is an inbound connection (communicator initiated)
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 };
Addresses useful in the local wireless network, i.e.
Addresses useful in the local wired network, i.e.
Addresses that are global and are insensitive (i.e.
Addresses that fall into no other category (i.e.
Addresses useful in the local bluetooth network.
Addresses that are global and are sensitive (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 214 of file gnunet_transport_service.h.

215 {
220 
225 
230 
235 
240 
245 
251 
258 
266 
272 
283 };
Connection got into trouble, rest of the system still believes it to be up, but we're getting a new a...
We have some primary connection, but ATS suggested we switch to some alternative; we now sent a SYN m...
Sent SYN over new address (either by ATS telling us to switch addresses or from RECONNECT_ATS); if th...
We're finished with the disconnect; and are cleaning up the state now! We put the struct into this st...
Received a SYN, asking ATS about address suggestions.
Fresh peer or completely disconnected.
Asked to initiate connection, trying to get address from ATS.
Sent SYN message to other peer, waiting for SYN_ACK.
Disconnect in progress (we're sending the DISCONNECT message to the other peer; after that is finishe...
Got our SYN_ACK/ACK, connection is up.
SYN request from other peer was SYN_ACK'ed, waiting for ACK.

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

448 {
453 
458 
463 
469 
475 };
Session is being torn down and about to disappear.
Initial session handshake is in progress.
This is just an update about the session, the state did not change.
The session was created (first call for each session object).

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

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

Referenced by run().

786 {
788 
790  ch->cfg = cfg;
792  ch->addr_prefix = addr_prefix;
793  ch->mq_init = mq_init;
794  ch->mq_init_cls = mq_init_cls;
795  ch->notify_cb = notify_cb;
797  ch->cc = cc;
798  reconnect (ch);
799  if (GNUNET_OK !=
802  "MAX_QUEUE_LENGTH",
803  &ch->max_queue_length))
805  if (NULL == ch->mq)
806  {
807  GNUNET_free (ch);
808  return NULL;
809  }
810  return ch;
811 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
int 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.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
unsigned long long max_queue_length
Maximum permissable queue length.
const char * config_section
Config section to use.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
GNUNET_TRANSPORT_CommunicatorNotify notify_cb
Function to call when the transport service receives messages for a communicator (i.e.
Opaque handle to the transport service for communicators.
const char * addr_prefix
Address prefix to use.
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...
struct GNUNET_MQ_Handle * mq
Queue to talk to the transport service.
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...
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
GNUNET_TRANSPORT_CommunicatorMqInit mq_init
Function to call when the transport service wants us to initiate a communication channel with another...
enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc
Characteristics of the communicator.
#define GNUNET_free(ptr)
Wrapper around free.
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 820 of file transport_api2_communication.c.

References GNUNET_TRANSPORT_CommunicatorHandle::ai_head, disconnect(), GNUNET_break, GNUNET_free, and GNUNET_TRANSPORT_communicator_address_remove().

Referenced by do_shutdown().

822 {
823  disconnect (ch);
824  while (NULL != ch->ai_head)
825  {
826  GNUNET_break (0); /* communicator forgot to remove address, warn! */
828  }
829  GNUNET_free (ch);
830 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void disconnect(struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
Disconnect from the transport service.
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...
struct GNUNET_TRANSPORT_AddressIdentifier * ai_head
Head of DLL of addresses this communicator offers to the transport service.
#define GNUNET_free(ptr)
Wrapper around free.
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 tranport 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 tranport service is not yet up

Definition at line 857 of file transport_api2_communication.c.

References FlowControl::cb, FlowControl::cb_cls, env, GNUNET_TRANSPORT_CommunicatorHandle::fc_gen, GNUNET_TRANSPORT_CommunicatorHandle::fc_head, GNUNET_TRANSPORT_CommunicatorHandle::fc_tail, 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_TRANSPORT_CommunicatorHandle::max_queue_length, GNUNET_TRANSPORT_CommunicatorHandle::mq, FlowControl::sender, and GNUNET_MessageHeader::size.

Referenced by pass_plaintext_to_core(), and select_read_cb().

864 {
865  struct GNUNET_MQ_Envelope *env;
866  struct GNUNET_TRANSPORT_IncomingMessage *im;
867  uint16_t msize;
868 
869  if (NULL == ch->mq)
870  return GNUNET_SYSERR;
871  if ((NULL == cb) && (GNUNET_MQ_get_length (ch->mq) >= ch->max_queue_length))
872  {
873  GNUNET_log (
875  "Dropping message: transprot is too slow, queue length %llu exceeded\n",
876  ch->max_queue_length);
877  return GNUNET_NO;
878  }
879 
880  msize = ntohs (msg->size);
881  env =
883  if (NULL == env)
884  {
885  GNUNET_break (0);
886  return GNUNET_SYSERR;
887  }
888  im->expected_address_validity =
889  GNUNET_TIME_relative_hton (expected_addr_validity);
890  im->sender = *sender;
891  memcpy (&im[1], msg, msize);
892  if (NULL != cb)
893  {
894  struct FlowControl *fc;
895 
896  im->fc_on = htonl (GNUNET_YES);
897  im->fc_id = ch->fc_gen++;
898  fc = GNUNET_new (struct FlowControl);
899  fc->sender = *sender;
900  fc->id = im->fc_id;
901  fc->cb = cb;
902  fc->cb_cls = cb_cls;
904  }
905  GNUNET_MQ_send (ch->mq, env);
906  return GNUNET_OK;
907 }
uint64_t id
More-or-less unique ID for the message.
unsigned long long max_queue_length
Maximum permissable queue length.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
GNUNET_TRANSPORT_MessageCompletedCallback cb
Function to call once the message was processed.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Information we track per packet to enable flow control.
void * cb_cls
Closure for cb.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG
inform transport about an incoming message
#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
uint64_t fc_gen
Flow-control identifier generator.
unsigned int GNUNET_MQ_get_length(struct GNUNET_MQ_Handle *mq)
Obtain the current length of the message queue.
Definition: mq.c:335
struct FlowControl * fc_head
DLL of messages awaiting flow control confirmation (ack).
struct GNUNET_PeerIdentity sender
Which peer is this about?
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:625
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
Queue to talk to the transport service.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
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:353
struct FlowControl * fc_tail
DLL of messages awaiting flow control confirmation (ack).
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,
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
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
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 930 of file transport_api2_communication.c.

References 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_CommunicatorHandle::queue_gen, GNUNET_TRANSPORT_CommunicatorHandle::queue_head, GNUNET_TRANSPORT_QueueHandle::queue_id, GNUNET_TRANSPORT_CommunicatorHandle::queue_tail, and send_add_queue().

Referenced by boot_queue(), setup_queue(), and setup_receiver_mq().

938 {
939  struct GNUNET_TRANSPORT_QueueHandle *qh;
940 
942  qh->ch = ch;
943  qh->peer = *peer;
944  qh->address = GNUNET_strdup (address);
945  qh->nt = nt;
946  qh->mtu = mtu;
947  qh->cs = cs;
948  qh->mq = mq;
949  qh->queue_id = ch->queue_gen++;
951  send_add_queue (qh);
952  return qh;
953 }
enum GNUNET_NetworkType nt
Network type of the communciation queue.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
static void send_add_queue(struct GNUNET_TRANSPORT_QueueHandle *qh)
Send message to the transport service about queue qh being now available.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
char * address
Address used by the communication queue.
uint32_t queue_id
ID for this queue when talking to the transport service.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Handle this queue belongs to.
struct GNUNET_TRANSPORT_QueueHandle * queue_head
DLL of queues we offer.
enum GNUNET_TRANSPORT_ConnectionStatus cs
Communication status of the queue.
struct GNUNET_TRANSPORT_QueueHandle * queue_tail
DLL of queues we offer.
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_PeerIdentity peer
Which peer we can communciate with.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MQ_Handle * mq
The queue itself.
uint32_t queue_gen
Queue identifier generator.
static char * address
GNS address for this phone.
uint32_t mtu
Maximum transmission unit for the queue.
Handle returned to identify the internal data structure the transport API has created to manage a mes...
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 963 of file transport_api2_communication.c.

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

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

964 {
966 
967  send_del_queue (qh);
969  GNUNET_MQ_destroy (qh->mq);
970  GNUNET_free (qh->address);
971  GNUNET_free (qh);
972 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
char * address
Address used by the communication queue.
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Handle this queue belongs to.
struct GNUNET_TRANSPORT_QueueHandle * queue_head
DLL of queues we offer.
Opaque handle to the transport service for communicators.
struct GNUNET_TRANSPORT_QueueHandle * queue_tail
DLL of queues we offer.
static void send_del_queue(struct GNUNET_TRANSPORT_QueueHandle *qh)
Send message to the transport service about queue qh being no longer available.
struct GNUNET_MQ_Handle * mq
The queue itself.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
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 985 of file transport_api2_communication.c.

References GNUNET_TRANSPORT_AddressIdentifier::address, ai, GNUNET_TRANSPORT_CommunicatorHandle::ai_head, GNUNET_TRANSPORT_CommunicatorHandle::ai_tail, GNUNET_TRANSPORT_AddressIdentifier::aid, GNUNET_TRANSPORT_CommunicatorHandle::aid_gen, 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().

990 {
992 
994  ai->ch = ch;
995  ai->address = GNUNET_strdup (address);
996  ai->nt = nt;
997  ai->expiration = expiration;
998  ai->aid = ch->aid_gen++;
1000  send_add_address (ai);
1001  return ai;
1002 }
uint32_t aid_gen
Internal UUID for the address used in communication with the transport service.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_TRANSPORT_AddressIdentifier * ai_tail
Tail of DLL of addresses this communicator offers to the transport service.
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Transport handle where the address was added.
struct GNUNET_TIME_Relative expiration
When does the address expire? (Expected lifetime of the address.)
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
static struct GNUNET_TRANSPORT_AddressIdentifier * ai
Handle to the operation that publishes our address.
struct GNUNET_TRANSPORT_AddressIdentifier * ai_head
Head of DLL of addresses this communicator offers to the transport service.
enum GNUNET_NetworkType nt
Network type for the address.
static void send_add_address(struct GNUNET_TRANSPORT_AddressIdentifier *ai)
Send message to the transport service about address ai being now available.
uint32_t aid
Internal UUID for the address used in communication with the transport service.
static char * address
GNS address for this phone.
Internal representation of an address a communicator is currently providing for the transport service...
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 1012 of file transport_api2_communication.c.

References GNUNET_TRANSPORT_AddressIdentifier::address, GNUNET_TRANSPORT_CommunicatorHandle::ai_head, GNUNET_TRANSPORT_CommunicatorHandle::ai_tail, ch, GNUNET_TRANSPORT_AddressIdentifier::ch, GNUNET_CONTAINER_DLL_remove, GNUNET_free, and send_del_address().

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

1014 {
1016 
1017  send_del_address (ai);
1019  GNUNET_free (ai->address);
1020  GNUNET_free (ai);
1021 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct GNUNET_TRANSPORT_AddressIdentifier * ai_tail
Tail of DLL of addresses this communicator offers to the transport service.
struct GNUNET_TRANSPORT_CommunicatorHandle * ch
Transport handle where the address was added.
Opaque handle to the transport service for communicators.
static void send_del_address(struct GNUNET_TRANSPORT_AddressIdentifier *ai)
Send message to the transport service about address ai being no longer available. ...
struct GNUNET_TRANSPORT_AddressIdentifier * ai_head
Head of DLL of addresses this communicator offers to the transport service.
#define GNUNET_free(ptr)
Wrapper around free.
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 1042 of file transport_api2_communication.c.

References FlowControl::cb, env, GNUNET_assert, GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TRANSPORT_CommunicatorHandle::mq, pid, and GNUNET_MessageHeader::size.

Referenced by consider_ss_ack().

1047 {
1048  struct GNUNET_MQ_Envelope *env;
1049  struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb;
1050  size_t slen = strlen (comm) + 1;
1051  uint16_t mlen = ntohs (header->size);
1052 
1053  GNUNET_assert (mlen + slen + sizeof(*cb) < UINT16_MAX);
1054  env =
1055  GNUNET_MQ_msg_extra (cb,
1056  slen + mlen,
1058  cb->pid = *pid;
1059  memcpy (&cb[1], header, mlen);
1060  memcpy (((char *) &cb[1]) + mlen, comm, slen);
1061  GNUNET_MQ_send (ch->mq, env);
1062 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#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_COMMUNICATOR_BACKCHANNEL
Tell transport that it should assist with exchanging a message between communicators.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
Queue to talk to the transport service.
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:353
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
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_core_get_mq(), GNUNET_TRANSPORT_TESTING_restart_peer(), GNUNET_TRANSPORT_TESTING_start_peer(), GSC_KX_init(), opstart_get_handle_transport(), run(), and transport_connect_adapter().

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 911 of file transport_api_core.c.

References ch, disconnect_and_schedule_reconnect(), Neighbour::env, GNUNET_assert, GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_free_non_null, GNUNET_MESSAGE_TYPE_TRANSPORT_RECV_OK, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SCHEDULER_cancel(), GNUNET_TRANSPORT_CoreHandle::handlers, RecvOkMessage::increase_window_delta, LOG, GNUNET_TRANSPORT_CoreHandle::mq, GNUNET_TRANSPORT_CoreHandle::neighbours, RecvOkMessage::peer, Neighbour::pid, GNUNET_TRANSPORT_CoreHandle::reconnect_task, and GNUNET_TRANSPORT_CoreHandle::rom_pending.

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

912 {
913  LOG (GNUNET_ERROR_TYPE_DEBUG, "Transport disconnect called!\n");
914  /* this disconnects all neighbours... */
915  if (NULL == handle->reconnect_task)
917  /* and now we stop trying to connect again... */
918  if (NULL != handle->reconnect_task)
919  {
921  handle->reconnect_task = NULL;
922  }
924  handle->neighbours = NULL;
925  GNUNET_free_non_null (handle->handlers);
926  handle->handlers = NULL;
927  GNUNET_free (handle);
928 }
struct GNUNET_MQ_MessageHandler * handlers
Functions to call for received data (template for new message queues).
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,...)
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct GNUNET_CONTAINER_MultiPeerMap * neighbours
Hash map of the current connected neighbours of this peer.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the task trying to reconnect to the service.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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.

References GNUNET_TRANSPORT_HelloGetHandle::ac, 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().

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 const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
struct GNUNET_MQ_Handle * mq
Transport handle.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
GNUNET_TRANSPORT_HelloUpdateCallback rec
Callback to call once we got our HELLO.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
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.
enum GNUNET_TRANSPORT_AddressClass ac
Type of HELLOs client cares about.
static void reconnect(void *cls)
Try again to connect to transport service.
Functions to call with this peer&#39;s HELLO.
#define GNUNET_free(ptr)
Wrapper around free.
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.

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

259 {
260  if (NULL != ghh->reconnect_task)
261  {
263  ghh->reconnect_task = NULL;
264  }
265  if (NULL != ghh->mq)
266  {
267  GNUNET_MQ_destroy (ghh->mq);
268  ghh->mq = NULL;
269  }
270  GNUNET_free (ghh);
271 }
struct GNUNET_MQ_Handle * mq
Transport handle.
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the task trying to reconnect to the service.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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.

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

Referenced by GNUNET_TRANSPORT_TESTING_start_peer(), and run().

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 const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Handle for the transport service (includes all of the state for the transport service).
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_MQ_Handle * mq
My client connection to the transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
My configuration.
#define LOG(kind,...)
static void reconnect(void *cls)
Try again to connect to transport service.
#define GNUNET_free(ptr)
Wrapper around free.
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.

References disconnect_and_schedule_reconnect(), GNUNET_free, GNUNET_SCHEDULER_cancel(), and GNUNET_TRANSPORT_ManipulationHandle::reconnect_task.

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

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  }
245  GNUNET_free (handle);
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.
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the task trying to reconnect to the service.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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.

References TrafficMetricMessage::delay_in, TrafficMetricMessage::delay_out, env, GNUNET_ATS_properties_hton(), GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_TIME_relative_hton(), GNUNET_TRANSPORT_ManipulationHandle::mq, msg, peer, TrafficMetricMessage::peer, TrafficMetricMessage::properties, and TrafficMetricMessage::reserved.

Referenced by run().

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;
192  prop);
193  msg->delay_in = GNUNET_TIME_relative_hton (delay_in);
194  msg->delay_out = GNUNET_TIME_relative_hton (delay_out);
195  GNUNET_MQ_send (handle->mq,
196  env);
197 }
struct GNUNET_PeerIdentity peer
The identity of the peer to look up.
Definition: transport.h:508
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TIME_RelativeNBO delay_in
Fake delay to add on inbound traffic.
Definition: transport.h:518
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_TIME_RelativeNBO delay_out
Fake delay to add on outbound traffic.
Definition: transport.h:523
struct GNUNET_MQ_Handle * mq
My client connection to the transport service.
Message from the library to the transport service asking for binary addresses known for a peer...
Definition: transport.h:493
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_ATS_PropertiesNBO properties
Fake properties to generate.
Definition: transport.h:513
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:625
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
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:353
uint32_t reserved
Always zero.
Definition: transport.h:503
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.

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

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 const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_PeerIdentity peer
Peer we monitor, all zeros for "all".
Opaque handle to the transport service for monitors.
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
struct GNUNET_MQ_Handle * mq
Queue to talk to the transport service.
static struct GNUNET_TESTBED_Controller * mc
Handle to the master controller.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
GNUNET_TRANSPORT_MonitorCallback cb
Function to call with monitor data.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
#define GNUNET_free(ptr)
Wrapper around free.
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.

References disconnect(), and GNUNET_free.

Referenced by handle_monitor_end().

286 {
287  disconnect (mc);
288  GNUNET_free (mc);
289 }
static void disconnect(struct GNUNET_TRANSPORT_MonitorContext *mc)
Disconnect from the transport service.
#define GNUNET_free(ptr)
Wrapper around free.
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.

References 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, and GNUNET_TRANSPORT_OfferHelloHandle::mq.

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

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 }
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
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:653
A HELLO message is used to exchange information about transports with other peers.
Entry in linked list for all offer-HELLO requests.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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:774
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
The identity of the host (wraps the signing key of the peer).
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:353
static void finished_hello(void *cls)
Done sending HELLO message to the service, notify application.
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
struct GNUNET_MQ_Handle * mq
Transport service handle we use for transmission.
GNUNET_SCHEDULER_TaskCallback cont
Function to call once we are done.
#define GNUNET_free(ptr)
Wrapper around free.
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.

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(), notify_connect(), offer_hello(), and try_connect().

136 {
137  GNUNET_MQ_destroy (ohh->mq);
138  GNUNET_free (ohh);
139 }
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
struct GNUNET_MQ_Handle * mq
Transport service handle we use for transmission.
#define GNUNET_free(ptr)
Wrapper around free.
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.

References GNUNET_HELLO_Address::address, GNUNET_HELLO_Address::address_length, AddressLookupMessage::addrlen, GNUNET_TRANSPORT_AddressToStringContext::cb, GNUNET_TRANSPORT_AddressToStringContext::cb_cls, 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(), GNUNET_TRANSPORT_AddressToStringContext::mq, mq_error_handler(), msg, AddressLookupMessage::numeric_only, GNUNET_HELLO_Address::peer, AddressLookupMessage::timeout, and GNUNET_HELLO_Address::transport_name.

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

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);
230  env = GNUNET_MQ_msg_extra (msg,
231  alen + slen,
233  msg->numeric_only = htons ((int16_t) numeric);
234  msg->addrlen = htons ((uint16_t) alen);
235  msg->timeout = GNUNET_TIME_relative_hton (timeout);
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 }
size_t address_length
Number of bytes in address.
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...
Message used to notify the transport API about an address to string conversion.
Definition: transport.h:323
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
const void * address
Binary representation of the address (plugin-specific).
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static int numeric
Option -n.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#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
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#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.
const char * transport_name
Name of the transport plugin enabling the communication using this address.
int16_t numeric_only
Should the conversion use numeric IP addresses (otherwise a reverse DNS lookup is OK – if applicable...
Definition: transport.h:359
Message handler for a specific message type.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING
Request to look addresses of peers in server.
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:625
struct GNUNET_TIME_RelativeNBO timeout
timeout to give up (for DNS resolution timeout mostly)
Definition: transport.h:369
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_PeerIdentity peer
For which peer is this an address?
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
Message from the library to the transport service asking for converting a transport address to a huma...
Definition: transport.h:348
GNUNET_TRANSPORT_AddressToStringCallback cb
Function to call with the human-readable address.
#define GNUNET_log(kind,...)
uint16_t addrlen
Length of the (binary) address in bytes, in big-endian.
Definition: transport.h:364
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:353
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MQ_Handle * mq
Connection to the service.
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.

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

258 {
259  GNUNET_MQ_destroy (alc->mq);
260  GNUNET_free (alc);
261 }
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MQ_Handle * mq
Connection to the service.
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.

References do_peer_connect(), 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, and GNUNET_TRANSPORT_PS_SYN_SENT.

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

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 }
Connection got into trouble, rest of the system still believes it to be up, but we&#39;re getting a new a...
We have some primary connection, but ATS suggested we switch to some alternative; we now sent a SYN m...
Sent SYN over new address (either by ATS telling us to switch addresses or from RECONNECT_ATS); if th...
We&#39;re finished with the disconnect; and are cleaning up the state now! We put the struct into this st...
Received a SYN, asking ATS about address suggestions.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Fresh peer or completely disconnected.
enum State state
current state of profiling
Asked to initiate connection, trying to get address from ATS.
Sent SYN message to other peer, waiting for SYN_ACK.
Disconnect in progress (we&#39;re sending the DISCONNECT message to the other peer; after that is finishe...
Got our SYN_ACK/ACK, connection is up.
SYN request from other peer was SYN_ACK&#39;ed, waiting for ACK.
Here is the call graph for this function:
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.

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, and GNUNET_YES.

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

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 }
Connection got into trouble, rest of the system still believes it to be up, but we&#39;re getting a new a...
We have some primary connection, but ATS suggested we switch to some alternative; we now sent a SYN m...
Sent SYN over new address (either by ATS telling us to switch addresses or from RECONNECT_ATS); if th...
We&#39;re finished with the disconnect; and are cleaning up the state now! We put the struct into this st...
#define GNUNET_NO
Definition: gnunet_common.h:78
Received a SYN, asking ATS about address suggestions.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Fresh peer or completely disconnected.
enum State state
current state of profiling
Asked to initiate connection, trying to get address from ATS.
const char * GNUNET_TRANSPORT_ps2s(enum GNUNET_TRANSPORT_PeerState state)
Convert peer state to human-readable string.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Sent SYN message to other peer, waiting for SYN_ACK.
Disconnect in progress (we&#39;re sending the DISCONNECT message to the other peer; after that is finishe...
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
Got our SYN_ACK/ACK, connection is up.
SYN request from other peer was SYN_ACK&#39;ed, waiting for ACK.
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.

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

Referenced by run().

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 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
GNUNET_TRANSPORT_PeerIterateCallback cb
Function to call with the binary address.
Context for iterating validation entries.
struct GNUNET_PeerIdentity peer
Identity of the peer to monitor.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_MQ_Handle * mq
Connection to the service.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
static void do_peer_connect(void *cls)
Task run to re-establish the connection.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_free(ptr)
Wrapper around free.
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.

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

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

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  {
463  pic->reconnect_task = NULL;
464  }
465  GNUNET_free (pic);
466 }
struct GNUNET_MQ_Handle * mq
Connection to the service.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task ID for reconnect.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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.

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

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

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 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_MQ_Handle * mq
Connection to transport service.
Handle for blacklisting requests.
GNUNET_TRANSPORT_BlacklistCallback cb
Function to call for determining if a peer is allowed to communicate with us.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
static void reconnect(struct GNUNET_TRANSPORT_Blacklist *br)
Establish blacklist connection to transport service.
#define GNUNET_free(ptr)
Wrapper around free.
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.

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

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

191 {
192  GNUNET_MQ_destroy (br->mq);
193  GNUNET_free (br);
194 }
struct GNUNET_MQ_Handle * mq
Connection to transport service.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
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.

References GNUNET_TRANSPORT_PluginMonitor::cb, GNUNET_TRANSPORT_PluginMonitor::cb_cls, 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().

415 {
417 
419  pm->cb = cb;
420  pm->cb_cls = cb_cls;
421  pm->cfg = cfg;
422  do_plugin_connect (pm);
423  if (NULL == pm->mq)
424  {
425  GNUNET_free (pm);
426  return NULL;
427  }
429  return pm;
430 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
struct GNUNET_MQ_Handle * mq
Connection to the service.
Handle for a plugin session state monitor.
GNUNET_TRANSPORT_SessionMonitorCallback cb
Callback to call.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
static void do_plugin_connect(void *cls)
Task run to re-establish the connection.
#define GNUNET_free(ptr)
Wrapper around free.
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
struct GNUNET_CONTAINER_MultiHashMap32 * sessions
Map of session_ids (reduced to 32-bits) to struct GNUNET_TRANSPORT_PluginSession objects.
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.

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

Referenced by shutdown_task().

444 {
445  if (NULL != pm->mq)
446  {
447  GNUNET_MQ_destroy (pm->mq);
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 }
static int free_entry(void *cls, uint32_t key, void *value)
Free the session entry and notify the callback about its demise.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task ID for reconnect.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_MQ_Handle * mq
Connection to the service.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_CONTAINER_MultiHashMap32 * sessions
Map of session_ids (reduced to 32-bits) to struct GNUNET_TRANSPORT_PluginSession objects.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
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 858 of file transport_api_core.c.

References GNUNET_MQ_MessageHandler::cb, cfg, GNUNET_TRANSPORT_CoreHandle::cfg, GNUNET_TRANSPORT_CoreHandle::check_self, GNUNET_TRANSPORT_CoreHandle::cls, GNUNET_CONTAINER_multipeermap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_free_non_null, GNUNET_memcpy, GNUNET_new, GNUNET_new_array, GNUNET_TIME_UNIT_ZERO, GNUNET_YES, Neighbour::h, GNUNET_TRANSPORT_CoreHandle::handlers, LOG, GNUNET_TRANSPORT_CoreHandle::mq, nc, GNUNET_TRANSPORT_CoreHandle::nc_cb, GNUNET_TRANSPORT_CoreHandle::nd_cb, GNUNET_TRANSPORT_CoreHandle::neb_cb, GNUNET_TRANSPORT_CoreHandle::neighbours, reconnect(), GNUNET_TRANSPORT_CoreHandle::reconnect_delay, GNUNET_TRANSPORT_CoreHandle::self, and STARTING_NEIGHBOURS_SIZE.

865 {
867  unsigned int i;
868 
870  if (NULL != self)
871  {
872  h->self = *self;
873  h->check_self = GNUNET_YES;
874  }
875  h->cfg = cfg;
876  h->cls = cls;
877  h->nc_cb = nc;
878  h->nd_cb = nd;
879  h->neb_cb = neb;
881  if (NULL != handlers)
882  {
883  for (i = 0; NULL != handlers[i].cb; i++)
884  ;
887  handlers,
888  i * sizeof(struct GNUNET_MQ_MessageHandler));
889  }
890  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service\n");
891  reconnect (h);
892  if (NULL == h->mq)
893  {
895  GNUNET_free (h);
896  return NULL;
897  }
898  h->neighbours =
900  return h;
901 }
struct GNUNET_MQ_MessageHandler * handlers
Functions to call for received data (template for new message queues).
void * cls
Closure for the callbacks.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
#define LOG(kind,...)
GNUNET_TRANSPORT_NotifyDisconnect nd_cb
function to call on disconnect events
const struct GNUNET_CONFIGURATION_Handle * cfg
My configuration.
struct GNUNET_MQ_Handle * mq
My client connection to the transport service.
GNUNET_TRANSPORT_NotifyExcessBandwidth neb_cb
function to call on excess bandwidth events
GNUNET_TRANSPORT_NotifyConnect nc_cb
function to call on connect events
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_PeerIdentity self
Peer identity as assumed by this process, or all zeros.
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).
struct GNUNET_CONTAINER_MultiPeerMap * neighbours
Hash map of the current connected neighbours of this peer.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_TIME_Relative reconnect_delay
Delay until we try to reconnect.
#define STARTING_NEIGHBOURS_SIZE
How large to start with for the hashmap of neighbours.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
int check_self
Should we check that self matches what the service thinks? (if GNUNET_NO, then self is all zeros!)...
GNUNET_MQ_MessageCallback cb
Callback, called every time a new message of the specified type has been receied. ...
static void reconnect(void *cls)
Try again to connect to transport service.
Message handler for a specific message type.
static struct GNUNET_PEERINFO_NotifyContext * nc
Iterator context.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
#define GNUNET_YES
Definition: gnunet_common.h:77
Handle for the transport service (includes all of the state for the transport service).
#define GNUNET_free(ptr)
Wrapper around free.
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.

References GNUNET_MQ_MessageHandler::cb, cfg, GNUNET_TRANSPORT_CoreHandle::cfg, ch, GNUNET_TRANSPORT_CoreHandle::check_self, GNUNET_TRANSPORT_CoreHandle::cls, disconnect(), Neighbour::env, GNUNET_CONTAINER_multipeermap_create(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_free_non_null, GNUNET_i2s(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TRANSPORT_RECV_OK, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_new_array, GNUNET_SCHEDULER_cancel(), GNUNET_TIME_UNIT_ZERO, GNUNET_TRANSPORT_core_connect(), GNUNET_TRANSPORT_core_disconnect(), GNUNET_YES, Neighbour::h, handle, GNUNET_TRANSPORT_CoreHandle::handlers, handlers, RecvOkMessage::increase_window_delta, LOG, Neighbour::mq, GNUNET_TRANSPORT_CoreHandle::mq, nc, GNUNET_TRANSPORT_CoreHandle::nc_cb, GNUNET_TRANSPORT_CoreHandle::nd_cb, neighbour_find(), GNUNET_TRANSPORT_CoreHandle::neighbours, RecvOkMessage::peer, Neighbour::pid, reconnect(), GNUNET_TRANSPORT_CoreHandle::reconnect_delay, GNUNET_TRANSPORT_CoreHandle::reconnect_task, GNUNET_TRANSPORT_CoreHandle::self, and STARTING_NEIGHBOURS_SIZE.

Referenced by rocc_cache_get_handle_transport_cb().

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.
Here is the call graph for this function:
Here is the caller graph for this function: