[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r17514 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r17514 - gnunet/src/ats |
Date: |
Mon, 17 Oct 2011 09:03:29 +0200 |
Author: grothoff
Date: 2011-10-17 09:03:29 +0200 (Mon, 17 Oct 2011)
New Revision: 17514
Modified:
gnunet/src/ats/gnunet-service-ats_addresses.c
gnunet/src/ats/gnunet-service-ats_performance.c
gnunet/src/ats/gnunet-service-ats_performance.h
Log:
send performance info to clients
Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c 2011-10-16 23:17:00 UTC
(rev 17513)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c 2011-10-17 07:03:29 UTC
(rev 17514)
@@ -271,6 +271,10 @@
aa->session_client,
aa->session_id,
aa->ats, aa->ats_count,
aa->bw_out, aa->bw_in);
+ GAS_performance_notify_clients (peer, aa->plugin,
+ aa->addr, aa->addr_len,
+ aa->ats, aa->ats_count,
+ aa->bw_out, aa->bw_in);
}
Modified: gnunet/src/ats/gnunet-service-ats_performance.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_performance.c 2011-10-16 23:17:00 UTC
(rev 17513)
+++ gnunet/src/ats/gnunet-service-ats_performance.c 2011-10-17 07:03:29 UTC
(rev 17514)
@@ -134,6 +134,61 @@
/**
+ * Transmit the given performance information to all performance
+ * clients.
+ *
+ * @param peer peer for which this is an address suggestion
+ * @param plugin_name 0-termintated string specifying the transport plugin
+ * @param plugin_addr binary address for the plugin to use
+ * @param plugin_addr_len number of bytes in plugin_addr
+ * @param atsi performance data for the address
+ * @param atsi_count number of performance records in 'ats'
+ * @param bandwidth_out assigned outbound bandwidth
+ * @param bandwidth_in assigned inbound bandwidth
+ */
+void
+GAS_performance_notify_clients (const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr, size_t plugin_addr_len,
+ const struct GNUNET_TRANSPORT_ATS_Information
*atsi,
+ uint32_t atsi_count,
+ struct GNUNET_BANDWIDTH_Value32NBO
bandwidth_out,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
+{
+ struct PerformanceClient *pc;
+ struct PeerInformationMessage *msg;
+ size_t plugin_name_length = strlen (plugin_name) + 1;
+ size_t msize = sizeof (struct PeerInformationMessage) + atsi_count * sizeof
(struct GNUNET_TRANSPORT_ATS_Information)
+ + plugin_addr_len + plugin_name_length;
+ char buf[msize];
+ struct GNUNET_TRANSPORT_ATS_Information *atsp;
+ char *addrp;
+
+ GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE);
+ GNUNET_assert (atsi_count < GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct
GNUNET_TRANSPORT_ATS_Information));
+ msg = (struct PeerInformationMessage*) buf;
+ msg->header.size = htons (msize);
+ msg->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION);
+ msg->ats_count = htonl (atsi_count);
+ msg->peer = *peer;
+ msg->address_length = htons (plugin_addr_len);
+ msg->plugin_name_length = htons (plugin_name_length);
+ msg->bandwidth_out = bandwidth_out;
+ msg->bandwidth_in = bandwidth_in;
+ atsp = (struct GNUNET_TRANSPORT_ATS_Information* ) &msg[1];
+ memcpy (atsp, atsi, sizeof (struct GNUNET_TRANSPORT_ATS_Information) *
atsi_count);
+ addrp = (char*) &atsp[atsi_count];
+ memcpy (addrp, plugin_addr, plugin_addr_len);
+ strcpy (&addrp[plugin_addr_len], plugin_name);
+ for (pc = pc_head; pc != NULL; pc = pc->next)
+ GNUNET_SERVER_notification_context_unicast (nc,
+ pc->client,
+ &msg->header,
+ GNUNET_YES);
+}
+
+
+/**
* Handle 'reservation request' messages from clients.
*
* @param cls unused, NULL
Modified: gnunet/src/ats/gnunet-service-ats_performance.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_performance.h 2011-10-16 23:17:00 UTC
(rev 17513)
+++ gnunet/src/ats/gnunet-service-ats_performance.h 2011-10-17 07:03:29 UTC
(rev 17514)
@@ -28,6 +28,7 @@
#define GNUNET_SERVICE_ATS_PERFORMANCE_H
#include "gnunet_util_lib.h"
+#include "gnunet_transport_service.h" // FIXME
#include "ats.h"
/**
@@ -52,6 +53,29 @@
/**
+ * Transmit the given performance information to all performance
+ * clients.
+ *
+ * @param peer peer for which this is an address suggestion
+ * @param plugin_name 0-termintated string specifying the transport plugin
+ * @param plugin_addr binary address for the plugin to use
+ * @param plugin_addr_len number of bytes in plugin_addr
+ * @param atsi performance data for the address
+ * @param atsi_count number of performance records in 'ats'
+ * @param bandwidth_out assigned outbound bandwidth
+ * @param bandwidth_in assigned inbound bandwidth
+ */
+void
+GAS_performance_notify_clients (const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr, size_t plugin_addr_len,
+ const struct GNUNET_TRANSPORT_ATS_Information
*atsi,
+ uint32_t atsi_count,
+ struct GNUNET_BANDWIDTH_Value32NBO
bandwidth_out,
+ struct GNUNET_BANDWIDTH_Value32NBO
bandwidth_in);
+
+
+/**
* Handle 'reservation request' messages from clients.
*
* @param cls unused, NULL
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r17514 - gnunet/src/ats,
gnunet <=