GNUnet  0.10.x
Data Structures | Macros | Functions | Variables
gnunet-transport.c File Reference

Tool to help configure, measure and control the transport subsystem. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_resolver_service.h"
#include "gnunet_protocols.h"
#include "gnunet_transport_service.h"
Include dependency graph for gnunet-transport.c:

Go to the source code of this file.

Data Structures

struct  ValidationResolutionContext
 Context to store name resolutions for valiation. More...
 
struct  MonitoredPeer
 Struct to store information about peers in monitor mode. More...
 
struct  PeerResolutionContext
 Context to store name resolutions for valiation. More...
 
struct  PluginMonitorAddress
 Context for address resolution by plugin_monitoring_cb(). More...
 

Macros

#define RESOLUTION_TIMEOUT   GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30)
 Timeout for a name resolution. More...
 
#define OP_TIMEOUT   GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30)
 Timeout for an operation. More...
 
#define BLOCKSIZE   4
 Benchmarking block size in KB. More...
 

Functions

static int destroy_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 Function called to release data stored in the monitored_peers map. More...
 
static void shutdown_task (void *cls)
 Task run in monitor mode when the user presses CTRL-C to abort. More...
 
static void operation_timeout (void *cls)
 We are done, shut down. More...
 
static void do_send (void *cls)
 Function called to notify a client about the socket begin ready to queue more data. More...
 
static void * notify_connect (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...
 
static void notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
 Function called to notify transport users that another peer disconnected from us. More...
 
static void * monitor_notify_connect (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...
 
static void monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
 Function called to notify transport users that another peer disconnected from us. More...
 
static int check_dummy (void *cls, const struct GNUNET_MessageHeader *message)
 Function called by the transport for each received message. More...
 
static void handle_dummy (void *cls, const struct GNUNET_MessageHeader *message)
 Function called by the transport for each received message. More...
 
static void resolve_peer_address (const struct GNUNET_HELLO_Address *address, int numeric, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout)
 Convert address to a printable format. More...
 
static void print_info (const struct GNUNET_PeerIdentity *id, const char *transport, const char *addr, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout)
 
static void process_peer_string (void *cls, const char *address, int res)
 Function called with a textual representation of an address. More...
 
static void process_peer_iteration_cb (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 called with information about a peers during a one shot iteration. More...
 
static void print_plugin_event_info (struct PluginMonitorAddress *addr, const struct GNUNET_TRANSPORT_SessionInfo *info)
 Print information about a plugin monitoring event. More...
 
static void address_cb (void *cls, const char *address, int res)
 Function called with a textual representation of an address. More...
 
static void plugin_monitoring_cb (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...
 
static void process_peer_monitoring_cb (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 called with information about a peers. More...
 
static int blacklist_cb (void *cls, const struct GNUNET_PeerIdentity *cpid)
 Function called with the transport service checking if we want to blacklist a peer. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *mycfg)
 Main function that will be run by the scheduler. More...
 
int main (int argc, char *const *argv)
 

Variables

static struct GNUNET_TRANSPORT_CoreHandlehandle
 Handle to transport service. More...
 
static struct GNUNET_CONFIGURATION_Handlecfg
 Configuration handle. More...
 
struct GNUNET_TRANSPORT_Blacklistblacklist
 Blacklisting handle. More...
 
static int benchmark_send
 Option -s. More...
 
static int benchmark_receive
 Option -b. More...
 
static int iterate_connections
 Option -i. More...
 
static int iterate_all
 Option -a. More...
 
static int monitor_connects
 Option -c. More...
 
static int monitor_connections
 Option -m. More...
 
static int monitor_plugins
 Option -P. More...
 
static int do_disconnect
 Option -D. More...
 
static int numeric
 Option -n. More...
 
static int ret
 Global return value (0 success). More...
 
static int monitor_connect_counter
 Current number of connections in monitor mode. More...
 
static unsigned long long traffic_received
 Number of bytes of traffic we received so far. More...
 
static unsigned long long traffic_sent
 Number of bytes of traffic we sent so far. More...
 
static struct GNUNET_TIME_Absolute start_time
 Starting time of transmitting/receiving data. More...
 
static struct GNUNET_CONTAINER_MultiPeerMapmonitored_peers
 Map storing information about monitored peers. More...
 
static struct GNUNET_CONTAINER_MultiPeerMapmonitored_plugins
 Map storing information about monitored plugins's sessions. More...
 
static struct GNUNET_TRANSPORT_PeerMonitoringContextpic
 Handle if we are monitoring peers at the transport level. More...
 
static struct GNUNET_TRANSPORT_PluginMonitorpm
 Handle if we are monitoring plugin session activity. More...
 
static struct GNUNET_PeerIdentity pid
 Identity of the peer we transmit to / connect to. More...
 
static struct GNUNET_SCHEDULER_Taskop_timeout
 Task for operation timeout. More...
 
static unsigned int verbosity
 Selected level of verbosity. More...
 
struct GNUNET_OS_Processresolver
 Resolver process handle. More...
 
static unsigned int address_resolutions
 Number of address resolutions pending. More...
 
static struct ValidationResolutionContextvc_head
 DLL: head of validation resolution entries. More...
 
static struct ValidationResolutionContextvc_tail
 DLL: tail of validation resolution entries. More...
 
static struct PeerResolutionContextrc_head
 DLL: head of resolution entries. More...
 
static struct PeerResolutionContextrc_tail
 DLL: head of resolution entries. More...
 

Detailed Description

Tool to help configure, measure and control the transport subsystem.

Author
Christian Grothoff
Nathan Evans

Definition in file gnunet-transport.c.

Macro Definition Documentation

◆ RESOLUTION_TIMEOUT

#define RESOLUTION_TIMEOUT   GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30)

Timeout for a name resolution.

Definition at line 36 of file gnunet-transport.c.

Referenced by resolve_peer_address().

◆ OP_TIMEOUT

Timeout for an operation.

Definition at line 42 of file gnunet-transport.c.

Referenced by process_peer_iteration_cb(), process_peer_monitoring_cb(), and run().

◆ BLOCKSIZE

#define BLOCKSIZE   4

Benchmarking block size in KB.

Definition at line 164 of file gnunet-transport.c.

Referenced by do_send(), and notify_connect().

Function Documentation

◆ destroy_it()

static int destroy_it ( void *  cls,
const struct GNUNET_PeerIdentity key,
void *  value 
)
static

Function called to release data stored in the monitored_peers map.

Parameters
clsunused
keythe peer identity
valuea struct MonitoredPeer to release
Returns
GNUNET_OK (continue to iterate)

Definition at line 332 of file gnunet-transport.c.

References MonitoredPeer::address, GNUNET_assert, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_free, GNUNET_free_non_null, GNUNET_OK, m, and value.

Referenced by shutdown_task().

333 {
334  struct MonitoredPeer *m = value;
335 
337  GNUNET_OK ==
341  return GNUNET_OK;
342 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Struct to store information about peers in monitor mode.
static struct GNUNET_CONTAINER_MultiPeerMap * monitored_peers
Map storing information about monitored peers.
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
static char * value
Value of the record to add/remove.
struct GNUNET_HELLO_Address * address
The address to convert.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Task run in monitor mode when the user presses CTRL-C to abort.

Stops monitoring activity.

Parameters
clsNULL

Definition at line 352 of file gnunet-transport.c.

References _, ValidationResolutionContext::addrcp, PeerResolutionContext::addrcp, ValidationResolutionContext::asc, PeerResolutionContext::asc, benchmark_receive, benchmark_send, destroy_it(), GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_free, GNUNET_HELLO_address_free, GNUNET_SCHEDULER_cancel(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_duration(), GNUNET_TRANSPORT_address_to_string_cancel(), GNUNET_TRANSPORT_blacklist_cancel(), GNUNET_TRANSPORT_core_disconnect(), GNUNET_TRANSPORT_monitor_peers_cancel(), GNUNET_TRANSPORT_monitor_plugins_cancel(), GNUNET_YES, ValidationResolutionContext::next, GNUNET_TIME_Relative::rel_value_us, ret, start_time, traffic_received, traffic_sent, ValidationResolutionContext::transport, PeerResolutionContext::transport, and vc_head.

Referenced by run().

353 {
355  struct ValidationResolutionContext *cur;
357  struct PeerResolutionContext *rc;
358 
359  if (NULL != op_timeout)
360  {
362  op_timeout = NULL;
363  }
364  if (NULL != pic)
365  {
367  pic = NULL;
368  }
369  if (NULL != pm)
370  {
372  pm = NULL;
373  }
374 
375  next = vc_head;
376  for (cur = next; NULL != cur; cur = next)
377  {
378  next = cur->next;
379 
382  GNUNET_free(cur->transport);
384  GNUNET_free(cur);
385  }
386  while (NULL != (rc = rc_head))
387  {
390  GNUNET_free(rc->transport);
391  GNUNET_free(rc->addrcp);
392  GNUNET_free(rc);
393  }
394  if (NULL != handle)
395  {
397  handle = NULL;
398  }
399  if (benchmark_send)
400  {
402  fprintf(stdout,
403  _("Transmitted %llu bytes/s (%llu bytes in %s)\n"),
404  1000LL * 1000LL * traffic_sent / (1 + duration.rel_value_us),
405  traffic_sent,
407  }
408  if (benchmark_receive)
409  {
411  fprintf(stdout,
412  _("Received %llu bytes/s (%llu bytes in %s)\n"),
413  1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us),
416  }
417 
418  if (NULL != monitored_peers)
419  {
422  monitored_peers = NULL;
423  }
424  if (NULL != monitored_plugins)
425  {
428  monitored_plugins = NULL;
429  }
430  if (NULL != blacklist)
431  {
433  blacklist = NULL;
434  ret = 0;
435  }
436 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static int benchmark_send
Option -s.
uint64_t rel_value_us
The actual value.
static struct GNUNET_TRANSPORT_PeerMonitoringContext * pic
Handle if we are monitoring peers at the transport level.
static struct GNUNET_SCHEDULER_Task * op_timeout
Task for operation timeout.
static struct GNUNET_CONTAINER_MultiPeerMap * monitored_plugins
Map storing information about monitored plugins's sessions.
char * transport
plugin name
Context to store name resolutions for valiation.
static int ret
Global return value (0 success).
static struct GNUNET_CONTAINER_MultiPeerMap * monitored_peers
Map storing information about monitored peers.
static int benchmark_receive
Option -b.
void GNUNET_TRANSPORT_blacklist_cancel(struct GNUNET_TRANSPORT_Blacklist *br)
Abort the blacklist.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
static struct ValidationResolutionContext * vc_tail
DLL: tail of validation resolution entries.
void GNUNET_TRANSPORT_monitor_peers_cancel(struct GNUNET_TRANSPORT_PeerMonitoringContext *pic)
Cancel request to monitor peers.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct ValidationResolutionContext * next
Next in DLL.
struct GNUNET_TRANSPORT_AddressToStringContext * asc
Tranport conversion handle.
void GNUNET_TRANSPORT_address_to_string_cancel(struct GNUNET_TRANSPORT_AddressToStringContext *alc)
Cancel request for address conversion.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:686
static unsigned long long traffic_received
Number of bytes of traffic we received so far.
static struct GNUNET_TIME_Absolute start_time
Starting time of transmitting/receiving data.
char * transport
transport plugin
struct GNUNET_HELLO_Address * addrcp
Address to resolve.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
static struct PeerResolutionContext * rc_head
DLL: head of resolution entries.
static struct GNUNET_TRANSPORT_CoreHandle * handle
Handle to transport service.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
static struct PeerResolutionContext * rc_tail
DLL: head of resolution entries.
struct GNUNET_HELLO_Address * addrcp
address to resolve
void GNUNET_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport service.
struct PeerResolutionContext * next
Next in DLL.
struct GNUNET_TRANSPORT_Blacklist * blacklist
Blacklisting handle.
static struct GNUNET_TIME_Relative duration
How long do we run the test?
static struct ValidationResolutionContext * vc_head
DLL: head of validation resolution entries.
void GNUNET_TRANSPORT_monitor_plugins_cancel(struct GNUNET_TRANSPORT_PluginMonitor *pm)
Cancel monitoring the plugin session state.
#define GNUNET_YES
Definition: gnunet_common.h:77
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
struct GNUNET_TRANSPORT_AddressToStringContext * asc
transport conversiion context
static unsigned long long traffic_sent
Number of bytes of traffic we sent so far.
static int destroy_it(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Function called to release data stored in the monitored_peers map.
#define GNUNET_HELLO_address_free(addr)
Free an address.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
Context to store name resolutions for valiation.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operation_timeout()

static void operation_timeout ( void *  cls)
static

We are done, shut down.

Definition at line 443 of file gnunet-transport.c.

References _, PeerResolutionContext::addrcp, PeerResolutionContext::asc, benchmark_receive, benchmark_send, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_i2s(), GNUNET_i2s_full(), GNUNET_SCHEDULER_shutdown(), GNUNET_TRANSPORT_address_to_string_cancel(), iterate_connections, ValidationResolutionContext::next, PeerResolutionContext::next, GNUNET_HELLO_Address::peer, pid, rc_head, ret, and PeerResolutionContext::transport.

Referenced by process_peer_iteration_cb(), process_peer_monitoring_cb(), and run().

444 {
445  struct PeerResolutionContext *cur;
446  struct PeerResolutionContext *next;
447 
448  op_timeout = NULL;
450  {
451  fprintf(stdout, _("Failed to connect to `%s'\n"), GNUNET_i2s_full(&pid));
453  ret = 1;
454  return;
455  }
457  {
458  next = rc_head;
459  while (NULL != (cur = next))
460  {
461  next = cur->next;
462  fprintf(stdout,
463  _("Failed to resolve address for peer `%s'\n"),
464  GNUNET_i2s(&cur->addrcp->peer));
465 
468  GNUNET_free(cur->transport);
469  GNUNET_free(cur->addrcp);
470  GNUNET_free(cur);
471  }
472  fprintf(stdout,
473  "%s",
474  _("Failed to list connections, timeout occurred\n"));
476  ret = 1;
477  return;
478  }
479 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static int benchmark_send
Option -s.
static struct GNUNET_SCHEDULER_Task * op_timeout
Task for operation timeout.
Context to store name resolutions for valiation.
static int ret
Global return value (0 success).
static int benchmark_receive
Option -b.
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static int iterate_connections
Option -i.
void GNUNET_TRANSPORT_address_to_string_cancel(struct GNUNET_TRANSPORT_AddressToStringContext *alc)
Cancel request for address conversion.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
char * transport
transport plugin
static struct PeerResolutionContext * rc_head
DLL: head of resolution entries.
static struct PeerResolutionContext * rc_tail
DLL: head of resolution entries.
struct GNUNET_HELLO_Address * addrcp
address to resolve
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
struct PeerResolutionContext * next
Next in DLL.
struct GNUNET_TRANSPORT_AddressToStringContext * asc
transport conversiion context
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_send()

static void do_send ( void *  cls)
static

Function called to notify a client about the socket begin ready to queue more data.

Sends another message.

Parameters
clsclosure with the message queue

Definition at line 489 of file gnunet-transport.c.

References _, BLOCKSIZE, env, GNUNET_MESSAGE_TYPE_DUMMY, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), m, mq, traffic_sent, and verbosity.

Referenced by notify_connect().

490 {
491  struct GNUNET_MQ_Handle *mq = cls;
492  struct GNUNET_MessageHeader *m;
493  struct GNUNET_MQ_Envelope *env;
494 
496  memset(&m[1], 52, BLOCKSIZE * 1024 - sizeof(struct GNUNET_MessageHeader));
497  traffic_sent += BLOCKSIZE * 1024;
498  GNUNET_MQ_notify_sent(env, &do_send, mq);
499  if (verbosity > 0)
500  fprintf(stdout,
501  _("Transmitting %u bytes\n"),
502  (unsigned int)BLOCKSIZE * 1024);
503  GNUNET_MQ_send(mq, env);
504 }
#define GNUNET_MESSAGE_TYPE_DUMMY
Dummy messages for testing / benchmarking.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
#define BLOCKSIZE
Benchmarking block size in KB.
#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
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore...
Definition: mq.c:772
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Handle to a message queue.
Definition: mq.c:84
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
static unsigned int verbosity
Selected level of verbosity.
Header for all communications.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:351
static void do_send(void *cls)
Function called to notify a client about the socket begin ready to queue more data.
static unsigned long long traffic_sent
Number of bytes of traffic we sent so far.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ notify_connect()

static void* notify_connect ( void *  cls,
const struct GNUNET_PeerIdentity peer,
struct GNUNET_MQ_Handle mq 
)
static

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

Parameters
clsclosure
peerthe peer that connected
mqmessage queue for sending to peer

Definition at line 516 of file gnunet-transport.c.

References _, benchmark_send, BLOCKSIZE, do_send(), GNUNET_i2s(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_absolute_get(), mq, pid, ret, start_time, and verbosity.

Referenced by run().

519 {
520  if (0 != memcmp(&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
521  return NULL;
522  ret = 0;
523  if (!benchmark_send)
524  return NULL;
525  if (NULL != op_timeout)
526  {
528  op_timeout = NULL;
529  }
530  if (verbosity > 0)
531  fprintf(
532  stdout,
533  _(
534  "Successfully connected to `%s', starting to send benchmark data in %u Kb blocks\n"),
535  GNUNET_i2s(peer),
536  BLOCKSIZE);
538  do_send(mq);
539  return mq;
540 }
static int benchmark_send
Option -s.
static struct GNUNET_SCHEDULER_Task * op_timeout
Task for operation timeout.
static int ret
Global return value (0 success).
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
#define BLOCKSIZE
Benchmarking block size in KB.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
static struct GNUNET_TIME_Absolute start_time
Starting time of transmitting/receiving data.
The identity of the host (wraps the signing key of the peer).
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
static unsigned int verbosity
Selected level of verbosity.
static void do_send(void *cls)
Function called to notify a client about the socket begin ready to queue more data.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:
Here is the caller graph for this function:

◆ notify_disconnect()

static void notify_disconnect ( void *  cls,
const struct GNUNET_PeerIdentity peer,
void *  internal_cls 
)
static

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

Parameters
clsclosure
peerthe peer that disconnected
internal_clswhat we returned from notify_connect()

Definition at line 552 of file gnunet-transport.c.

References _, benchmark_send, GNUNET_i2s(), and pid.

Referenced by run().

555 {
556  if (0 != memcmp(&pid, peer, sizeof(struct GNUNET_PeerIdentity)))
557  return;
558  if (NULL == internal_cls)
559  return; /* not about target peer */
560  if (!benchmark_send)
561  return; /* not transmitting */
562  fprintf(stdout,
563  _("Disconnected from peer `%s' while benchmarking\n"),
564  GNUNET_i2s(&pid));
565 }
static int benchmark_send
Option -s.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
The identity of the host (wraps the signing key of the peer).
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ monitor_notify_connect()

static void* monitor_notify_connect ( void *  cls,
const struct GNUNET_PeerIdentity peer,
struct GNUNET_MQ_Handle mq 
)
static

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

Parameters
clsclosure
peerthe peer that connected
mqfor sending messages to peer
Returns
NULL

Definition at line 578 of file gnunet-transport.c.

References _, GNUNET_i2s(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute_get(), and monitor_connect_counter.

Referenced by run().

581 {
583  const char *now_str = GNUNET_STRINGS_absolute_time_to_string(now);
584 
586  fprintf(stdout,
587  _("%24s: %-17s %4s (%u connections in total)\n"),
588  now_str,
589  _("Connected to"),
590  GNUNET_i2s(peer),
592  return NULL;
593 }
static int monitor_connect_counter
Current number of connections in monitor mode.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
Time for absolute times used by GNUnet, in microseconds.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:741
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ monitor_notify_disconnect()

static void monitor_notify_disconnect ( void *  cls,
const struct GNUNET_PeerIdentity peer,
void *  internal_cls 
)
static

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

Parameters
clsclosure
peerthe peer that disconnected
internal_clswhat we returned from monitor_notify_connect()

Definition at line 605 of file gnunet-transport.c.

References _, GNUNET_assert, GNUNET_i2s(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute_get(), and monitor_connect_counter.

Referenced by run().

608 {
610  const char *now_str = GNUNET_STRINGS_absolute_time_to_string(now);
611 
614 
615  fprintf(stdout,
616  _("%24s: %-17s %4s (%u connections in total)\n"),
617  now_str,
618  _("Disconnected from"),
619  GNUNET_i2s(peer),
621 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static int monitor_connect_counter
Current number of connections in monitor mode.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
Time for absolute times used by GNUnet, in microseconds.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:741
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_dummy()

static int check_dummy ( void *  cls,
const struct GNUNET_MessageHeader message 
)
static

Function called by the transport for each received message.

Parameters
clsclosure
messagethe message
Returns
GNUNET_OK

Definition at line 632 of file gnunet-transport.c.

References GNUNET_OK.

633 {
634  return GNUNET_OK; /* all messages are fine */
635 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75

◆ handle_dummy()

static void handle_dummy ( void *  cls,
const struct GNUNET_MessageHeader message 
)
static

Function called by the transport for each received message.

Parameters
clsclosure
messagethe message

Definition at line 645 of file gnunet-transport.c.

References _, address, benchmark_receive, GNUNET_TIME_absolute_get(), numeric, resolve_peer_address(), GNUNET_MessageHeader::size, start_time, state, traffic_received, and verbosity.

646 {
647  if (!benchmark_receive)
648  return;
649  if (verbosity > 0)
650  fprintf(stdout,
651  _("Received %u bytes\n"),
652  (unsigned int)ntohs(message->size));
653  if (0 == traffic_received)
655  traffic_received += ntohs(message->size);
656 }
static int benchmark_receive
Option -b.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
static unsigned long long traffic_received
Number of bytes of traffic we received so far.
static struct GNUNET_TIME_Absolute start_time
Starting time of transmitting/receiving data.
static unsigned int verbosity
Selected level of verbosity.
Here is the call graph for this function:

◆ resolve_peer_address()

static void resolve_peer_address ( const struct GNUNET_HELLO_Address address,
int  numeric,
enum GNUNET_TRANSPORT_PeerState  state,
struct GNUNET_TIME_Absolute  state_timeout 
)
static

Convert address to a printable format.

Convert address to a printable format and print it together with the given state data.

Parameters
addressthe address
numericGNUNET_YES to convert to numeric format, GNUNET_NO to try to use reverse DNS
statestate the peer is in
state_timeoutwhen will the peer's state expire

Definition at line 813 of file gnunet-transport.c.

References PeerResolutionContext::addrcp, address_resolutions, PeerResolutionContext::asc, GNUNET_CONTAINER_DLL_insert, GNUNET_HELLO_address_copy(), GNUNET_new, GNUNET_NO, GNUNET_strdup, GNUNET_TRANSPORT_address_to_string(), PeerResolutionContext::printed, process_peer_string(), RESOLUTION_TIMEOUT, PeerResolutionContext::state, state, PeerResolutionContext::state_timeout, PeerResolutionContext::transport, and GNUNET_HELLO_Address::transport_name.

Referenced by handle_dummy(), process_peer_iteration_cb(), process_peer_monitoring_cb(), and process_peer_string().

817 {
818  struct PeerResolutionContext *rc;
819 
820  rc = GNUNET_new(struct PeerResolutionContext);
823  rc->transport = GNUNET_strdup(address->transport_name);
824  rc->addrcp = GNUNET_HELLO_address_copy(address);
825  rc->printed = GNUNET_NO;
826  rc->state = state;
828  /* Resolve address to string */
830  address,
831  numeric,
834  rc);
835 }
static unsigned int address_resolutions
Number of address resolutions pending.
int printed
was the entry printed
struct GNUNET_TIME_Absolute state_timeout
state timeout
enum GNUNET_TRANSPORT_PeerState state
peer state
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
Context to store name resolutions for valiation.
#define GNUNET_NO
Definition: gnunet_common.h:78
static int numeric
Option -n.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle.
enum State state
current state of profiling
const char * transport_name
Name of the transport plugin enabling the communication using this address.
#define RESOLUTION_TIMEOUT
Timeout for a name resolution.
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.
char * transport
transport plugin
static void process_peer_string(void *cls, const char *address, int res)
Function called with a textual representation of an address.
static struct PeerResolutionContext * rc_head
DLL: head of resolution entries.
static struct PeerResolutionContext * rc_tail
DLL: head of resolution entries.
struct GNUNET_HELLO_Address * addrcp
address to resolve
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Definition: address.c:109
struct GNUNET_TRANSPORT_AddressToStringContext * asc
transport conversiion context
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_info()

static void print_info ( const struct GNUNET_PeerIdentity id,
const char *  transport,
const char *  addr,
enum GNUNET_TRANSPORT_PeerState  state,
struct GNUNET_TIME_Absolute  state_timeout 
)
static

Definition at line 676 of file gnunet-transport.c.

References _, GNUNET_i2s(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TRANSPORT_is_connected(), GNUNET_TRANSPORT_ps2s(), GNUNET_YES, iterate_all, iterate_connections, and monitor_connections.

Referenced by process_peer_iteration_cb(), process_peer_monitoring_cb(), and process_peer_string().

681 {
684  {
685  fprintf(stdout,
686  _("Peer `%s': %s %s in state `%s' until %s\n"),
687  GNUNET_i2s(id),
688  (NULL == transport) ? "<none>" : transport,
689  (NULL == transport) ? "<none>" : addr,
692  }
693  else if ((GNUNET_YES == iterate_connections) &&
695  {
696  /* Only connected peers, skip state */
697  fprintf(stdout,
698  _("Peer `%s': %s %s\n"),
699  GNUNET_i2s(id),
700  transport,
701  addr);
702  }
703 }
static int iterate_all
Option -a.
static struct GNUNET_TRANSPORT_CoreHandle * transport
Transport service.
static int monitor_connections
Option -m.
int GNUNET_TRANSPORT_is_connected(enum GNUNET_TRANSPORT_PeerState state)
Check if a state is defined as connected.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static int iterate_connections
Option -i.
enum State state
current state of profiling
const char * GNUNET_TRANSPORT_ps2s(enum GNUNET_TRANSPORT_PeerState state)
Convert a transport state to a human readable string.
#define GNUNET_YES
Definition: gnunet_common.h:77
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:741
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_peer_string()

static void process_peer_string ( void *  cls,
const char *  address,
int  res 
)
static

Function called 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 723 of file gnunet-transport.c.

References PeerResolutionContext::addrcp, GNUNET_HELLO_Address::address_length, address_resolutions, PeerResolutionContext::asc, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_i2s(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_shutdown(), GNUNET_SYSERR, GNUNET_YES, iterate_connections, numeric, GNUNET_HELLO_Address::peer, print_info(), PeerResolutionContext::printed, resolve_peer_address(), ret, PeerResolutionContext::state, PeerResolutionContext::state_timeout, PeerResolutionContext::transport, and GNUNET_HELLO_Address::transport_name.

Referenced by resolve_peer_address().

724 {
725  struct PeerResolutionContext *rc = cls;
726 
727  if (NULL != address)
728  {
729  if (GNUNET_SYSERR == res)
730  {
731  fprintf(
732  stderr,
733  "Failed to convert address for peer `%s' plugin `%s' length %u to string \n",
734  GNUNET_i2s(&rc->addrcp->peer),
735  rc->addrcp->transport_name,
736  (unsigned int)rc->addrcp->address_length);
737  print_info(&rc->addrcp->peer,
738  rc->transport,
739  NULL,
740  rc->state,
741  rc->state_timeout);
742  rc->printed = GNUNET_YES;
743  return;
744  }
745  if (GNUNET_OK == res)
746  {
747  print_info(&rc->addrcp->peer,
748  rc->transport,
749  address,
750  rc->state,
751  rc->state_timeout);
752  rc->printed = GNUNET_YES;
753  return; /* Wait for done call */
754  }
755  /* GNUNET_NO == res: ignore, was simply not supported */
756  return;
757  }
758  /* NULL == address, last call, we are done */
759 
760  rc->asc = NULL;
763  if (GNUNET_NO == rc->printed)
764  {
765  if (numeric == GNUNET_NO)
766  {
767  /* Failed to resolve address, try numeric lookup
768  (note: this should not be needed, as transport
769  should fallback to numeric conversion if DNS takes
770  too long) */
772  GNUNET_YES,
773  rc->state,
774  rc->state_timeout);
775  }
776  else
777  {
778  print_info(&rc->addrcp->peer,
779  rc->transport,
780  NULL,
781  rc->state,
782  rc->state_timeout);
783  }
784  }
785  GNUNET_free(rc->transport);
786  GNUNET_free(rc->addrcp);
788  GNUNET_free(rc);
790  {
791  if (NULL != op_timeout)
792  {
794  op_timeout = NULL;
795  }
796  ret = 0;
798  }
799 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
size_t address_length
Number of bytes in address.
static unsigned int address_resolutions
Number of address resolutions pending.
int printed
was the entry printed
struct GNUNET_TIME_Absolute state_timeout
state timeout
enum GNUNET_TRANSPORT_PeerState state
peer state
static struct GNUNET_SCHEDULER_Task * op_timeout
Task for operation timeout.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Context to store name resolutions for valiation.
static int ret
Global return value (0 success).
#define GNUNET_NO
Definition: gnunet_common.h:78
static int numeric
Option -n.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static void resolve_peer_address(const struct GNUNET_HELLO_Address *address, int numeric, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout)
Convert address to a printable format.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
static int iterate_connections
Option -i.
static void print_info(const struct GNUNET_PeerIdentity *id, const char *transport, const char *addr, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout)
const char * transport_name
Name of the transport plugin enabling the communication using this address.
static int res
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_PeerIdentity peer
For which peer is this an address?
char * transport
transport plugin
static struct PeerResolutionContext * rc_head
DLL: head of resolution entries.
static struct PeerResolutionContext * rc_tail
DLL: head of resolution entries.
struct GNUNET_HELLO_Address * addrcp
address to resolve
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_TRANSPORT_AddressToStringContext * asc
transport conversiion context
static char * address
GNS address for this phone.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_peer_iteration_cb()

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

Function called with information about a peers during a one shot iteration.

Parameters
clsclosure
peeridentity of the peer, NULL for final callback when operation done
addressbinary address used to communicate with this peer, NULL on disconnect or when done
statecurrent state this peer is in
state_timeouttime out for the current state

Definition at line 849 of file gnunet-transport.c.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_TRANSPORT_is_connected(), iterate_all, numeric, OP_TIMEOUT, operation_timeout(), print_info(), resolve_peer_address(), and GNUNET_HELLO_Address::transport_name.

Referenced by run().

854 {
855  if (NULL == peer)
856  {
857  /* done */
858  pic = NULL;
859  return;
860  }
861 
862  if ((GNUNET_NO == iterate_all) &&
864  return; /* Display only connected peers */
865 
866  if (NULL != op_timeout)
868  op_timeout =
870 
872  "Received address for peer `%s': %s\n",
873  GNUNET_i2s(peer),
874  address ? address->transport_name : "");
875 
876  if (NULL != address)
877  resolve_peer_address(address, numeric, state, state_timeout);
878  else
879  print_info(peer, NULL, NULL, state, state_timeout);
880 }
static int iterate_all
Option -a.
static struct GNUNET_SCHEDULER_Task * op_timeout
Task for operation timeout.
static struct GNUNET_TRANSPORT_PeerMonitoringContext * pic
Handle if we are monitoring peers at the transport level.
#define GNUNET_NO
Definition: gnunet_common.h:78
static int numeric
Option -n.
static void resolve_peer_address(const struct GNUNET_HELLO_Address *address, int numeric, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout)
Convert address to a printable format.
int GNUNET_TRANSPORT_is_connected(enum GNUNET_TRANSPORT_PeerState state)
Check if a state is defined as connected.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1237
enum State state
current state of profiling
static void print_info(const struct GNUNET_PeerIdentity *id, const char *transport, const char *addr, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout)
const char * transport_name
Name of the transport plugin enabling the communication using this address.
static void operation_timeout(void *cls)
We are done, shut down.
#define OP_TIMEOUT
Timeout for an operation.
#define GNUNET_log(kind,...)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_plugin_event_info()

static void print_plugin_event_info ( struct PluginMonitorAddress addr,
const struct GNUNET_TRANSPORT_SessionInfo info 
)
static

Print information about a plugin monitoring event.

Parameters
addrout internal context
infothe monitoring information

Definition at line 912 of file gnunet-transport.c.

References GNUNET_TRANSPORT_SessionInfo::address, GNUNET_i2s(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TRANSPORT_SS_DONE, GNUNET_TRANSPORT_SS_HANDSHAKE, GNUNET_TRANSPORT_SS_INIT, GNUNET_TRANSPORT_SS_UP, GNUNET_TRANSPORT_SS_UPDATE, GNUNET_YES, GNUNET_TRANSPORT_SessionInfo::is_inbound, GNUNET_TRANSPORT_SessionInfo::num_bytes_pending, GNUNET_TRANSPORT_SessionInfo::num_msg_pending, GNUNET_HELLO_Address::peer, GNUNET_TRANSPORT_SessionInfo::receive_delay, GNUNET_TIME_Relative::rel_value_us, GNUNET_TRANSPORT_SessionInfo::session_timeout, state, GNUNET_TRANSPORT_SessionInfo::state, and PluginMonitorAddress::str.

Referenced by address_cb(), and plugin_monitoring_cb().

914 {
915  const char *state;
916 
917  switch (info->state)
918  {
920  state = "INIT";
921  break;
922 
924  state = "HANDSHAKE";
925  break;
926 
928  state = "UP";
929  break;
930 
932  state = "UPDATE";
933  break;
934 
936  state = "DONE";
937  break;
938 
939  default:
940  state = "UNKNOWN";
941  break;
942  }
943  fprintf(stdout,
944  "%s: state %s timeout in %s @ %s%s\n",
945  GNUNET_i2s(&info->address->peer),
946  state,
949  GNUNET_YES),
950  addr->str,
951  (info->is_inbound == GNUNET_YES) ? " (INBOUND)" : "");
952  fprintf(stdout,
953  "%s: queue has %3u messages and %6u bytes\n",
954  GNUNET_i2s(&info->address->peer),
955  info->num_msg_pending,
956  info->num_bytes_pending);
957  if (0 !=
959  fprintf(stdout,
960  "%s: receiving blocked until %s\n",
961  GNUNET_i2s(&info->address->peer),
963 }
Session is being torn down and about to disappear.
uint32_t num_bytes_pending
Number of bytes pending transmission for this session.
uint64_t rel_value_us
The actual value.
int is_inbound
GNUNET_YES if this is an inbound connection, GNUNET_NO if this is an outbound connection, GNUNET_SYSERR if connections of this plugin are so fundamentally bidirectional that they have no &#39;initiator&#39;
enum GNUNET_TRANSPORT_SessionState state
New state of the session.
Initial session handshake is in progress.
const struct GNUNET_HELLO_Address * address
Address used by the session.
uint32_t num_msg_pending
Number of messages pending transmission for this session.
struct GNUNET_TIME_Absolute receive_delay
Until when does this plugin refuse to receive to manage staying within the inbound quota...
char * str
Resolved address as string.
enum State state
current state of profiling
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:686
struct GNUNET_TIME_Absolute session_timeout
At what time will this session timeout (unless activity happens)?
struct GNUNET_PeerIdentity peer
For which peer is this an address?
This is just an update about the session, the state did not change.
The session was created (first call for each session object).
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:331
#define GNUNET_YES
Definition: gnunet_common.h:77
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:741
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ address_cb()

static void address_cb ( void *  cls,
const char *  address,
int  res 
)
static

Function called 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 983 of file gnunet-transport.c.

References PluginMonitorAddress::asc, GNUNET_strdup, print_plugin_event_info(), PluginMonitorAddress::si, and PluginMonitorAddress::str.

Referenced by plugin_monitoring_cb().

984 {
985  struct PluginMonitorAddress *addr = cls;
986 
987  if (NULL == address)
988  {
989  addr->asc = NULL;
990  return;
991  }
992  if (NULL != addr->str)
993  return;
994  addr->str = GNUNET_strdup(address);
995  print_plugin_event_info(addr, &addr->si);
996 }
static void print_plugin_event_info(struct PluginMonitorAddress *addr, const struct GNUNET_TRANSPORT_SessionInfo *info)
Print information about a plugin monitoring event.
struct GNUNET_TRANSPORT_AddressToStringContext * asc
Ongoing resolution request.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
char * str
Resolved address as string.
struct GNUNET_TRANSPORT_SessionInfo si
Last event we got and did not yet print because str was NULL (address not yet resolved).
Context for address resolution by plugin_monitoring_cb().
static char * address
GNS address for this phone.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ plugin_monitoring_cb()

static void plugin_monitoring_cb ( void *  cls,
struct GNUNET_TRANSPORT_PluginSession session,
void **  session_ctx,
const struct GNUNET_TRANSPORT_SessionInfo info 
)
static

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

Parameters
clsclosure (NULL)
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 1017 of file gnunet-transport.c.

References GNUNET_TRANSPORT_SessionInfo::address, address_cb(), PluginMonitorAddress::asc, GNUNET_free, GNUNET_free_non_null, GNUNET_new, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TRANSPORT_address_to_string(), GNUNET_TRANSPORT_address_to_string_cancel(), GNUNET_TRANSPORT_SS_DONE, numeric, GNUNET_HELLO_Address::peer, pid, print_plugin_event_info(), PluginMonitorAddress::si, GNUNET_TRANSPORT_SessionInfo::state, and PluginMonitorAddress::str.

Referenced by run().

1021 {
1022  struct PluginMonitorAddress *addr;
1023 
1024  if ((NULL == info) && (NULL == session))
1025  return; /* in sync with transport service */
1026  addr = *session_ctx;
1027  if (NULL == info)
1028  {
1029  if (NULL != addr)
1030  {
1031  if (NULL != addr->asc)
1032  {
1034  addr->asc = NULL;
1035  }
1036  GNUNET_free_non_null(addr->str);
1037  GNUNET_free(addr);
1038  *session_ctx = NULL;
1039  }
1040  return; /* shutdown */
1041  }
1042  if (0 !=
1043  memcmp(&info->address->peer, &pid, sizeof(struct GNUNET_PeerIdentity)))
1044  return; /* filtered */
1045  if (NULL == addr)
1046  {
1047  addr = GNUNET_new(struct PluginMonitorAddress);
1048  addr->asc =
1050  info->address,
1051  numeric,
1053  &address_cb,
1054  addr);
1055  *session_ctx = addr;
1056  }
1057  if (NULL == addr->str)
1058  addr->si = *info;
1059  else
1060  print_plugin_event_info(addr, info);
1061  if (GNUNET_TRANSPORT_SS_DONE == info->state)
1062  {
1063  if (NULL != addr->asc)
1064  {
1066  addr->asc = NULL;
1067  }
1068  GNUNET_free_non_null(addr->str);
1069  GNUNET_free(addr);
1070  *session_ctx = NULL;
1071  }
1072 }
Session is being torn down and about to disappear.
static void print_plugin_event_info(struct PluginMonitorAddress *addr, const struct GNUNET_TRANSPORT_SessionInfo *info)
Print information about a plugin monitoring event.
static void address_cb(void *cls, const char *address, int res)
Function called with a textual representation of an address.
enum GNUNET_TRANSPORT_SessionState state
New state of the session.
struct GNUNET_TRANSPORT_AddressToStringContext * asc
Ongoing resolution request.
static int numeric
Option -n.
#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.
const struct GNUNET_HELLO_Address * address
Address used by the session.
static struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle.
char * str
Resolved address as string.
void GNUNET_TRANSPORT_address_to_string_cancel(struct GNUNET_TRANSPORT_AddressToStringContext *alc)
Cancel request for address conversion.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
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.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
struct GNUNET_TRANSPORT_SessionInfo si
Last event we got and did not yet print because str was NULL (address not yet resolved).
The identity of the host (wraps the signing key of the peer).
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
Context for address resolution by plugin_monitoring_cb().
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_peer_monitoring_cb()

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

Function called with information about a peers.

Parameters
clsclosure, NULL
peeridentity of the peer, NULL for final callback when operation done
addressbinary address used to communicate with this peer, NULL on disconnect or when done
statecurrent state this peer is in
state_timeouttime out for the current state

Definition at line 1086 of file gnunet-transport.c.

References _, GNUNET_TIME_Absolute::abs_value_us, MonitoredPeer::address, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CONTAINER_multipeermap_get(), GNUNET_CONTAINER_multipeermap_put(), GNUNET_free, GNUNET_HELLO_address_cmp(), GNUNET_HELLO_address_copy(), GNUNET_new, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), m, numeric, OP_TIMEOUT, operation_timeout(), print_info(), resolve_peer_address(), MonitoredPeer::state, state, and MonitoredPeer::state_timeout.

Referenced by run().

1091 {
1092  struct MonitoredPeer *m;
1093 
1094  if (NULL == peer)
1095  {
1096  fprintf(stdout,
1097  "%s",
1098  _(
1099  "Monitor disconnected from transport service. Reconnecting.\n"));
1100  return;
1101  }
1102 
1103  if (NULL != op_timeout)
1105  op_timeout =
1107 
1108  if (NULL == (m = GNUNET_CONTAINER_multipeermap_get(monitored_peers, peer)))
1109  {
1110  m = GNUNET_new(struct MonitoredPeer);
1113  peer,
1114  m,
1116  }
1117  else
1118  {
1119  if ((m->state == state) &&
1120  (m->state_timeout.abs_value_us == state_timeout.abs_value_us) &&
1121  (NULL == address) && (NULL == m->address))
1122  {
1123  return; /* No real change */
1124  }
1125  if ((m->state == state) && (NULL != address) && (NULL != m->address) &&
1126  (0 == GNUNET_HELLO_address_cmp(m->address, address)))
1127  return; /* No real change */
1128  }
1129 
1130  if (NULL != m->address)
1131  {
1132  GNUNET_free(m->address);
1133  m->address = NULL;
1134  }
1135  if (NULL != address)
1136  m->address = GNUNET_HELLO_address_copy(address);
1137  m->state = state;
1139 
1140  if (NULL != address)
1142  else
1143  print_info(peer, NULL, NULL, m->state, m->state_timeout);
1144 }
static struct GNUNET_SCHEDULER_Task * op_timeout
Task for operation timeout.
Struct to store information about peers in monitor mode.
static struct GNUNET_CONTAINER_MultiPeerMap * monitored_peers
Map storing information about monitored peers.
enum GNUNET_TRANSPORT_PeerState state
State of the peer.
static int numeric
Option -n.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void resolve_peer_address(const struct GNUNET_HELLO_Address *address, int numeric, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout)
Convert address to a printable format.
uint64_t abs_value_us
The actual value.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
Definition: address.c:130
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1237
enum State state
current state of profiling
, &#39; bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_...
static void print_info(const struct GNUNET_PeerIdentity *id, const char *transport, const char *addr, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout)
struct GNUNET_TIME_Absolute state_timeout
Timeout.
static void operation_timeout(void *cls)
We are done, shut down.
#define OP_TIMEOUT
Timeout for an operation.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Definition: address.c:109
struct GNUNET_HELLO_Address * address
The address to convert.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:
Here is the caller graph for this function:

◆ blacklist_cb()

static int blacklist_cb ( void *  cls,
const struct GNUNET_PeerIdentity cpid 
)
static

Function called with the transport service checking if we want to blacklist a peer.

Return GNUNET_SYSERR for the peer that we should disconnect from.

Parameters
clsNULL
cpidpeer to check blacklisting for
Returns
GNUNET_OK if the connection is allowed, GNUNET_SYSERR if not

Definition at line 1157 of file gnunet-transport.c.

References GNUNET_OK, GNUNET_SYSERR, and pid.

Referenced by run().

1158 {
1159  if (0 == memcmp(cpid, &pid, sizeof(struct GNUNET_PeerIdentity)))
1160  return GNUNET_SYSERR;
1161  return GNUNET_OK;
1162 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
The identity of the host (wraps the signing key of the peer).
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle mycfg 
)
static

Main function that will be run by the scheduler.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
mycfgconfiguration

Definition at line 1174 of file gnunet-transport.c.

References _, benchmark_receive, benchmark_send, blacklist_cb(), do_disconnect, dummy, GNUNET_break, GNUNET_CONTAINER_multipeermap_create(), GNUNET_MESSAGE_TYPE_DUMMY, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_TIME_absolute_get(), GNUNET_TRANSPORT_blacklist(), GNUNET_TRANSPORT_core_connect(), GNUNET_TRANSPORT_monitor_peers(), GNUNET_TRANSPORT_monitor_plugins(), GNUNET_YES, iterate_connections, monitor_connect_counter, monitor_connections, monitor_connects, monitor_notify_connect(), monitor_notify_disconnect(), monitor_plugins, notify_connect(), notify_disconnect(), OP_TIMEOUT, operation_timeout(), pid, plugin_monitoring_cb(), process_peer_iteration_cb(), process_peer_monitoring_cb(), ret, shutdown_task(), start_time, and verbosity.

Referenced by main().

1178 {
1179  static struct GNUNET_PeerIdentity zero_pid;
1180  int counter = 0;
1181 
1182  ret = 1;
1183 
1184  cfg = (struct GNUNET_CONFIGURATION_Handle *)mycfg;
1185 
1189 
1190  if (1 < counter)
1191  {
1192  fprintf(
1193  stderr,
1194  _(
1195  "Multiple operations given. Please choose only one operation: %s, %s, %s, %s, %s, %s %s\n"),
1196  "disconnect",
1197  "benchmark send",
1198  "benchmark receive",
1199  "information",
1200  "monitor",
1201  "events",
1202  "plugins");
1203  return;
1204  }
1205  if (0 == counter)
1206  {
1207  fprintf(
1208  stderr,
1209  _(
1210  "No operation given. Please choose one operation: %s, %s, %s, %s, %s, %s, %s\n"),
1211  "disconnect",
1212  "benchmark send",
1213  "benchmark receive",
1214  "information",
1215  "monitor",
1216  "events",
1217  "plugins");
1218  return;
1219  }
1220 
1221  if (do_disconnect) /* -D: Disconnect from peer */
1222  {
1223  if (0 == memcmp(&zero_pid, &pid, sizeof(pid)))
1224  {
1225  fprintf(stderr,
1226  _("Option `%s' makes no sense without option `%s'.\n"),
1227  "-D",
1228  "-p");
1229  ret = 1;
1230  return;
1231  }
1233  if (NULL == blacklist)
1234  {
1235  fprintf(stderr,
1236  "%s",
1237  _(
1238  "Failed to connect to transport service for disconnection\n"));
1239  ret = 1;
1240  return;
1241  }
1242  fprintf(stdout,
1243  "%s",
1244  _("Blacklisting request in place, stop with CTRL-C\n"));
1245  }
1246  else if (benchmark_send) /* -s: Benchmark sending */
1247  {
1248  if (0 == memcmp(&zero_pid, &pid, sizeof(pid)))
1249  {
1250  fprintf(stderr,
1251  _("Option `%s' makes no sense without option `%s'.\n"),
1252  "-s",
1253  "-p");
1254  ret = 1;
1255  return;
1256  }
1258  NULL,
1259  NULL,
1260  NULL,
1261  &notify_connect,
1263  NULL);
1264  if (NULL == handle)
1265  {
1266  fprintf(stderr, "%s", _("Failed to connect to transport service\n"));
1267  ret = 1;
1268  return;
1269  }
1271  op_timeout =
1273  }
1274  else if (benchmark_receive) /* -b: Benchmark receiving */
1275  {
1279  struct GNUNET_MessageHeader,
1280  NULL),
1282 
1284  NULL,
1285  handlers,
1286  NULL,
1287  NULL,
1288  NULL,
1289  NULL);
1290  if (NULL == handle)
1291  {
1292  fprintf(stderr, "%s", _("Failed to connect to transport service\n"));
1293  ret = 1;
1294  return;
1295  }
1296  if (verbosity > 0)
1297  fprintf(stdout, "%s", _("Starting to receive benchmark data\n"));
1299  }
1300  else if (iterate_connections) /* -i: List information about peers once */
1301  {
1303  &pid,
1304  GNUNET_YES,
1306  (void *)cfg);
1307  op_timeout =
1309  }
1310  else if (monitor_connections) /* -m: List information about peers continuously
1311  */
1312  {
1315  &pid,
1316  GNUNET_NO,
1318  NULL);
1319  }
1320  else if (monitor_plugins) /* -P: List information about plugins continuously
1321  */
1322  {
1325  }
1326  else if (monitor_connects) /* -e : Monitor (dis)connect events continuously */
1327  {
1330  NULL,
1331  NULL,
1332  NULL,
1335  NULL);
1336  if (NULL == handle)
1337  {
1338  fprintf(stderr, "%s", _("Failed to connect to transport service\n"));
1339  ret = 1;
1340  return;
1341  }
1342  ret = 0;
1343  }
1344  else
1345  {
1346  GNUNET_break(0);
1347  return;
1348  }
1349 
1351 }
static int benchmark_send
Option -s.
static struct GNUNET_TRANSPORT_PeerMonitoringContext * pic
Handle if we are monitoring peers at the transport level.
static struct GNUNET_SCHEDULER_Task * op_timeout
Task for operation timeout.
static void * notify_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Function called to notify transport users that another peer connected to us.
static struct GNUNET_CONTAINER_MultiPeerMap * monitored_plugins
Map storing information about monitored plugins&#39;s sessions.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1284
static int monitor_connect_counter
Current number of connections in monitor mode.
static int ret
Global return value (0 success).
#define GNUNET_MESSAGE_TYPE_DUMMY
Dummy messages for testing / benchmarking.
static struct GNUNET_CONTAINER_MultiPeerMap * monitored_peers
Map storing information about monitored peers.
static void process_peer_monitoring_cb(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 called with information about a peers.
static int benchmark_receive
Option -b.
#define GNUNET_NO
Definition: gnunet_common.h:78
static void * monitor_notify_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Function called to notify transport users that another peer connected to us.
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.
static int monitor_connections
Option -m.
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_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...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void shutdown_task(void *cls)
Task run in monitor mode when the user presses CTRL-C to abort.
static void monitor_notify_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
Function called to notify transport users that another peer disconnected from us. ...
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static int iterate_connections
Option -i.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1237
static struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle.
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
struct GNUNET_TRANSPORT_Blacklist * GNUNET_TRANSPORT_blacklist(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_TRANSPORT_BlacklistCallback cb, void *cb_cls)
Install a blacklist callback.
static int monitor_plugins
Option -P.
static void plugin_monitoring_cb(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 ...
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.
static void process_peer_iteration_cb(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 called with information about a peers during a one shot iteration.
Message handler for a specific message type.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
static struct GNUNET_TIME_Absolute start_time
Starting time of transmitting/receiving data.
static void operation_timeout(void *cls)
We are done, shut down.
#define OP_TIMEOUT
Timeout for an operation.
static int do_disconnect
Option -D.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
The identity of the host (wraps the signing key of the peer).
static struct GNUNET_TRANSPORT_CoreHandle * handle
Handle to transport service.
configuration data
Definition: configuration.c:83
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static void notify_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
Function called to notify transport users that another peer disconnected from us. ...
struct GNUNET_TRANSPORT_Blacklist * blacklist
Blacklisting handle.
static unsigned int verbosity
Selected level of verbosity.
Header for all communications.
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
static int monitor_connects
Option -c.
static int blacklist_cb(void *cls, const struct GNUNET_PeerIdentity *cpid)
Function called with the transport service checking if we want to blacklist a peer.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

Definition at line 1355 of file gnunet-transport.c.

References benchmark_receive, benchmark_send, do_disconnect, gettext_noop, GNUNET_free, GNUNET_GETOPT_option_base32_auto, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_verbose(), GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), iterate_all, iterate_connections, monitor_connections, monitor_connects, monitor_plugins, numeric, pid, res, ret, run(), and verbosity.

1356 {
1357  int res;
1360  'a',
1361  "all",
1362  gettext_noop(
1363  "print information for all peers (instead of only connected peers)"),
1364  &iterate_all),
1366  'b',
1367  "benchmark",
1368  gettext_noop(
1369  "measure how fast we are receiving data from all peers (until CTRL-C)"),
1372  "disconnect",
1373  gettext_noop("disconnect from a peer"),
1374  &do_disconnect),
1376  'i',
1377  "information",
1378  gettext_noop(
1379  "provide information about all current connections (once)"),
1382  'm',
1383  "monitor",
1384  gettext_noop(
1385  "provide information about all current connections (continuously)"),
1388  'e',
1389  "events",
1390  gettext_noop(
1391  "provide information about all connects and disconnect events (continuously)"),
1392  &monitor_connects),
1394  "numeric",
1395  gettext_noop("do not resolve hostnames"),
1396  &numeric),
1398  "peer",
1399  "PEER",
1400  gettext_noop("peer identity"),
1401  &pid),
1403  "plugins",
1404  gettext_noop("monitor plugin sessions"),
1405  &monitor_plugins),
1407  's',
1408  "send",
1409  gettext_noop(
1410  "send data for benchmarking to the other peer (until CTRL-C)"),
1411  &benchmark_send),
1414 
1415  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv))
1416  return 2;
1417 
1418  res =
1419  GNUNET_PROGRAM_run(argc,
1420  argv,
1421  "gnunet-transport",
1422  gettext_noop("Direct access to transport service."),
1423  options,
1424  &run,
1425  NULL);
1426  GNUNET_free((void *)argv);
1427  if (GNUNET_OK == res)
1428  return ret;
1429  return 1;
1430 }
static int iterate_all
Option -a.
static int benchmark_send
Option -s.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the &#39;-V&#39; verbosity option.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1439
static int ret
Global return value (0 success).
static int benchmark_receive
Option -b.
static int numeric
Option -n.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
Definition of a command line option.
static int monitor_connections
Option -m.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
static int iterate_connections
Option -i.
static int monitor_plugins
Option -P.
static int res
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *mycfg)
Main function that will be run by the scheduler.
static int do_disconnect
Option -D.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
#define GNUNET_GETOPT_option_base32_auto(shortName, name, argumentHelp, description, val)
Allow user to specify a binary value using Crockford Base32 encoding where the size of the binary val...
static unsigned int verbosity
Selected level of verbosity.
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:367
#define GNUNET_free(ptr)
Wrapper around free.
#define gettext_noop(String)
Definition: gettext.h:69
static int monitor_connects
Option -c.
Here is the call graph for this function:

Variable Documentation

◆ handle

struct GNUNET_TRANSPORT_CoreHandle* handle
static

Handle to transport service.

Definition at line 169 of file gnunet-transport.c.

◆ cfg

struct GNUNET_CONFIGURATION_Handle* cfg
static

Configuration handle.

Definition at line 174 of file gnunet-transport.c.

◆ blacklist

struct GNUNET_TRANSPORT_Blacklist* blacklist

Blacklisting handle.

Definition at line 179 of file gnunet-transport.c.

◆ benchmark_send

int benchmark_send
static

Option -s.

Definition at line 184 of file gnunet-transport.c.

Referenced by main(), notify_connect(), notify_disconnect(), operation_timeout(), run(), and shutdown_task().

◆ benchmark_receive

static int benchmark_receive
static

Option -b.

Option -l.

Definition at line 189 of file gnunet-transport.c.

Referenced by handle_dummy(), main(), operation_timeout(), run(), and shutdown_task().

◆ iterate_connections

int iterate_connections
static

Option -i.

Definition at line 199 of file gnunet-transport.c.

Referenced by main(), operation_timeout(), print_info(), process_peer_string(), and run().

◆ iterate_all

int iterate_all
static

Option -a.

Definition at line 204 of file gnunet-transport.c.

Referenced by main(), print_info(), and process_peer_iteration_cb().

◆ monitor_connects

int monitor_connects
static

Option -c.

Definition at line 209 of file gnunet-transport.c.

Referenced by main(), and run().

◆ monitor_connections

int monitor_connections
static

Option -m.

Definition at line 214 of file gnunet-transport.c.

Referenced by main(), print_info(), and run().

◆ monitor_plugins

int monitor_plugins
static

Option -P.

Definition at line 219 of file gnunet-transport.c.

Referenced by main(), and run().

◆ do_disconnect

int do_disconnect
static

Option -D.

Definition at line 224 of file gnunet-transport.c.

Referenced by main(), and run().

◆ numeric

int numeric
static

◆ ret

int ret
static

Global return value (0 success).

Definition at line 234 of file gnunet-transport.c.

Referenced by main(), notify_connect(), operation_timeout(), process_peer_string(), run(), and shutdown_task().

◆ monitor_connect_counter

int monitor_connect_counter
static

Current number of connections in monitor mode.

Definition at line 239 of file gnunet-transport.c.

Referenced by monitor_notify_connect(), monitor_notify_disconnect(), and run().

◆ traffic_received

unsigned long long traffic_received
static

Number of bytes of traffic we received so far.

Definition at line 244 of file gnunet-transport.c.

Referenced by handle_dummy(), and shutdown_task().

◆ traffic_sent

unsigned long long traffic_sent
static

Number of bytes of traffic we sent so far.

Definition at line 249 of file gnunet-transport.c.

Referenced by do_send(), and shutdown_task().

◆ start_time

struct GNUNET_TIME_Absolute start_time
static

Starting time of transmitting/receiving data.

Definition at line 254 of file gnunet-transport.c.

Referenced by handle_dummy(), notify_connect(), run(), and shutdown_task().

◆ monitored_peers

struct GNUNET_CONTAINER_MultiPeerMap* monitored_peers
static

Map storing information about monitored peers.

Definition at line 259 of file gnunet-transport.c.

◆ monitored_plugins

struct GNUNET_CONTAINER_MultiPeerMap* monitored_plugins
static

Map storing information about monitored plugins's sessions.

Definition at line 264 of file gnunet-transport.c.

◆ pic

Handle if we are monitoring peers at the transport level.

Definition at line 269 of file gnunet-transport.c.

◆ pm

struct GNUNET_TRANSPORT_PluginMonitor* pm
static

◆ pid

struct GNUNET_PeerIdentity pid
static

Identity of the peer we transmit to / connect to.

('-p' command-line option).

Definition at line 280 of file gnunet-transport.c.

Referenced by blacklist_cb(), main(), notify_connect(), notify_disconnect(), operation_timeout(), plugin_monitoring_cb(), and run().

◆ op_timeout

struct GNUNET_SCHEDULER_Task* op_timeout
static

Task for operation timeout.

Definition at line 285 of file gnunet-transport.c.

◆ verbosity

unsigned int verbosity
static

Selected level of verbosity.

Definition at line 290 of file gnunet-transport.c.

Referenced by do_send(), handle_dummy(), main(), notify_connect(), and run().

◆ resolver

struct GNUNET_OS_Process* resolver

Resolver process handle.

Definition at line 295 of file gnunet-transport.c.

◆ address_resolutions

unsigned int address_resolutions
static

Number of address resolutions pending.

Definition at line 300 of file gnunet-transport.c.

Referenced by process_peer_string(), and resolve_peer_address().

◆ vc_head

struct ValidationResolutionContext* vc_head
static

DLL: head of validation resolution entries.

Definition at line 305 of file gnunet-transport.c.

Referenced by shutdown_task().

◆ vc_tail

struct ValidationResolutionContext* vc_tail
static

DLL: tail of validation resolution entries.

Definition at line 310 of file gnunet-transport.c.

◆ rc_head

struct PeerResolutionContext* rc_head
static

DLL: head of resolution entries.

Definition at line 315 of file gnunet-transport.c.

Referenced by operation_timeout().

◆ rc_tail

struct PeerResolutionContext* rc_tail
static

DLL: head of resolution entries.

Definition at line 320 of file gnunet-transport.c.