*/
static struct Session *
lookup_session_by_client (struct Plugin *plugin,
- const struct GNUNET_SERVER_Client *client)
+ struct GNUNET_SERVER_Client *client)
{
struct Session *ret;
struct SessionClientCtx sc_ctx;
}
+/**
+ * Function that is called to get the keepalive factor.
+ * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to
+ * calculate the interval between keepalive packets.
+ *
+ * @param cls closure with the `struct Plugin`
+ * @return keepalive factor
+ */
+static unsigned int
+tcp_query_keepalive_factor (void *cls)
+{
+ return 3;
+}
+
+
/**
* Session was idle, so disconnect it
*
session))
{
GNUNET_assert (session->client != NULL);
- reschedule_session_timeout (session);
GNUNET_SERVER_client_set_timeout (session->client,
GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
GNUNET_STATISTICS_update (plugin->env->stats,
LOG (GNUNET_ERROR_TYPE_DEBUG,
"This NAT WAIT session for peer `%s' is not yet ready!\n",
GNUNET_i2s (&session->target));
- reschedule_session_timeout (session);
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# bytes currently in TCP buffers"),
msgbuf_size, GNUNET_NO);
session);
}
+static void
+tcp_plugin_update_session_timeout (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ struct Session *session)
+{
+ struct Plugin *plugin = cls;
+ if (GNUNET_SYSERR == find_session (plugin, session))
+ return;
+
+ reschedule_session_timeout (session);
+}
+
/**
* Create a new session to transmit data to the target
asc (asc_cls, NULL);
return;
}
- ppc = GNUNET_malloc (sizeof (struct PrettyPrinterContext));
+ ppc = GNUNET_new (struct PrettyPrinterContext);
if (addrlen == sizeof (struct IPv6TcpAddress))
ppc->ipv6 = GNUNET_YES;
else
/* FIXME: do we need to track these probe context objects so that
* we can clean them up on plugin unload? */
- tcp_probe_ctx = GNUNET_malloc (sizeof (struct TCPProbeContext));
+ tcp_probe_ctx = GNUNET_new (struct TCPProbeContext);
tcp_probe_ctx->message.header.size =
htons (sizeof (struct TCP_NAT_ProbeMessage));
tcp_probe_ctx->message.header.type =
api->get_session = &tcp_plugin_get_session;
api->disconnect_session = &tcp_disconnect_session;
+ api->query_keepalive_factor = &tcp_query_keepalive_factor;
api->disconnect_peer = &tcp_plugin_disconnect;
api->address_pretty_printer = &tcp_plugin_address_pretty_printer;
api->check_address = &tcp_plugin_check_address;
api->address_to_string = &tcp_address_to_string;
api->string_to_address = &tcp_string_to_address;
api->get_network = &tcp_get_network;
+ api->update_session_timeout = &tcp_plugin_update_session_timeout;
plugin->service = service;
if (NULL != service)
{