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 126 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 181 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 122 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 168 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 127 of file gnunet_transport_monitor_service.h.

◆ GNUNET_TRANSPORT_AddressToStringCallback

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

Function to call with a textual representation of an address.

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

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

Definition at line 118 of file gnunet_transport_service.h.

◆ GNUNET_TRANSPORT_PeerIterateCallback

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

Function to call with information about a peer.

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

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

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

Definition at line 329 of file gnunet_transport_service.h.

◆ GNUNET_TRANSPORT_BlacklistCallback

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

Function that decides if a connection is acceptable or not.

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

Definition at line 397 of file gnunet_transport_service.h.

◆ GNUNET_TRANSPORT_SessionMonitorCallback

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

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

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

Definition at line 547 of file gnunet_transport_service.h.

◆ GNUNET_TRANSPORT_NotifyConnect [2/2]

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

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

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

Definition at line 599 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 616 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 638 of file gnunet_transport_service.h.

Enumeration Type Documentation

◆ GNUNET_TRANSPORT_CommunicatorCharacteristics

What characteristics does this communicator have?

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

Enumerator
GNUNET_TRANSPORT_CC_UNKNOWN 

Characteristics are unknown (i.e.

DV).

GNUNET_TRANSPORT_CC_RELIABLE 

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

TCP/HTTP/HTTPS.

GNUNET_TRANSPORT_CC_UNRELIABLE 

Transmission is unreliable (i.e.

UDP)

Definition at line 90 of file gnunet_transport_communication_service.h.

91 {
92 
97 
102 
107 
108 };
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 227 of file gnunet_transport_communication_service.h.

228 {
229 
234 
239 
244 };
this is an inbound connection (communicator initiated)
this is an outbound connection (transport initiated)

◆ GNUNET_TRANSPORT_AddressClass

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

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

Enumerator
GNUNET_TRANSPORT_AC_NONE 

No address.

GNUNET_TRANSPORT_AC_OTHER 

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

incoming which we cannot use elsewhere).

GNUNET_TRANSPORT_AC_GLOBAL 

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

IPv4).

GNUNET_TRANSPORT_AC_GLOBAL_PRIVATE 

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

IPv6 with our MAC).

GNUNET_TRANSPORT_AC_LAN 

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

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

GNUNET_TRANSPORT_AC_WLAN 

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

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

GNUNET_TRANSPORT_AC_BT 

Addresses useful in the local bluetooth network.

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

GNUNET_TRANSPORT_AC_ANY 

Bitmask for "any" address.

Definition at line 61 of file gnunet_transport_hello_service.h.

62 {
63 
68 
74 
80 
86 
93 
100 
106 
111 
112 };
Addresses useful in the local wireless network, i.e.
Addresses useful in the local wired network, i.e.
Addresses that are global and are insensitive (i.e.
Addresses that fall into no other category (i.e.
Addresses useful in the local bluetooth network.
Addresses that are global and are sensitive (i.e.

◆ GNUNET_TRANSPORT_PeerState

Possible state of a neighbour.

Initially, we are GNUNET_TRANSPORT_PS_NOT_CONNECTED.

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

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

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

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

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

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

Enumerator
GNUNET_TRANSPORT_PS_NOT_CONNECTED 

Fresh peer or completely disconnected.

GNUNET_TRANSPORT_PS_INIT_ATS 

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

GNUNET_TRANSPORT_PS_SYN_SENT 

Sent SYN message to other peer, waiting for SYN_ACK.

GNUNET_TRANSPORT_PS_SYN_RECV_ATS 

Received a SYN, asking ATS about address suggestions.

GNUNET_TRANSPORT_PS_SYN_RECV_ACK 

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

GNUNET_TRANSPORT_PS_CONNECTED 

Got our SYN_ACK/ACK, connection is up.

GNUNET_TRANSPORT_PS_RECONNECT_ATS 

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

GNUNET_TRANSPORT_PS_RECONNECT_SENT 

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

GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT 

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

GNUNET_TRANSPORT_PS_DISCONNECT 

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

GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED 

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

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

Definition at line 214 of file gnunet_transport_service.h.

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

◆ GNUNET_TRANSPORT_SessionState

Possible states of a session in a plugin.

Enumerator
GNUNET_TRANSPORT_SS_INIT 

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

GNUNET_TRANSPORT_SS_HANDSHAKE 

Initial session handshake is in progress.

GNUNET_TRANSPORT_SS_UP 

Session is fully UP.

GNUNET_TRANSPORT_SS_UPDATE 

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

GNUNET_TRANSPORT_SS_DONE 

Session is being torn down and about to disappear.

Last call for each session object.

Definition at line 447 of file gnunet_transport_service.h.

448 {
449 
454 
459 
464 
470 
476 
477 };
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 779 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().

788 {
790 
792  ch->cfg = cfg;
794  ch->addr_prefix = addr_prefix;
795  ch->mq_init = mq_init;
796  ch->mq_init_cls = mq_init_cls;
797  ch->notify_cb = notify_cb;
799  ch->cc = cc;
800  reconnect (ch);
801  if (GNUNET_OK !=
804  "MAX_QUEUE_LENGTH",
805  &ch->max_queue_length))
807  if (NULL == ch->mq)
808  {
809  GNUNET_free (ch);
810  return NULL;
811  }
812  return ch;
813 }
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:78
#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 822 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().

824 {
825  disconnect (ch);
826  while (NULL != ch->ai_head)
827  {
828  GNUNET_break (0); /* communicator forgot to remove address, warn! */
830  }
831  GNUNET_free (ch);
832 }
#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 859 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().

866 {
867  struct GNUNET_MQ_Envelope *env;
868  struct GNUNET_TRANSPORT_IncomingMessage *im;
869  uint16_t msize;
870 
871  if (NULL == ch->mq)
872  return GNUNET_SYSERR;
873  if ((NULL == cb) && (GNUNET_MQ_get_length (ch->mq) >= ch->max_queue_length))
874  {
875  GNUNET_log (
877  "Dropping message: transprot is too slow, queue length %llu exceeded\n",
878  ch->max_queue_length);
879  return GNUNET_NO;
880  }
881 
882  msize = ntohs (msg->size);
883  env =
885  if (NULL == env)
886  {
887  GNUNET_break (0);
888  return GNUNET_SYSERR;
889  }
890  im->expected_address_validity =
891  GNUNET_TIME_relative_hton (expected_addr_validity);
892  im->sender = *sender;
893  memcpy (&im[1], msg, msize);
894  if (NULL != cb)
895  {
896  struct FlowControl *fc;
897 
898  im->fc_on = htonl (GNUNET_YES);
899  im->fc_id = ch->fc_gen++;
900  fc = GNUNET_new (struct FlowControl);
901  fc->sender = *sender;
902  fc->id = im->fc_id;
903  fc->cb = cb;
904  fc->cb_cls = cb_cls;
906  }
907  GNUNET_MQ_send (ch->mq, env);
908  return GNUNET_OK;
909 }
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:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Information we track per packet to enable flow control.
void * cb_cls
Closure for cb.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG
inform transport about an incoming message
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
uint64_t fc_gen
Flow-control identifier generator.
unsigned int GNUNET_MQ_get_length(struct GNUNET_MQ_Handle *mq)
Obtain the current length of the message queue.
Definition: mq.c:335
struct FlowControl * fc_head
DLL of messages awaiting flow control confirmation (ack).
struct GNUNET_PeerIdentity sender
Which peer is this about?
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:622
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:80
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
struct FlowControl * fc_tail
DLL of messages awaiting flow control confirmation (ack).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_communicator_mq_add()

struct GNUNET_TRANSPORT_QueueHandle* GNUNET_TRANSPORT_communicator_mq_add ( struct GNUNET_TRANSPORT_CommunicatorHandle ch,
const struct GNUNET_PeerIdentity peer,
const char *  address,
uint32_t  mtu,
enum GNUNET_NetworkType  nt,
enum GNUNET_TRANSPORT_ConnectionStatus  cs,
struct GNUNET_MQ_Handle mq 
)

Notify transport service that a MQ became available due to an "inbound" connection or because the communicator discovered the presence of another peer.

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

Notify transport service that a MQ became available due to an "inbound" connection or because the communicator discovered the presence of another peer.

Parameters
chconnection to transport service
peerpeer with which we can now communicate
addressaddress in human-readable format, 0-terminated, UTF-8
mtumaximum message size supported by queue, 0 if sending is not supported, SIZE_MAX for no MTU
ntwhich network type does the address belong to?
ccwhat characteristics does the communicator have?
cswhat is the connection status of the queue?
mqmessage queue of the peer
Returns
API handle identifying the new MQ

Definition at line 932 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().

940 {
941  struct GNUNET_TRANSPORT_QueueHandle *qh;
942 
944  qh->ch = ch;
945  qh->peer = *peer;
946  qh->address = GNUNET_strdup (address);
947  qh->nt = nt;
948  qh->mtu = mtu;
949  qh->cs = cs;
950  qh->mq = mq;
951  qh->queue_id = ch->queue_gen++;
953  send_add_queue (qh);
954  return qh;
955 }
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 965 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().

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

◆ GNUNET_TRANSPORT_communicator_address_add()

struct GNUNET_TRANSPORT_AddressIdentifier* GNUNET_TRANSPORT_communicator_address_add ( struct GNUNET_TRANSPORT_CommunicatorHandle ch,
const char *  address,
enum GNUNET_NetworkType  nt,
struct GNUNET_TIME_Relative  expiration 
)

Notify transport service about an address that this communicator provides for this peer.

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

Definition at line 987 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().

992 {
994 
996  ai->ch = ch;
997  ai->address = GNUNET_strdup (address);
998  ai->nt = nt;
999  ai->expiration = expiration;
1000  ai->aid = ch->aid_gen++;
1002  send_add_address (ai);
1003  return ai;
1004 }
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 1014 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().

1016 {
1018 
1019  send_del_address (ai);
1021  GNUNET_free (ai->address);
1022  GNUNET_free (ai);
1023 }
#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 1044 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().

1049 {
1050  struct GNUNET_MQ_Envelope *env;
1051  struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb;
1052  size_t slen = strlen (comm) + 1;
1053  uint16_t mlen = ntohs (header->size);
1054 
1055  GNUNET_assert (mlen + slen + sizeof (*cb) < UINT16_MAX);
1056  env =
1057  GNUNET_MQ_msg_extra (cb,
1058  slen + mlen,
1060  cb->pid = *pid;
1061  memcpy (&cb[1], header, mlen);
1062  memcpy (((char *) &cb[1]) + mlen, comm, slen);
1063  GNUNET_MQ_send (ch->mq, env);
1064 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL
Tell transport that it should assist with exchanging a message between communicators.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Handle * mq
Queue to talk to the transport service.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_core_connect() [1/2]

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

Connect to the transport service.

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

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

Referenced by GNUNET_TRANSPORT_core_get_mq(), GNUNET_TRANSPORT_TESTING_restart_peer(), GNUNET_TRANSPORT_TESTING_start_peer(), GSC_KX_init(), opstart_get_handle_transport(), run(), and transport_connect_adapter().

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_core_disconnect()

void GNUNET_TRANSPORT_core_disconnect ( struct GNUNET_TRANSPORT_CoreHandle handle)

Disconnect from the transport service.

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

Definition at line 912 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().

913 {
914  LOG (GNUNET_ERROR_TYPE_DEBUG, "Transport disconnect called!\n");
915  /* this disconnects all neighbours... */
916  if (NULL == handle->reconnect_task)
918  /* and now we stop trying to connect again... */
919  if (NULL != handle->reconnect_task)
920  {
922  handle->reconnect_task = NULL;
923  }
925  handle->neighbours = NULL;
926  GNUNET_free_non_null (handle->handlers);
927  handle->handlers = NULL;
928  GNUNET_free (handle);
929 }
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:965
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 231 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().

235 {
237 
239  ghh->rec = rec;
240  ghh->rec_cls = rec_cls;
241  ghh->cfg = cfg;
242  ghh->ac = ac;
243  reconnect (ghh);
244  if (NULL == ghh->mq)
245  {
246  GNUNET_free (ghh);
247  return NULL;
248  }
249  return ghh;
250 }
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 259 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().

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

207 {
209 
211  h->cfg = cfg;
213  "Connecting to transport service.\n");
214  reconnect (h);
215  if (NULL == h->mq)
216  {
217  GNUNET_free (h);
218  return NULL;
219  }
220  return h;
221 }
#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 230 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().

231 {
232  if (NULL == handle->reconnect_task)
234  /* and now we stop trying to connect again... */
235  if (NULL != handle->reconnect_task)
236  {
238  handle->reconnect_task = NULL;
239  }
240  GNUNET_free (handle);
241 }
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:965
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 174 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().

179 {
180  struct GNUNET_MQ_Envelope *env;
181  struct TrafficMetricMessage *msg;
182 
183  if (NULL == handle->mq)
184  return;
185  env = GNUNET_MQ_msg (msg,
187  msg->reserved = htonl (0);
188  msg->peer = *peer;
190  prop);
191  msg->delay_in = GNUNET_TIME_relative_hton (delay_in);
192  msg->delay_out = GNUNET_TIME_relative_hton (delay_out);
193  GNUNET_MQ_send (handle->mq,
194  env);
195 }
struct GNUNET_PeerIdentity peer
The identity of the peer to look up.
Definition: transport.h:523
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_TIME_RelativeNBO delay_in
Fake delay to add on inbound traffic.
Definition: transport.h:533
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:538
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:508
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_ATS_PropertiesNBO properties
Fake properties to generate.
Definition: transport.h:528
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:622
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
uint32_t reserved
Always zero.
Definition: transport.h:518
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_monitor()

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

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

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

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

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

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

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

Definition at line 254 of file transport_api2_monitor.c.

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

259 {
261 
263  mc->cfg = cfg;
264  if (NULL != peer)
265  mc->peer = *peer;
266  mc->one_shot = one_shot;
267  mc->cb = cb;
268  mc->cb_cls = cb_cls;
269  reconnect (mc);
270  if (NULL == mc->mq)
271  {
272  GNUNET_free (mc);
273  return NULL;
274  }
275  return mc;
276 }
#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 285 of file transport_api2_monitor.c.

References disconnect(), and GNUNET_free.

Referenced by handle_monitor_end().

286 {
287  disconnect (mc);
288  GNUNET_free (mc);
289 }
static void disconnect(struct GNUNET_TRANSPORT_MonitorContext *mc)
Disconnect from the transport service.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_offer_hello()

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

Offer the transport service the HELLO of another peer.

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

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

Definition at line 89 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().

93 {
96  struct GNUNET_MQ_Envelope *env;
98 
99  if (GNUNET_OK !=
100  GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hello,
101  &peer))
102  {
103  GNUNET_break (0);
104  GNUNET_free (ohh);
105  return NULL;
106  }
107  ohh->mq = GNUNET_CLIENT_connect (cfg,
108  "transport",
109  NULL,
110  NULL,
111  ohh);
112  if (NULL == ohh->mq)
113  {
114  GNUNET_free (ohh);
115  return NULL;
116  }
117  ohh->cont = cont;
118  ohh->cls = cont_cls;
119  GNUNET_break (ntohs (hello->type) == GNUNET_MESSAGE_TYPE_HELLO);
120  env = GNUNET_MQ_msg_copy (hello);
123  ohh);
124  GNUNET_MQ_send (ohh->mq,
125  env);
126  return ohh;
127 }
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:668
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
Definition: mq.c:653
A HELLO message is used to exchange information about transports with other peers.
Entry in linked list for all offer-HELLO requests.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:901
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore...
Definition: mq.c:774
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
The identity of the host (wraps the signing key of the peer).
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
static void finished_hello(void *cls)
Done sending HELLO message to the service, notify application.
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
struct GNUNET_MQ_Handle * mq
Transport service handle we use for transmission.
GNUNET_SCHEDULER_TaskCallback cont
Function to call once we are done.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_offer_hello_cancel()

void GNUNET_TRANSPORT_offer_hello_cancel ( struct GNUNET_TRANSPORT_OfferHelloHandle ohh)

Cancel the request to transport to offer the HELLO message.

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

Definition at line 136 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().

137 {
138  GNUNET_MQ_destroy (ohh->mq);
139  GNUNET_free (ohh);
140 }
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
struct GNUNET_MQ_Handle * mq
Transport service handle we use for transmission.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_address_to_string()

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

Convert a binary address into a human readable address.

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

Definition at line 178 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().

184 {
188  GNUNET_MQ_hd_var_size (reply,
191  alc),
193  };
194  size_t alen;
195  size_t slen;
196  struct AddressLookupMessage *msg;
197  struct GNUNET_MQ_Envelope *env;
198  char *addrbuf;
199 
200  alen = address->address_length;
201  slen = strlen (address->transport_name) + 1;
202  if ( (alen + slen >= GNUNET_MAX_MESSAGE_SIZE
203  - sizeof (struct AddressLookupMessage)) ||
204  (alen >= GNUNET_MAX_MESSAGE_SIZE) ||
205  (slen >= GNUNET_MAX_MESSAGE_SIZE) )
206  {
207  GNUNET_break (0);
208  GNUNET_free (alc);
209  return NULL;
210  }
211  alc->cb = aluc;
212  alc->cb_cls = aluc_cls;
213  alc->mq = GNUNET_CLIENT_connect (cfg,
214  "transport",
215  handlers,
217  alc);
218  if (NULL == alc->mq)
219  {
220  GNUNET_break (0);
221  GNUNET_free (alc);
222  return NULL;
223  }
225  "Client tries to resolve for peer `%s' address plugin %s len %u\n",
226  GNUNET_i2s (&address->peer),
227  address->transport_name,
228  (unsigned int) address->address_length);
229  env = GNUNET_MQ_msg_extra (msg,
230  alen + slen,
232  msg->numeric_only = htons ((int16_t) numeric);
233  msg->addrlen = htons ((uint16_t) alen);
234  msg->timeout = GNUNET_TIME_relative_hton (timeout);
235  addrbuf = (char *) &msg[1];
236  GNUNET_memcpy (addrbuf,
237  address->address,
238  alen);
239  GNUNET_memcpy (&addrbuf[alen],
240  address->transport_name,
241  slen);
242  GNUNET_MQ_send (alc->mq,
243  env);
244  return alc;
245 }
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:336
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:901
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
#define GNUNET_memcpy(dst, src, n)
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:374
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:622
struct GNUNET_TIME_RelativeNBO timeout
timeout to give up (for DNS resolution timeout mostly)
Definition: transport.h:384
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:362
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:379
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MQ_Handle * mq
Connection to the service.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_address_to_string_cancel()

void GNUNET_TRANSPORT_address_to_string_cancel ( struct GNUNET_TRANSPORT_AddressToStringContext alc)

Cancel request for address conversion.

Parameters
alcthe context handle

Definition at line 254 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().

255 {
256  GNUNET_MQ_destroy (alc->mq);
257  GNUNET_free (alc);
258 }
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MQ_Handle * mq
Connection to the service.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_ps2s()

const char* GNUNET_TRANSPORT_ps2s ( enum GNUNET_TRANSPORT_PeerState  state)

Convert a transport state to a human readable string.

Parameters
statethe state

Convert a transport state to a human readable string.

Parameters
statethe state value
Returns
corresponding string

Definition at line 129 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().

130 {
131  switch (state)
132  {
134  return "S_NOT_CONNECTED";
136  return "S_INIT_ATS";
138  return "S_SYN_SENT";
140  return "S_SYN_RECV_ATS";
142  return "S_SYN_RECV_ACK";
144  return "S_CONNECTED";
146  return "S_RECONNECT_ATS";
148  return "S_RECONNECT_SENT";
150  return "S_SWITCH_SYN_SENT";
152  return "S_DISCONNECT";
154  return "S_DISCONNECT_FINISHED";
155  default:
156  GNUNET_break (0);
157  return "UNDEFINED";
158  }
159 }
Connection got into trouble, rest of the system still believes it to be up, but we&#39;re getting a new a...
We have some primary connection, but ATS suggested we switch to some alternative; we now sent a SYN m...
Sent SYN over new address (either by ATS telling us to switch addresses or from RECONNECT_ATS); if th...
We&#39;re finished with the disconnect; and are cleaning up the state now! We put the struct into this st...
Received a SYN, asking ATS about address suggestions.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Fresh peer or completely disconnected.
enum State state
current state of profiling
Asked to initiate connection, trying to get address from ATS.
Sent SYN message to other peer, waiting for SYN_ACK.
Disconnect in progress (we&#39;re sending the DISCONNECT message to the other peer; after that is finishe...
Got our SYN_ACK/ACK, connection is up.
SYN request from other peer was SYN_ACK&#39;ed, waiting for ACK.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_is_connected()

int GNUNET_TRANSPORT_is_connected ( enum GNUNET_TRANSPORT_PeerState  state)

Check if a state is defined as connected.

Parameters
statethe state value
Returns
GNUNET_YES or GNUNET_NO

Definition at line 93 of file transport_api_monitor_peers.c.

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

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

94 {
95  switch (state)
96  {
102  return GNUNET_NO;
107  return GNUNET_YES;
110  return GNUNET_NO;
111  default:
113  "Unhandled state `%s'\n",
115  GNUNET_break (0);
116  break;
117  }
118  return GNUNET_SYSERR;
119 }
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:81
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:79
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:80
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 406 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().

411 {
414 
415  pal_ctx->cb = peer_callback;
416  pal_ctx->cb_cls = peer_callback_cls;
417  pal_ctx->cfg = cfg;
418  if (NULL != peer)
419  pal_ctx->peer = *peer;
420  pal_ctx->one_shot = one_shot;
421  do_peer_connect (pal_ctx);
422  if (NULL == pal_ctx->mq)
423  {
424  GNUNET_free (pal_ctx);
425  return NULL;
426  }
427  return pal_ctx;
428 }
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 437 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().

438 {
439  if (NULL != pic->mq)
440  {
441  GNUNET_MQ_destroy (pic->mq);
442  pic->mq = NULL;
443  }
444  if (NULL != pic->reconnect_task)
445  {
447  pic->reconnect_task = NULL;
448  }
449  GNUNET_free (pic);
450 }
struct GNUNET_MQ_Handle * mq
Connection to the service.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task ID for reconnect.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
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 164 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().

167 {
168  struct GNUNET_TRANSPORT_Blacklist *br;
169 
171  br->cfg = cfg;
172  br->cb = cb;
173  br->cb_cls = cb_cls;
174  reconnect (br);
175  if (NULL == br->mq)
176  {
177  GNUNET_free (br);
178  return NULL;
179  }
180  return br;
181 }
#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 191 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().

192 {
193  GNUNET_MQ_destroy (br->mq);
194  GNUNET_free (br);
195 }
struct GNUNET_MQ_Handle * mq
Connection to transport service.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_monitor_plugins()

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

Install a plugin session state monitor callback.

The callback will be notified whenever the session changes.

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

Definition at line 415 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().

418 {
420 
422  pm->cb = cb;
423  pm->cb_cls = cb_cls;
424  pm->cfg = cfg;
425  do_plugin_connect (pm);
426  if (NULL == pm->mq)
427  {
428  GNUNET_free (pm);
429  return NULL;
430  }
432  return pm;
433 }
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 445 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().

446 {
447  if (NULL != pm->mq)
448  {
449  GNUNET_MQ_destroy (pm->mq);
450  pm->mq = NULL;
451  }
452  if (NULL != pm->reconnect_task)
453  {
455  pm->reconnect_task = NULL;
456  }
458  &free_entry,
459  pm);
461  GNUNET_free (pm);
462 }
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.
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.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_HashMapIterator32 it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_CONTAINER_MultiHashMap32 * sessions
Map of session_ids (reduced to 32-bits) to struct GNUNET_TRANSPORT_PluginSession objects.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_core_connect() [2/2]

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

Connect to the transport service.

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

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

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

Parameters
cfgconfiguration to use
selfour own identity (API should check that it matches the identity found by transport), or NULL (no check)
clsclosure for the callbacks
recreceive function to call
ncfunction to call on connect events
ndfunction to call on disconnect events
nebfunction to call if we have excess bandwidth to a peer
Returns
NULL on error

Definition at line 859 of file transport_api_core.c.

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.

866 {
868  unsigned int i;
869 
871  if (NULL != self)
872  {
873  h->self = *self;
874  h->check_self = GNUNET_YES;
875  }
876  h->cfg = cfg;
877  h->cls = cls;
878  h->nc_cb = nc;
879  h->nd_cb = nd;
880  h->neb_cb = neb;
882  if (NULL != handlers)
883  {
884  for (i = 0; NULL != handlers[i].cb; i++)
885  ;
888  handlers,
889  i * sizeof (struct GNUNET_MQ_MessageHandler));
890  }
891  LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service\n");
892  reconnect (h);
893  if (NULL == h->mq)
894  {
896  GNUNET_free (h);
897  return NULL;
898  }
899  h->neighbours =
901  return h;
902 }
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_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_memcpy(dst, src, n)
#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:80
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 668 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().

670 {
671  struct Neighbour *n;
672 
673  n = neighbour_find (handle, peer);
674  if (NULL == n)
675  return NULL;
676  return n->mq;
677 }
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: