aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-12-18 13:43:19 +0000
committerChristian Grothoff <christian@grothoff.org>2013-12-18 13:43:19 +0000
commit12d65c145ff0f22fc17c84bba20c7f81cc1603f9 (patch)
tree84b230337aeaf879ff9ae7250e8b2c7b738a46d1 /src/transport/gnunet-service-transport.c
parente85f3c49ff318af847a3bbd97571ce25b0ae2752 (diff)
downloadgnunet-12d65c145ff0f22fc17c84bba20c7f81cc1603f9.tar.gz
gnunet-12d65c145ff0f22fc17c84bba20c7f81cc1603f9.zip
pass ATS information for incoming sessions immediately to ATS service
Diffstat (limited to 'src/transport/gnunet-service-transport.c')
-rw-r--r--src/transport/gnunet-service-transport.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 1f8ffd5bc..f54d30e21 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -205,7 +205,7 @@ process_payload (const struct GNUNET_PeerIdentity *peer,
205 return ret; 205 return ret;
206 } 206 }
207 207
208 GST_ats_add_address (address, session); 208 GST_ats_add_address (address, session, NULL, 0);
209 209
210 if (GNUNET_YES != do_forward) 210 if (GNUNET_YES != do_forward)
211 return ret; 211 return ret;
@@ -531,13 +531,17 @@ plugin_env_address_to_type (void *cls,
531 * 531 *
532 * @param address the address 532 * @param address the address
533 * @param session the session 533 * @param session the session
534 * @param ats ats information
535 * @param ats_count number of @a ats information
534 */ 536 */
535void 537void
536GST_ats_add_address (const struct GNUNET_HELLO_Address *address, 538GST_ats_add_address (const struct GNUNET_HELLO_Address *address,
537 struct Session *session) 539 struct Session *session,
540 const struct GNUNET_ATS_Information *ats,
541 uint32_t ats_count)
538{ 542{
539 struct GNUNET_TRANSPORT_PluginFunctions *papi; 543 struct GNUNET_TRANSPORT_PluginFunctions *papi;
540 struct GNUNET_ATS_Information ats; 544 struct GNUNET_ATS_Information ats2[ats_count + 1];
541 uint32_t net; 545 uint32_t net;
542 546
543 /* valid new address, let ATS know! */ 547 /* valid new address, let ATS know! */
@@ -566,8 +570,9 @@ GST_ats_add_address (const struct GNUNET_HELLO_Address *address,
566 address->transport_name); 570 address->transport_name);
567 GNUNET_break (0); 571 GNUNET_break (0);
568 } 572 }
569 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE); 573 ats2[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
570 ats.value = htonl(net); 574 ats2[0].value = htonl(net);
575 memcpy (&ats2[1], ats, sizeof (struct GNUNET_ATS_Information) * ats_count);
571 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 576 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
572 "Notifying ATS about peer `%s''s new address `%s' session %p in network %s\n", 577 "Notifying ATS about peer `%s''s new address `%s' session %p in network %s\n",
573 GNUNET_i2s (&address->peer), 578 GNUNET_i2s (&address->peer),
@@ -575,7 +580,8 @@ GST_ats_add_address (const struct GNUNET_HELLO_Address *address,
575 session, 580 session,
576 GNUNET_ATS_print_network_type(net)); 581 GNUNET_ATS_print_network_type(net));
577 GNUNET_ATS_address_add (GST_ats, 582 GNUNET_ATS_address_add (GST_ats,
578 address, session, &ats, 1); 583 address, session,
584 ats2, ats_count + 1);
579} 585}
580 586
581 587
@@ -704,16 +710,13 @@ plugin_env_session_start (void *cls,
704 } 710 }
705 711
706 addr = GNUNET_HELLO_address_allocate (peer, plugin, address, address_len); 712 addr = GNUNET_HELLO_address_allocate (peer, plugin, address, address_len);
707 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 713 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
708 "Notification from plugin `%s' about new session %p from peer `%s' address `%s'\n", 714 "Notification from plugin `%s' about new session %p from peer `%s' address `%s'\n",
709 plugin, 715 plugin,
710 session, 716 session,
711 GNUNET_i2s (peer), 717 GNUNET_i2s (peer),
712 GST_plugins_a2s (addr)); 718 GST_plugins_a2s (addr));
713 GST_ats_add_address (addr, session); 719 GST_ats_add_address (addr, session, ats, ats_count);
714
715 if (0 < ats_count)
716 GST_ats_update_metrics (peer, addr, session, ats, ats_count);
717 GNUNET_free(addr); 720 GNUNET_free(addr);
718} 721}
719 722