diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-11-16 16:35:20 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-11-16 16:35:20 +0000 |
commit | d4ac85e28841ad1940f2c2aeff7de5e804061dc8 (patch) | |
tree | 3866cb2d1671bc3b76fb27cee3075c0e89281e1c | |
parent | 47c29f30a706c4d108e2884e2de1053c3b4e548a (diff) | |
download | gnunet-d4ac85e28841ad1940f2c2aeff7de5e804061dc8.tar.gz gnunet-d4ac85e28841ad1940f2c2aeff7de5e804061dc8.zip |
transmit all ats properties
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 45 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 2 |
2 files changed, 43 insertions, 4 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index aafa90526..d081eb421 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -69,21 +69,53 @@ static int ats_mode; | |||
69 | static int running; | 69 | static int running; |
70 | 70 | ||
71 | 71 | ||
72 | static unsigned int | ||
73 | assemble_ats_information (struct ATS_Address *aa, struct GNUNET_ATS_Information **dest) | ||
74 | { | ||
75 | unsigned int ats_count = GNUNET_ATS_PropertyCount - 1; | ||
76 | struct GNUNET_ATS_Information *ats = GNUNET_malloc (ats_count * sizeof (struct GNUNET_ATS_Information)); | ||
77 | (*dest) = ats; | ||
78 | |||
79 | ats[0].type = ntohl(GNUNET_ATS_UTILIZATION_UP); | ||
80 | ats[0].value = aa->atsp_utilization_out.value__; | ||
81 | ats[1].type = ntohl(GNUNET_ATS_UTILIZATION_DOWN); | ||
82 | ats[1].value = aa->atsp_utilization_in.value__; | ||
83 | ats[2].type = ntohl(GNUNET_ATS_NETWORK_TYPE); | ||
84 | ats[2].value = ntohl(aa->atsp_network_type); | ||
85 | ats[3].type = ntohl(GNUNET_ATS_QUALITY_NET_DELAY); | ||
86 | ats[3].value = ntohl(aa->atsp_latency.rel_value); | ||
87 | ats[4].type = ntohl(GNUNET_ATS_QUALITY_NET_DISTANCE); | ||
88 | ats[4].value = ntohl(aa->atsp_distance); | ||
89 | ats[5].type = ntohl(GNUNET_ATS_COST_WAN); | ||
90 | ats[5].value = ntohl (aa->atsp_cost_wan); | ||
91 | ats[6].type = ntohl(GNUNET_ATS_COST_LAN); | ||
92 | ats[6].value = ntohl (aa->atsp_cost_lan); | ||
93 | ats[7].type = ntohl(GNUNET_ATS_COST_WLAN); | ||
94 | ats[7].value = ntohl (aa->atsp_cost_wlan); | ||
95 | return ats_count; | ||
96 | } | ||
97 | |||
72 | static void | 98 | static void |
73 | send_bw_notification (struct ATS_Address *aa) | 99 | send_bw_notification (struct ATS_Address *aa) |
74 | { | 100 | { |
101 | struct GNUNET_ATS_Information *ats; | ||
102 | uint32_t ats_count; | ||
103 | |||
75 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New bandwidth for peer %s is %u/%u\n", | 104 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New bandwidth for peer %s is %u/%u\n", |
76 | GNUNET_i2s (&aa->peer), ntohl (aa->assigned_bw_in.value__), | 105 | GNUNET_i2s (&aa->peer), ntohl (aa->assigned_bw_in.value__), |
77 | ntohl (aa->assigned_bw_out.value__)); | 106 | ntohl (aa->assigned_bw_out.value__)); |
107 | ats_count = assemble_ats_information (aa, &ats); | ||
108 | |||
78 | GAS_scheduling_transmit_address_suggestion (&aa->peer, aa->plugin, aa->addr, | 109 | GAS_scheduling_transmit_address_suggestion (&aa->peer, aa->plugin, aa->addr, |
79 | aa->addr_len, aa->session_id, | 110 | aa->addr_len, aa->session_id, |
80 | aa->ats, aa->ats_count, | 111 | ats, ats_count, |
81 | aa->assigned_bw_out, | 112 | aa->assigned_bw_out, |
82 | aa->assigned_bw_in); | 113 | aa->assigned_bw_in); |
83 | GAS_reservations_set_bandwidth (&aa->peer, aa->assigned_bw_in); | 114 | GAS_reservations_set_bandwidth (&aa->peer, aa->assigned_bw_in); |
84 | GAS_performance_notify_all_clients (&aa->peer, aa->plugin, aa->addr, aa->addr_len, | 115 | GAS_performance_notify_all_clients (&aa->peer, aa->plugin, aa->addr, aa->addr_len, |
85 | aa->ats, aa->ats_count, aa->assigned_bw_out, | 116 | ats, ats_count, aa->assigned_bw_out, |
86 | aa->assigned_bw_in); | 117 | aa->assigned_bw_in); |
118 | GNUNET_free (ats); | ||
87 | } | 119 | } |
88 | 120 | ||
89 | /** | 121 | /** |
@@ -1121,15 +1153,22 @@ peerinfo_it (void *cls, | |||
1121 | { | 1153 | { |
1122 | struct PeerInfoIteratorContext *pi_ctx = cls; | 1154 | struct PeerInfoIteratorContext *pi_ctx = cls; |
1123 | struct ATS_Address *addr = (struct ATS_Address *) value; | 1155 | struct ATS_Address *addr = (struct ATS_Address *) value; |
1156 | struct GNUNET_ATS_Information *ats; | ||
1157 | uint32_t ats_count; | ||
1124 | 1158 | ||
1125 | if ((NULL != pi_ctx->it) && (GNUNET_YES == addr->used)) | 1159 | if ((NULL != pi_ctx->it) && (GNUNET_YES == addr->used)) |
1160 | { | ||
1161 | ats_count = assemble_ats_information (addr, &ats); | ||
1162 | |||
1126 | pi_ctx->it (pi_ctx->it_cls, | 1163 | pi_ctx->it (pi_ctx->it_cls, |
1127 | &addr->peer, | 1164 | &addr->peer, |
1128 | addr->plugin, | 1165 | addr->plugin, |
1129 | addr->addr, addr->addr_len, | 1166 | addr->addr, addr->addr_len, |
1130 | addr->ats, addr->ats_count, | 1167 | ats, ats_count, |
1131 | addr->assigned_bw_out, | 1168 | addr->assigned_bw_out, |
1132 | addr->assigned_bw_in); | 1169 | addr->assigned_bw_in); |
1170 | GNUNET_free (ats); | ||
1171 | } | ||
1133 | return GNUNET_YES; | 1172 | return GNUNET_YES; |
1134 | } | 1173 | } |
1135 | 1174 | ||
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 9f089caba..932f3bdcb 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -1363,7 +1363,7 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour, | |||
1363 | n->expect_latency_response = GNUNET_NO; | 1363 | n->expect_latency_response = GNUNET_NO; |
1364 | n->latency = GNUNET_TIME_absolute_get_duration (n->last_keep_alive_time); | 1364 | n->latency = GNUNET_TIME_absolute_get_duration (n->last_keep_alive_time); |
1365 | n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | 1365 | n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); |
1366 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1366 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1367 | "Latency for peer `%s' is %llu ms\n", | 1367 | "Latency for peer `%s' is %llu ms\n", |
1368 | GNUNET_i2s (&n->id), n->latency.rel_value); | 1368 | GNUNET_i2s (&n->id), n->latency.rel_value); |
1369 | memcpy (ats_new, ats, sizeof (struct GNUNET_ATS_Information) * ats_count); | 1369 | memcpy (ats_new, ats, sizeof (struct GNUNET_ATS_Information) * ats_count); |