aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_neighbours.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-07-06 13:24:20 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-07-06 13:24:20 +0000
commit56389a7d277b05c9c2968b7ebd529a12f8be15eb (patch)
tree693ef3440c9db0a2c0662d321f91fcea166176fc /src/transport/gnunet-service-transport_neighbours.c
parent88d047688f2aa11526316fdeaedb4c607bba3cf1 (diff)
downloadgnunet-56389a7d277b05c9c2968b7ebd529a12f8be15eb.tar.gz
gnunet-56389a7d277b05c9c2968b7ebd529a12f8be15eb.zip
- implementation for mantis 0002485
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index cd60ad956..ce407a382 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -595,7 +595,7 @@ static void *callback_cls;
595/** 595/**
596 * Function to call when we connected to a neighbour. 596 * Function to call when we connected to a neighbour.
597 */ 597 */
598static GNUNET_TRANSPORT_NotifyConnect connect_notify_cb; 598static NotifyConnect connect_notify_cb;
599 599
600/** 600/**
601 * Function to call when we disconnected from a neighbour. 601 * Function to call when we disconnected from a neighbour.
@@ -2170,11 +2170,14 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
2170 } 2170 }
2171 2171
2172 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2172 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2173 "ATS tells us to switch to address '%s' session %p for peer `%s' in state %s\n", 2173 "ATS tells us to switch to address '%s' session %p for "
2174 "peer `%s' in state %s (quota in/out %u %u )\n",
2174 (address->address_length != 0) ? GST_plugins_a2s (address): "<inbound>", 2175 (address->address_length != 0) ? GST_plugins_a2s (address): "<inbound>",
2175 session, 2176 session,
2176 GNUNET_i2s (peer), 2177 GNUNET_i2s (peer),
2177 print_state (n->state)); 2178 print_state (n->state),
2179 ntohl (bandwidth_in.value__),
2180 ntohl (bandwidth_out.value__));
2178 2181
2179 if (NULL == session) 2182 if (NULL == session)
2180 { 2183 {
@@ -2634,7 +2637,9 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
2634 gettext_noop ("# peers connected"), 2637 gettext_noop ("# peers connected"),
2635 ++neighbours_connected, 2638 ++neighbours_connected,
2636 GNUNET_NO); 2639 GNUNET_NO);
2637 connect_notify_cb (callback_cls, &n->id, ats, ats_count); 2640 connect_notify_cb (callback_cls, &n->id, ats, ats_count,
2641 n->primary_address.bandwidth_in,
2642 n->primary_address.bandwidth_out);
2638 /* Tell ATS that the outbound session we created to send CONNECT was successfull */ 2643 /* Tell ATS that the outbound session we created to send CONNECT was successfull */
2639 GNUNET_ATS_address_add (GST_ats, 2644 GNUNET_ATS_address_add (GST_ats,
2640 n->primary_address.address, 2645 n->primary_address.address,
@@ -2894,7 +2899,9 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
2894 gettext_noop ("# peers connected"), 2899 gettext_noop ("# peers connected"),
2895 ++neighbours_connected, 2900 ++neighbours_connected,
2896 GNUNET_NO); 2901 GNUNET_NO);
2897 connect_notify_cb (callback_cls, &n->id, ats, ats_count); 2902 connect_notify_cb (callback_cls, &n->id, ats, ats_count,
2903 n->primary_address.bandwidth_in,
2904 n->primary_address.bandwidth_out);
2898 GNUNET_ATS_address_add(GST_ats, 2905 GNUNET_ATS_address_add(GST_ats,
2899 n->primary_address.address, 2906 n->primary_address.address,
2900 n->primary_address.session, 2907 n->primary_address.session,
@@ -3062,7 +3069,25 @@ neighbours_iterate (void *cls, const struct GNUNET_HashCode * key, void *value)
3062 struct NeighbourMapEntry *n = value; 3069 struct NeighbourMapEntry *n = value;
3063 3070
3064 if (GNUNET_YES == test_connected (n)) 3071 if (GNUNET_YES == test_connected (n))
3065 ic->cb (ic->cb_cls, &n->id, NULL, 0, n->primary_address.address); 3072 {
3073 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
3074 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
3075
3076 if (NULL != n->primary_address.address)
3077 {
3078 bandwidth_in = n->primary_address.bandwidth_in;
3079 bandwidth_out = n->primary_address.bandwidth_out;
3080 }
3081 else
3082 {
3083 bandwidth_in = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT;
3084 bandwidth_out = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT;
3085 }
3086
3087 ic->cb (ic->cb_cls, &n->id, NULL, 0,
3088 n->primary_address.address,
3089 bandwidth_in, bandwidth_out);
3090 }
3066 return GNUNET_OK; 3091 return GNUNET_OK;
3067} 3092}
3068 3093
@@ -3180,7 +3205,7 @@ GST_neighbour_get_current_address (const struct GNUNET_PeerIdentity *peer)
3180 */ 3205 */
3181void 3206void
3182GST_neighbours_start (void *cls, 3207GST_neighbours_start (void *cls,
3183 GNUNET_TRANSPORT_NotifyConnect connect_cb, 3208 NotifyConnect connect_cb,
3184 GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb, 3209 GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb,
3185 GNUNET_TRANSPORT_PeerIterateCallback peer_address_cb) 3210 GNUNET_TRANSPORT_PeerIterateCallback peer_address_cb)
3186{ 3211{