+ * @param address NULL on end of iteration,
+ * otherwise 0-terminated printable UTF-8 string,
+ * in particular an empty string if @a res is #GNUNET_NO
+ * @param res result 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)
+ */
+static void
+address_cb (void *cls,
+ const char *address,
+ int res)
+{
+ struct PluginMonitorAddress *addr = cls;
+
+ if (NULL == address)
+ {
+ addr->asc = NULL;
+ return;
+ }
+ if (NULL != addr->str)
+ return;
+ addr->str = GNUNET_strdup (address);
+ print_plugin_event_info (addr,
+ &addr->si);
+}
+
+
+/**
+ * Function called by the plugin with information about the
+ * current sessions managed by the plugin (for monitoring).
+ *
+ * @param cls closure (NULL)
+ * @param session session handle this information is about,
+ * NULL to indicate that we are "in sync" (initial
+ * iteration complete)
+ * @param session_ctx storage 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
+ * @param info information about the state of the session,
+ * NULL if @a session is also NULL and we are
+ * merely signalling that the initial iteration is over;
+ * NULL with @a session being non-NULL if the monitor
+ * was being cancelled while sessions were active
+ */
+static void
+plugin_monitoring_cb (void *cls,
+ struct GNUNET_TRANSPORT_PluginSession *session,
+ void **session_ctx,
+ const struct GNUNET_TRANSPORT_SessionInfo *info)
+{
+ struct PluginMonitorAddress *addr;
+
+ if ( (NULL == info) &&
+ (NULL == session) )
+ return; /* in sync with transport service */
+ addr = *session_ctx;
+ if (NULL == info)
+ {
+ if (NULL != addr)
+ {
+ if (NULL != addr->asc)
+ {
+ GNUNET_TRANSPORT_address_to_string_cancel (addr->asc);
+ addr->asc = NULL;
+ }
+ GNUNET_free_non_null (addr->str);
+ GNUNET_free (addr);
+ *session_ctx = NULL;
+ }
+ return; /* shutdown */
+ }
+ if ( (NULL != cpid) &&
+ (0 != memcmp (&info->address->peer,
+ cpid,
+ sizeof (struct GNUNET_PeerIdentity))) )
+ return; /* filtered */
+ if (NULL == addr)
+ {
+ addr = GNUNET_new (struct PluginMonitorAddress);
+ addr->asc = GNUNET_TRANSPORT_address_to_string (cfg,
+ info->address,
+ numeric,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &address_cb,
+ addr);
+ *session_ctx = addr;
+ }
+ if (NULL == addr->str)
+ addr->si = *info;
+ else
+ print_plugin_event_info (addr,
+ info);
+ if (GNUNET_TRANSPORT_SS_DONE == info->state)
+ {
+ if (NULL != addr->asc)
+ {
+ GNUNET_TRANSPORT_address_to_string_cancel (addr->asc);
+ addr->asc = NULL;
+ }
+ GNUNET_free_non_null (addr->str);
+ GNUNET_free (addr);
+ *session_ctx = NULL;
+ }
+}
+
+
+/**
+ * Function called with information about a peers
+ *
+ * @param cls closure, NULL