diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-07 22:06:02 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-07 22:06:02 +0000 |
commit | f8c0f7d5c566bbddc2909eceeb63e6ecee591d70 (patch) | |
tree | cb03a293b5a5372f18bb114b01d02fd48d76865d /src/transport/gnunet-service-transport_neighbours.c | |
parent | 174ab5aba2bdfde8a4614bf0069a33a7bbe57ce7 (diff) | |
download | gnunet-f8c0f7d5c566bbddc2909eceeb63e6ecee591d70.tar.gz gnunet-f8c0f7d5c566bbddc2909eceeb63e6ecee591d70.zip |
more code to get latency in ATSI working; not complete, also now generating a warning -- for a real problem that still needs to be fixed
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 68 |
1 files changed, 63 insertions, 5 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 32ac7c05d..e7d458e7f 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -870,6 +870,12 @@ disconnect_neighbour (struct NeighbourMapEntry *n) | |||
870 | if (is_disconnecting (n)) | 870 | if (is_disconnecting (n)) |
871 | return; | 871 | return; |
872 | change_state (n, S_DISCONNECT); | 872 | change_state (n, S_DISCONNECT); |
873 | GST_validation_set_address_use (&n->id, | ||
874 | n->plugin_name, | ||
875 | n->session, | ||
876 | n->addr, | ||
877 | n->addrlen, | ||
878 | GNUNET_NO); | ||
873 | 879 | ||
874 | if (n->plugin_name != NULL) | 880 | if (n->plugin_name != NULL) |
875 | { | 881 | { |
@@ -1301,7 +1307,13 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
1301 | return GNUNET_NO; | 1307 | return GNUNET_NO; |
1302 | } | 1308 | } |
1303 | } | 1309 | } |
1304 | 1310 | if (n->state == S_CONNECTED) | |
1311 | GST_validation_set_address_use (&n->id, | ||
1312 | n->plugin_name, | ||
1313 | n->session, | ||
1314 | n->addr, | ||
1315 | n->addrlen, | ||
1316 | GNUNET_NO); | ||
1305 | GNUNET_free_non_null (n->addr); | 1317 | GNUNET_free_non_null (n->addr); |
1306 | n->addr = GNUNET_malloc (address_len); | 1318 | n->addr = GNUNET_malloc (address_len); |
1307 | memcpy (n->addr, address, address_len); | 1319 | memcpy (n->addr, address, address_len); |
@@ -1315,6 +1327,14 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
1315 | n->timeout_task = | 1327 | n->timeout_task = |
1316 | GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | 1328 | GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, |
1317 | &neighbour_timeout_task, n); | 1329 | &neighbour_timeout_task, n); |
1330 | if (n->state == S_CONNECTED) | ||
1331 | GST_validation_set_address_use (&n->id, | ||
1332 | n->plugin_name, | ||
1333 | n->session, | ||
1334 | n->addr, | ||
1335 | n->addrlen, | ||
1336 | GNUNET_YES); | ||
1337 | |||
1318 | 1338 | ||
1319 | if (n->state == S_DISCONNECT) | 1339 | if (n->state == S_DISCONNECT) |
1320 | { | 1340 | { |
@@ -1400,6 +1420,29 @@ GST_neighbours_switch_to_address_3way (const struct GNUNET_PeerIdentity *peer, | |||
1400 | 1420 | ||
1401 | 1421 | ||
1402 | /** | 1422 | /** |
1423 | * Obtain current latency information for the given neighbour. | ||
1424 | * | ||
1425 | * @param peer | ||
1426 | * @return observed latency of the address, FOREVER if the address was | ||
1427 | * never successfully validated | ||
1428 | */ | ||
1429 | struct GNUNET_TIME_Relative | ||
1430 | GST_neighbour_get_latency (const struct GNUNET_PeerIdentity *peer) | ||
1431 | { | ||
1432 | struct NeighbourMapEntry *n; | ||
1433 | |||
1434 | n = lookup_neighbour (peer); | ||
1435 | if (NULL == n) | ||
1436 | return GNUNET_TIME_UNIT_FOREVER_REL; | ||
1437 | return GST_validation_get_address_latency (peer, | ||
1438 | n->plugin_name, | ||
1439 | n->session, | ||
1440 | n->addr, | ||
1441 | n->addrlen); | ||
1442 | } | ||
1443 | |||
1444 | |||
1445 | /** | ||
1403 | * Create an entry in the neighbour map for the given peer | 1446 | * Create an entry in the neighbour map for the given peer |
1404 | * | 1447 | * |
1405 | * @param peer peer to create an entry for | 1448 | * @param peer peer to create an entry for |
@@ -2042,7 +2085,15 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message, | |||
2042 | 2085 | ||
2043 | was_connected = is_connected (n); | 2086 | was_connected = is_connected (n); |
2044 | if (!is_connected (n)) | 2087 | if (!is_connected (n)) |
2088 | { | ||
2045 | change_state (n, S_CONNECTED); | 2089 | change_state (n, S_CONNECTED); |
2090 | GST_validation_set_address_use (&n->id, | ||
2091 | n->plugin_name, | ||
2092 | n->session, | ||
2093 | n->addr, | ||
2094 | n->addrlen, | ||
2095 | GNUNET_YES); | ||
2096 | } | ||
2046 | 2097 | ||
2047 | GNUNET_ATS_address_in_use (GST_ats, &n->id, n->plugin_name, n->addr, | 2098 | GNUNET_ATS_address_in_use (GST_ats, &n->id, n->plugin_name, n->addr, |
2048 | n->addrlen, n->addr, GNUNET_YES); | 2099 | n->addrlen, n->addr, GNUNET_YES); |
@@ -2174,6 +2225,12 @@ GST_neighbours_handle_ack (const struct GNUNET_MessageHeader *message, | |||
2174 | 2225 | ||
2175 | if (!was_connected) | 2226 | if (!was_connected) |
2176 | { | 2227 | { |
2228 | GST_validation_set_address_use (&n->id, | ||
2229 | n->plugin_name, | ||
2230 | n->session, | ||
2231 | n->addr, | ||
2232 | n->addrlen, | ||
2233 | GNUNET_YES); | ||
2177 | neighbours_connected++; | 2234 | neighbours_connected++; |
2178 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, | 2235 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1, |
2179 | GNUNET_NO); | 2236 | GNUNET_NO); |
@@ -2333,19 +2390,20 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message, | |||
2333 | /* do blacklist check */ | 2390 | /* do blacklist check */ |
2334 | bcc = | 2391 | bcc = |
2335 | GNUNET_malloc (sizeof (struct BlackListCheckContext) + | 2392 | GNUNET_malloc (sizeof (struct BlackListCheckContext) + |
2336 | sizeof (struct GNUNET_ATS_Information) * ats_count + | 2393 | sizeof (struct GNUNET_ATS_Information) * (ats_count + 1) + |
2337 | sender_address_len + strlen (plugin_name) + 1); | 2394 | sender_address_len + strlen (plugin_name) + 1); |
2338 | 2395 | ||
2339 | bcc->ts = GNUNET_TIME_absolute_ntoh (scm->timestamp); | 2396 | bcc->ts = GNUNET_TIME_absolute_ntoh (scm->timestamp); |
2340 | 2397 | ||
2341 | bcc->ats_count = ats_count; | 2398 | bcc->ats_count = ats_count + 1; |
2342 | bcc->sender_address_len = sender_address_len; | 2399 | bcc->sender_address_len = sender_address_len; |
2343 | bcc->session = session; | 2400 | bcc->session = session; |
2344 | 2401 | ||
2345 | bcc->ats = (struct GNUNET_ATS_Information *) &bcc[1]; | 2402 | bcc->ats = (struct GNUNET_ATS_Information *) &bcc[1]; |
2346 | memcpy (bcc->ats, ats, sizeof (struct GNUNET_ATS_Information) * ats_count); | 2403 | memcpy (bcc->ats, ats, sizeof (struct GNUNET_ATS_Information) * ats_count); |
2347 | 2404 | bcc->ats[ats_count].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); | |
2348 | bcc->sender_address = (char *) &bcc->ats[ats_count]; | 2405 | bcc->ats[ats_count].value = htonl ((uint32_t) GST_neighbour_get_latency (peer).rel_value); |
2406 | bcc->sender_address = (char *) &bcc->ats[ats_count + 1]; | ||
2349 | memcpy (bcc->sender_address, sender_address, sender_address_len); | 2407 | memcpy (bcc->sender_address, sender_address, sender_address_len); |
2350 | 2408 | ||
2351 | bcc->plugin_name = &bcc->sender_address[sender_address_len]; | 2409 | bcc->plugin_name = &bcc->sender_address[sender_address_len]; |