+
+/**
+ * Function to convert an address to a human-readable string.
+ *
+ * @param cls closure
+ * @param addr address to convert
+ * @param addrlen address length
+ * @return res string if conversion was successful, NULL otherwise
+ */
+static const char *
+http_client_plugin_address_to_string (void *cls,
+ const void *addr,
+ size_t addrlen)
+{
+ return http_common_plugin_address_to_string (PLUGIN_NAME,
+ addr,
+ addrlen);
+}
+
+
+/**
+ * Function that will be called whenever the transport service wants to
+ * notify the plugin that a session is still active and in use and
+ * therefore the session timeout for this session has to be updated
+ *
+ * @param cls closure
+ * @param peer which peer was the session for
+ * @param session which session is being updated
+ */
+static void
+http_client_plugin_update_session_timeout (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ struct GNUNET_ATS_Session *session)
+{
+ client_reschedule_session_timeout (session);
+}
+
+
+/**
+ * Function that will be called whenever the transport service wants to
+ * notify the plugin that the inbound quota changed and that the plugin
+ * should update it's delay for the next receive value
+ *
+ * @param cls closure
+ * @param peer which peer was the session for
+ * @param s which session is being updated
+ * @param delay new delay to use for receiving
+ */
+static void
+http_client_plugin_update_inbound_delay (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ struct GNUNET_ATS_Session *s,
+ struct GNUNET_TIME_Relative delay)
+{
+ s->next_receive = GNUNET_TIME_relative_to_absolute (delay);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "New inbound delay %s\n",
+ GNUNET_STRINGS_relative_time_to_string (delay,
+ GNUNET_NO));
+ if (s->recv_wakeup_task != NULL)
+ {
+ GNUNET_SCHEDULER_cancel (s->recv_wakeup_task);
+ s->recv_wakeup_task
+ = GNUNET_SCHEDULER_add_delayed (delay,
+ &client_wake_up,
+ s);
+ }
+}
+
+
+/**
+ * Return information about the given session to the
+ * monitor callback.
+ *
+ * @param cls the `struct Plugin` with the monitor callback (`sic`)
+ * @param peer peer we send information about
+ * @param value our `struct GNUNET_ATS_Session` to send information about
+ * @return #GNUNET_OK (continue to iterate)
+ */
+static int
+send_session_info_iter (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ void *value)
+{
+ struct HTTP_Client_Plugin *plugin = cls;
+ struct GNUNET_ATS_Session *session = value;
+
+ notify_session_monitor (plugin,
+ session,
+ GNUNET_TRANSPORT_SS_INIT);
+ notify_session_monitor (plugin,
+ session,
+ GNUNET_TRANSPORT_SS_UP); /* FIXME: or handshake? */
+ return GNUNET_OK;
+}
+
+
+/**
+ * Begin monitoring sessions of a plugin. There can only
+ * be one active monitor per plugin (i.e. if there are
+ * multiple monitors, the transport service needs to
+ * multiplex the generated events over all of them).
+ *
+ * @param cls closure of the plugin
+ * @param sic callback to invoke, NULL to disable monitor;
+ * plugin will being by iterating over all active
+ * sessions immediately and then enter monitor mode
+ * @param sic_cls closure for @a sic
+ */
+static void
+http_client_plugin_setup_monitor (void *cls,
+ GNUNET_TRANSPORT_SessionInfoCallback sic,
+ void *sic_cls)
+{
+ struct HTTP_Client_Plugin *plugin = cls;
+
+ plugin->sic = sic;
+ plugin->sic_cls = sic_cls;
+ if (NULL != sic)
+ {
+ GNUNET_CONTAINER_multipeermap_iterate (plugin->sessions,
+ &send_session_info_iter,
+ plugin);
+ /* signal end of first iteration */
+ sic (sic_cls, NULL, NULL);
+ }
+}
+
+