aboutsummaryrefslogtreecommitdiff
path: root/src/dv/gnunet-service-dv.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dv/gnunet-service-dv.c')
-rw-r--r--src/dv/gnunet-service-dv.c52
1 files changed, 5 insertions, 47 deletions
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c
index 93cc0628f..7ea4a300e 100644
--- a/src/dv/gnunet-service-dv.c
+++ b/src/dv/gnunet-service-dv.c
@@ -1159,46 +1159,6 @@ schedule_refresh_routes ()
1159 1159
1160 1160
1161/** 1161/**
1162 * Get distance information from 'atsi'.
1163 *
1164 * @param atsi performance data
1165 * @param atsi_count number of entries in atsi
1166 * @return connected transport distance
1167 */
1168static uint32_t
1169get_atsi_distance (const struct GNUNET_ATS_Information *atsi,
1170 uint32_t atsi_count)
1171{
1172 uint32_t i;
1173
1174 for (i = 0; i < atsi_count; i++)
1175 if (ntohl (atsi[i].type) == GNUNET_ATS_QUALITY_NET_DISTANCE)
1176 return (0 == ntohl (atsi[i].value)) ? DIRECT_NEIGHBOR_COST : ntohl (atsi[i].value); // FIXME: 0 check should not be required once ATS is fixed!
1177 /* If we do not have explicit distance data, assume direct neighbor. */
1178 return DIRECT_NEIGHBOR_COST;
1179}
1180
1181
1182/**
1183 * Get network information from 'atsi'.
1184 *
1185 * @param atsi performance data
1186 * @param atsi_count number of entries in atsi
1187 * @return connected transport network
1188 */
1189static enum GNUNET_ATS_Network_Type
1190get_atsi_network (const struct GNUNET_ATS_Information *atsi,
1191 uint32_t atsi_count)
1192{
1193 uint32_t i;
1194
1195 for (i = 0; i < atsi_count; i++)
1196 if (ntohl (atsi[i].type) == GNUNET_ATS_NETWORK_TYPE)
1197 return (enum GNUNET_ATS_Network_Type) ntohl (atsi[i].value);
1198 return GNUNET_ATS_NET_UNSPECIFIED;
1199}
1200
1201/**
1202 * Multipeermap iterator for freeing routes that go via a particular 1162 * Multipeermap iterator for freeing routes that go via a particular
1203 * neighbor that disconnected and is thus no longer available. 1163 * neighbor that disconnected and is thus no longer available.
1204 * 1164 *
@@ -1308,8 +1268,7 @@ handle_direct_disconnect (struct DirectNeighbor *neighbor)
1308 * #GNUNET_SYSERR if this address is no longer available for ATS 1268 * #GNUNET_SYSERR if this address is no longer available for ATS
1309 * @param bandwidth_out assigned outbound bandwidth for the connection 1269 * @param bandwidth_out assigned outbound bandwidth for the connection
1310 * @param bandwidth_in assigned inbound bandwidth for the connection 1270 * @param bandwidth_in assigned inbound bandwidth for the connection
1311 * @param ats performance data for the address (as far as known) 1271 * @param prop performance data for the address (as far as known)
1312 * @param ats_count number of performance records in @a ats
1313 */ 1272 */
1314static void 1273static void
1315handle_ats_update (void *cls, 1274handle_ats_update (void *cls,
@@ -1317,12 +1276,11 @@ handle_ats_update (void *cls,
1317 int active, 1276 int active,
1318 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 1277 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
1319 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, 1278 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
1320 const struct GNUNET_ATS_Information *ats, 1279 const struct GNUNET_ATS_Properties *prop)
1321 uint32_t ats_count)
1322{ 1280{
1323 struct DirectNeighbor *neighbor; 1281 struct DirectNeighbor *neighbor;
1324 uint32_t distance; 1282 uint32_t distance;
1325 enum GNUNET_ATS_Network_Type network = GNUNET_ATS_NET_UNSPECIFIED; 1283 enum GNUNET_ATS_Network_Type network;
1326 1284
1327 if (NULL == address) 1285 if (NULL == address)
1328 { 1286 {
@@ -1335,8 +1293,8 @@ handle_ats_update (void *cls,
1335 // FIXME: handle disconnect/inactive case too! 1293 // FIXME: handle disconnect/inactive case too!
1336 return; 1294 return;
1337 } 1295 }
1338 distance = get_atsi_distance (ats, ats_count); 1296 distance = prop->distance;
1339 network = get_atsi_network (ats, ats_count); 1297 network = prop->scope;
1340 GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network); 1298 GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network);
1341 /* check if entry exists */ 1299 /* check if entry exists */
1342 neighbor = GNUNET_CONTAINER_multipeermap_get (direct_neighbors, 1300 neighbor = GNUNET_CONTAINER_multipeermap_get (direct_neighbors,