aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-17 07:03:29 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-17 07:03:29 +0000
commit7610732f7dc73ec59c5768b707f75cde484e877f (patch)
treecfa9160888e25cb7235eaadd9cbb0c757589e17a /src/ats
parentcdff0fc0f6f3f2b8a0e1ec1b98eba0b3a1aa6faa (diff)
downloadgnunet-7610732f7dc73ec59c5768b707f75cde484e877f.tar.gz
gnunet-7610732f7dc73ec59c5768b707f75cde484e877f.zip
send performance info to clients
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/gnunet-service-ats_addresses.c4
-rw-r--r--src/ats/gnunet-service-ats_performance.c55
-rw-r--r--src/ats/gnunet-service-ats_performance.h24
3 files changed, 83 insertions, 0 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index 3d296dcf6..dcb107590 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -271,6 +271,10 @@ GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer)
271 aa->session_client, aa->session_id, 271 aa->session_client, aa->session_id,
272 aa->ats, aa->ats_count, 272 aa->ats, aa->ats_count,
273 aa->bw_out, aa->bw_in); 273 aa->bw_out, aa->bw_in);
274 GAS_performance_notify_clients (peer, aa->plugin,
275 aa->addr, aa->addr_len,
276 aa->ats, aa->ats_count,
277 aa->bw_out, aa->bw_in);
274} 278}
275 279
276 280
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c
index 1089b6a6d..8a1ad611c 100644
--- a/src/ats/gnunet-service-ats_performance.c
+++ b/src/ats/gnunet-service-ats_performance.c
@@ -134,6 +134,61 @@ GAS_performance_remove_client (struct GNUNET_SERVER_Client *client)
134 134
135 135
136/** 136/**
137 * Transmit the given performance information to all performance
138 * clients.
139 *
140 * @param peer peer for which this is an address suggestion
141 * @param plugin_name 0-termintated string specifying the transport plugin
142 * @param plugin_addr binary address for the plugin to use
143 * @param plugin_addr_len number of bytes in plugin_addr
144 * @param atsi performance data for the address
145 * @param atsi_count number of performance records in 'ats'
146 * @param bandwidth_out assigned outbound bandwidth
147 * @param bandwidth_in assigned inbound bandwidth
148 */
149void
150GAS_performance_notify_clients (const struct GNUNET_PeerIdentity *peer,
151 const char *plugin_name,
152 const void *plugin_addr, size_t plugin_addr_len,
153 const struct GNUNET_TRANSPORT_ATS_Information *atsi,
154 uint32_t atsi_count,
155 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
156 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
157{
158 struct PerformanceClient *pc;
159 struct PeerInformationMessage *msg;
160 size_t plugin_name_length = strlen (plugin_name) + 1;
161 size_t msize = sizeof (struct PeerInformationMessage) + atsi_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)
162 + plugin_addr_len + plugin_name_length;
163 char buf[msize];
164 struct GNUNET_TRANSPORT_ATS_Information *atsp;
165 char *addrp;
166
167 GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE);
168 GNUNET_assert (atsi_count < GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_TRANSPORT_ATS_Information));
169 msg = (struct PeerInformationMessage*) buf;
170 msg->header.size = htons (msize);
171 msg->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION);
172 msg->ats_count = htonl (atsi_count);
173 msg->peer = *peer;
174 msg->address_length = htons (plugin_addr_len);
175 msg->plugin_name_length = htons (plugin_name_length);
176 msg->bandwidth_out = bandwidth_out;
177 msg->bandwidth_in = bandwidth_in;
178 atsp = (struct GNUNET_TRANSPORT_ATS_Information* ) &msg[1];
179 memcpy (atsp, atsi, sizeof (struct GNUNET_TRANSPORT_ATS_Information) * atsi_count);
180 addrp = (char*) &atsp[atsi_count];
181 memcpy (addrp, plugin_addr, plugin_addr_len);
182 strcpy (&addrp[plugin_addr_len], plugin_name);
183 for (pc = pc_head; pc != NULL; pc = pc->next)
184 GNUNET_SERVER_notification_context_unicast (nc,
185 pc->client,
186 &msg->header,
187 GNUNET_YES);
188}
189
190
191/**
137 * Handle 'reservation request' messages from clients. 192 * Handle 'reservation request' messages from clients.
138 * 193 *
139 * @param cls unused, NULL 194 * @param cls unused, NULL
diff --git a/src/ats/gnunet-service-ats_performance.h b/src/ats/gnunet-service-ats_performance.h
index 79ffeb5b3..6dfd11202 100644
--- a/src/ats/gnunet-service-ats_performance.h
+++ b/src/ats/gnunet-service-ats_performance.h
@@ -28,6 +28,7 @@
28#define GNUNET_SERVICE_ATS_PERFORMANCE_H 28#define GNUNET_SERVICE_ATS_PERFORMANCE_H
29 29
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_transport_service.h" // FIXME
31#include "ats.h" 32#include "ats.h"
32 33
33/** 34/**
@@ -52,6 +53,29 @@ GAS_performance_remove_client (struct GNUNET_SERVER_Client *client);
52 53
53 54
54/** 55/**
56 * Transmit the given performance information to all performance
57 * clients.
58 *
59 * @param peer peer for which this is an address suggestion
60 * @param plugin_name 0-termintated string specifying the transport plugin
61 * @param plugin_addr binary address for the plugin to use
62 * @param plugin_addr_len number of bytes in plugin_addr
63 * @param atsi performance data for the address
64 * @param atsi_count number of performance records in 'ats'
65 * @param bandwidth_out assigned outbound bandwidth
66 * @param bandwidth_in assigned inbound bandwidth
67 */
68void
69GAS_performance_notify_clients (const struct GNUNET_PeerIdentity *peer,
70 const char *plugin_name,
71 const void *plugin_addr, size_t plugin_addr_len,
72 const struct GNUNET_TRANSPORT_ATS_Information *atsi,
73 uint32_t atsi_count,
74 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
75 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in);
76
77
78/**
55 * Handle 'reservation request' messages from clients. 79 * Handle 'reservation request' messages from clients.
56 * 80 *
57 * @param cls unused, NULL 81 * @param cls unused, NULL