GNUnet  0.20.0
Transport service

address information More...

Collaboration diagram for Transport service:

Data Structures

struct  GNUNET_TRANSPORT_SessionInfo
 Information about a plugin's session. More...
 

Macros

#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_VERSION   0x00000003
 Version number of the transport API. More...
 

Typedefs

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_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_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_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_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...
 
void GNUNET_TRANSPORT_core_disconnect (struct GNUNET_TRANSPORT_CoreHandle *handle)
 Disconnect from 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

address information

Low-level P2P IO.

See also
Documentation

Macro Definition Documentation

◆ GNUNET_TRANSPORT_HELLO_VERSION

#define GNUNET_TRANSPORT_HELLO_VERSION   0x00000000

Version number of the transport API.

Definition at line 56 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 57 of file gnunet_transport_manipulation_service.h.

◆ GNUNET_TRANSPORT_VERSION

#define GNUNET_TRANSPORT_VERSION   0x00000003

Version number of the transport API.

Definition at line 55 of file gnunet_transport_service.h.

Typedef Documentation

◆ 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 124 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 170 of file gnunet_transport_hello_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 122 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 334 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 404 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 552 of file gnunet_transport_service.h.

◆ GNUNET_TRANSPORT_NotifyConnect

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

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

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

Definition at line 605 of file gnunet_transport_service.h.

◆ GNUNET_TRANSPORT_NotifyDisconnect

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

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

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

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

Definition at line 623 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 646 of file gnunet_transport_service.h.

Enumeration Type Documentation

◆ 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 65 of file gnunet_transport_hello_service.h.

66 {
71 
77 
83 
89 
96 
103 
109 
114 };
@ GNUNET_TRANSPORT_AC_BT
Addresses useful in the local bluetooth network.
@ GNUNET_TRANSPORT_AC_OTHER
Addresses that fall into no other category (i.e.
@ GNUNET_TRANSPORT_AC_LAN
Addresses useful in the local wired network, i.e.
@ GNUNET_TRANSPORT_AC_GLOBAL
Addresses that are global and are insensitive (i.e.
@ GNUNET_TRANSPORT_AC_NONE
No address.
@ GNUNET_TRANSPORT_AC_GLOBAL_PRIVATE
Addresses that are global and are sensitive (i.e.
@ GNUNET_TRANSPORT_AC_ANY
Bitmask for "any" address.
@ GNUNET_TRANSPORT_AC_WLAN
Addresses useful in the local wireless network, i.e.

◆ GNUNET_TRANSPORT_PeerState

Possible state of a neighbour.

Initially, we are GNUNET_TRANSPORT_PS_NOT_CONNECTED.

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

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

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

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

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

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

Enumerator
GNUNET_TRANSPORT_PS_NOT_CONNECTED 

Fresh peer or completely disconnected.

GNUNET_TRANSPORT_PS_INIT_ATS 

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

GNUNET_TRANSPORT_PS_SYN_SENT 

Sent SYN message to other peer, waiting for SYN_ACK.

GNUNET_TRANSPORT_PS_SYN_RECV_ATS 

Received a SYN, asking ATS about address suggestions.

GNUNET_TRANSPORT_PS_SYN_RECV_ACK 

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

GNUNET_TRANSPORT_PS_CONNECTED 

Got our SYN_ACK/ACK, connection is up.

GNUNET_TRANSPORT_PS_RECONNECT_ATS 

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

GNUNET_TRANSPORT_PS_RECONNECT_SENT 

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

GNUNET_TRANSPORT_PS_SWITCH_SYN_SENT 

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

GNUNET_TRANSPORT_PS_DISCONNECT 

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

GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED 

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

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

Definition at line 219 of file gnunet_transport_service.h.

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

◆ GNUNET_TRANSPORT_SessionState

Possible states of a session in a plugin.

Enumerator
GNUNET_TRANSPORT_SS_INIT 

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

GNUNET_TRANSPORT_SS_HANDSHAKE 

Initial session handshake is in progress.

GNUNET_TRANSPORT_SS_UP 

Session is fully UP.

GNUNET_TRANSPORT_SS_UPDATE 

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

GNUNET_TRANSPORT_SS_DONE 

Session is being torn down and about to disappear.

Last call for each session object.

Definition at line 455 of file gnunet_transport_service.h.

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

Function Documentation

◆ GNUNET_TRANSPORT_hello_get()

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

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

The callback given in this function is never called synchronously.

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

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

The callback given in this function is never called synchronously.

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

Definition at line 230 of file transport_api_hello_get.c.

234 {
236 
238  ghh->rec = rec;
239  ghh->rec_cls = rec_cls;
240  ghh->cfg = cfg;
241  ghh->ac = ac;
242  reconnect (ghh);
243  if (NULL == ghh->mq)
244  {
245  GNUNET_free (ghh);
246  return NULL;
247  }
248  return ghh;
249 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
Functions to call with this peer's HELLO.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
GNUNET_TRANSPORT_HelloUpdateCallback rec
Callback to call once we got our HELLO.
enum GNUNET_TRANSPORT_AddressClass ac
Type of HELLOs client cares about.
struct GNUNET_MQ_Handle * mq
Transport handle.
static void reconnect(void *cls)
Try again to connect to transport service.

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

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

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

◆ GNUNET_TRANSPORT_hello_get_cancel()

void GNUNET_TRANSPORT_hello_get_cancel ( struct GNUNET_TRANSPORT_HelloGetHandle ghh)

Stop receiving updates about changes to our HELLO message.

Parameters
ghhhandle to cancel

Definition at line 258 of file transport_api_hello_get.c.

259 {
260  if (NULL != ghh->reconnect_task)
261  {
263  ghh->reconnect_task = NULL;
264  }
265  if (NULL != ghh->mq)
266  {
267  GNUNET_MQ_destroy (ghh->mq);
268  ghh->mq = NULL;
269  }
270  GNUNET_free (ghh);
271 }
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the task trying to reconnect to the service.

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

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

◆ GNUNET_TRANSPORT_hello_parse()

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

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

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

◆ GNUNET_TRANSPORT_manipulation_connect()

struct GNUNET_TRANSPORT_ManipulationHandle* GNUNET_TRANSPORT_manipulation_connect ( const struct GNUNET_CONFIGURATION_Handle cfg)

Connect to the transport service.

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

Parameters
cfgconfiguration to use
Returns
NULL on error

Definition at line 208 of file transport_api_manipulation.c.

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

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

Referenced by GNUNET_TRANSPORT_TESTING_start_peer(), and run().

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

◆ GNUNET_TRANSPORT_manipulation_disconnect()

void GNUNET_TRANSPORT_manipulation_disconnect ( struct GNUNET_TRANSPORT_ManipulationHandle handle)

Disconnect from the transport service.

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

Definition at line 233 of file transport_api_manipulation.c.

236 {
237  if (NULL == handle->reconnect_task)
239  /* and now we stop trying to connect again... */
240  if (NULL != handle->reconnect_task)
241  {
243  handle->reconnect_task = NULL;
244  }
246 }
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task to reconnect to the service.
Definition: dns_api.c:81
static void disconnect_and_schedule_reconnect(struct GNUNET_TRANSPORT_ManipulationHandle *h)
Function that will schedule the job that will try to connect us again to the client.

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

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

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

◆ GNUNET_TRANSPORT_manipulation_set()

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

Set transport metrics for a peer and a direction.

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

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

Definition at line 175 of file transport_api_manipulation.c.

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

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

Referenced by run().

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

◆ GNUNET_TRANSPORT_offer_hello()

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

Offer the transport service the HELLO of another peer.

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

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

Definition at line 87 of file transport_api_offer_hello.c.

91 {
94  struct GNUNET_MQ_Envelope *env;
96 
97  if (GNUNET_OK !=
98  GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hello,
99  &peer))
100  {
101  GNUNET_break (0);
102  GNUNET_free (ohh);
103  return NULL;
104  }
105  ohh->mq = GNUNET_CLIENT_connect (cfg,
106  "transport",
107  NULL,
108  NULL,
109  ohh);
110  if (NULL == ohh->mq)
111  {
112  GNUNET_free (ohh);
113  return NULL;
114  }
115  ohh->cont = cont;
116  ohh->cls = cont_cls;
117  GNUNET_break (ntohs (hello->type) == GNUNET_MESSAGE_TYPE_HELLO);
118  env = GNUNET_MQ_msg_copy (hello);
121  ohh);
122  GNUNET_MQ_send (ohh->mq,
123  env);
124  return ohh;
125 }
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
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:649
@ GNUNET_OK
#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:638
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:533
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
A HELLO message is used to exchange information about transports with other peers.
The identity of the host (wraps the signing key of the peer).
Entry in linked list for all offer-HELLO requests.
GNUNET_SCHEDULER_TaskCallback cont
Function to call once we are done.
struct GNUNET_MQ_Handle * mq
Transport service handle we use for transmission.
static void finished_hello(void *cls)
Done sending HELLO message to the service, notify application.

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

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

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

Definition at line 129 of file transport_api_offer_hello.c.

131 {
132  GNUNET_MQ_destroy (ohh->mq);
133  GNUNET_free (ohh);
134 }

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

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

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

◆ GNUNET_TRANSPORT_address_to_string()

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

Convert a binary address into a human readable address.

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

Definition at line 177 of file transport_api_address_to_string.c.

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

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

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

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

◆ GNUNET_TRANSPORT_address_to_string_cancel()

void GNUNET_TRANSPORT_address_to_string_cancel ( struct GNUNET_TRANSPORT_AddressToStringContext alc)

Cancel request for address conversion.

Parameters
alcthe context handle

Definition at line 255 of file transport_api_address_to_string.c.

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

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

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

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

◆ GNUNET_TRANSPORT_ps2s()

const char* GNUNET_TRANSPORT_ps2s ( enum GNUNET_TRANSPORT_PeerState  state)

Convert a transport state to a human readable string.

Parameters
statethe state

Convert a transport state to a human readable string.

Parameters
statethe state value
Returns
corresponding string

Definition at line 132 of file transport_api_monitor_peers.c.

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

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

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

Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_is_connected()

int GNUNET_TRANSPORT_is_connected ( enum GNUNET_TRANSPORT_PeerState  state)

Check if a state is defined as connected.

Parameters
statethe state value
Returns
GNUNET_YES or GNUNET_NO

Definition at line 93 of file transport_api_monitor_peers.c.

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

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

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

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

◆ GNUNET_TRANSPORT_monitor_peers()

struct GNUNET_TRANSPORT_PeerMonitoringContext* GNUNET_TRANSPORT_monitor_peers ( const struct GNUNET_CONFIGURATION_Handle cfg,
const struct GNUNET_PeerIdentity peer,
int  one_shot,
GNUNET_TRANSPORT_PeerIterateCallback  peer_callback,
void *  peer_callback_cls 
)

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

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

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

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

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

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

Definition at line 393 of file transport_api_monitor_peers.c.

399 {
402 
403  pal_ctx->cb = peer_callback;
404  pal_ctx->cb_cls = peer_callback_cls;
405  pal_ctx->cfg = cfg;
406  if (NULL != peer)
407  pal_ctx->peer = *peer;
408  pal_ctx->one_shot = one_shot;
409  do_peer_connect (pal_ctx);
410  if (NULL == pal_ctx->mq)
411  {
412  GNUNET_free (pal_ctx);
413  return NULL;
414  }
415  return pal_ctx;
416 }
Context for iterating validation entries.
struct GNUNET_MQ_Handle * mq
Connection to the service.
GNUNET_TRANSPORT_PeerIterateCallback cb
Function to call with the binary address.
struct GNUNET_PeerIdentity peer
Identity of the peer to monitor.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
static void do_peer_connect(void *cls)
Task run to re-establish the connection.

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

Referenced by run().

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

◆ GNUNET_TRANSPORT_monitor_peers_cancel()

void GNUNET_TRANSPORT_monitor_peers_cancel ( struct GNUNET_TRANSPORT_PeerMonitoringContext pic)

Cancel request to monitor peers.

Parameters
pichandle for the request to cancel

Definition at line 425 of file transport_api_monitor_peers.c.

428 {
429  if (NULL != pic->mq)
430  {
431  GNUNET_MQ_destroy (pic->mq);
432  pic->mq = NULL;
433  }
434  if (NULL != pic->reconnect_task)
435  {
436  GNUNET_SCHEDULER_cancel (pic->reconnect_task);
437  pic->reconnect_task = NULL;
438  }
439  GNUNET_free (pic);
440 }
static struct GNUNET_PEERINFO_IteratorContext * pic
Current iterator context (if active, otherwise NULL).

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

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

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

◆ GNUNET_TRANSPORT_blacklist()

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

Install a blacklist callback.

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

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

Definition at line 163 of file transport_api_blacklist.c.

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

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

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

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

◆ GNUNET_TRANSPORT_blacklist_cancel()

void GNUNET_TRANSPORT_blacklist_cancel ( struct GNUNET_TRANSPORT_Blacklist br)

Abort the blacklist.

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

Parameters
brhandle of the request that is to be cancelled

Definition at line 190 of file transport_api_blacklist.c.

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

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

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

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

◆ GNUNET_TRANSPORT_monitor_plugins()

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

Install a plugin session state monitor callback.

The callback will be notified whenever the session changes.

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

Definition at line 412 of file transport_api_monitor_plugins.c.

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

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

Referenced by run().

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

◆ GNUNET_TRANSPORT_monitor_plugins_cancel()

void GNUNET_TRANSPORT_monitor_plugins_cancel ( struct GNUNET_TRANSPORT_PluginMonitor pm)

Cancel monitoring the plugin session state.

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

Parameters
pmhandle of the request that is to be cancelled

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

Parameters
pmhandle of the request that is to be cancelled

Definition at line 442 of file transport_api_monitor_plugins.c.

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

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

Referenced by shutdown_task().

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

◆ GNUNET_TRANSPORT_core_connect()

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

Connect to the transport service.

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

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

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

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

Definition at line 859 of file transport_api_core.c.

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

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

Here is the call graph for this function:

◆ GNUNET_TRANSPORT_core_disconnect()

void GNUNET_TRANSPORT_core_disconnect ( struct GNUNET_TRANSPORT_CoreHandle handle)

Disconnect from the transport service.

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

Definition at line 912 of file transport_api_core.c.

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

◆ 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 687 of file transport_api2_core.c.

689 {
690  struct Neighbour *n;
691 
692  n = neighbour_find (handle, peer);
693  if (NULL == n)
694  return NULL;
695  return n->mq;
696 }
A connected controller which is not our child.
struct GNUNET_MQ_Handle * mq
Active message queue for the peer.
static struct Neighbour * neighbour_find(struct GNUNET_TRANSPORT_CoreHandle *h, const struct GNUNET_PeerIdentity *peer)
Get the neighbour list entry for the given peer.

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

Referenced by rocc_cache_get_handle_transport_cb().

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