/**
* Function to call when we connected to a neighbour.
*/
-static GNUNET_TRANSPORT_NotifyConnect connect_notify_cb;
+static NotifyConnect connect_notify_cb;
/**
* Function to call when we disconnected from a neighbour.
return "S_DISCONNECT_FINISHED";
break;
default:
- return "UNDEFINED";
GNUNET_break (0);
+ return "UNDEFINED";
break;
}
GNUNET_break (0);
{
struct MessageQueue *mq;
struct GNUNET_TRANSPORT_PluginFunctions *papi;
- //struct GNUNET_HELLO_Address *old_address;
+ struct GNUNET_HELLO_Address *backup_primary;
n->is_active = NULL; /* always free'd by its own continuation! */
disconnect_notify_cb (callback_cls, &n->id);
}
+ n->state = S_DISCONNECT_FINISHED;
- /* cut transport-level connection */
- //old_address = GNUNET_HELLO_address_copy(n->primary_address.address);
-
+ if (NULL != n->primary_address.address)
+ backup_primary = GNUNET_HELLO_address_copy(n->primary_address.address);
+ else
+ backup_primary = NULL;
+ /* free addresses and mark as unused */
+ free_address (&n->primary_address);
+ free_address (&n->alternative_address);
/* FIXME-PLUGIN-API: This does not seem to guarantee that all
transport sessions eventually get killed due to inactivity; they
them! Killing all sessions like this seems to be very, very
wrong. */
+ /* cut transport-level connection */
if ((GNUNET_NO == keep_sessions) &&
- (NULL != n->primary_address.address) &&
- (NULL != (papi = GST_plugins_find (n->primary_address.address->transport_name))))
+ (NULL != backup_primary) &&
+ (NULL != (papi = GST_plugins_find (backup_primary->transport_name))))
papi->disconnect (papi->cls, &n->id);
-
- n->state = S_DISCONNECT_FINISHED;
-
- free_address (&n->primary_address);
- free_address (&n->alternative_address);
+ GNUNET_free_non_null (backup_primary);
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (neighbours,
/* fallthrough */
case S_INIT_BLACKLIST:
case S_CONNECT_SENT:
+ case S_CONNECT_RECV_BLACKLIST_INBOUND:
case S_CONNECT_RECV_ATS:
case S_CONNECT_RECV_BLACKLIST:
case S_CONNECT_RECV_ACK:
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ATS tells us to switch to address '%s' session %p for peer `%s' in state %s\n",
+ "ATS tells us to switch to address '%s' session %p for "
+ "peer `%s' in state %s (quota in/out %u %u )\n",
(address->address_length != 0) ? GST_plugins_a2s (address): "<inbound>",
session,
GNUNET_i2s (peer),
- print_state (n->state));
+ print_state (n->state),
+ ntohl (bandwidth_in.value__),
+ ntohl (bandwidth_out.value__));
if (NULL == session)
{
gettext_noop ("# peers connected"),
++neighbours_connected,
GNUNET_NO);
- connect_notify_cb (callback_cls, &n->id, ats, ats_count);
+ connect_notify_cb (callback_cls, &n->id, ats, ats_count,
+ n->primary_address.bandwidth_in,
+ n->primary_address.bandwidth_out);
/* Tell ATS that the outbound session we created to send CONNECT was successfull */
GNUNET_ATS_address_add (GST_ats,
n->primary_address.address,
gettext_noop ("# peers connected"),
++neighbours_connected,
GNUNET_NO);
- connect_notify_cb (callback_cls, &n->id, ats, ats_count);
+ connect_notify_cb (callback_cls, &n->id, ats, ats_count,
+ n->primary_address.bandwidth_in,
+ n->primary_address.bandwidth_out);
GNUNET_ATS_address_add(GST_ats,
n->primary_address.address,
n->primary_address.session,
struct NeighbourMapEntry *n = value;
if (GNUNET_YES == test_connected (n))
- ic->cb (ic->cb_cls, &n->id, NULL, 0, n->primary_address.address);
+ {
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
+
+ if (NULL != n->primary_address.address)
+ {
+ bandwidth_in = n->primary_address.bandwidth_in;
+ bandwidth_out = n->primary_address.bandwidth_out;
+ }
+ else
+ {
+ bandwidth_in = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT;
+ bandwidth_out = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT;
+ }
+
+ ic->cb (ic->cb_cls, &n->id, NULL, 0,
+ n->primary_address.address,
+ bandwidth_in, bandwidth_out);
+ }
return GNUNET_OK;
}
switch (n->state)
{
case S_CONNECTED:
+ case S_CONNECTED_SWITCHING_CONNECT_SENT:
+ case S_CONNECTED_SWITCHING_BLACKLIST:
case S_RECONNECT_SENT:
case S_RECONNECT_ATS:
+ case S_RECONNECT_BLACKLIST:
return n->latency;
case S_NOT_CONNECTED:
case S_INIT_BLACKLIST:
case S_INIT_ATS:
case S_CONNECT_RECV_BLACKLIST_INBOUND:
- case S_CONNECT_SENT:
+ case S_CONNECT_RECV_ATS:
case S_CONNECT_RECV_BLACKLIST:
+ case S_CONNECT_RECV_ACK:
+ case S_CONNECT_SENT:
case S_DISCONNECT:
case S_DISCONNECT_FINISHED:
return GNUNET_TIME_UNIT_FOREVER_REL;
*/
void
GST_neighbours_start (void *cls,
- GNUNET_TRANSPORT_NotifyConnect connect_cb,
+ NotifyConnect connect_cb,
GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb,
GNUNET_TRANSPORT_PeerIterateCallback peer_address_cb)
{