aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_neighbours.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c55
1 files changed, 30 insertions, 25 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 729de12d3..c4886520b 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -1402,7 +1402,7 @@ send_keepalive (struct NeighbourMapEntry *n)
1402 GNUNET_YES, 1402 GNUNET_YES,
1403 NULL, NULL); 1403 NULL, NULL);
1404 GNUNET_STATISTICS_update (GST_stats, 1404 GNUNET_STATISTICS_update (GST_stats,
1405 gettext_noop ("# keepalives sent"), 1405 gettext_noop ("# KEEPALIVES sent"),
1406 1, 1406 1,
1407 GNUNET_NO); 1407 GNUNET_NO);
1408 n->primary_address.keep_alive_nonce = nonce; 1408 n->primary_address.keep_alive_nonce = nonce;
@@ -1428,9 +1428,12 @@ GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour,
1428 struct SessionKeepAliveMessage msg; 1428 struct SessionKeepAliveMessage msg;
1429 1429
1430 if (sizeof (struct SessionKeepAliveMessage) != ntohs (m->size)) 1430 if (sizeof (struct SessionKeepAliveMessage) != ntohs (m->size))
1431 {
1432 GNUNET_break_op (0);
1431 return; 1433 return;
1434 }
1432 1435
1433 msg_in = (struct SessionKeepAliveMessage *) m; 1436 msg_in = (const struct SessionKeepAliveMessage *) m;
1434 if (NULL == (n = lookup_neighbour (neighbour))) 1437 if (NULL == (n = lookup_neighbour (neighbour)))
1435 { 1438 {
1436 GNUNET_STATISTICS_update (GST_stats, 1439 GNUNET_STATISTICS_update (GST_stats,
@@ -1449,8 +1452,9 @@ GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour,
1449 } 1452 }
1450 1453
1451 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1454 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1452 "Received keep alive request from peer `%s' with nonce %u\n", 1455 "Received KEEPALIVE request from peer `%s' with nonce %u\n",
1453 GNUNET_i2s (&n->id), ntohl (msg_in->nonce)); 1456 GNUNET_i2s (&n->id),
1457 ntohl (msg_in->nonce));
1454 1458
1455 /* send reply to allow neighbour to measure latency */ 1459 /* send reply to allow neighbour to measure latency */
1456 msg.header.size = htons (sizeof (struct SessionKeepAliveMessage)); 1460 msg.header.size = htons (sizeof (struct SessionKeepAliveMessage));
@@ -1484,50 +1488,50 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour,
1484 struct GNUNET_TIME_Relative latency; 1488 struct GNUNET_TIME_Relative latency;
1485 1489
1486 if (sizeof (struct SessionKeepAliveMessage) != ntohs (m->size)) 1490 if (sizeof (struct SessionKeepAliveMessage) != ntohs (m->size))
1491 {
1492 GNUNET_break_op (0);
1487 return; 1493 return;
1494 }
1488 1495
1489 msg = (const struct SessionKeepAliveMessage *) m; 1496 msg = (const struct SessionKeepAliveMessage *) m;
1490 if (NULL == (n = lookup_neighbour (neighbour))) 1497 if (NULL == (n = lookup_neighbour (neighbour)))
1491 { 1498 {
1492 GNUNET_STATISTICS_update (GST_stats, 1499 GNUNET_STATISTICS_update (GST_stats,
1493 gettext_noop 1500 gettext_noop ("# KEEPALIVE_RESPONSE messages discarded (not connected)"),
1494 ("# KEEPALIVE_RESPONSE messages discarded (not connected)"), 1501 1,
1495 1, GNUNET_NO); 1502 GNUNET_NO);
1496 return; 1503 return;
1497 } 1504 }
1498 if ( (GNUNET_TRANSPORT_PS_CONNECTED != n->state) || 1505 if ( (GNUNET_TRANSPORT_PS_CONNECTED != n->state) ||
1499 (GNUNET_YES != n->expect_latency_response) ) 1506 (GNUNET_YES != n->expect_latency_response) )
1500 { 1507 {
1501 GNUNET_STATISTICS_update (GST_stats, 1508 GNUNET_STATISTICS_update (GST_stats,
1502 gettext_noop 1509 gettext_noop ("# KEEPALIVE_RESPONSE messages discarded (not expected)"),
1503 ("# KEEPALIVE_RESPONSE messages discarded (not expected)"), 1510 1,
1504 1, GNUNET_NO); 1511 GNUNET_NO);
1505 return; 1512 return;
1506 } 1513 }
1507 if (NULL == n->primary_address.address) 1514 if (NULL == n->primary_address.address)
1508 { 1515 {
1509 GNUNET_STATISTICS_update (GST_stats, 1516 GNUNET_STATISTICS_update (GST_stats,
1510 gettext_noop 1517 gettext_noop ("# KEEPALIVE_RESPONSE messages discarded (address changed)"),
1511 ("# KEEPALIVE_RESPONSE messages discarded (address changed)"), 1518 1,
1512 1, GNUNET_NO); 1519 GNUNET_NO);
1513 return; 1520 return;
1514 } 1521 }
1515 if (n->primary_address.keep_alive_nonce != ntohl (msg->nonce)) 1522 if (n->primary_address.keep_alive_nonce != ntohl (msg->nonce))
1516 { 1523 {
1517 GNUNET_STATISTICS_update (GST_stats, 1524 GNUNET_STATISTICS_update (GST_stats,
1518 gettext_noop 1525 gettext_noop ("# KEEPALIVE_RESPONSE messages discarded (wrong nonce)"),
1519 ("# KEEPALIVE_RESPONSE messages discarded (wrong nonce)"), 1526 1,
1520 1, GNUNET_NO); 1527 GNUNET_NO);
1521 return; 1528 return;
1522 } 1529 }
1523 else 1530 GNUNET_STATISTICS_update (GST_stats,
1524 { 1531 gettext_noop ("# KEEPALIVE_RESPONSE messages received in good order"),
1525 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1532 1,
1526 "Received keep alive response from peer `%s' for session %p\n", 1533 GNUNET_NO);
1527 GNUNET_i2s (&n->id),
1528 n->primary_address.session);
1529 1534
1530 }
1531 1535
1532 /* Update session timeout here */ 1536 /* Update session timeout here */
1533 if (NULL != (papi = GST_plugins_find (n->primary_address.address->transport_name))) 1537 if (NULL != (papi = GST_plugins_find (n->primary_address.address->transport_name)))
@@ -1553,12 +1557,13 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour,
1553 1557
1554 latency = GNUNET_TIME_absolute_get_duration (n->last_keep_alive_time); 1558 latency = GNUNET_TIME_absolute_get_duration (n->last_keep_alive_time);
1555 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1559 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1556 "Latency for peer `%s' is %s\n", 1560 "Received KEEPALIVE_RESPONSE from peer `%s', latency is %s\n",
1557 GNUNET_i2s (&n->id), 1561 GNUNET_i2s (&n->id),
1558 GNUNET_STRINGS_relative_time_to_string (latency, 1562 GNUNET_STRINGS_relative_time_to_string (latency,
1559 GNUNET_YES)); 1563 GNUNET_YES));
1560 GST_ats_update_delay (n->primary_address.address, 1564 GST_ats_update_delay (n->primary_address.address,
1561 GNUNET_TIME_relative_divide (latency, 2)); 1565 GNUNET_TIME_relative_divide (latency,
1566 2));
1562} 1567}
1563 1568
1564 1569