* @param ats performance information (unused)
* @param ats_count number of records in ats (unused)
* @param address the address
+ * @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_ATS_Information *ats,
uint32_t ats_count,
- const struct GNUNET_HELLO_Address *address)
+ const struct GNUNET_HELLO_Address *address,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
{
const struct GNUNET_MessageHeader *hello = cls;
neighbours_connect_notification (void *cls,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ uint32_t ats_count,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
{
size_t len =
sizeof (struct ConnectInfoMessage) +
connect_msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
connect_msg->ats_count = htonl (ats_count);
connect_msg->id = *peer;
+ connect_msg->quota_in = bandwidth_in;
+ connect_msg->quota_out = bandwidth_out;
ap = (struct GNUNET_ATS_Information *) &connect_msg[1];
memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
GST_clients_broadcast (&connect_msg->header, GNUNET_NO);
* @param ats performance data
* @param ats_count number of entries in ats (excluding 0-termination)
* @param address the address
+ * @param bandwidth_in inbound quota in NBO
+ * @param bandwidth_out outbound quota in NBO
*/
static void
test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour,
const struct GNUNET_ATS_Information *ats,
uint32_t ats_count,
- const struct GNUNET_HELLO_Address *address)
+ const struct GNUNET_HELLO_Address *address,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
{
struct TestConnectionContext *tcc = cls;
struct GST_BlacklistCheck *bc;
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *ats,
uint32_t ats_count,
- const struct GNUNET_HELLO_Address *address)
+ const struct GNUNET_HELLO_Address *address,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
{
struct TransportClient *tc = cls;
struct ConnectInfoMessage *cim;
cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
cim->ats_count = htonl (ats_count);
cim->id = *peer;
+ cim->quota_in = bandwidth_in;
+ cim->quota_out = bandwidth_out;
ap = (struct GNUNET_ATS_Information *) &cim[1];
memcpy (ap, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
unicast (tc, &cim->header, GNUNET_NO);
* @param ats performance data
* @param ats_count number of entries in ats (excluding 0-termination)
* @param address the address
+ * @param bandwidth_in inbound quota in NBO
+ * @param bandwidth_out outbound quota in NBO
*/
static void
output_address (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *ats, uint32_t ats_count,
- const struct GNUNET_HELLO_Address *address)
+ const struct GNUNET_HELLO_Address *address,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
{
struct GNUNET_SERVER_TransmitContext *tc = cls;
struct AddressIterateResponseMessage *msg;
/* just return one neighbour */
address = GST_neighbour_get_current_address (&msg->peer);
if (address != NULL)
- output_address (tc, &msg->peer, NULL, 0, address);
+ output_address (tc, &msg->peer, NULL, 0, address,
+ GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
+ GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT);
}
if (GNUNET_YES != ntohl (msg->one_shot))
setup_monitoring_client (client, &msg->peer);
/**
* 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.
}
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;
}
*/
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)
{
#include "gnunet_statistics_service.h"
#include "gnunet_transport_service.h"
#include "gnunet_transport_plugin.h"
+#include "transport.h"
#include "gnunet_util_lib.h"
// TODO:
*/
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);
* @param ats performance data
* @param ats_count number of entries in ats (including 0-termination)
* @param address the address (or NULL)
+ * @param bandwidth_in inbound quota in NBO
+ * @param bandwidth_out outbound quota in NBO
*/
typedef void (*GST_NeighbourIterator) (void *cls,
const struct GNUNET_PeerIdentity *
const struct GNUNET_ATS_Information *
ats, uint32_t ats_count,
const struct GNUNET_HELLO_Address *
- address);
+ address,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out);
/**
*/
#define CONNECTED_LATENCY_EVALUATION_MAX_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
+/**
+ * Similiar to GNUNET_TRANSPORT_NotifyDisconnect but in and out quotas are
+ * included here. These values are not required outside transport_api
+ *
+ * @param cls closure
+ * @param peer the peer that connected
+ * @param ats performance data
+ * @param ats_count number of entries in ats (excluding 0-termination)
+ * @param bandwidth_in inbound bandwidth in NBO
+ * @param bandwidth_out outbound bandwidth in NBO
+ *
+ */
+
+typedef void (*NotifyConnect) (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_ATS_Information *ats,
+ uint32_t ats_count,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out);
+
GNUNET_NETWORK_STRUCT_BEGIN
/**
* Identity of the new neighbour.
*/
struct GNUNET_PeerIdentity id;
+
+ /**
+ * Current inbound quota for this peer
+ */
+ struct GNUNET_BANDWIDTH_Value32NBO quota_in;
+
+ /**
+ * Current outbound quota for this peer
+ */
+ struct GNUNET_BANDWIDTH_Value32NBO quota_out;
};
break;
}
n = neighbour_add (h, &cim->id);
+ GNUNET_BANDWIDTH_tracker_update_quota (&n->out_tracker, cim->quota_out);
if (h->nc_cb != NULL)
h->nc_cb (h->cls, &n->id, ats, ats_count);
break;