GNUnet  0.10.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 123 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 178 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 119 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 165 of file gnunet_transport_hello_service.h.

◆ GNUNET_TRANSPORT_MonitorCallback

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

Function to call with information about a peer.

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

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

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

Definition at line 124 of file gnunet_transport_monitor_service.h.

◆ GNUNET_TRANSPORT_AddressToStringCallback

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

Function to call with a textual representation of an address.

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

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

Definition at line 118 of file gnunet_transport_service.h.

◆ GNUNET_TRANSPORT_PeerIterateCallback

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

Function to call with information about a peer.

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

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

Parameters
clsclosure
peerpeer this update is about, NULL if this is the final last callback for a iteration operation
addressaddress, NULL if this is the final callback for iteration op
statecurrent state this peer is in
state_timeouttimeout for the current state of the peer

Definition at line 328 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 396 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 541 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 593 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 610 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 632 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.

90  {
95 
100 
105 };
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 224 of file gnunet_transport_communication_service.h.

224  {
229 
234 
239 };
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.

61  {
66 
72 
78 
84 
91 
98 
104 
109 };
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.

214  {
219 
224 
229 
234 
239 
244 
250 
257 
265 
271 
282 };
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 446 of file gnunet_transport_service.h.

446  {
451 
456 
461 
467 
473 };
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 772 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().

781 {
783 
785  ch->cfg = cfg;
787  ch->addr_prefix = addr_prefix;
788  ch->mq_init = mq_init;
789  ch->mq_init_cls = mq_init_cls;
790  ch->notify_cb = notify_cb;
792  ch->cc = cc;
793  reconnect(ch);
794  if (GNUNET_OK !=
797  "MAX_QUEUE_LENGTH",
798  &ch->max_queue_length))
800  if (NULL == ch->mq)
801  {
802  GNUNET_free(ch);
803  return NULL;
804  }
805  return ch;
806 }
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.
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 struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
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 815 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().

817 {
818  disconnect(ch);
819  while (NULL != ch->ai_head)
820  {
821  GNUNET_break(0); /* communicator forgot to remove address, warn! */
823  }
824  GNUNET_free(ch);
825 }
#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 852 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().

859 {
860  struct GNUNET_MQ_Envelope *env;
861  struct GNUNET_TRANSPORT_IncomingMessage *im;
862  uint16_t msize;
863 
864  if (NULL == ch->mq)
865  return GNUNET_SYSERR;
866  if ((NULL == cb) && (GNUNET_MQ_get_length(ch->mq) >= ch->max_queue_length))
867  {
868  GNUNET_log(
870  "Dropping message: transprot is too slow, queue length %llu exceeded\n",
871  ch->max_queue_length);
872  return GNUNET_NO;
873  }
874 
875  msize = ntohs(msg->size);
876  env =
878  if (NULL == env)
879  {
880  GNUNET_break(0);
881  return GNUNET_SYSERR;
882  }
883  im->expected_address_validity =
884  GNUNET_TIME_relative_hton(expected_addr_validity);
885  im->sender = *sender;
886  memcpy(&im[1], msg, msize);
887  if (NULL != cb)
888  {
889  struct FlowControl *fc;
890 
891  im->fc_on = htonl(GNUNET_YES);
892  im->fc_id = ch->fc_gen++;
893  fc = GNUNET_new(struct FlowControl);
894  fc->sender = *sender;
895  fc->id = im->fc_id;
896  fc->cb = cb;
897  fc->cb_cls = cb_cls;
899  }
900  GNUNET_MQ_send(ch->mq, env);
901  return GNUNET_OK;
902 }
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:333
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:623
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:351
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 925 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().

933 {
934  struct GNUNET_TRANSPORT_QueueHandle *qh;
935 
937  qh->ch = ch;
938  qh->peer = *peer;
940  qh->nt = nt;
941  qh->mtu = mtu;
942  qh->cs = cs;
943  qh->mq = mq;
944  qh->queue_id = ch->queue_gen++;
946  send_add_queue(qh);
947  return qh;
948 }
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 958 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().

959 {
961 
962  send_del_queue(qh);
964  GNUNET_MQ_destroy(qh->mq);
965  GNUNET_free(qh->address);
966  GNUNET_free(qh);
967 }
#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:821
#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 980 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().

985 {
987 
989  ai->ch = ch;
991  ai->nt = nt;
992  ai->expiration = expiration;
993  ai->aid = ch->aid_gen++;
995  send_add_address(ai);
996  return ai;
997 }
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
static char * expiration
Credential TTL.
#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 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 1007 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().

1009 {
1011 
1012  send_del_address(ai);
1014  GNUNET_free(ai->address);
1015  GNUNET_free(ai);
1016 }
#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 1037 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().

1042 {
1043  struct GNUNET_MQ_Envelope *env;
1044  struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb;
1045  size_t slen = strlen(comm) + 1;
1046  uint16_t mlen = ntohs(header->size);
1047 
1048  GNUNET_assert(mlen + slen + sizeof(*cb) < UINT16_MAX);
1049  env =
1051  slen + mlen,
1053  cb->pid = *pid;
1054  memcpy(&cb[1], header, mlen);
1055  memcpy(((char *)&cb[1]) + mlen, comm, slen);
1056  GNUNET_MQ_send(ch->mq, env);
1057 }
#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:351
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 909 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().

910 {
911  LOG(GNUNET_ERROR_TYPE_DEBUG, "Transport disconnect called!\n");
912  /* this disconnects all neighbours... */
913  if (NULL == handle->reconnect_task)
915  /* and now we stop trying to connect again... */
916  if (NULL != handle->reconnect_task)
917  {
919  handle->reconnect_task = NULL;
920  }
922  handle->neighbours = NULL;
924  handle->handlers = NULL;
925  GNUNET_free(handle);
926 }
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:956
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 229 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().

233 {
235 
237  ghh->rec = rec;
238  ghh->rec_cls = rec_cls;
239  ghh->cfg = cfg;
240  ghh->ac = ac;
241  reconnect(ghh);
242  if (NULL == ghh->mq)
243  {
244  GNUNET_free(ghh);
245  return NULL;
246  }
247  return ghh;
248 }
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.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
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 257 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().

258 {
259  if (NULL != ghh->reconnect_task)
260  {
262  ghh->reconnect_task = NULL;
263  }
264  if (NULL != ghh->mq)
265  {
266  GNUNET_MQ_destroy(ghh->mq);
267  ghh->mq = NULL;
268  }
269  GNUNET_free(ghh);
270 }
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:821
#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:956
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 204 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().

205 {
207 
209  h->cfg = cfg;
211  "Connecting to transport service.\n");
212  reconnect(h);
213  if (NULL == h->mq)
214  {
215  GNUNET_free(h);
216  return NULL;
217  }
218  return h;
219 }
#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:94
struct GNUNET_MQ_Handle * mq
My client connection to the transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
My configuration.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
#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 228 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().

229 {
230  if (NULL == handle->reconnect_task)
232  /* and now we stop trying to connect again... */
233  if (NULL != handle->reconnect_task)
234  {
236  handle->reconnect_task = NULL;
237  }
238  GNUNET_free(handle);
239 }
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:956
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 172 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().

177 {
178  struct GNUNET_MQ_Envelope *env;
179  struct TrafficMetricMessage *msg;
180 
181  if (NULL == handle->mq)
182  return;
183  env = GNUNET_MQ_msg(msg,
185  msg->reserved = htonl(0);
186  msg->peer = *peer;
188  prop);
189  msg->delay_in = GNUNET_TIME_relative_hton(delay_in);
190  msg->delay_out = GNUNET_TIME_relative_hton(delay_out);
191  GNUNET_MQ_send(handle->mq,
192  env);
193 }
struct GNUNET_PeerIdentity peer
The identity of the peer to look up.
Definition: transport.h:494
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TIME_RelativeNBO delay_in
Fake delay to add on inbound traffic.
Definition: transport.h:504
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:509
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:480
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_ATS_PropertiesNBO properties
Fake properties to generate.
Definition: transport.h:499
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:623
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:351
uint32_t reserved
Always zero.
Definition: transport.h:489
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 253 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().

258 {
260 
262  mc->cfg = cfg;
263  if (NULL != peer)
264  mc->peer = *peer;
265  mc->one_shot = one_shot;
266  mc->cb = cb;
267  mc->cb_cls = cb_cls;
268  reconnect(mc);
269  if (NULL == mc->mq)
270  {
271  GNUNET_free(mc);
272  return NULL;
273  }
274  return mc;
275 }
#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.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
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 284 of file transport_api2_monitor.c.

References disconnect(), and GNUNET_free.

Referenced by handle_monitor_end().

285 {
286  disconnect(mc);
287  GNUNET_free(mc);
288 }
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 86 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().

90 {
93  struct GNUNET_MQ_Envelope *env;
95 
96  if (GNUNET_OK !=
97  GNUNET_HELLO_get_id((const struct GNUNET_HELLO_Message *)hello,
98  &peer))
99  {
100  GNUNET_break(0);
101  GNUNET_free(ohh);
102  return NULL;
103  }
104  ohh->mq = GNUNET_CLIENT_connect(cfg,
105  "transport",
106  NULL,
107  NULL,
108  ohh);
109  if (NULL == ohh->mq)
110  {
111  GNUNET_free(ohh);
112  return NULL;
113  }
114  ohh->cont = cont;
115  ohh->cls = cont_cls;
116  GNUNET_break(ntohs(hello->type) == GNUNET_MESSAGE_TYPE_HELLO);
117  env = GNUNET_MQ_msg_copy(hello);
120  ohh);
121  GNUNET_MQ_send(ohh->mq,
122  env);
123  return ohh;
124 }
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:662
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:651
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:900
#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:772
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:351
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 133 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().

134 {
135  GNUNET_MQ_destroy(ohh->mq);
136  GNUNET_free(ohh);
137 }
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
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 176 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().

182 {
186  GNUNET_MQ_hd_var_size(reply,
189  alc),
191  };
192  size_t alen;
193  size_t slen;
194  struct AddressLookupMessage *msg;
195  struct GNUNET_MQ_Envelope *env;
196  char *addrbuf;
197 
198  alen = address->address_length;
199  slen = strlen(address->transport_name) + 1;
200  if ((alen + slen >= GNUNET_MAX_MESSAGE_SIZE
201  - sizeof(struct AddressLookupMessage)) ||
202  (alen >= GNUNET_MAX_MESSAGE_SIZE) ||
203  (slen >= GNUNET_MAX_MESSAGE_SIZE))
204  {
205  GNUNET_break(0);
206  GNUNET_free(alc);
207  return NULL;
208  }
209  alc->cb = aluc;
210  alc->cb_cls = aluc_cls;
211  alc->mq = GNUNET_CLIENT_connect(cfg,
212  "transport",
213  handlers,
215  alc);
216  if (NULL == alc->mq)
217  {
218  GNUNET_break(0);
219  GNUNET_free(alc);
220  return NULL;
221  }
223  "Client tries to resolve for peer `%s' address plugin %s len %u\n",
224  GNUNET_i2s(&address->peer),
225  address->transport_name,
226  (unsigned int)address->address_length);
227  env = GNUNET_MQ_msg_extra(msg,
228  alen + slen,
230  msg->numeric_only = htons((int16_t)numeric);
231  msg->addrlen = htons((uint16_t)alen);
232  msg->timeout = GNUNET_TIME_relative_hton(timeout);
233  addrbuf = (char *)&msg[1];
234  GNUNET_memcpy(addrbuf,
235  address->address,
236  alen);
237  GNUNET_memcpy(&addrbuf[alen],
238  address->transport_name,
239  slen);
240  GNUNET_MQ_send(alc->mq,
241  env);
242  return alc;
243 }
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:315
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:900
#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:349
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:623
struct GNUNET_TIME_RelativeNBO timeout
timeout to give up (for DNS resolution timeout mostly)
Definition: transport.h:359
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:339
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:354
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:351
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 252 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().

253 {
254  GNUNET_MQ_destroy(alc->mq);
255  GNUNET_free(alc);
256 }
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
#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 131 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().

132 {
133  switch (state)
134  {
136  return "S_NOT_CONNECTED";
137 
139  return "S_INIT_ATS";
140 
142  return "S_SYN_SENT";
143 
145  return "S_SYN_RECV_ATS";
146 
148  return "S_SYN_RECV_ACK";
149 
151  return "S_CONNECTED";
152 
154  return "S_RECONNECT_ATS";
155 
157  return "S_RECONNECT_SENT";
158 
160  return "S_SWITCH_SYN_SENT";
161 
163  return "S_DISCONNECT";
164 
166  return "S_DISCONNECT_FINISHED";
167 
168  default:
169  GNUNET_break(0);
170  return "UNDEFINED";
171  }
172 }
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 92 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().

93 {
94  switch (state)
95  {
101  return GNUNET_NO;
102 
107  return GNUNET_YES;
108 
111  return GNUNET_NO;
112 
113  default:
115  "Unhandled state `%s'\n",
117  GNUNET_break(0);
118  break;
119  }
120  return GNUNET_SYSERR;
121 }
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().

424 {
427 
428  pal_ctx->cb = peer_callback;
429  pal_ctx->cb_cls = peer_callback_cls;
430  pal_ctx->cfg = cfg;
431  if (NULL != peer)
432  pal_ctx->peer = *peer;
433  pal_ctx->one_shot = one_shot;
434  do_peer_connect(pal_ctx);
435  if (NULL == pal_ctx->mq)
436  {
437  GNUNET_free(pal_ctx);
438  return NULL;
439  }
440  return pal_ctx;
441 }
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.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
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 450 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().

451 {
452  if (NULL != pic->mq)
453  {
454  GNUNET_MQ_destroy(pic->mq);
455  pic->mq = NULL;
456  }
457  if (NULL != pic->reconnect_task)
458  {
460  pic->reconnect_task = NULL;
461  }
462  GNUNET_free(pic);
463 }
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:821
#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:956
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 161 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().

164 {
165  struct GNUNET_TRANSPORT_Blacklist *br;
166 
168  br->cfg = cfg;
169  br->cb = cb;
170  br->cb_cls = cb_cls;
171  reconnect(br);
172  if (NULL == br->mq)
173  {
174  GNUNET_free(br);
175  return NULL;
176  }
177  return br;
178 }
#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.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
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 188 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().

189 {
190  GNUNET_MQ_destroy(br->mq);
191  GNUNET_free(br);
192 }
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:821
#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 407 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().

410 {
412 
414  pm->cb = cb;
415  pm->cb_cls = cb_cls;
416  pm->cfg = cfg;
417  do_plugin_connect(pm);
418  if (NULL == pm->mq)
419  {
420  GNUNET_free(pm);
421  return NULL;
422  }
424  return pm;
425 }
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 struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
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 437 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().

438 {
439  if (NULL != pm->mq)
440  {
441  GNUNET_MQ_destroy(pm->mq);
442  pm->mq = NULL;
443  }
444  if (NULL != pm->reconnect_task)
445  {
447  pm->reconnect_task = NULL;
448  }
450  &free_entry,
451  pm);
453  GNUNET_free(pm);
454 }
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:821
#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:956
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 856 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.

863 {
865  unsigned int i;
866 
868  if (NULL != self)
869  {
870  h->self = *self;
871  h->check_self = GNUNET_YES;
872  }
873  h->cfg = cfg;
874  h->cls = cls;
875  h->nc_cb = nc;
876  h->nd_cb = nd;
877  h->neb_cb = neb;
879  if (NULL != handlers)
880  {
881  for (i = 0; NULL != handlers[i].cb; i++)
882  ;
885  handlers,
886  i * sizeof(struct GNUNET_MQ_MessageHandler));
887  }
888  LOG(GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service\n");
889  reconnect(h);
890  if (NULL == h->mq)
891  {
893  GNUNET_free(h);
894  return NULL;
895  }
896  h->neighbours =
898  return h;
899 }
struct GNUNET_MQ_MessageHandler * handlers
Functions to call for received data (template for new message queues).
void * cls
Closure for the callbacks.
#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:94
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_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
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 664 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().

666 {
667  struct Neighbour *n;
668 
669  n = neighbour_find(handle, peer);
670  if (NULL == n)
671  return NULL;
672  return n->mq;
673 }
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: