aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_neighbours.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-07-09 15:23:13 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-07-09 15:23:13 +0000
commitdc330efac154fab36391d376265ffe07460b9cfd (patch)
treee9a94f7ed577e926d2e1d5c0a5bfbfd725bf03a5 /src/transport/gnunet-service-transport_neighbours.c
parentd09bb1a4e9fb25c31bf9058c7d61ccf3e376da85 (diff)
downloadgnunet-dc330efac154fab36391d376265ffe07460b9cfd.tar.gz
gnunet-dc330efac154fab36391d376265ffe07460b9cfd.zip
new api function to get network for session
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c119
1 files changed, 103 insertions, 16 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 32a0706dc..4cc75790e 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -1925,6 +1925,9 @@ handle_test_blacklist_cont (void *cls,
1925{ 1925{
1926 struct BlackListCheckContext *bcc = cls; 1926 struct BlackListCheckContext *bcc = cls;
1927 struct NeighbourMapEntry *n; 1927 struct NeighbourMapEntry *n;
1928 struct GNUNET_TRANSPORT_PluginFunctions *papi;
1929 struct GNUNET_ATS_Information ats;
1930 int net;
1928 1931
1929 bcc->bc = NULL; 1932 bcc->bc = NULL;
1930 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1933 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1990,10 +1993,29 @@ handle_test_blacklist_cont (void *cls,
1990 if (GNUNET_OK == result) 1993 if (GNUNET_OK == result)
1991 { 1994 {
1992 /* valid new address, let ATS know! */ 1995 /* valid new address, let ATS know! */
1993 GNUNET_ATS_address_add (GST_ats, 1996 GNUNET_assert (bcc->na.address->transport_name != NULL);
1994 bcc->na.address, 1997 if (NULL == (papi = GST_plugins_find (bcc->na.address->transport_name)))
1995 bcc->na.session, 1998 {
1996 NULL, 0); 1999 /* we don't have the plugin for this address */
2000 GNUNET_break (0);
2001 }
2002 else
2003 {
2004 if (NULL != papi->get_network)
2005 {
2006 net = papi->get_network (NULL, bcc->na.session);
2007 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
2008 ats.value = net;
2009// GNUNET_break (0);
2010// fprintf (stderr, "NET: %u\n", ntohl(net));
2011 GNUNET_ATS_address_add (GST_ats,
2012 bcc->na.address,
2013 bcc->na.session,
2014 &ats, 1);
2015 }
2016 else
2017 GNUNET_break (0);
2018 }
1997 } 2019 }
1998 n->state = S_CONNECT_RECV_ATS; 2020 n->state = S_CONNECT_RECV_ATS;
1999 n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT); 2021 n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
@@ -2755,6 +2777,9 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2755 const struct SessionConnectMessage *scm; 2777 const struct SessionConnectMessage *scm;
2756 struct GNUNET_TIME_Absolute ts; 2778 struct GNUNET_TIME_Absolute ts;
2757 struct NeighbourMapEntry *n; 2779 struct NeighbourMapEntry *n;
2780 struct GNUNET_TRANSPORT_PluginFunctions *papi;
2781 struct GNUNET_ATS_Information ats;
2782 int net;
2758 2783
2759 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2784 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2760 "Received CONNECT_ACK message from peer `%s'\n", 2785 "Received CONNECT_ACK message from peer `%s'\n",
@@ -2802,10 +2827,29 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2802 n->primary_address.bandwidth_in, 2827 n->primary_address.bandwidth_in,
2803 n->primary_address.bandwidth_out); 2828 n->primary_address.bandwidth_out);
2804 /* Tell ATS that the outbound session we created to send CONNECT was successfull */ 2829 /* Tell ATS that the outbound session we created to send CONNECT was successfull */
2805 GNUNET_ATS_address_add (GST_ats, 2830 GNUNET_assert (n->primary_address.address->transport_name != NULL);
2806 n->primary_address.address, 2831 if (NULL == (papi = GST_plugins_find (n->primary_address.address->transport_name)))
2807 n->primary_address.session, 2832 {
2808 NULL, 0); 2833 /* we don't have the plugin for this address */
2834 GNUNET_break (0);
2835 }
2836 else
2837 {
2838 if (NULL != papi->get_network)
2839 {
2840 net = papi->get_network (NULL, n->primary_address.session);
2841 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
2842 ats.value = net;
2843// GNUNET_break (0);
2844// fprintf (stderr, "NET: %u\n", ntohl(net));
2845 GNUNET_ATS_address_add (GST_ats,
2846 n->primary_address.address,
2847 n->primary_address.session,
2848 &ats, 1);
2849 }
2850 else
2851 GNUNET_break (0);
2852 }
2809 set_address (&n->primary_address, 2853 set_address (&n->primary_address,
2810 n->primary_address.address, 2854 n->primary_address.address,
2811 n->primary_address.session, 2855 n->primary_address.session,
@@ -2850,10 +2894,31 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2850 n->state = S_CONNECTED; 2894 n->state = S_CONNECTED;
2851 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 2895 n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
2852 GNUNET_break (GNUNET_NO == n->alternative_address.ats_active); 2896 GNUNET_break (GNUNET_NO == n->alternative_address.ats_active);
2853 GNUNET_ATS_address_add(GST_ats, 2897
2854 n->alternative_address.address, 2898 GNUNET_assert (n->alternative_address.address->transport_name != NULL);
2855 n->alternative_address.session, 2899 if (NULL == (papi = GST_plugins_find (n->alternative_address.address->transport_name)))
2856 NULL, 0); 2900 {
2901 /* we don't have the plugin for this address */
2902 GNUNET_break (0);
2903 }
2904 else
2905 {
2906 if (NULL != papi->get_network)
2907 {
2908 net = papi->get_network (NULL, n->alternative_address.session);
2909 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
2910 ats.value = net;
2911// GNUNET_break (0);
2912// fprintf (stderr, "NET: %u\n", ntohl(net));
2913 GNUNET_ATS_address_add (GST_ats,
2914 n->alternative_address.address,
2915 n->alternative_address.session,
2916 &ats, 1);
2917 }
2918 else
2919 GNUNET_break (0);
2920 }
2921
2857 set_address (&n->primary_address, 2922 set_address (&n->primary_address,
2858 n->alternative_address.address, 2923 n->alternative_address.address,
2859 n->alternative_address.session, 2924 n->alternative_address.session,
@@ -3060,10 +3125,32 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
3060 connect_notify_cb (callback_cls, &n->id, 3125 connect_notify_cb (callback_cls, &n->id,
3061 n->primary_address.bandwidth_in, 3126 n->primary_address.bandwidth_in,
3062 n->primary_address.bandwidth_out); 3127 n->primary_address.bandwidth_out);
3063 GNUNET_ATS_address_add(GST_ats, 3128
3064 n->primary_address.address, 3129 GNUNET_assert (n->primary_address.address->transport_name != NULL);
3065 n->primary_address.session, 3130 struct GNUNET_TRANSPORT_PluginFunctions *papi;
3066 NULL, 0); 3131 if (NULL == (papi = GST_plugins_find (n->primary_address.address->transport_name)))
3132 {
3133 /* we don't have the plugin for this address */
3134 GNUNET_break (0);
3135 }
3136 else
3137 {
3138 if (NULL != papi->get_network)
3139 {
3140 int net = papi->get_network (NULL, n->primary_address.session);
3141 struct GNUNET_ATS_Information ats;
3142 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
3143 ats.value = net;
3144// GNUNET_break (0);
3145// fprintf (stderr, "NET: %u\n", ntohl(net));
3146 GNUNET_ATS_address_add (GST_ats,
3147 n->primary_address.address,
3148 n->primary_address.session,
3149 &ats, 1);
3150 }
3151 else
3152 GNUNET_break (0);
3153 }
3067 set_address (&n->primary_address, 3154 set_address (&n->primary_address,
3068 n->primary_address.address, 3155 n->primary_address.address,
3069 n->primary_address.session, 3156 n->primary_address.session,