#include "gnunet_common.h"
#include "gnunet_crypto_lib.h"
#include "gnunet_lockmanager_service.h"
+#include "gnunet_statistics_service.h"
#include "gnunet_stream_lib.h"
#include "stream_protocol.h"
struct GNUNET_STREAM_Socket
{
/**
- * Retransmission timeout
- */
- struct GNUNET_TIME_Relative retransmit_timeout;
-
- /**
- * The Acknowledgement Bitmap
- */
- GNUNET_STREAM_AckBitmap ack_bitmap;
-
- /**
- * Time when the Acknowledgement was queued
- */
- struct GNUNET_TIME_Absolute ack_time_registered;
-
- /**
- * Queued Acknowledgement deadline
+ * The mesh handle
*/
- struct GNUNET_TIME_Relative ack_time_deadline;
+ struct GNUNET_MESH_Handle *mesh;
/**
- * The mesh handle
+ * Handle to statistics
*/
- struct GNUNET_MESH_Handle *mesh;
+ struct GNUNET_STATISTICS_Handle *stat_handle;
/**
* The mesh tunnel handle
*/
struct GNUNET_PeerIdentity other_peer;
+ /**
+ * The Acknowledgement Bitmap
+ */
+ GNUNET_STREAM_AckBitmap ack_bitmap;
+
/**
* Task identifier for retransmission task after timeout
*/
*/
GNUNET_SCHEDULER_TaskIdentifier ack_task_id;
+ /**
+ * Retransmission timeout
+ */
+ struct GNUNET_TIME_Relative retransmit_timeout;
+
+ /**
+ * Time when the Acknowledgement was queued
+ */
+ struct GNUNET_TIME_Absolute ack_time_registered;
+
+ /**
+ * Queued Acknowledgement deadline
+ */
+ struct GNUNET_TIME_Relative ack_time_deadline;
+
/**
* The state of the protocol associated with this socket
*/
unsigned int retries;
/**
- * The application port number (type: uint32_t)
+ * Whether testing mode is active or not
*/
- GNUNET_MESH_ApplicationType app_port;
+ int testing_active;
/**
- * Whether testing mode is active or not
+ * The application port number (type: uint32_t)
*/
- int testing_active;
+ GNUNET_MESH_ApplicationType app_port;
/**
* The write sequence number to be set incase of testing
*/
struct GNUNET_MESH_Handle *mesh;
+ /**
+ * Handle to statistics
+ */
+ struct GNUNET_STATISTICS_Handle *stat_handle;
+
/**
* Our configuration
*/
socket->tunnel = tunnel;
socket->state = STATE_INIT;
socket->lsocket = lsocket;
+ socket->stat_handle = lsocket->stat_handle;
socket->retransmit_timeout = lsocket->retransmit_timeout;
socket->testing_active = lsocket->testing_active;
socket->testing_set_write_sequence_number_value =
"%s: Peer %s initiated tunnel to us\n",
GNUNET_i2s (&socket->other_peer),
GNUNET_i2s (&socket->other_peer));
+ if (NULL != socket->stat_handle)
+ {
+ GNUNET_STATISTICS_update (socket->stat_handle,
+ "total inbound connections received",
+ 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (socket->stat_handle,
+ "inbound connections", 1, GNUNET_NO);
+ }
+
return socket;
}
"%s: Peer %s has terminated connection abruptly\n",
GNUNET_i2s (&socket->other_peer),
GNUNET_i2s (&socket->other_peer));
+ if (NULL != socket->stat_handle)
+ {
+ GNUNET_STATISTICS_update (socket->stat_handle,
+ "connections terminated abruptly", 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (socket->stat_handle,
+ "inbound connections", -1, GNUNET_NO);
+ }
socket->status = GNUNET_STREAM_SHUTDOWN;
/* Clear Transmit handles */
if (NULL != socket->transmit_handle)
GNUNET_assert (NULL != socket->tunnel);
GNUNET_MESH_peer_request_connect_add (socket->tunnel,
&socket->other_peer);
+ socket->stat_handle = GNUNET_STATISTICS_create ("stream", cfg);
LOG (GNUNET_ERROR_TYPE_DEBUG, "%s() END\n", __func__);
return socket;
}
socket->tunnel = NULL;
}
/* Close mesh connection */
- if (NULL != socket->mesh && NULL == socket->lsocket)
+ if ((NULL != socket->mesh) && (NULL == socket->lsocket))
{
GNUNET_MESH_disconnect (socket->mesh);
socket->mesh = NULL;
- }
+ }
+ /* Close statistics connection */
+ if ( (NULL != socket->stat_handle) && (NULL == socket->lsocket) )
+ GNUNET_STATISTICS_destroy (socket->stat_handle, GNUNET_YES);
/* Release receive buffer */
if (NULL != socket->receive_buffer)
{
void *listen_cb_cls,
...)
{
- /* FIXME: Add variable args for passing configration options? */
struct GNUNET_STREAM_ListenSocket *lsocket;
struct GNUNET_TIME_Relative listen_timeout;
enum GNUNET_STREAM_Option option;
lsocket->lockmanager_acquire_timeout_task =
GNUNET_SCHEDULER_add_delayed (listen_timeout,
&lockmanager_acquire_timeout, lsocket);
+ lsocket->stat_handle = GNUNET_STATISTICS_create ("stream",
+ lsocket->cfg);
return lsocket;
}
/* Close MESH connection */
if (NULL != lsocket->mesh)
GNUNET_MESH_disconnect (lsocket->mesh);
+ if (NULL != lsocket->stat_handle)
+ GNUNET_STATISTICS_destroy (lsocket->stat_handle, GNUNET_YES);
GNUNET_CONFIGURATION_destroy (lsocket->cfg);
if (GNUNET_SCHEDULER_NO_TASK != lsocket->lockmanager_acquire_timeout_task)
GNUNET_SCHEDULER_cancel (lsocket->lockmanager_acquire_timeout_task);