aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-10-13 13:06:01 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-10-13 13:06:01 +0000
commitf40b9f4d92412da3a1461f16069c8bbb425bd136 (patch)
treea1f9df4553aace1af037e465fe39b0f00a05c116 /src/transport/gnunet-service-transport.c
parent86ad1393cdf6c8b37437c330fce25ebfffbc8ffd (diff)
downloadgnunet-f40b9f4d92412da3a1461f16069c8bbb425bd136.tar.gz
gnunet-f40b9f4d92412da3a1461f16069c8bbb425bd136.zip
compile
Diffstat (limited to 'src/transport/gnunet-service-transport.c')
-rw-r--r--src/transport/gnunet-service-transport.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index ce4c240a7..e551cbf49 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -246,7 +246,6 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
246 break; 246 break;
247 } 247 }
248 } 248 }
249 GNUNET_assert ((ats_count > 0) && (ats != NULL));
250 /* 249 /*
251 FIXME: this gives an address that might not have been validated to 250 FIXME: this gives an address that might not have been validated to
252 ATS for 'selection', which is probably not what we want; this 251 ATS for 'selection', which is probably not what we want; this
@@ -254,9 +253,11 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
254 validation) as 'GNUNET_ATS_address_update' currently ignores 253 validation) as 'GNUNET_ATS_address_update' currently ignores
255 the expiration given. 254 the expiration given.
256 */ 255 */
257 GNUNET_ATS_address_update (GST_ats, peer, GNUNET_TIME_absolute_get (), /* valid at least until right now... */ 256 if ((ats_count > 0) && (ats != NULL))
258 plugin_name, session, sender_address, 257 GNUNET_ATS_address_update (GST_ats, peer,
259 sender_address_len, ats, ats_count); 258 plugin_name, sender_address, sender_address_len,
259 session,
260 ats, ats_count);
260 return ret; 261 return ret;
261} 262}
262 263
@@ -304,7 +305,7 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
304 "Session %X to peer `%s' ended \n", 305 "Session %X to peer `%s' ended \n",
305 session, GNUNET_i2s (peer)); 306 session, GNUNET_i2s (peer));
306#endif 307#endif
307 GNUNET_ATS_session_destroyed(GST_ats, peer, session); 308 GNUNET_ATS_address_destroyed(GST_ats, peer, NULL, NULL, 0, session);
308 GST_neighbours_session_terminated (peer, session); 309 GST_neighbours_session_terminated (peer, session);
309} 310}
310 311
@@ -327,15 +328,32 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
327 */ 328 */
328static void 329static void
329ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer, 330ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer,
330 const char *plugin_name, struct Session *session, 331 const char *plugin_name,
331 const void *plugin_addr, size_t plugin_addr_len, 332 const void *plugin_addr, size_t plugin_addr_len,
333 struct Session *session,
332 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 334 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
333 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) 335 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
334{ 336{
335 GST_neighbours_switch_to_address (peer, plugin_name, plugin_addr, 337 GST_neighbours_switch_to_address (peer, plugin_name, plugin_addr,
336 plugin_addr_len, session, NULL, 0); 338 plugin_addr_len, session, NULL, 0);
337 GST_neighbours_set_incoming_quota (peer, bandwidth_in); 339 GST_neighbours_set_incoming_quota (peer, bandwidth_in);
338 // FIXME: use 'bandwidth_out'! 340
341#if DEBUG_TRANSPORT
342 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending outbound quota of %u Bps for peer `%s' to all clients\n",
343 ntohl (bandwidth_out.value__), GNUNET_i2s (target));
344#endif
345 struct QuotaSetMessage msg;
346 msg.header.size = htons (sizeof (struct QuotaSetMessage));
347 msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA);
348 msg.quota = bandwidth_out;
349 msg.peer = (*peer);
350 GST_clients_broadcast ((struct GNUNET_MessageHeader *) &msg, GNUNET_NO);
351
352#if DEBUG_TRANSPORT
353 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting inbound quota of %u for peer `%s' to \n",
354 ntohl (bandwidth_in.value__), GNUNET_i2s (target));
355#endif
356 GST_neighbours_set_incoming_quota (peer, bandwidth_in);
339} 357}
340 358
341 359
@@ -346,7 +364,7 @@ ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer,
346 * @param cls closure 364 * @param cls closure
347 * @param peer the peer that connected 365 * @param peer the peer that connected
348 * @param ats performance data 366 * @param ats performance data
349 * @param ats_count number of entries in ats (excluding 0-termination) 367 * @param ats_count number of entries in ats
350 */ 368 */
351static void 369static void
352neighbours_connect_notification (void *cls, 370neighbours_connect_notification (void *cls,
@@ -357,16 +375,13 @@ neighbours_connect_notification (void *cls,
357 char buf[sizeof (struct ConnectInfoMessage) + 375 char buf[sizeof (struct ConnectInfoMessage) +
358 ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)]; 376 ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)];
359 struct ConnectInfoMessage *connect_msg = (struct ConnectInfoMessage *) buf; 377 struct ConnectInfoMessage *connect_msg = (struct ConnectInfoMessage *) buf;
360 struct GNUNET_TRANSPORT_ATS_Information *atsm = &connect_msg->ats;
361 378
362 connect_msg->header.size = htons (sizeof (buf)); 379 connect_msg->header.size = htons (sizeof (buf));
363 connect_msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); 380 connect_msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
364 connect_msg->ats_count = htonl (ats_count); 381 connect_msg->ats_count = htonl (ats_count);
365 connect_msg->id = *peer; 382 connect_msg->id = *peer;
366 memcpy (&connect_msg->ats, ats, 383 memcpy (&connect_msg->ats, &connect_msg->ats,
367 ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)); 384 ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information));
368 atsm[ats_count].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
369 atsm[ats_count].value = htonl (0);
370 GST_clients_broadcast (&connect_msg->header, GNUNET_NO); 385 GST_clients_broadcast (&connect_msg->header, GNUNET_NO);
371} 386}
372 387
@@ -405,7 +420,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
405 GST_validation_stop (); 420 GST_validation_stop ();
406 GST_plugins_unload (); 421 GST_plugins_unload ();
407 GST_neighbours_stop (); 422 GST_neighbours_stop ();
408 GNUNET_ATS_shutdown (GST_ats); 423 GNUNET_ATS_scheduling_done (GST_ats);
409 GST_ats = NULL; 424 GST_ats = NULL;
410 GST_clients_stop (); 425 GST_clients_stop ();
411 GST_blacklist_stop (); 426 GST_blacklist_stop ();
@@ -484,7 +499,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
484 GST_plugins_load (&plugin_env_receive_callback, 499 GST_plugins_load (&plugin_env_receive_callback,
485 &plugin_env_address_change_notification, 500 &plugin_env_address_change_notification,
486 &plugin_env_session_end); 501 &plugin_env_session_end);
487 GST_ats = GNUNET_ATS_init (GST_cfg, &ats_request_address_change, NULL); 502 GST_ats = GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, NULL);
488 GST_neighbours_start (NULL, &neighbours_connect_notification, 503 GST_neighbours_start (NULL, &neighbours_connect_notification,
489 &neighbours_disconnect_notification); 504 &neighbours_disconnect_notification);
490 GST_clients_start (server); 505 GST_clients_start (server);