aboutsummaryrefslogtreecommitdiff
path: root/src/ats/gnunet-service-ats_scheduling.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-06-14 12:50:27 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-06-14 12:50:27 +0000
commitc18fcd88d8897d0645900a1b6f527232d0153f88 (patch)
tree445441c0ac27a28e747757d7d347c8f44e1df72f /src/ats/gnunet-service-ats_scheduling.c
parent21f92c1b07d8361c270fa08f9f41d78a3e8e18b3 (diff)
downloadgnunet-c18fcd88d8897d0645900a1b6f527232d0153f88.tar.gz
gnunet-c18fcd88d8897d0645900a1b6f527232d0153f88.zip
- adding GNUNET_ATS_address_add functionality .. no changes to scheduling API yet
Diffstat (limited to 'src/ats/gnunet-service-ats_scheduling.c')
-rw-r--r--src/ats/gnunet-service-ats_scheduling.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/ats/gnunet-service-ats_scheduling.c b/src/ats/gnunet-service-ats_scheduling.c
index 0b66ac566..a4c04275f 100644
--- a/src/ats/gnunet-service-ats_scheduling.c
+++ b/src/ats/gnunet-service-ats_scheduling.c
@@ -222,6 +222,64 @@ GAS_handle_reset_backoff (void *cls,
222 GNUNET_SERVER_receive_done (client, GNUNET_OK); 222 GNUNET_SERVER_receive_done (client, GNUNET_OK);
223} 223}
224 224
225/**
226 * Handle 'address add' messages from clients.
227 *
228 * @param cls unused, NULL
229 * @param client client that sent the request
230 * @param message the request message
231 */
232void
233GAS_handle_address_add (void *cls, struct GNUNET_SERVER_Client *client,
234 const struct GNUNET_MessageHeader *message)
235{
236 const struct AddressUpdateMessage *m;
237 const struct GNUNET_ATS_Information *atsi;
238 const char *address;
239 const char *plugin_name;
240 uint16_t address_length;
241 uint16_t plugin_name_length;
242 uint32_t ats_count;
243 uint16_t size;
244
245 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
246 "ADDRESS_ADD");
247 size = ntohs (message->size);
248 if (size < sizeof (struct AddressUpdateMessage))
249 {
250 GNUNET_break (0);
251 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
252 return;
253 }
254 m = (const struct AddressUpdateMessage *) message;
255 ats_count = ntohl (m->ats_count);
256 address_length = ntohs (m->address_length);
257 plugin_name_length = ntohs (m->plugin_name_length);
258 atsi = (const struct GNUNET_ATS_Information *) &m[1];
259 address = (const char *) &atsi[ats_count];
260 if (plugin_name_length != 0)
261 plugin_name = &address[address_length];
262 else
263 plugin_name = "";
264
265 if ((address_length + plugin_name_length +
266 ats_count * sizeof (struct GNUNET_ATS_Information) +
267 sizeof (struct AddressUpdateMessage) != ntohs (message->size)) ||
268 (ats_count >
269 GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information)) ||
270 ((plugin_name_length > 0) && (plugin_name[plugin_name_length - 1] != '\0')))
271 {
272 GNUNET_break (0);
273 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
274 return;
275 }
276 GNUNET_STATISTICS_update (GSA_stats, "# address updates received", 1,
277 GNUNET_NO);
278 GAS_addresses_add (&m->peer, plugin_name, address, address_length,
279 ntohl (m->session_id), atsi, ats_count);
280 GNUNET_SERVER_receive_done (client, GNUNET_OK);
281}
282
225 283
226/** 284/**
227 * Handle 'address update' messages from clients. 285 * Handle 'address update' messages from clients.