[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r31841 - in gnunet/src: include transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r31841 - in gnunet/src: include transport |
Date: |
Wed, 8 Jan 2014 18:51:54 +0100 |
Author: wachs
Date: 2014-01-08 18:51:53 +0100 (Wed, 08 Jan 2014)
New Revision: 31841
Modified:
gnunet/src/include/gnunet_transport_service.h
gnunet/src/transport/Makefile.am
gnunet/src/transport/gnunet-service-transport.c
gnunet/src/transport/gnunet-service-transport.h
gnunet/src/transport/gnunet-service-transport_blacklist.c
gnunet/src/transport/gnunet-service-transport_clients.c
gnunet/src/transport/gnunet-service-transport_clients.h
gnunet/src/transport/gnunet-service-transport_neighbours.c
gnunet/src/transport/gnunet-service-transport_neighbours.h
gnunet/src/transport/gnunet-service-transport_validation.c
gnunet/src/transport/gnunet-service-transport_validation.h
gnunet/src/transport/gnunet-transport.c
gnunet/src/transport/transport.h
gnunet/src/transport/transport_api_address_to_string.c
gnunet/src/transport/transport_api_monitoring.c
Log:
neighbour monitoring api implemented
Modified: gnunet/src/include/gnunet_transport_service.h
===================================================================
--- gnunet/src/include/gnunet_transport_service.h 2014-01-08 15:02:20 UTC
(rev 31840)
+++ gnunet/src/include/gnunet_transport_service.h 2014-01-08 17:51:53 UTC
(rev 31841)
@@ -580,7 +580,7 @@
/**
* Cancel request for address conversion.
*
- * @param alc handle for the request to cancel
+ * @param pic the context handle
*/
void
GNUNET_TRANSPORT_address_to_string_cancel (struct
@@ -590,7 +590,7 @@
/**
* Convert a transport state to a human readable string.
*
- * @param alc handle for the request to cancel
+ * @param state the state
*/
const char *
GNUNET_TRANSPORT_p2s (enum GNUNET_TRANSPORT_PeerState state);
@@ -626,8 +626,8 @@
* @param one_shot GNUNET_YES to return the current state and then end (with
NULL+NULL),
* GNUNET_NO to monitor peers continuously
* @param timeout how long is the lookup allowed to take at most
- * @param peer_address_callback function to call with the results
- * @param peer_address_callback_cls closure for peer_address_callback
+ * @param peer_callback function to call with the results
+ * @param peer_callback_cls closure for peer_address_callback
*/
struct GNUNET_TRANSPORT_PeerMonitoringContext *
GNUNET_TRANSPORT_monitor_peers (const struct
Modified: gnunet/src/transport/Makefile.am
===================================================================
--- gnunet/src/transport/Makefile.am 2014-01-08 15:02:20 UTC (rev 31840)
+++ gnunet/src/transport/Makefile.am 2014-01-08 17:51:53 UTC (rev 31841)
@@ -405,6 +405,7 @@
$(BT_API_TEST) \
$(BT_TIMEOUT_TEST) \
test_transport_api_multi \
+ test_transport_api_monitoring \
test_transport_blacklisting_no_bl \
test_transport_blacklisting_outbound_bl_full \
test_transport_blacklisting_outbound_bl_plugin \
@@ -469,6 +470,7 @@
$(BT_API_TEST) \
$(BT_TIMEOUT_TEST) \
test_transport_api_multi \
+ test_transport_api_monitoring \
test_transport_blacklisting_no_bl \
test_transport_blacklisting_outbound_bl_full \
test_transport_blacklisting_outbound_bl_plugin \
@@ -767,8 +769,6 @@
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/transport/libgnunettransporttesting.la
-
-
test_transport_api_reliability_tcp_SOURCES = \
test_transport_api_reliability.c
test_transport_api_reliability_tcp_LDADD = \
@@ -1099,6 +1099,15 @@
$(top_builddir)/src/transport/libgnunettransporttesting.la
+test_transport_api_monitoring_SOURCES = \
+ test_transport_api_monitoring.c
+test_transport_api_monitoring_LDADD = \
+ $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/hello/libgnunethello.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/transport/libgnunettransporttesting.la
+
+
EXTRA_DIST = \
test_plugin_hostkey \
test_plugin_hostkey.ecc \
Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c 2014-01-08 15:02:20 UTC
(rev 31840)
+++ gnunet/src/transport/gnunet-service-transport.c 2014-01-08 17:51:53 UTC
(rev 31841)
@@ -137,17 +137,24 @@
* @param cls the 'HELLO' message
* @param target a connected neighbour
* @param address the address
+ * @param state current state this peer is in
+ * @param state_timeout timeout for the current state of the peer
* @param bandwidth_in inbound quota in NBO
* @param bandwidth_out outbound quota in NBO
*/
static void
transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target,
const struct GNUNET_HELLO_Address *address,
+ enum GNUNET_TRANSPORT_PeerState state,
+ struct GNUNET_TIME_Absolute state_timeout,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
{
const struct GNUNET_MessageHeader *hello = cls;
+ if ( GNUNET_NO == GST_neighbours_test_connected(target) )
+ return;
+
GST_neighbours_send (target,
hello,
ntohs (hello->size),
@@ -838,13 +845,28 @@
* @param cls closure
* @param peer peer this update is about (never NULL)
* @param address address, NULL on disconnect
+ * @param state current state this peer is in
+ * @param state_timeout timeout for the current state of the peer
+ * @param bandwidth_in bandwidth assigned inbound
+ * @param bandwidth_out bandwidth assigned outbound
*/
static void
-neighbours_address_notification (void *cls,
+neighbours_changed_notification (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Address *address)
+ const struct GNUNET_HELLO_Address *address,
+ enum GNUNET_TRANSPORT_PeerState state,
+ struct GNUNET_TIME_Absolute state_timeout,
+ struct GNUNET_BANDWIDTH_Value32NBO
bandwidth_in,
+ struct GNUNET_BANDWIDTH_Value32NBO
bandwidth_out)
{
- GST_clients_broadcast_address_notification (peer, address);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Notifying about change for peer `%s' with address `%s' in state `%s'
timing out at %s\n",
+ GNUNET_i2s (peer),
+ (NULL != address) ? GST_plugins_a2s (address) : "<none>",
+ GNUNET_TRANSPORT_p2s(state),
+ GNUNET_STRINGS_absolute_time_to_string(state_timeout));
+
+ GST_clients_broadcast_peer_notification (peer, address, state,
state_timeout);
}
@@ -994,7 +1016,7 @@
GST_neighbours_start (NULL,
&neighbours_connect_notification,
&neighbours_disconnect_notification,
- &neighbours_address_notification,
+ &neighbours_changed_notification,
(max_fd / 3) * 2);
GST_clients_start (GST_server);
GST_validation_start ((max_fd / 3));
Modified: gnunet/src/transport/gnunet-service-transport.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport.h 2014-01-08 15:02:20 UTC
(rev 31840)
+++ gnunet/src/transport/gnunet-service-transport.h 2014-01-08 17:51:53 UTC
(rev 31841)
@@ -70,9 +70,14 @@
* @param peer peer this update is about,
* @param address address, NULL for disconnect notification
*/
-typedef void (*GNUNET_TRANSPORT_AddressChangeCallback) (void *cls,
- const struct
GNUNET_PeerIdentity *peer,
- const struct
GNUNET_HELLO_Address *address);
+typedef void
+(*GNUNET_TRANSPORT_NeighbourChangeCallback) (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_HELLO_Address *address,
+ enum GNUNET_TRANSPORT_PeerState state,
+ struct GNUNET_TIME_Absolute state_timeout,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out);
/**
Modified: gnunet/src/transport/gnunet-service-transport_blacklist.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_blacklist.c 2014-01-08
15:02:20 UTC (rev 31840)
+++ gnunet/src/transport/gnunet-service-transport_blacklist.c 2014-01-08
17:51:53 UTC (rev 31841)
@@ -474,29 +474,32 @@
struct Blacklisters *bl;
};
-
/**
* Test if an existing connection is still acceptable given a new
* blacklisting client.
*
* @param cls the 'struct TestConnectionContest'
- * @param neighbour neighbour's identity
+ * @param peer neighbour's identity
* @param address the address
- * @param bandwidth_in inbound quota in NBO
- * @param bandwidth_out outbound quota in NBO
+ * @param state current state this peer is in
+ * @param state_timeout timeout for the current state of the peer
+ * @param bandwidth_in bandwidth assigned inbound
+ * @param bandwidth_out bandwidth assigned outbound
*/
static void
-test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour,
- const struct GNUNET_HELLO_Address *address,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
+test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_HELLO_Address *address,
+ enum GNUNET_TRANSPORT_PeerState state,
+ struct GNUNET_TIME_Absolute state_timeout,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
{
struct TestConnectionContext *tcc = cls;
struct GST_BlacklistCheck *bc;
bc = GNUNET_new (struct GST_BlacklistCheck);
- GNUNET_CONTAINER_DLL_insert (bc_head, bc_tail, bc);
- bc->peer = *neighbour;
+ GNUNET_CONTAINER_DLL_insert(bc_head, bc_tail, bc);
+ bc->peer = *peer;
bc->cont = &confirm_or_drop_neighbour;
bc->cont_cls = NULL;
bc->bl_pos = tcc->bl;
Modified: gnunet/src/transport/gnunet-service-transport_clients.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.c 2014-01-08
15:02:20 UTC (rev 31840)
+++ gnunet/src/transport/gnunet-service-transport_clients.c 2014-01-08
17:51:53 UTC (rev 31841)
@@ -463,6 +463,8 @@
* @param cls the `struct TransportClient *` to notify
* @param peer identity of the neighbour
* @param address the address
+ * @param state the current state of the peer
+ * @param state_timeout the time out for the state
* @param bandwidth_in inbound bandwidth in NBO
* @param bandwidth_out outbound bandwidth in NBO
*/
@@ -908,6 +910,8 @@
* @param cls the 'struct PeerIterationContext'
* @param peer identity of the neighbour
* @param address the address
+ * @param state current state this peer is in
+ * @param state_timeout timeout for the current state of the peer
* @param bandwidth_in inbound quota in NBO
* @param bandwidth_out outbound quota in NBO
*/
@@ -928,7 +932,9 @@
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending information about `%s' using address `%s' in state `%s'\n",
- GNUNET_i2s(peer), address);
+ GNUNET_i2s(peer),
+ (address != NULL) ? GST_plugins_a2s (address) : "<none>",
+ GNUNET_TRANSPORT_p2s (state));
msg = compose_address_iterate_response_message (peer, address);
msg->state = htonl (state);
msg->state_timeout = GNUNET_TIME_absolute_hton(state_timeout);
@@ -1119,15 +1125,21 @@
*
* @param peer peer this update is about (never NULL)
* @param address address, NULL on disconnect
+ * @param state the current state of the peer
+ * @param state_timeout the time out for the state
*/
void
-GST_clients_broadcast_address_notification (const struct GNUNET_PeerIdentity
*peer,
- const struct GNUNET_HELLO_Address
*address)
+GST_clients_broadcast_peer_notification (const struct GNUNET_PeerIdentity
*peer,
+ const struct GNUNET_HELLO_Address *address,
+ enum GNUNET_TRANSPORT_PeerState state,
+ struct GNUNET_TIME_Absolute state_timeout)
{
struct PeerIterateResponseMessage *msg;
struct MonitoringClient *mc;
static struct GNUNET_PeerIdentity all_zeros;
msg = compose_address_iterate_response_message (peer, address);
+ msg->state = htonl (state);
+ msg->state_timeout = GNUNET_TIME_absolute_hton (state_timeout);
mc = monitoring_clients_head;
while (mc != NULL)
{
Modified: gnunet/src/transport/gnunet-service-transport_clients.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.h 2014-01-08
15:02:20 UTC (rev 31840)
+++ gnunet/src/transport/gnunet-service-transport_clients.h 2014-01-08
17:51:53 UTC (rev 31841)
@@ -20,12 +20,13 @@
/**
* @file transport/gnunet-service-transport_clients.h
- * @brief plugin management API
+ * @brief client management API
* @author Christian Grothoff
*/
#ifndef GNUNET_SERVICE_TRANSPORT_CLIENTS_H
#define GNUNET_SERVICE_TRANSPORT_CLIENTS_H
+#include "gnunet_transport_service.h"
#include "gnunet_statistics_service.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_lib.h"
@@ -75,10 +76,14 @@
*
* @param peer peer this update is about (never NULL)
* @param address address, NULL on disconnect
+ * @param state the current state of the peer
+ * @param state_timeout the time out for the state
*/
void
-GST_clients_broadcast_address_notification (const struct GNUNET_PeerIdentity
*peer,
- const struct GNUNET_HELLO_Address
*address);
+GST_clients_broadcast_peer_notification (const struct GNUNET_PeerIdentity
*peer,
+ const struct GNUNET_HELLO_Address *address,
+ enum GNUNET_TRANSPORT_PeerState state,
+ struct GNUNET_TIME_Absolute state_timeout);
#endif
Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c 2014-01-08
15:02:20 UTC (rev 31840)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c 2014-01-08
17:51:53 UTC (rev 31841)
@@ -463,7 +463,7 @@
static struct BlackListCheckContext *bc_tail;
/**
- * Closure for #connect_notify_cb, #disconnect_notify_cb and #address_change_cb
+ * Closure for #connect_notify_cb, #disconnect_notify_cb and
#neighbour_change_cb
*/
static void *callback_cls;
@@ -478,9 +478,9 @@
static GNUNET_TRANSPORT_NotifyDisconnect disconnect_notify_cb;
/**
- * Function to call when we changed an active address of a neighbour.
+ * Function to call when a neighbour changed address, state or bandwidth.
*/
-static GNUNET_TRANSPORT_AddressChangeCallback address_change_cb;
+static GNUNET_TRANSPORT_NeighbourChangeCallback neighbour_change_cb;
/**
* counter for connected neighbours
@@ -562,9 +562,8 @@
{
if (GNUNET_YES == na->ats_active)
{
- GST_validation_set_address_use (na->address, na->session, GNUNET_NO,
__LINE__);
+ GST_validation_set_address_use (na->address, na->session, GNUNET_NO);
GNUNET_ATS_address_in_use (GST_ats, na->address, na->session, GNUNET_NO);
- address_change_cb (callback_cls, &na->address->peer, NULL);
}
na->ats_active = GNUNET_NO;
@@ -577,11 +576,64 @@
na->session = NULL;
}
+/* Change the status of the neighbour */
+static void
+set_state (struct NeighbourMapEntry *n, enum GNUNET_TRANSPORT_PeerState s)
+{
+ n->state = s;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Neighbour `%s' changed state to %s\n",
+ GNUNET_i2s (&n->id),
+ GNUNET_TRANSPORT_p2s(s));
+ neighbour_change_cb (callback_cls,
+ &n->id,
+ n->primary_address.address,
+ n->state, n->timeout,
+ n->primary_address.bandwidth_in,
+ n->primary_address.bandwidth_out);
+
+}
+
+static void
+set_state_and_timeout (struct NeighbourMapEntry *n,
+ enum GNUNET_TRANSPORT_PeerState s,
+ struct GNUNET_TIME_Absolute timeout)
+{
+ n->state = s;
+ n->timeout = timeout;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Neighbour `%s' changed state to %s
with timeout %s\n",
+ GNUNET_i2s (&n->id),
+ GNUNET_TRANSPORT_p2s(s),
+ GNUNET_STRINGS_absolute_time_to_string (timeout));
+ neighbour_change_cb (callback_cls,
+ &n->id,
+ n->primary_address.address,
+ n->state, n->timeout,
+ n->primary_address.bandwidth_in,
+ n->primary_address.bandwidth_out);
+}
+
+static void
+set_timeout (struct NeighbourMapEntry *n,
+ struct GNUNET_TIME_Absolute timeout)
+{
+ n->timeout = timeout;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Neighbour `%s' changed timeout %s\n",
+ GNUNET_i2s (&n->id),
+ GNUNET_STRINGS_absolute_time_to_string (timeout));
+ neighbour_change_cb (callback_cls,
+ &n->id,
+ n->primary_address.address,
+ n->state, n->timeout,
+ n->primary_address.bandwidth_in,
+ n->primary_address.bandwidth_out);
+}
+
+
/**
- * Initialize the 'struct NeighbourAddress'.
+ * Initialize the alternative address of a neighbour
*
- * @param na neighbour address to initialize
+ * @param n the neighbour
* @param address address of the other peer, NULL if other peer
* connected to us
* @param session session to use (or NULL, in which case an
@@ -591,7 +643,85 @@
* @param is_active #GNUNET_YES to mark this as the active address with ATS
*/
static void
-set_address (struct NeighbourAddress *na,
+set_alternative_address (struct NeighbourMapEntry *n,
+ const struct GNUNET_HELLO_Address *address,
+ struct Session *session,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
+ int is_active)
+{
+ struct GNUNET_TRANSPORT_PluginFunctions *papi;
+ if (NULL == (papi = GST_plugins_find (address->transport_name)))
+ {
+ GNUNET_break (0);
+ return;
+ }
+ if (session == n->alternative_address.session)
+ {
+ n->alternative_address.bandwidth_in = bandwidth_in;
+ n->alternative_address.bandwidth_out = bandwidth_out;
+ if (is_active != n->alternative_address.ats_active)
+ {
+ n->alternative_address.ats_active = is_active;
+ GNUNET_ATS_address_in_use (GST_ats, n->alternative_address.address,
+ n->alternative_address.session, is_active);
+ GST_validation_set_address_use (n->alternative_address.address,
+ n->alternative_address.session, is_active);
+ }
+ if (GNUNET_YES == is_active)
+ {
+ GST_neighbours_set_incoming_quota (&address->peer, bandwidth_in);
+ send_outbound_quota (&address->peer, bandwidth_out);
+ }
+ return;
+ }
+ free_address (&n->alternative_address);
+ if (NULL == session)
+ session = papi->get_session (papi->cls, address);
+ if (NULL == session)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Failed to obtain new session for peer `%s' and address
'%s'\n",
+ GNUNET_i2s (&address->peer), GST_plugins_a2s (address));
+ GNUNET_ATS_address_destroyed (GST_ats, address, NULL);
+ return;
+ }
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Neighbour `%s' switched to address
%s\n",
+ GNUNET_i2s (&n->id),
+ GST_plugins_a2s(address));
+
+ n->alternative_address.address = GNUNET_HELLO_address_copy (address);
+ n->alternative_address.bandwidth_in = bandwidth_in;
+ n->alternative_address.bandwidth_out = bandwidth_out;
+ n->alternative_address.session = session;
+ n->alternative_address.ats_active = is_active;
+ n->alternative_address.keep_alive_nonce = 0;
+ if (GNUNET_YES == is_active)
+ {
+ /* Telling ATS about new session */
+ GNUNET_ATS_address_in_use (GST_ats, n->alternative_address.address,
n->alternative_address.session, GNUNET_YES);
+ GST_validation_set_address_use (n->alternative_address.address,
n->alternative_address.session, GNUNET_YES);
+ GST_neighbours_set_incoming_quota (&address->peer, bandwidth_in);
+ send_outbound_quota (&address->peer, bandwidth_out);
+ }
+}
+
+
+/**
+ * Initialize the primary address of a neighbour
+ *
+ * @param n the neighbour
+ * @param address address of the other peer, NULL if other peer
+ * connected to us
+ * @param session session to use (or NULL, in which case an
+ * address must be setup)
+ * @param bandwidth_in inbound quota to be used when connection is up
+ * @param bandwidth_out outbound quota to be used when connection is up
+ * @param is_active #GNUNET_YES to mark this as the active address with ATS
+ */
+static void
+set_primary_address (struct NeighbourMapEntry *n,
const struct GNUNET_HELLO_Address *address,
struct Session *session,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
@@ -605,27 +735,24 @@
GNUNET_break (0);
return;
}
- if (session == na->session)
+ if (session == n->primary_address.session)
{
- na->bandwidth_in = bandwidth_in;
- na->bandwidth_out = bandwidth_out;
- if (is_active != na->ats_active)
+ n->primary_address.bandwidth_in = bandwidth_in;
+ n->primary_address.bandwidth_out = bandwidth_out;
+ if (is_active != n->primary_address.ats_active)
{
- na->ats_active = is_active;
- GNUNET_ATS_address_in_use (GST_ats, na->address, na->session, is_active);
- GST_validation_set_address_use (na->address, na->session, is_active,
__LINE__);
- if (is_active)
- address_change_cb (callback_cls, &address->peer, address);
+ n->primary_address.ats_active = is_active;
+ GNUNET_ATS_address_in_use (GST_ats, n->primary_address.address,
n->primary_address.session, is_active);
+ GST_validation_set_address_use (n->primary_address.address,
n->primary_address.session, is_active);
}
if (GNUNET_YES == is_active)
{
- /* FIXME: is this the right place to set quotas? */
GST_neighbours_set_incoming_quota (&address->peer, bandwidth_in);
send_outbound_quota (&address->peer, bandwidth_out);
}
return;
}
- free_address (na);
+ free_address (&n->primary_address);
if (NULL == session)
session = papi->get_session (papi->cls, address);
if (NULL == session)
@@ -636,22 +763,32 @@
GNUNET_ATS_address_destroyed (GST_ats, address, NULL);
return;
}
- na->address = GNUNET_HELLO_address_copy (address);
- na->bandwidth_in = bandwidth_in;
- na->bandwidth_out = bandwidth_out;
- na->session = session;
- na->ats_active = is_active;
- na->keep_alive_nonce = 0;
+
+ n->primary_address.address = GNUNET_HELLO_address_copy (address);
+ n->primary_address.bandwidth_in = bandwidth_in;
+ n->primary_address.bandwidth_out = bandwidth_out;
+ n->primary_address.session = session;
+ n->primary_address.ats_active = is_active;
+ n->primary_address.keep_alive_nonce = 0;
if (GNUNET_YES == is_active)
{
/* Telling ATS about new session */
- GNUNET_ATS_address_in_use (GST_ats, na->address, na->session, GNUNET_YES);
- GST_validation_set_address_use (na->address, na->session, GNUNET_YES,
__LINE__);
- address_change_cb (callback_cls, &address->peer, address);
- /* FIXME: is this the right place to set quotas? */
+ GNUNET_ATS_address_in_use (GST_ats, n->primary_address.address,
n->primary_address.session, GNUNET_YES);
+ GST_validation_set_address_use (n->primary_address.address,
n->primary_address.session, GNUNET_YES);
GST_neighbours_set_incoming_quota (&address->peer, bandwidth_in);
send_outbound_quota (&address->peer, bandwidth_out);
}
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Neighbour `%s' switched to address
%s\n",
+ GNUNET_i2s (&n->id),
+ GST_plugins_a2s(address));
+
+ neighbour_change_cb (callback_cls,
+ &n->id,
+ n->primary_address.address,
+ n->state, n->timeout,
+ n->primary_address.bandwidth_in,
+ n->primary_address.bandwidth_out);
}
@@ -693,7 +830,7 @@
GNUNET_NO);
disconnect_notify_cb (callback_cls, &n->id);
}
- n->state = S_DISCONNECT_FINISHED;
+ set_state (n, S_DISCONNECT_FINISHED);
if (NULL != n->primary_address.address)
{
@@ -892,24 +1029,24 @@
case S_INIT_ATS:
case S_INIT_BLACKLIST:
/* other peer is completely unaware of us, no need to send DISCONNECT */
- n->state = S_DISCONNECT_FINISHED;
+ set_state (n, S_DISCONNECT_FINISHED);
free_neighbour (n, GNUNET_NO);
return;
case S_CONNECT_SENT:
send_disconnect (n);
- n->state = S_DISCONNECT;
+ set_state (n, S_DISCONNECT);
break;
case S_CONNECT_RECV_BLACKLIST_INBOUND:
case S_CONNECT_RECV_ATS:
case S_CONNECT_RECV_BLACKLIST:
/* we never ACK'ed the other peer's request, no need to send DISCONNECT */
- n->state = S_DISCONNECT_FINISHED;
+ set_state (n, S_DISCONNECT_FINISHED);
free_neighbour (n, GNUNET_NO);
return;
case S_CONNECT_RECV_ACK:
/* we DID ACK the other peer's request, must send DISCONNECT */
send_disconnect (n);
- n->state = S_DISCONNECT;
+ set_state (n, S_DISCONNECT);
break;
case S_CONNECTED:
case S_RECONNECT_BLACKLIST:
@@ -924,7 +1061,7 @@
--neighbours_connected,
GNUNET_NO);
disconnect_notify_cb (callback_cls, &n->id);
- n->state = S_DISCONNECT;
+ set_state (n, S_DISCONNECT);
break;
case S_RECONNECT_ATS:
/* ATS address request timeout, disconnect without sending disconnect
message */
@@ -933,7 +1070,7 @@
--neighbours_connected,
GNUNET_NO);
disconnect_notify_cb (callback_cls, &n->id);
- n->state = S_DISCONNECT;
+ set_state (n, S_DISCONNECT);
break;
case S_DISCONNECT:
/* already disconnected, ignore */
@@ -1268,7 +1405,8 @@
n->primary_address.keep_alive_nonce = 0;
n->expect_latency_response = GNUNET_NO;
n->latency = GNUNET_TIME_absolute_get_duration (n->last_keep_alive_time);
- n->timeout = GNUNET_TIME_relative_to_absolute
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ set_timeout (n, GNUNET_TIME_relative_to_absolute
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT));
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Latency for peer `%s' is %s\n",
GNUNET_i2s (&n->id),
@@ -1550,7 +1688,6 @@
GNUNET_i2s (peer));
n = GNUNET_new (struct NeighbourMapEntry);
n->id = *peer;
- n->state = S_NOT_CONNECTED;
n->latency = GNUNET_TIME_UNIT_FOREVER_REL;
n->last_util_transmission = GNUNET_TIME_absolute_get();
n->util_payload_bytes_recv = 0;
@@ -1561,6 +1698,7 @@
GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
MAX_BANDWIDTH_CARRY_S);
n->task = GNUNET_SCHEDULER_add_now (&master_task, n);
+ set_state_and_timeout (n, S_NOT_CONNECTED, GNUNET_TIME_UNIT_FOREVER_ABS);
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multipeermap_put (neighbours,
&n->id, n,
@@ -1664,8 +1802,7 @@
}
}
n = setup_neighbour (target);
- n->state = S_INIT_ATS;
- n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
+ set_state_and_timeout (n, S_INIT_ATS, GNUNET_TIME_relative_to_absolute
(ATS_RESPONSE_TIMEOUT));
GNUNET_ATS_reset_backoff (GST_ats, target);
n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, target);
@@ -1751,15 +1888,13 @@
}
if (GNUNET_OK == result)
{
- n->timeout = GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT);
- n->state = S_CONNECT_SENT;
+ set_state_and_timeout (n, S_CONNECT_SENT,
GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT));
send_session_connect (&n->primary_address);
}
else
{
free_address (&n->primary_address);
- n->state = S_INIT_ATS;
- n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
+ set_state_and_timeout (n, S_INIT_ATS, GNUNET_TIME_relative_to_absolute
(ATS_RESPONSE_TIMEOUT));
}
break;
case S_CONNECT_SENT:
@@ -1774,8 +1909,7 @@
}
break;
case S_CONNECT_RECV_BLACKLIST_INBOUND:
- n->state = S_CONNECT_RECV_ATS;
- n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
+ set_state_and_timeout (n, S_CONNECT_RECV_ATS,
GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
GNUNET_ATS_reset_backoff (GST_ats, peer);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Suggesting address for peer %s to ATS\n",
@@ -1794,8 +1928,7 @@
}
if (GNUNET_OK == result)
{
- n->timeout = GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT);
- n->state = S_CONNECT_RECV_ACK;
+ set_state_and_timeout (n, S_CONNECT_RECV_ACK,
GNUNET_TIME_relative_to_absolute (SETUP_CONNECTION_TIMEOUT));
send_session_connect_ack_message (bcc->na.address,
bcc->na.session,
n->connect_ack_timestamp);
@@ -1816,8 +1949,7 @@
}
GNUNET_break (NULL != plugin);
free_address (&n->primary_address);
- n->state = S_INIT_ATS;
- n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
+ set_state_and_timeout (n, S_INIT_ATS, GNUNET_TIME_relative_to_absolute
(ATS_RESPONSE_TIMEOUT));
GNUNET_ATS_reset_backoff (GST_ats, peer);
}
break;
@@ -1855,14 +1987,12 @@
}
if (GNUNET_OK == result)
{
- n->state = S_RECONNECT_SENT;
+ set_state_and_timeout (n, S_RECONNECT_SENT,
GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT));
send_session_connect (&n->primary_address);
- n->timeout = GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT);
}
else
{
- n->state = S_RECONNECT_ATS;
- n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
+ set_state_and_timeout (n, S_RECONNECT_ATS,
GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
}
break;
case S_RECONNECT_SENT:
@@ -1886,11 +2016,11 @@
if (GNUNET_OK == result)
{
send_session_connect (&n->alternative_address);
- n->state = S_CONNECTED_SWITCHING_CONNECT_SENT;
+ set_state (n, S_CONNECTED_SWITCHING_CONNECT_SENT);
}
else
{
- n->state = S_CONNECTED;
+ set_state(n, S_CONNECTED);
free_address (&n->alternative_address);
}
break;
@@ -2021,13 +2151,13 @@
switch (n->state)
{
case S_NOT_CONNECTED:
- n->state = S_CONNECT_RECV_BLACKLIST_INBOUND;
/* Do a blacklist check for the new address */
+ set_state (n, S_CONNECT_RECV_BLACKLIST_INBOUND);
check_blacklist (peer, ts, address, session);
break;
case S_INIT_ATS:
/* CONNECT message takes priority over us asking ATS for address */
- n->state = S_CONNECT_RECV_BLACKLIST_INBOUND;
+ set_state (n, S_CONNECT_RECV_BLACKLIST_INBOUND);
/* fallthrough */
case S_INIT_BLACKLIST:
case S_CONNECT_SENT:
@@ -2073,7 +2203,7 @@
/* get rid of remains without terminating sessions, ready to re-try */
free_neighbour (n, GNUNET_YES);
n = setup_neighbour (peer);
- n->state = S_CONNECT_RECV_ATS;
+ set_state (n, S_CONNECT_RECV_ATS);
GNUNET_ATS_reset_backoff (GST_ats, peer);
n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, peer);
break;
@@ -2184,44 +2314,41 @@
free_neighbour (n, GNUNET_NO);
return;
case S_INIT_ATS:
- set_address (&n->primary_address,
- address, session, bandwidth_in, bandwidth_out, GNUNET_NO);
- n->state = S_INIT_BLACKLIST;
- n->timeout = GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT);
+ set_primary_address (n, address, session, bandwidth_in, bandwidth_out,
GNUNET_NO);
+ set_state_and_timeout (n, S_INIT_BLACKLIST,
GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT));
check_blacklist (&n->id,
n->connect_ack_timestamp,
address, session);
break;
case S_INIT_BLACKLIST:
/* ATS suggests a different address, switch again */
- set_address (&n->primary_address,
+ set_primary_address (n,
address, session, bandwidth_in, bandwidth_out, GNUNET_NO);
- n->timeout = GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT);
+ set_timeout (n, GNUNET_TIME_relative_to_absolute
(BLACKLIST_RESPONSE_TIMEOUT));
check_blacklist (&n->id,
n->connect_ack_timestamp,
address, session);
break;
case S_CONNECT_SENT:
/* ATS suggests a different address, switch again */
- set_address (&n->primary_address,
- address, session, bandwidth_in, bandwidth_out, GNUNET_NO);
- n->state = S_INIT_BLACKLIST;
- n->timeout = GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT);
+ set_primary_address (n, address, session, bandwidth_in, bandwidth_out,
GNUNET_NO);
+ set_state_and_timeout (n, S_INIT_BLACKLIST,
GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT));
check_blacklist (&n->id,
n->connect_ack_timestamp,
address, session);
break;
case S_CONNECT_RECV_ATS:
- set_address (&n->primary_address,
+ set_primary_address (n,
address, session, bandwidth_in, bandwidth_out, GNUNET_NO);
- n->state = S_CONNECT_RECV_BLACKLIST;
- n->timeout = GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT);
+ set_state_and_timeout (n, S_CONNECT_RECV_BLACKLIST,
GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT));
check_blacklist (&n->id,
n->connect_ack_timestamp,
address, session);
break;
case S_CONNECT_RECV_BLACKLIST_INBOUND:
- n->timeout = GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT);
+ set_timeout (n, GNUNET_TIME_relative_to_absolute
(BLACKLIST_RESPONSE_TIMEOUT));
+ neighbour_change_cb (callback_cls, &n->id, n->primary_address.address,
+ n->state, n->timeout, bandwidth_in, bandwidth_out);
check_blacklist (&n->id,
n->connect_ack_timestamp,
address, session);
@@ -2230,10 +2357,11 @@
case S_CONNECT_RECV_ACK:
/* ATS asks us to switch while we were trying to connect; switch to new
address and check blacklist again */
- set_address (&n->primary_address,
+ set_primary_address (n,
address, session, bandwidth_in, bandwidth_out, GNUNET_NO);
- n->state = S_CONNECT_RECV_BLACKLIST;
- n->timeout = GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT);
+ set_state_and_timeout (n, S_CONNECT_RECV_BLACKLIST,
GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT));
+ neighbour_change_cb (callback_cls, &n->id, n->primary_address.address,
+ n->state, n->timeout, bandwidth_in, bandwidth_out);
check_blacklist (&n->id,
n->connect_ack_timestamp,
address, session);
@@ -2244,24 +2372,29 @@
if (n->primary_address.session == session)
{
/* not an address change, just a quota change */
- set_address (&n->primary_address,
+ set_primary_address (n,
address, session, bandwidth_in, bandwidth_out, GNUNET_YES);
+ neighbour_change_cb (callback_cls, &n->id, n->primary_address.address,
+ n->state, n->timeout, bandwidth_in, bandwidth_out);
break;
}
/* ATS asks us to switch a life connection; see if we can get
a CONNECT_ACK on it before we actually do this! */
- n->state = S_CONNECTED_SWITCHING_BLACKLIST;
- set_address (&n->alternative_address,
+ set_state (n, S_CONNECTED_SWITCHING_BLACKLIST);
+ set_alternative_address (n,
address, session, bandwidth_in, bandwidth_out, GNUNET_NO);
+ neighbour_change_cb (callback_cls, &n->id, n->primary_address.address,
+ n->state, n->timeout, bandwidth_in, bandwidth_out);
check_blacklist (&n->id,
GNUNET_TIME_absolute_get (),
address, session);
break;
case S_RECONNECT_ATS:
- n->state = S_RECONNECT_BLACKLIST;
- set_address (&n->primary_address,
+ set_primary_address (n,
address, session, bandwidth_in, bandwidth_out, GNUNET_NO);
- n->timeout = GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT);
+ set_state_and_timeout (n, S_RECONNECT_BLACKLIST,
GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT));
+ neighbour_change_cb (callback_cls, &n->id, n->primary_address.address,
+ n->state, n->timeout, bandwidth_in, bandwidth_out);
check_blacklist (&n->id,
n->connect_ack_timestamp,
address, session);
@@ -2269,9 +2402,11 @@
case S_RECONNECT_BLACKLIST:
/* ATS asks us to switch while we were trying to reconnect; switch to new
address and check blacklist again */
- set_address (&n->primary_address,
+ set_primary_address (n,
address, session, bandwidth_in, bandwidth_out, GNUNET_NO);
- n->timeout = GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT);
+ set_timeout (n, GNUNET_TIME_relative_to_absolute
(BLACKLIST_RESPONSE_TIMEOUT));
+ neighbour_change_cb (callback_cls, &n->id, n->primary_address.address,
+ n->state, n->timeout, bandwidth_in, bandwidth_out);
check_blacklist (&n->id,
n->connect_ack_timestamp,
address, session);
@@ -2279,10 +2414,11 @@
case S_RECONNECT_SENT:
/* ATS asks us to switch while we were trying to reconnect; switch to new
address and check blacklist again */
- n->state = S_RECONNECT_BLACKLIST;
- set_address (&n->primary_address,
+ set_primary_address (n,
address, session, bandwidth_in, bandwidth_out, GNUNET_NO);
- n->timeout = GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT);
+ set_state_and_timeout (n, S_RECONNECT_BLACKLIST,
GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT));
+ neighbour_change_cb (callback_cls, &n->id, n->primary_address.address,
+ n->state, n->timeout, bandwidth_in, bandwidth_out);
check_blacklist (&n->id,
n->connect_ack_timestamp,
address, session);
@@ -2291,13 +2427,15 @@
if (n->primary_address.session == session)
{
/* ATS switches back to still-active session */
- n->state = S_CONNECTED;
+ set_state(n, S_CONNECTED);
free_address (&n->alternative_address);
break;
}
/* ATS asks us to switch a life connection, update blacklist check */
- set_address (&n->alternative_address,
+ set_primary_address (n,
address, session, bandwidth_in, bandwidth_out, GNUNET_NO);
+ neighbour_change_cb (callback_cls, &n->id, n->primary_address.address,
+ n->state, n->timeout, bandwidth_in, bandwidth_out);
check_blacklist (&n->id,
GNUNET_TIME_absolute_get (),
address, session);
@@ -2307,13 +2445,15 @@
{
/* ATS switches back to still-active session */
free_address (&n->alternative_address);
- n->state = S_CONNECTED;
+ set_state (n, S_CONNECTED);
break;
}
/* ATS asks us to switch a life connection, update blacklist check */
- n->state = S_CONNECTED_SWITCHING_BLACKLIST;
- set_address (&n->alternative_address,
+ set_state (n, S_CONNECTED_SWITCHING_BLACKLIST);
+ set_alternative_address (n,
address, session, bandwidth_in, bandwidth_out, GNUNET_NO);
+ neighbour_change_cb (callback_cls, &n->id, n->primary_address.address,
+ n->state, n->timeout, bandwidth_in, bandwidth_out);
check_blacklist (&n->id,
GNUNET_TIME_absolute_get (),
address, session);
@@ -2502,7 +2642,7 @@
case S_NOT_CONNECTED:
/* invalid state for master task, clean up */
GNUNET_break (0);
- n->state = S_DISCONNECT_FINISHED;
+ set_state (n, S_DISCONNECT_FINISHED);
free_neighbour (n, GNUNET_NO);
return;
case S_INIT_ATS:
@@ -2511,7 +2651,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Connection to `%s' timed out waiting for ATS to provide
address\n",
GNUNET_i2s (&n->id));
- n->state = S_DISCONNECT_FINISHED;
+ set_state (n, S_DISCONNECT_FINISHED);
free_neighbour (n, GNUNET_NO);
return;
}
@@ -2522,7 +2662,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Connection to `%s' timed out waiting for BLACKLIST to
approve address\n",
GNUNET_i2s (&n->id));
- n->state = S_DISCONNECT_FINISHED;
+ set_state (n, S_DISCONNECT_FINISHED);
free_neighbour (n, GNUNET_NO);
return;
}
@@ -2549,7 +2689,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Connection to `%s' timed out waiting BLACKLIST to approve
address to use for received CONNECT\n",
GNUNET_i2s (&n->id));
- n->state = S_DISCONNECT_FINISHED;
+ set_state (n, S_DISCONNECT_FINISHED);
free_neighbour (n, GNUNET_NO);
return;
}
@@ -2560,7 +2700,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Connection to `%s' timed out waiting ATS to provide address
to use for CONNECT_ACK\n",
GNUNET_i2s (&n->id));
- n->state = S_DISCONNECT_FINISHED;
+ set_state (n, S_DISCONNECT_FINISHED);
free_neighbour (n, GNUNET_NO);
return;
}
@@ -2571,7 +2711,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Connection to `%s' timed out waiting BLACKLIST to approve
address to use for CONNECT_ACK\n",
GNUNET_i2s (&n->id));
- n->state = S_DISCONNECT_FINISHED;
+ set_state (n, S_DISCONNECT_FINISHED);
free_neighbour (n, GNUNET_NO);
return;
}
@@ -2771,8 +2911,7 @@
"CONNECT_ACK ignored as the timestamp does not match our
CONNECT request\n");
return GNUNET_OK;
}
- n->state = S_CONNECTED;
- n->timeout = GNUNET_TIME_relative_to_absolute
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ set_state_and_timeout (n, S_CONNECTED, GNUNET_TIME_relative_to_absolute
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT));
GNUNET_STATISTICS_set (GST_stats,
gettext_noop ("# peers connected"),
++neighbours_connected,
@@ -2784,7 +2923,7 @@
GST_ats_add_address (n->primary_address.address,
n->primary_address.session,
NULL, 0);
- set_address (&n->primary_address,
+ set_primary_address (n,
n->primary_address.address,
n->primary_address.session,
n->primary_address.bandwidth_in,
@@ -2816,7 +2955,7 @@
break;
case S_RECONNECT_SENT:
/* new address worked; go back to connected! */
- n->state = S_CONNECTED;
+ set_state (n, S_CONNECTED);
send_session_ack_message (n);
break;
case S_CONNECTED_SWITCHING_BLACKLIST:
@@ -2825,14 +2964,13 @@
break;
case S_CONNECTED_SWITCHING_CONNECT_SENT:
/* new address worked; adopt it and go back to connected! */
- n->state = S_CONNECTED;
- n->timeout = GNUNET_TIME_relative_to_absolute
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ set_state_and_timeout (n, S_CONNECTED, GNUNET_TIME_relative_to_absolute
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT));
GNUNET_break (GNUNET_NO == n->alternative_address.ats_active);
GST_ats_add_address (n->alternative_address.address,
n->alternative_address.session,
NULL, 0);
- set_address (&n->primary_address,
+ set_alternative_address (n,
n->alternative_address.address,
n->alternative_address.session,
n->alternative_address.bandwidth_in,
@@ -2902,7 +3040,7 @@
{
if ( (S_CONNECTED_SWITCHING_BLACKLIST == n->state) ||
(S_CONNECTED_SWITCHING_CONNECT_SENT == n->state) )
- n->state = S_CONNECTED;
+ set_state (n, S_CONNECTED);
else
GNUNET_break (0);
free_address (&n->alternative_address);
@@ -2924,10 +3062,7 @@
case S_INIT_BLACKLIST:
case S_CONNECT_SENT:
free_address (&n->primary_address);
- n->state = S_INIT_ATS;
- n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
- // FIXME: need to ask ATS for suggestions again?
- n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, &n->id);
+ set_state_and_timeout (n, S_INIT_ATS, GNUNET_TIME_relative_to_absolute
(ATS_RESPONSE_TIMEOUT));
break;
case S_CONNECT_RECV_BLACKLIST_INBOUND:
case S_CONNECT_RECV_ATS:
@@ -2938,11 +3073,8 @@
free_neighbour (n, GNUNET_NO);
return GNUNET_YES;
case S_CONNECTED:
- n->state = S_RECONNECT_ATS;
+ set_state_and_timeout (n, S_INIT_ATS, GNUNET_TIME_relative_to_absolute
(ATS_RESPONSE_TIMEOUT));
free_address (&n->primary_address);
- n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
- /* FIXME: is this ATS call needed? */
- n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, &n->id);
break;
case S_RECONNECT_ATS:
/* we don't have an address, how can it go down? */
@@ -2950,28 +3082,23 @@
break;
case S_RECONNECT_BLACKLIST:
case S_RECONNECT_SENT:
- n->state = S_RECONNECT_ATS;
- n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
- // FIXME: need to ask ATS for suggestions again?
- n->suggest_handle = GNUNET_ATS_suggest_address (GST_ats, &n->id);
+ set_state_and_timeout (n, S_RECONNECT_ATS,
GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
break;
case S_CONNECTED_SWITCHING_BLACKLIST:
/* primary went down while we were checking secondary against
blacklist, adopt secondary as primary */
- n->state = S_RECONNECT_BLACKLIST;
free_address (&n->primary_address);
+ set_state_and_timeout (n, S_RECONNECT_BLACKLIST,
GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT));
n->primary_address = n->alternative_address;
memset (&n->alternative_address, 0, sizeof (struct NeighbourAddress));
- n->timeout = GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT);
break;
case S_CONNECTED_SWITCHING_CONNECT_SENT:
/* primary went down while we were waiting for CONNECT_ACK on secondary;
secondary as primary */
- n->state = S_RECONNECT_SENT;
free_address (&n->primary_address);
n->primary_address = n->alternative_address;
memset (&n->alternative_address, 0, sizeof (struct NeighbourAddress));
- n->timeout = GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT);
+ set_state_and_timeout (n, S_RECONNECT_SENT,
GNUNET_TIME_relative_to_absolute (FAST_RECONNECT_TIMEOUT));
break;
case S_DISCONNECT:
free_address (&n->primary_address);
@@ -3047,8 +3174,7 @@
GNUNET_NO);
return GNUNET_OK;
}
- n->state = S_CONNECTED;
- n->timeout = GNUNET_TIME_relative_to_absolute
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ set_state_and_timeout (n, S_CONNECTED, GNUNET_TIME_relative_to_absolute
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT));
GNUNET_STATISTICS_set (GST_stats,
gettext_noop ("# peers connected"),
++neighbours_connected,
@@ -3060,7 +3186,7 @@
GST_ats_add_address (n->primary_address.address,
n->primary_address.session,
NULL, 0);
- set_address (&n->primary_address,
+ set_primary_address (n,
n->primary_address.address,
n->primary_address.session,
n->primary_address.bandwidth_in,
@@ -3379,13 +3505,13 @@
GST_neighbours_start (void *cls,
NotifyConnect connect_cb,
GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb,
- GNUNET_TRANSPORT_AddressChangeCallback peer_address_cb,
+ GNUNET_TRANSPORT_NeighbourChangeCallback peer_address_cb,
unsigned int max_fds)
{
callback_cls = cls;
connect_notify_cb = connect_cb;
disconnect_notify_cb = disconnect_cb;
- address_change_cb = peer_address_cb;
+ neighbour_change_cb = peer_address_cb;
neighbours = GNUNET_CONTAINER_multipeermap_create (NEIGHBOUR_TABLE_SIZE,
GNUNET_NO);
util_transmission_tk = GNUNET_SCHEDULER_add_delayed
(UTIL_TRANSMISSION_INTERVAL,
utilization_transmission, NULL);
@@ -3410,7 +3536,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Disconnecting peer `%4s', %s\n",
GNUNET_i2s (&n->id), "SHUTDOWN_TASK");
- n->state = S_DISCONNECT_FINISHED;
+ set_state (n, S_DISCONNECT_FINISHED);
free_neighbour (n, GNUNET_NO);
return GNUNET_OK;
}
@@ -3438,7 +3564,7 @@
callback_cls = NULL;
connect_notify_cb = NULL;
disconnect_notify_cb = NULL;
- address_change_cb = NULL;
+ neighbour_change_cb = NULL;
}
Modified: gnunet/src/transport/gnunet-service-transport_neighbours.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.h 2014-01-08
15:02:20 UTC (rev 31840)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.h 2014-01-08
17:51:53 UTC (rev 31841)
@@ -51,7 +51,7 @@
GST_neighbours_start (void *cls,
NotifyConnect connect_cb,
GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb,
- GNUNET_TRANSPORT_AddressChangeCallback peer_address_cb,
+ GNUNET_TRANSPORT_NeighbourChangeCallback peer_address_cb,
unsigned int max_fds);
Modified: gnunet/src/transport/gnunet-service-transport_validation.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_validation.c 2014-01-08
15:02:20 UTC (rev 31840)
+++ gnunet/src/transport/gnunet-service-transport_validation.c 2014-01-08
17:51:53 UTC (rev 31841)
@@ -264,10 +264,6 @@
*/
int expecting_pong;
- /* FIXME: DEBUGGING */
- int last_line_set_to_no;
- int last_line_set_to_yes;
-
enum GNUNET_ATS_Network_Type network;
};
@@ -720,8 +716,6 @@
return NULL;
ve = GNUNET_new (struct ValidationEntry);
ve->in_use = GNUNET_SYSERR; /* not defined */
- ve->last_line_set_to_no = 0;
- ve->last_line_set_to_yes = 0;
ve->address = GNUNET_HELLO_address_copy (address);
ve->public_key = *public_key;
ve->pid = address->peer;
@@ -1526,13 +1520,11 @@
* @param session the session
* @param in_use #GNUNET_YES if we are now using the address for a connection,
* #GNUNET_NO if we are no longer using the address for a
connection
- * @param line line of caller just for DEBUGGING!
*/
void
GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address,
struct Session *session,
- int in_use,
- int line)
+ int in_use)
{
struct ValidationEntry *ve;
@@ -1551,28 +1543,17 @@
if (GNUNET_YES == in_use)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error setting address in use for peer `%s' `%s' to USED:
set last time by %i, called now by %i\n",
- GNUNET_i2s (&address->peer), GST_plugins_a2s (address),
- ve->last_line_set_to_yes, line);
+ "Error setting address in use for peer `%s' `%s' to USED\n",
+ GNUNET_i2s (&address->peer), GST_plugins_a2s (address));
}
if (GNUNET_NO == in_use)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Error setting address in use for peer `%s' `%s' to
NOT_USED: set last time by %i, called now by %i\n",
- GNUNET_i2s (&address->peer), GST_plugins_a2s (address),
- ve->last_line_set_to_no, line);
+ "Error setting address in use for peer `%s' `%s' to
NOT_USED\n",
+ GNUNET_i2s (&address->peer), GST_plugins_a2s (address));
}
}
- if (GNUNET_YES == in_use)
- {
- ve->last_line_set_to_yes = line;
- }
- if (GNUNET_NO == in_use)
- {
- ve->last_line_set_to_no = line;
- }
-
GNUNET_break (ve->in_use != in_use); /* should be different... */
ve->in_use = in_use;
if (in_use == GNUNET_YES)
Modified: gnunet/src/transport/gnunet-service-transport_validation.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_validation.h 2014-01-08
15:02:20 UTC (rev 31840)
+++ gnunet/src/transport/gnunet-service-transport_validation.h 2014-01-08
17:51:53 UTC (rev 31841)
@@ -57,13 +57,11 @@
* @param session the session
* @param in_use GNUNET_YES if we are now using the address for a connection,
* GNUNET_NO if we are no longer using the address for a
connection
- * @param line line of caller just for DEBUGGING!
*/
void
GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address,
struct Session *session,
- int in_use,
- int line);
+ int in_use);
/**
Modified: gnunet/src/transport/gnunet-transport.c
===================================================================
--- gnunet/src/transport/gnunet-transport.c 2014-01-08 15:02:20 UTC (rev
31840)
+++ gnunet/src/transport/gnunet-transport.c 2014-01-08 17:51:53 UTC (rev
31841)
@@ -149,6 +149,11 @@
static struct GNUNET_TRANSPORT_TransmitHandle *th;
/**
+ * Map storing information about monitored peers
+ */
+static struct GNUNET_CONTAINER_MultiPeerMap *monitored_peers;
+
+/**
*
*/
struct GNUNET_TRANSPORT_PeerMonitoringContext *pic;
@@ -194,6 +199,7 @@
*/
static unsigned int address_resolution_in_progress;
+
/**
* Context for a plugin test.
*/
@@ -217,6 +223,25 @@
};
+struct MonitoredPeer
+{
+ enum GNUNET_TRANSPORT_PeerState state;
+ struct GNUNET_TIME_Absolute state_timeout;
+ struct GNUNET_HELLO_Address *address;
+};
+
+
+ int destroy_it (void *cls,
+ const struct GNUNET_PeerIdentity *key,
+ void *value)
+{
+ struct MonitoredPeer *m = value;
+ GNUNET_CONTAINER_multipeermap_remove (monitored_peers, key, value);
+ GNUNET_free_non_null (m->address);
+ GNUNET_free (value);
+ return GNUNET_OK;
+}
+
/**
* Task run in monitor mode when the user presses CTRL-C to abort.
* Stops monitoring activity.
@@ -270,6 +295,13 @@
traffic_received,
GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
}
+
+ if (NULL != monitored_peers)
+ {
+ GNUNET_CONTAINER_multipeermap_iterate (monitored_peers, &destroy_it, NULL);
+ GNUNET_CONTAINER_multipeermap_destroy (monitored_peers);
+ monitored_peers = NULL;
+ }
}
static struct ResolutionContext *rc_head;
@@ -279,8 +311,12 @@
{
struct ResolutionContext *next;
struct ResolutionContext *prev;
+ struct GNUNET_PeerIdentity id;
struct GNUNET_HELLO_Address *addrcp;
struct GNUNET_TRANSPORT_AddressToStringContext *asc;
+ enum GNUNET_TRANSPORT_PeerState state;
+ struct GNUNET_TIME_Absolute state_timeout;
+ char *transport;
int printed;
};
@@ -310,6 +346,7 @@
GNUNET_CONTAINER_DLL_remove(rc_head, rc_tail, cur);
GNUNET_TRANSPORT_address_to_string_cancel (cur->asc);
+ GNUNET_free(cur->transport);
GNUNET_free(cur->addrcp);
GNUNET_free(cur);
@@ -641,18 +678,41 @@
}
static void
-resolve_address (const struct GNUNET_HELLO_Address *address, int numeric);
+resolve_address (const struct GNUNET_PeerIdentity *id,
+ const struct GNUNET_HELLO_Address *address, int numeric,
+ enum GNUNET_TRANSPORT_PeerState state,
+ struct GNUNET_TIME_Absolute state_timeout);
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)
+{
+ if ((GNUNET_YES == iterate_all) || (GNUNET_YES == monitor_connections) )
+ {
+ FPRINTF (stdout, _("Peer `%s': %s %s in state `%s' until %s\n"),
+ GNUNET_i2s (id),
+ (NULL == transport) ? "<none>" : transport,
+ (NULL == transport) ? "<none>" : addr,
+ GNUNET_TRANSPORT_p2s (state),
+ GNUNET_STRINGS_absolute_time_to_string (state_timeout));
+ }
+ else
+ {
+ /* Only connected peers, skip state */
+ FPRINTF (stdout, _("Peer `%s': %s %s\n"), GNUNET_i2s (id), transport,
addr);
+ }
+
+}
+
+static void
process_string (void *cls, const char *address)
{
struct ResolutionContext *rc = cls;
- struct GNUNET_HELLO_Address *addrcp = rc->addrcp;
if (address != NULL )
{
- FPRINTF (stdout, _("Peer `%s': %s %s\n"), GNUNET_i2s (&addrcp->peer),
- addrcp->transport_name, address);
+ print_info (&rc->id, rc->transport, address, rc->state, rc->state_timeout);
rc->printed = GNUNET_YES;
}
else
@@ -664,13 +724,18 @@
{
if (numeric == GNUNET_NO)
{
- resolve_address (rc->addrcp, GNUNET_YES); /* Failed to resolve
address, try numeric lookup */
+ /* Failed to resolve address, try numeric lookup */
+ resolve_address (&rc->id, rc->addrcp, GNUNET_YES,
+ rc->state, rc->state_timeout);
}
else
- FPRINTF (stdout, _("Peer `%s': %s <unable to resolve address>\n"),
- GNUNET_i2s (&addrcp->peer), addrcp->transport_name);
+ {
+ print_info (&rc->id, rc->transport, "<unable to resolve address>",
+ rc->state, rc->state_timeout);
+ }
}
- GNUNET_free(rc->addrcp);
+ GNUNET_free (rc->transport);
+ GNUNET_free (rc->addrcp);
GNUNET_CONTAINER_DLL_remove(rc_head, rc_tail, rc);
GNUNET_free(rc);
if ((0 == address_resolutions) && (iterate_connections))
@@ -692,7 +757,10 @@
}
static void
-resolve_address (const struct GNUNET_HELLO_Address *address, int numeric)
+resolve_address (const struct GNUNET_PeerIdentity *id,
+ const struct GNUNET_HELLO_Address *address, int numeric,
+ enum GNUNET_TRANSPORT_PeerState state,
+ struct GNUNET_TIME_Absolute state_timeout)
{
struct ResolutionContext *rc;
@@ -701,15 +769,19 @@
GNUNET_CONTAINER_DLL_insert(rc_head, rc_tail, rc);
address_resolutions++;
+ rc->id = (*id);
+ rc->transport = GNUNET_strdup(address->transport_name);
rc->addrcp = GNUNET_HELLO_address_copy (address);
rc->printed = GNUNET_NO;
+ rc->state = state;
+ rc->state_timeout = state_timeout;
/* Resolve address to string */
rc->asc = GNUNET_TRANSPORT_address_to_string (cfg, address, numeric,
RESOLUTION_TIMEOUT, &process_string, rc);
}
/**
- * Function called with information about a peers
+ * Function called with information about a peers during a one shot iteration
*
* @param cls closure
* @param peer identity of the peer, NULL for final callback when operation
done
@@ -720,7 +792,7 @@
*
*/
static void
-process_peer_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
+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)
@@ -735,9 +807,52 @@
end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL );
return;
}
- if (address == NULL )
+
+ if ((GNUNET_NO == iterate_all) && (GNUNET_NO ==
GNUNET_TRANSPORT_is_connected(state)) )
+ return; /* Display only connected peers */
+
+ if (GNUNET_SCHEDULER_NO_TASK != op_timeout)
+ GNUNET_SCHEDULER_cancel (op_timeout);
+ op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
+ NULL );
+
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received address for peer `%s': %s\n",
+ GNUNET_i2s (peer), address->transport_name);
+
+ if (NULL != address)
+ resolve_address (peer, address, numeric, state, state_timeout);
+ else
+ print_info (peer, NULL, NULL, state, state_timeout);
+}
+
+
+/**
+ * Function called with information about a peers
+ *
+ * @param cls closure
+ * @param peer identity of the peer, NULL for final callback when operation
done
+ * @param address binary address used to communicate with this peer,
+ * NULL on disconnect or when done
+ * @param state current state this peer is in
+ * @param state_timeout time out for the current state
+ *
+ */
+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)
+{
+ struct MonitoredPeer *m;
+
+ if (peer == NULL )
{
- FPRINTF (stdout, _("Peer `%s' disconnected\n"), GNUNET_i2s (peer));
+ /* done */
+ address_resolution_in_progress = GNUNET_NO;
+ pic = NULL;
+ if (GNUNET_SCHEDULER_NO_TASK != end)
+ GNUNET_SCHEDULER_cancel (end);
+ end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL );
return;
}
@@ -746,9 +861,40 @@
op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
NULL );
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received address for peer `%s': %s\n",
- GNUNET_i2s (peer), address->transport_name);
- resolve_address (address, numeric);
+ if (NULL == (m = GNUNET_CONTAINER_multipeermap_get (monitored_peers, peer)))
+ {
+ m = GNUNET_new (struct MonitoredPeer);
+ GNUNET_CONTAINER_multipeermap_put (monitored_peers, peer,
+ m, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
+ }
+ else
+ {
+ if ( (m->state == state) &&
+ (m->state_timeout.abs_value_us == state_timeout.abs_value_us) &&
+ ((NULL == address) && (NULL == m->address)) )
+ {
+ return; /* No real change */
+ }
+ if ( ((NULL != address) && (NULL != m->address)) &&
+ (0 == GNUNET_HELLO_address_cmp(m->address, address)) )
+ return; /* No real change */
+ }
+
+
+ if (NULL != m->address)
+ {
+ GNUNET_free (m->address);
+ m->address = NULL;
+ }
+ if (NULL != address)
+ m->address = GNUNET_HELLO_address_copy (address);
+ m->state = state;
+ m->state_timeout = state_timeout;
+
+ if (NULL != address)
+ resolve_address (peer, m->address, numeric, m->state, m->state_timeout);
+ else
+ print_info (peer, NULL, NULL, m->state, m->state_timeout);
}
static void
@@ -903,15 +1049,16 @@
{
address_resolution_in_progress = GNUNET_YES;
pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid,
- GNUNET_YES, TIMEOUT, &process_peer_cb, (void *) cfg);
+ GNUNET_YES, TIMEOUT, &process_peer_iteration_cb, (void *) cfg);
op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout,
NULL );
}
else if (monitor_connections) /* -m: List information about peers
continuously */
{
+ monitored_peers = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
address_resolution_in_progress = GNUNET_YES;
pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid,
- GNUNET_NO, TIMEOUT, &process_peer_cb, (void *) cfg);
+ GNUNET_NO, TIMEOUT, &process_peer_monitoring_cb, (void *) cfg);
}
else if (monitor_connects) /* -e : Monitor (dis)connect events continuously
*/
{
Modified: gnunet/src/transport/transport.h
===================================================================
--- gnunet/src/transport/transport.h 2014-01-08 15:02:20 UTC (rev 31840)
+++ gnunet/src/transport/transport.h 2014-01-08 17:51:53 UTC (rev 31841)
@@ -441,7 +441,7 @@
struct PeerIterateResponseMessage
{
/**
- * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE
+ * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE
*/
struct GNUNET_MessageHeader header;
Modified: gnunet/src/transport/transport_api_address_to_string.c
===================================================================
--- gnunet/src/transport/transport_api_address_to_string.c 2014-01-08
15:02:20 UTC (rev 31840)
+++ gnunet/src/transport/transport_api_address_to_string.c 2014-01-08
17:51:53 UTC (rev 31841)
@@ -170,15 +170,15 @@
/**
* Cancel request for address conversion.
*
- * @param alc handle for the request to cancel
+ * @param pic the context handle
*/
void
GNUNET_TRANSPORT_address_to_string_cancel (struct
GNUNET_TRANSPORT_AddressToStringContext
- *alc)
+ *pic)
{
- GNUNET_CLIENT_disconnect (alc->client);
- GNUNET_free (alc);
+ GNUNET_CLIENT_disconnect (pic->client);
+ GNUNET_free (pic);
}
Modified: gnunet/src/transport/transport_api_monitoring.c
===================================================================
--- gnunet/src/transport/transport_api_monitoring.c 2014-01-08 15:02:20 UTC
(rev 31840)
+++ gnunet/src/transport/transport_api_monitoring.c 2014-01-08 17:51:53 UTC
(rev 31841)
@@ -19,7 +19,7 @@
*/
/**
- * @file transport/transport_api_montoring.c
+ * @file transport/transport_api_monitoring.c
* @brief montoring api for transport peer status and validation entries
*
* This api provides the ability to query the transport service about
@@ -450,16 +450,16 @@
* @param one_shot GNUNET_YES to return the current state and then end (with
NULL+NULL),
* GNUNET_NO to monitor the set of addresses used
(continuously, must be explicitly canceled)
* @param timeout how long is the lookup allowed to take at most (irrelevant
if one_shot is set to GNUNET_NO)
- * @param peer_address_callback function to call with the results
- * @param peer_address_callback_cls closure for peer_address_callback
+ * @param peer_callback function to call with the results
+ * @param peer_callback_cls closure for peer_address_callback
*/
struct GNUNET_TRANSPORT_PeerMonitoringContext *
GNUNET_TRANSPORT_monitor_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
const struct GNUNET_PeerIdentity *peer,
int one_shot,
struct GNUNET_TIME_Relative timeout,
- GNUNET_TRANSPORT_PeerIterateCallback peer_address_callback,
- void *peer_address_callback_cls)
+ GNUNET_TRANSPORT_PeerIterateCallback peer_callback,
+ void *peer_callback_cls)
{
struct GNUNET_TRANSPORT_PeerMonitoringContext *pal_ctx;
struct GNUNET_CLIENT_Connection *client;
@@ -470,8 +470,8 @@
if (GNUNET_YES != one_shot)
timeout = GNUNET_TIME_UNIT_FOREVER_REL;
pal_ctx = GNUNET_new (struct GNUNET_TRANSPORT_PeerMonitoringContext);
- pal_ctx->cb = peer_address_callback;
- pal_ctx->cb_cls = peer_address_callback_cls;
+ pal_ctx->cb = peer_callback;
+ pal_ctx->cb_cls = peer_callback_cls;
pal_ctx->cfg = cfg;
pal_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout);
if (NULL != peer)
@@ -485,30 +485,30 @@
/**
- * Cancel request for address conversion.
+ * Cancel request to monitor peers
*
- * @param alc handle for the request to cancel
+ * @param pic handle for the request to cancel
*/
void
-GNUNET_TRANSPORT_monitor_peers_cancel (
- struct GNUNET_TRANSPORT_PeerMonitoringContext *alc)
+GNUNET_TRANSPORT_monitor_peers_cancel (struct
GNUNET_TRANSPORT_PeerMonitoringContext *pic)
{
- if (NULL != alc->client)
+ if (NULL != pic->client)
{
- GNUNET_CLIENT_disconnect (alc->client);
- alc->client = NULL;
+ GNUNET_CLIENT_disconnect (pic->client);
+ pic->client = NULL;
}
- if (GNUNET_SCHEDULER_NO_TASK != alc->reconnect_task)
+ if (GNUNET_SCHEDULER_NO_TASK != pic->reconnect_task)
{
- GNUNET_SCHEDULER_cancel (alc->reconnect_task);
- alc->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_SCHEDULER_cancel (pic->reconnect_task);
+ pic->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
}
- GNUNET_free (alc);
+ GNUNET_free (pic);
}
/**
- * Return information about a peer's or all current pending validation
operations
+ * Return information about pending address validation operations for a
specific
+ * or all peers
*
* @param cfg configuration to use
* @param peer a specific peer identity to obtain validation entries for,
@@ -516,8 +516,8 @@
* @param one_shot GNUNET_YES to return all entries and then end (with
NULL+NULL),
* GNUNET_NO to monitor validation entries continuously
* @param timeout how long is the lookup allowed to take at most
- * @param peer_address_callback function to call with the results
- * @param peer_address_callback_cls closure for peer_address_callback
+ * @param validation_callback function to call with the results
+ * @param validation_callback_cls closure for peer_address_callback
*/
struct GNUNET_TRANSPORT_ValidationMonitoringContext *
GNUNET_TRANSPORT_monitor_validation_entries (const struct
@@ -545,4 +545,4 @@
}
-/* end of transport_api_montoring.c */
+/* end of transport_api_monitoring.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r31841 - in gnunet/src: include transport,
gnunet <=