[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24536 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24536 - gnunet/src/ats |
Date: |
Thu, 25 Oct 2012 14:33:59 +0200 |
Author: wachs
Date: 2012-10-25 14:33:59 +0200 (Thu, 25 Oct 2012)
New Revision: 24536
Modified:
gnunet/src/ats/gnunet-ats.c
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:
gnunet-ats working and bug 0002593
Modified: gnunet/src/ats/gnunet-ats.c
===================================================================
--- gnunet/src/ats/gnunet-ats.c 2012-10-25 11:57:32 UTC (rev 24535)
+++ gnunet/src/ats/gnunet-ats.c 2012-10-25 12:33:59 UTC (rev 24536)
@@ -51,7 +51,9 @@
GNUNET_ATS_Information *
ats, uint32_t ats_count)
{
- fprintf (stderr, "Peer `%s'\n", GNUNET_i2s (&address->peer));
+ fprintf (stderr, "Peer `%s' plugin `%s', bandwidth out: %u Bytes/s,
bandwidth in %u Bytes/s\n",
+ GNUNET_i2s (&address->peer), address->transport_name,
+ ntohl (bandwidth_out.value__), ntohl (bandwidth_in.value__));
results++;
}
@@ -60,8 +62,7 @@
{
GNUNET_ATS_performance_done (ph);
ph = NULL;
- /*FIXME */fprintf (stderr, "NOT IMPLEMENTED!\n");
- fprintf (stderr, "ATS returned %u addresses\n", results);
+ fprintf (stderr, "ATS returned results for %u addresses\n", results);
ret = 0;
}
@@ -76,7 +77,7 @@
return;
}
- ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
+ ph = GNUNET_ATS_performance_init (cfg, ats_perf_cb, NULL);
if (NULL == ph)
fprintf (stderr, "Cannot connect to ATS service, exiting...\n");
@@ -97,7 +98,7 @@
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
GNUNET_CLIENT_service_test ("ats", cfg,
- GNUNET_TIME_UNIT_SECONDS,
+ GNUNET_TIME_UNIT_MINUTES,
&testservice_task,
(void *) cfg);
}
Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c 2012-10-25 11:57:32 UTC
(rev 24535)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c 2012-10-25 12:33:59 UTC
(rev 24536)
@@ -83,7 +83,7 @@
aa->assigned_bw_out,
aa->assigned_bw_in);
GAS_reservations_set_bandwidth (&aa->peer, aa->assigned_bw_in);
- GAS_performance_notify_clients (&aa->peer, aa->plugin, aa->addr,
aa->addr_len,
+ GAS_performance_notify_all_clients (&aa->peer, aa->plugin, aa->addr,
aa->addr_len,
aa->ats, aa->ats_count, aa->assigned_bw_out,
aa->assigned_bw_in);
}
@@ -1072,7 +1072,7 @@
{
GNUNET_CONTAINER_multihashmap_put(ip_ctx->peers_returned, key, NULL,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
tmp.hashPubKey = (*key);
- ip_ctx->it (ip_ctx, &tmp);
+ ip_ctx->it (ip_ctx->it_cls, &tmp);
}
return GNUNET_OK;
Modified: gnunet/src/ats/gnunet-service-ats_performance.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_performance.c 2012-10-25 11:57:32 UTC
(rev 24535)
+++ gnunet/src/ats/gnunet-service-ats_performance.c 2012-10-25 12:33:59 UTC
(rev 24536)
@@ -93,66 +93,7 @@
return NULL;
}
-static void
-peerinfo_it (void *cls,
- const struct GNUNET_PeerIdentity *id,
- const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t atsi_count,
- struct GNUNET_BANDWIDTH_Value32NBO
- bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
-{
- struct PerformanceClient *pc = cls;
- GNUNET_assert (NULL != pc);
- if (NULL != id)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s' plugin `%s'
BW out %llu, BW in %llu \n",
- GNUNET_i2s (id),
- plugin_name, ntohl (bandwidth_out.value__), ntohl
(bandwidth_in.value__));
- /* TODO: Notify client here! */
- }
-
-}
-
-static void
-peer_it (void *cls,
- const struct GNUNET_PeerIdentity *id)
-{
- if (NULL != id)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s'\n",
GNUNET_i2s (id));
- GAS_addresses_get_peer_info (id, &peerinfo_it, cls);
- }
-}
-
/**
- * Register a new performance client.
- *
- * @param client handle of the new client
- * @param flag flag specifying the type of the client
- */
-void
-GAS_performance_add_client (struct GNUNET_SERVER_Client *client,
- enum StartFlag flag)
-{
- struct PerformanceClient *pc;
-
- GNUNET_break (NULL == find_client (client));
- pc = GNUNET_malloc (sizeof (struct PerformanceClient));
- pc->client = client;
- pc->flag = flag;
- GNUNET_SERVER_notification_context_add (nc, client);
- GNUNET_SERVER_client_keep (client);
- GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc);
-
- /* Send information about clients */
- GAS_addresses_iterate_peers (&peer_it, pc);
-}
-
-
-/**
* Unregister a client (which may have been a performance client,
* but this is not assured).
*
@@ -162,7 +103,6 @@
GAS_performance_remove_client (struct GNUNET_SERVER_Client *client)
{
struct PerformanceClient *pc;
-
pc = find_client (client);
if (NULL == pc)
return;
@@ -171,11 +111,11 @@
GNUNET_free (pc);
}
-
/**
* Transmit the given performance information to all performance
* clients.
*
+ * @param pc performance client to send to
* @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
@@ -186,16 +126,17 @@
* @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_ATS_Information *atsi,
- uint32_t atsi_count,
- struct GNUNET_BANDWIDTH_Value32NBO
- bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO
bandwidth_in)
+GAS_performance_notify_client (struct PerformanceClient *pc,
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr, size_t plugin_addr_len,
+ const struct GNUNET_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 =
@@ -206,6 +147,10 @@
struct GNUNET_ATS_Information *atsp;
char *addrp;
+ GNUNET_assert (NULL != pc);
+ if (NULL == find_client (pc->client))
+ return; /* Client disconnected */
+
GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE);
GNUNET_assert (atsi_count <
GNUNET_SERVER_MAX_MESSAGE_SIZE /
@@ -224,19 +169,115 @@
addrp = (char *) &atsp[atsi_count];
memcpy (addrp, plugin_addr, plugin_addr_len);
strcpy (&addrp[plugin_addr_len], plugin_name);
+ GNUNET_SERVER_notification_context_unicast (nc, pc->client, &msg->header,
+ GNUNET_YES);
+}
+
+
+/**
+ * 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_all_clients (const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr, size_t
plugin_addr_len,
+ const struct GNUNET_ATS_Information *atsi,
+ uint32_t atsi_count,
+ struct GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_out,
+ struct GNUNET_BANDWIDTH_Value32NBO
bandwidth_in)
+{
+ struct PerformanceClient *pc;
+
for (pc = pc_head; pc != NULL; pc = pc->next)
if (pc->flag == START_FLAG_PERFORMANCE_WITH_PIC)
{
- GNUNET_SERVER_notification_context_unicast (nc, pc->client, &msg->header,
- GNUNET_YES);
- GNUNET_STATISTICS_update (GSA_stats,
- "# performance updates given to clients", 1,
- GNUNET_NO);
+ GAS_performance_notify_client (pc,
+ peer,
+ plugin_name, plugin_addr,
plugin_addr_len,
+ atsi, atsi_count,
+ bandwidth_out, bandwidth_in);
}
+
+ GNUNET_STATISTICS_update (GSA_stats,
+ "# performance updates given to clients", 1,
+ GNUNET_NO);
}
+static void
+peerinfo_it (void *cls,
+ const struct GNUNET_PeerIdentity *id,
+ const char *plugin_name,
+ const void *plugin_addr, size_t plugin_addr_len,
+ const struct GNUNET_ATS_Information *atsi,
+ uint32_t atsi_count,
+ struct GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_out,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
+{
+ GNUNET_assert (NULL != cls);
+ if (NULL != id)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s' plugin `%s'
BW out %llu, BW in %llu \n",
+ GNUNET_i2s (id),
+ plugin_name, ntohl (bandwidth_out.value__), ntohl
(bandwidth_in.value__));
+ GAS_performance_notify_client(cls,
+ id,
+ plugin_name, plugin_addr, plugin_addr_len,
+ atsi, atsi_count,
+ bandwidth_out, bandwidth_in);
+ }
+}
+
+static void
+peer_it (void *cls,
+ const struct GNUNET_PeerIdentity *id)
+{
+ if (NULL != id)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s'\n",
GNUNET_i2s (id));
+ GAS_addresses_get_peer_info (id, &peerinfo_it, cls);
+ }
+}
+
/**
+ * Register a new performance client.
+ *
+ * @param client handle of the new client
+ * @param flag flag specifying the type of the client
+ */
+void
+GAS_performance_add_client (struct GNUNET_SERVER_Client *client,
+ enum StartFlag flag)
+{
+ struct PerformanceClient *pc;
+
+ GNUNET_break (NULL == find_client (client));
+ pc = GNUNET_malloc (sizeof (struct PerformanceClient));
+ pc->client = client;
+ pc->flag = flag;
+ GNUNET_SERVER_notification_context_add (nc, client);
+ GNUNET_SERVER_client_keep (client);
+ GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc);
+
+ /* Send information about clients */
+ GAS_addresses_iterate_peers (&peer_it, pc);
+}
+
+
+
+/**
* 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 2012-10-25 11:57:32 UTC
(rev 24535)
+++ gnunet/src/ats/gnunet-service-ats_performance.h 2012-10-25 12:33:59 UTC
(rev 24536)
@@ -66,7 +66,7 @@
* @param bandwidth_in assigned inbound bandwidth
*/
void
-GAS_performance_notify_clients (const struct GNUNET_PeerIdentity *peer,
+GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer,
const char *plugin_name,
const void *plugin_addr, size_t
plugin_addr_len,
const struct GNUNET_ATS_Information *atsi,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24536 - gnunet/src/ats,
gnunet <=