GNUnet  0.11.x
Data Structures | Functions | Variables
gnunet-service-transport_plugins.c File Reference

plugin management More...

#include "platform.h"
#include "gnunet-service-transport.h"
#include "gnunet-service-transport_hello.h"
#include "gnunet-service-transport_ats.h"
#include "gnunet-service-transport_plugins.h"
Include dependency graph for gnunet-service-transport_plugins.c:

Go to the source code of this file.

Data Structures

struct  TransportPlugin
 Entry in doubly-linked list of all of our plugins. More...
 

Functions

static void plugin_env_update_distance (void *cls, const struct GNUNET_HELLO_Address *address, uint32_t distance)
 Function that will be called to update metrics for an address. More...
 
static enum GNUNET_NetworkType plugin_env_address_to_type (void *cls, const struct sockaddr *addr, size_t addrlen)
 Function that will be called to figure if an address is an loopback, LAN, WAN etc. More...
 
void GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, GNUNET_TRANSPORT_AddressNotification address_cb, GNUNET_TRANSPORT_SessionStart session_start_cb, GNUNET_TRANSPORT_SessionEnd session_end_cb)
 Load and initialize all plugins. More...
 
void GST_plugins_unload ()
 Unload all plugins. More...
 
struct GNUNET_TRANSPORT_PluginFunctionsGST_plugins_find (const char *name)
 Obtain the plugin API based on a plugin name. More...
 
struct GNUNET_TRANSPORT_PluginFunctionsGST_plugins_printer_find (const char *name)
 Obtain the plugin API based on a the stripped plugin name after the underscore. More...
 
const char * GST_plugins_a2s (const struct GNUNET_HELLO_Address *address)
 Convert a given address to a human-readable format. More...
 
void GST_plugins_monitor_subscribe (GNUNET_TRANSPORT_SessionInfoCallback cb, void *cb_cls)
 Register callback with all plugins to monitor their status. More...
 

Variables

static struct TransportPluginplugins_head
 Head of DLL of all loaded plugins. More...
 
static struct TransportPluginplugins_tail
 Head of DLL of all loaded plugins. More...
 

Detailed Description

plugin management

Author
Christian Grothoff

Definition in file gnunet-service-transport_plugins.c.

Function Documentation

◆ plugin_env_update_distance()

static void plugin_env_update_distance ( void *  cls,
const struct GNUNET_HELLO_Address address,
uint32_t  distance 
)
static

Function that will be called to update metrics for an address.

Parameters
clsclosure
addressaddress to update metrics for
sessionthe session
distancenew distance

Definition at line 90 of file gnunet-service-transport_plugins.c.

References GST_ats_update_distance().

Referenced by GST_plugins_load().

93 {
94  GST_ats_update_distance (address,
95  distance);
96 }
void GST_ats_update_distance(const struct GNUNET_HELLO_Address *address, uint32_t distance)
Notify ATS about DV distance change to an address.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ plugin_env_address_to_type()

static enum GNUNET_NetworkType plugin_env_address_to_type ( void *  cls,
const struct sockaddr *  addr,
size_t  addrlen 
)
static

Function that will be called to figure if an address is an loopback, LAN, WAN etc.

address

Parameters
clsclosure
addrbinary address
addrlenlength of the addr
Returns
type of the network addr belongs to

Definition at line 109 of file gnunet-service-transport_plugins.c.

References GNUNET_break, GNUNET_NT_scanner_get_type(), GNUNET_NT_UNSPECIFIED, and GST_is.

Referenced by GST_plugins_load().

112 {
113  if (NULL == GST_is)
114  {
115  GNUNET_break (0);
116  return GNUNET_NT_UNSPECIFIED;
117  }
119  addr,
120  addrlen);
121 }
enum GNUNET_NetworkType GNUNET_NT_scanner_get_type(struct GNUNET_NT_InterfaceScanner *is, const struct sockaddr *addr, socklen_t addrlen)
Returns where the address is located: loopback, LAN or WAN.
Definition: nt.c:314
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_NT_InterfaceScanner * GST_is
Interface scanner determines our LAN address range(s).
Category of last resort.
Definition: gnunet_nt_lib.h:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_plugins_load()

void GST_plugins_load ( GNUNET_TRANSPORT_PluginReceiveCallback  recv_cb,
GNUNET_TRANSPORT_AddressNotification  address_cb,
GNUNET_TRANSPORT_SessionStart  session_start_cb,
GNUNET_TRANSPORT_SessionEnd  session_end_cb 
)

Load and initialize all plugins.

The respective functions will be invoked by the plugins when the respective events happen. The closure will be set to a 'const char*' containing the name of the plugin that caused the call.

Parameters
recv_cbfunction to call when data is received
address_cbfunction to call when our public addresses changed
session_start_cbfunction to call when a session was created
session_end_cbfunction to call when a session was terminated
address_type_cbfunction to call when a address type is requested

Definition at line 137 of file gnunet-service-transport_plugins.c.

References _, address_cb(), GNUNET_TRANSPORT_PluginFunctions::address_pretty_printer, GNUNET_TRANSPORT_PluginFunctions::address_to_string, TransportPlugin::api, GNUNET_TRANSPORT_PluginEnvironment::cfg, GNUNET_TRANSPORT_PluginFunctions::check_address, GNUNET_TRANSPORT_PluginEnvironment::cls, GNUNET_TRANSPORT_PluginFunctions::disconnect_peer, GNUNET_TRANSPORT_PluginFunctions::disconnect_session, TransportPlugin::env, GNUNET_TRANSPORT_PluginEnvironment::get_address_type, GNUNET_TRANSPORT_PluginFunctions::get_network, GNUNET_TRANSPORT_PluginEnvironment::get_our_hello, GNUNET_TRANSPORT_PluginFunctions::get_session, GNUNET_asprintf(), GNUNET_break, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_PLUGIN_load(), GNUNET_PLUGIN_unload(), GNUNET_strdup, GNUNET_YES, GST_cfg, GST_hello_get(), GST_my_identity, GST_stats, TransportPlugin::lib_name, GNUNET_TRANSPORT_PluginEnvironment::max_connections, GNUNET_TRANSPORT_PluginEnvironment::my_identity, TransportPlugin::next, GNUNET_TRANSPORT_PluginEnvironment::notify_address, plugin_env_address_to_type(), plugin_env_update_distance(), plugins_head, GNUNET_TRANSPORT_PluginFunctions::query_keepalive_factor, GNUNET_TRANSPORT_PluginEnvironment::receive, GNUNET_TRANSPORT_PluginFunctions::send, GNUNET_TRANSPORT_PluginEnvironment::session_end, GNUNET_TRANSPORT_PluginEnvironment::session_start, TransportPlugin::short_name, GNUNET_TRANSPORT_PluginEnvironment::stats, GNUNET_TRANSPORT_PluginFunctions::string_to_address, GNUNET_TRANSPORT_PluginEnvironment::update_address_distance, and GNUNET_TRANSPORT_PluginFunctions::update_session_timeout.

Referenced by run().

141 {
142  struct TransportPlugin *plug;
143  struct TransportPlugin *next;
144  unsigned long long tneigh;
145  char *libname;
146  char *plugs;
147  char *pos;
148  int fail;
149 
150  if (GNUNET_OK !=
152  "TRANSPORT",
153  "NEIGHBOUR_LIMIT",
154  &tneigh))
155  {
157  _ ("Transport service is lacking NEIGHBOUR_LIMIT option.\n"));
158  return;
159  }
160  if (GNUNET_OK !=
162  "TRANSPORT",
163  "PLUGINS",
164  &plugs))
165  return;
167  _ ("Starting transport plugins `%s'\n"),
168  plugs);
169  for (pos = strtok (plugs, " "); pos != NULL; pos = strtok (NULL, " "))
170  {
172  _ ("Loading `%s' transport plugin\n"),
173  pos);
174  GNUNET_asprintf (&libname,
175  "libgnunet_plugin_transport_%s",
176  pos);
177  plug = GNUNET_new (struct TransportPlugin);
178  plug->short_name = GNUNET_strdup (pos);
179  plug->lib_name = libname;
180  plug->env.cfg = GST_cfg;
183  plug->env.cls = plug->short_name;
184  plug->env.receive = recv_cb;
185  plug->env.notify_address = address_cb;
186  plug->env.session_start = session_start_cb;
187  plug->env.session_end = session_end_cb;
190  plug->env.max_connections = tneigh;
191  plug->env.stats = GST_stats;
193  plugins_tail,
194  plug);
195  }
196  GNUNET_free (plugs);
197  next = plugins_head;
198  while (NULL != next)
199  {
200  plug = next;
201  next = plug->next;
202  plug->api = GNUNET_PLUGIN_load (plug->lib_name,
203  &plug->env);
204  if (NULL == plug->api)
205  {
207  _ ("Failed to load transport plugin for `%s'\n"),
208  plug->lib_name);
210  plugins_tail,
211  plug);
212  GNUNET_free (plug->short_name);
213  GNUNET_free (plug->lib_name);
214  GNUNET_free (plug);
215  continue;
216  }
217  fail = GNUNET_NO;
218  if (NULL == plug->api->address_pretty_printer)
219  {
220  fail = GNUNET_YES;
222  _ ("Missing function `%s' in transport plugin for `%s'\n"),
223  "address_pretty_printer",
224  plug->lib_name);
225  }
226  if (NULL == plug->api->address_to_string)
227  {
228  fail = GNUNET_YES;
230  _ ("Missing function `%s' in transport plugin for `%s'\n"),
231  "address_to_string",
232  plug->lib_name);
233  }
234  if (NULL == plug->api->string_to_address)
235  {
236  fail = GNUNET_YES;
238  _ ("Missing function `%s' in transport plugin for `%s'\n"),
239  "string_to_address",
240  plug->lib_name);
241  }
242  if (NULL == plug->api->check_address)
243  {
244  fail = GNUNET_YES;
246  _ ("Missing function `%s' in transport plugin for `%s'\n"),
247  "check_address",
248  plug->lib_name);
249  }
250  if (NULL == plug->api->get_session)
251  {
252  fail = GNUNET_YES;
254  _ ("Missing function `%s' in transport plugin for `%s'\n"),
255  "get_session",
256  plug->lib_name);
257  }
258  if (NULL == plug->api->get_network)
259  {
260  fail = GNUNET_YES;
262  _ ("Missing function `%s' in transport plugin for `%s'\n"),
263  "get_network",
264  plug->lib_name);
265  }
266  if (NULL == plug->api->send)
267  {
268  fail = GNUNET_YES;
270  _ ("Missing function `%s' in transport plugin for `%s'\n"),
271  "send",
272  plug->lib_name);
273  }
274  if (NULL == plug->api->disconnect_peer)
275  {
276  fail = GNUNET_YES;
278  _ ("Missing function `%s' in transport plugin for `%s'\n"),
279  "disconnect_peer",
280  plug->lib_name);
281  }
282  if (NULL == plug->api->disconnect_session)
283  {
284  fail = GNUNET_YES;
286  _ ("Missing function `%s' in transport plugin for `%s'\n"),
287  "disconnect_session",
288  plug->lib_name);
289  }
290  if (NULL == plug->api->query_keepalive_factor)
291  {
292  fail = GNUNET_YES;
294  _ ("Missing function `%s' in transport plugin for `%s'\n"),
295  "query_keepalive_factor",
296  plug->lib_name);
297  }
298  if (NULL == plug->api->update_session_timeout)
299  {
300  fail = GNUNET_YES;
302  _ ("Missing function `%s' in transport plugin for `%s'\n"),
303  "update_session_timeout",
304  plug->lib_name);
305  }
306  if (GNUNET_YES == fail)
307  {
309  _ ("Did not load plugin `%s' due to missing functions\n"),
310  plug->lib_name);
311  GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api));
313  plugins_tail,
314  plug);
315  GNUNET_free (plug->short_name);
316  GNUNET_free (plug->lib_name);
317  GNUNET_free (plug);
318  }
319  }
320 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_PeerIdentity GST_my_identity
Our public key.
char * short_name
Short name for the plugin (i.e.
GNUNET_TRANSPORT_CreateSession get_session
Function that will be called tell the plugin to create a session object.
GNUNET_TRANSPORT_AddressToString address_to_string
Function that will be called to convert a binary address to a string (numeric conversion only)...
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.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
GNUNET_TRANSPORT_SessionStart session_start
Function called by the plugin when a new (incoming) session was created not explicitly created using ...
struct TransportPlugin * next
This is a doubly-linked list.
GNUNET_TRANSPORT_TransmitFunction send
Function that the transport service will use to transmit data to another peer.
GNUNET_TRANSPORT_DisconnectPeerFunction disconnect_peer
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...
GNUNET_TRANSPORT_AddressToType get_address_type
Function that will be called to figure if an address is an loopback, LAN, WAN etc.
GNUNET_TRANSPORT_DisconnectSessionFunction disconnect_session
Function that can be used to force the plugin to disconnect from the given peer and cancel all previo...
const struct GNUNET_PeerIdentity * my_identity
Identity of this peer.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static enum GNUNET_NetworkType plugin_env_address_to_type(void *cls, const struct sockaddr *addr, size_t addrlen)
Function that will be called to figure if an address is an loopback, LAN, WAN etc.
uint32_t max_connections
What is the maximum number of connections that this transport should allow? Transports that do not ha...
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void plugin_env_update_distance(void *cls, const struct GNUNET_HELLO_Address *address, uint32_t distance)
Function that will be called to update metrics for an address.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
Definition: plugin.c:256
static void address_cb(void *cls, void **app_ctx, int add_remove, enum GNUNET_NAT_AddressClass ac, const struct sockaddr *addr, socklen_t addrlen)
Signature of the callback passed to GNUNET_NAT_register() for a function to call whenever our set of ...
Definition: gnunet-nat.c:122
GNUNET_TRANSPORT_SessionEnd session_end
Function that must be called by the plugin when a non-NULL session handle stops being valid (is destr...
GNUNET_TRANSPORT_PluginReceiveCallback receive
Function that should be called by the transport plugin whenever a message is received.
GNUNET_TRANSPORT_UpdateSessionTimeout update_session_timeout
Function that will be called whenever the transport service wants to notify the plugin that a session...
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
static struct GNUNET_STATISTICS_Handle * GST_stats
Statistics handle.
void * cls
Closure for the various callbacks.
static struct TransportPlugin * plugins_head
Head of DLL of all loaded plugins.
GNUNET_TRANSPORT_GetHelloCallback get_our_hello
Function that returns our HELLO.
GNUNET_TRANSPORT_StringToAddress string_to_address
Function that will be called to convert a string address to binary (numeric conversion only)...
struct GNUNET_TRANSPORT_PluginEnvironment env
Environment this transport service is using for this plugin.
GNUNET_TRANSPORT_GetNetworkType get_network
Function to obtain the network type for a session.
static struct TransportPlugin * plugins_tail
Head of DLL of all loaded plugins.
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
char * lib_name
Name of the library (i.e.
GNUNET_TRANSPORT_UpdateAddressDistance update_address_distance
Function that will be called by DV to update distance for an address.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
const struct GNUNET_MessageHeader * GST_hello_get()
Obtain this peers HELLO message.
GNUNET_TRANSPORT_QueryKeepaliveFactorFunction query_keepalive_factor
Function that is used to query keepalive factor.
Entry in doubly-linked list of all of our plugins.
struct GNUNET_TRANSPORT_PluginFunctions * api
API of the transport as returned by the plugin's initialization function.
struct GNUNET_STATISTICS_Handle * stats
Handle for reporting statistics.
#define GNUNET_log(kind,...)
GNUNET_TRANSPORT_AddressNotification notify_address
Function that must be called by each plugin to notify the transport service about the addresses under...
GNUNET_TRANSPORT_AddressPrettyPrinter address_pretty_printer
Function to pretty-print addresses.
#define GNUNET_YES
Definition: gnunet_common.h:77
static const struct GNUNET_CONFIGURATION_Handle * GST_cfg
Configuration handle.
void * GNUNET_PLUGIN_load(const char *library_name, void *arg)
Setup plugin (runs the "init" callback and returns whatever "init" returned).
Definition: plugin.c:207
GNUNET_TRANSPORT_CheckAddress check_address
Function that will be called to check if a binary address for this plugin is well-formed and correspo...
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_plugins_unload()

void GST_plugins_unload ( void  )

Unload all plugins.

Definition at line 327 of file gnunet-service-transport_plugins.c.

References TransportPlugin::api, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_PLUGIN_unload(), TransportPlugin::lib_name, and TransportPlugin::short_name.

Referenced by shutdown_task().

328 {
329  struct TransportPlugin *plug;
330 
331  while (NULL != (plug = plugins_head))
332  {
333  GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api));
334  GNUNET_free (plug->lib_name);
335  GNUNET_free (plug->short_name);
337  GNUNET_free (plug);
338  }
339 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
char * short_name
Short name for the plugin (i.e.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
Definition: plugin.c:256
static struct TransportPlugin * plugins_head
Head of DLL of all loaded plugins.
static struct TransportPlugin * plugins_tail
Head of DLL of all loaded plugins.
char * lib_name
Name of the library (i.e.
Entry in doubly-linked list of all of our plugins.
struct GNUNET_TRANSPORT_PluginFunctions * api
API of the transport as returned by the plugin's initialization function.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_plugins_find()

struct GNUNET_TRANSPORT_PluginFunctions* GST_plugins_find ( const char *  name)

Obtain the plugin API based on a plugin name.

Parameters
namename of the plugin
Returns
the plugin's API, NULL if the plugin is not loaded

Definition at line 349 of file gnunet-service-transport_plugins.c.

References TransportPlugin::api, TransportPlugin::next, and TransportPlugin::short_name.

Referenced by add_valid_address(), GST_neighbours_keepalive_response(), GST_neighbours_switch_to_address(), GST_validation_handle_address(), GST_validation_handle_ping(), GST_validation_handle_pong(), GST_validation_set_address_use(), inbound_bw_tracker_update(), kill_session(), multicast_pong(), send_syn(), send_syn_ack_message(), send_with_session(), set_alternative_address(), switch_address_bl_check_cont(), and transmit_ping_if_allowed().

350 {
351  struct TransportPlugin *pos;
352 
353  for (pos = plugins_head; NULL != pos; pos = pos->next)
354  if (0 == strcmp (name, pos->short_name))
355  break;
356  if (NULL == pos)
357  return NULL;
358  return pos->api;
359 }
char * short_name
Short name for the plugin (i.e.
struct TransportPlugin * next
This is a doubly-linked list.
static struct TransportPlugin * plugins_head
Head of DLL of all loaded plugins.
Entry in doubly-linked list of all of our plugins.
struct GNUNET_TRANSPORT_PluginFunctions * api
API of the transport as returned by the plugin's initialization function.
const char * name
Here is the caller graph for this function:

◆ GST_plugins_printer_find()

struct GNUNET_TRANSPORT_PluginFunctions* GST_plugins_printer_find ( const char *  name)

Obtain the plugin API based on a the stripped plugin name after the underscore.

Example: GST_plugins_printer_find (http_client) will return all plugins starting with the prefix "http": http_client or server if loaded

Parameters
namename of the plugin
Returns
the plugin's API, NULL if the plugin is not loaded

Definition at line 373 of file gnunet-service-transport_plugins.c.

References TransportPlugin::api, GNUNET_free, GNUNET_strdup, TransportPlugin::next, and TransportPlugin::short_name.

Referenced by GST_plugins_a2s(), and handle_client_address_to_string().

374 {
375  struct TransportPlugin *pos;
376  char *stripped = GNUNET_strdup (name);
377  char *sep = strchr (stripped, '_');
378 
379  if (NULL != sep)
380  sep[0] = '\0';
381  for (pos = plugins_head; NULL != pos; pos = pos->next)
382  if (pos->short_name == strstr (pos->short_name, stripped))
383  break;
384  GNUNET_free (stripped);
385  if (NULL == pos)
386  return NULL;
387  return pos->api;
388 }
char * short_name
Short name for the plugin (i.e.
struct TransportPlugin * next
This is a doubly-linked list.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static struct TransportPlugin * plugins_head
Head of DLL of all loaded plugins.
Entry in doubly-linked list of all of our plugins.
struct GNUNET_TRANSPORT_PluginFunctions * api
API of the transport as returned by the plugin's initialization function.
const char * name
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ GST_plugins_a2s()

const char* GST_plugins_a2s ( const struct GNUNET_HELLO_Address address)

Convert a given address to a human-readable format.

Note that the return value will be overwritten on the next call to this function.

Parameters
addressthe address to convert
Returns
statically allocated (!) human-readable address

Definition at line 399 of file gnunet-service-transport_plugins.c.

References GNUNET_HELLO_Address::address, GNUNET_HELLO_Address::address_length, GNUNET_TRANSPORT_PluginFunctions::address_to_string, TransportPlugin::api, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_snprintf(), GST_plugins_printer_find(), GNUNET_HELLO_Address::transport_name, and TRANSPORT_SESSION_INBOUND_STRING.

Referenced by add_valid_address(), connect_bl_check_cont(), GST_ats_add_address(), GST_ats_add_inbound_address(), GST_ats_block_address(), GST_ats_expire_address(), GST_ats_update_utilization(), GST_hello_modify_addresses(), GST_neighbours_session_terminated(), GST_neighbours_switch_to_address(), GST_receive_callback(), GST_validation_handle_address(), GST_validation_handle_ping(), GST_validation_handle_pong(), neighbours_changed_notification(), plugin_env_session_end(), plugin_env_session_start(), plugin_env_session_start_bl_check_cont(), revalidate_address(), send_peer_information(), send_session_syn_ack_cont(), send_syn(), send_syn_ack_message(), set_alternative_address(), set_primary_address(), switch_address_bl_check_cont(), transmit_ping_if_allowed(), and unblock_address().

400 {
402  static char unable_to_show[1024];
403  static const char *s;
404 
405  if (NULL == address)
406  return "<NULL>";
407  if (0 == address->address_length)
408  return TRANSPORT_SESSION_INBOUND_STRING; /* Addresse with length 0 are inbound, address->address itself may be NULL */
409  api = GST_plugins_printer_find (address->transport_name);
410  if (NULL == api)
411  {
413  "Failed to find transport plugin `%s'\n",
414  address->transport_name);
415  return "<plugin unknown>";
416  }
417  if (0 == address->address_length)
418  {
419  GNUNET_snprintf (unable_to_show,
420  sizeof(unable_to_show),
421  "<unable to stringify %u-byte long address of %s transport>",
422  (unsigned int) address->address_length,
423  address->transport_name);
424  return unable_to_show;
425  }
426  return(NULL != (s = api->address_to_string (NULL,
427  address->address,
428  address->address_length))
429  ? s
430  : "<invalid>");
431 }
size_t address_length
Number of bytes in address.
GNUNET_TRANSPORT_AddressToString address_to_string
Function that will be called to convert a binary address to a string (numeric conversion only)...
const void * address
Binary representation of the address (plugin-specific).
int GNUNET_snprintf(char *buf, size_t size, const char *format,...)
Like snprintf, just aborts if the buffer is of insufficient size.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
#define TRANSPORT_SESSION_INBOUND_STRING
struct GNUNET_TRANSPORT_PluginFunctions * GST_plugins_printer_find(const char *name)
Obtain the plugin API based on a the stripped plugin name after the underscore.
const char * transport_name
Name of the transport plugin enabling the communication using this address.
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_plugins_monitor_subscribe()

void GST_plugins_monitor_subscribe ( GNUNET_TRANSPORT_SessionInfoCallback  cb,
void *  cb_cls 
)

Register callback with all plugins to monitor their status.

Parameters
cbcallback to register, NULL to unsubscribe
cb_clsclosure for cb

Definition at line 441 of file gnunet-service-transport_plugins.c.

References TransportPlugin::api, GNUNET_TRANSPORT_PluginFunctions::cls, GNUNET_break, TransportPlugin::next, and GNUNET_TRANSPORT_PluginFunctions::setup_monitor.

Referenced by handle_client_monitor_plugins(), and plugin_session_info_cb().

443 {
444  struct TransportPlugin *pos;
445 
446  for (pos = plugins_head; NULL != pos; pos = pos->next)
447  if (NULL == pos->api->setup_monitor)
448  GNUNET_break (0);
449  else
450  pos->api->setup_monitor (pos->api->cls,
451  cb,
452  cb_cls);
453 }
struct TransportPlugin * next
This is a doubly-linked list.
GNUNET_TRANSPORT_SessionMonitorSetup setup_monitor
Function to monitor the sessions managed by the plugin.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void * cls
Closure for all of the callbacks.
static struct TransportPlugin * plugins_head
Head of DLL of all loaded plugins.
Entry in doubly-linked list of all of our plugins.
struct GNUNET_TRANSPORT_PluginFunctions * api
API of the transport as returned by the plugin&#39;s initialization function.
Here is the caller graph for this function:

Variable Documentation

◆ plugins_head

struct TransportPlugin* plugins_head
static

Head of DLL of all loaded plugins.

Definition at line 73 of file gnunet-service-transport_plugins.c.

Referenced by GST_plugins_load().

◆ plugins_tail

struct TransportPlugin* plugins_tail
static

Head of DLL of all loaded plugins.

Definition at line 78 of file gnunet-service-transport_plugins.c.