diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/transport/gnunet-service-transport.c | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/transport/gnunet-service-transport.c')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 900 |
1 files changed, 398 insertions, 502 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 4f962d117..5b0a58fac 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -1065,8 +1065,7 @@ is_blacklisted (const struct GNUNET_PeerIdentity *peer, | |||
1065 | (plugin->blacklist, &peer->hashPubKey) == GNUNET_YES) | 1065 | (plugin->blacklist, &peer->hashPubKey) == GNUNET_YES) |
1066 | { | 1066 | { |
1067 | #if DEBUG_BLACKLIST | 1067 | #if DEBUG_BLACKLIST |
1068 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1068 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s:%s' is blacklisted!\n", |
1069 | "Peer `%s:%s' is blacklisted!\n", | ||
1070 | plugin->short_name, GNUNET_i2s (peer)); | 1069 | plugin->short_name, GNUNET_i2s (peer)); |
1071 | #endif | 1070 | #endif |
1072 | if (stats != NULL) | 1071 | if (stats != NULL) |
@@ -1097,8 +1096,7 @@ add_peer_to_blacklist (struct GNUNET_PeerIdentity *peer, char *transport_name) | |||
1097 | plugin->blacklist = | 1096 | plugin->blacklist = |
1098 | GNUNET_CONTAINER_multihashmap_create (TRANSPORT_BLACKLIST_HT_SIZE); | 1097 | GNUNET_CONTAINER_multihashmap_create (TRANSPORT_BLACKLIST_HT_SIZE); |
1099 | GNUNET_assert (plugin->blacklist != NULL); | 1098 | GNUNET_assert (plugin->blacklist != NULL); |
1100 | GNUNET_CONTAINER_multihashmap_put (plugin->blacklist, &peer->hashPubKey, | 1099 | GNUNET_CONTAINER_multihashmap_put (plugin->blacklist, &peer->hashPubKey, NULL, |
1101 | NULL, | ||
1102 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); | 1100 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); |
1103 | } | 1101 | } |
1104 | 1102 | ||
@@ -1124,8 +1122,7 @@ read_blacklist_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1124 | char *transport_name; | 1122 | char *transport_name; |
1125 | 1123 | ||
1126 | if (GNUNET_OK != | 1124 | if (GNUNET_OK != |
1127 | GNUNET_CONFIGURATION_get_value_filename (cfg, | 1125 | GNUNET_CONFIGURATION_get_value_filename (cfg, "TRANSPORT", |
1128 | "TRANSPORT", | ||
1129 | "BLACKLIST_FILE", &fn)) | 1126 | "BLACKLIST_FILE", &fn)) |
1130 | { | 1127 | { |
1131 | #if DEBUG_TRANSPORT | 1128 | #if DEBUG_TRANSPORT |
@@ -1136,8 +1133,9 @@ read_blacklist_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1136 | return; | 1133 | return; |
1137 | } | 1134 | } |
1138 | if (GNUNET_OK != GNUNET_DISK_file_test (fn)) | 1135 | if (GNUNET_OK != GNUNET_DISK_file_test (fn)) |
1139 | GNUNET_DISK_fn_write (fn, NULL, 0, GNUNET_DISK_PERM_USER_READ | 1136 | GNUNET_DISK_fn_write (fn, NULL, 0, |
1140 | | GNUNET_DISK_PERM_USER_WRITE); | 1137 | GNUNET_DISK_PERM_USER_READ | |
1138 | GNUNET_DISK_PERM_USER_WRITE); | ||
1141 | if (0 != STAT (fn, &frstat)) | 1139 | if (0 != STAT (fn, &frstat)) |
1142 | { | 1140 | { |
1143 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1141 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1148,8 +1146,8 @@ read_blacklist_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1148 | if (frstat.st_size == 0) | 1146 | if (frstat.st_size == 0) |
1149 | { | 1147 | { |
1150 | #if DEBUG_TRANSPORT | 1148 | #if DEBUG_TRANSPORT |
1151 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1149 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklist file `%s' is empty.\n"), |
1152 | _("Blacklist file `%s' is empty.\n"), fn); | 1150 | fn); |
1153 | #endif | 1151 | #endif |
1154 | GNUNET_free (fn); | 1152 | GNUNET_free (fn); |
1155 | return; | 1153 | return; |
@@ -1225,8 +1223,8 @@ read_blacklist_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1225 | #endif | 1223 | #endif |
1226 | memcpy (&enc, &data[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); | 1224 | memcpy (&enc, &data[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); |
1227 | if (!isspace | 1225 | if (!isspace |
1228 | ((unsigned char) | 1226 | ((unsigned char) enc. |
1229 | enc.encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1])) | 1227 | encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1])) |
1230 | { | 1228 | { |
1231 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1229 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1232 | _ | 1230 | _ |
@@ -1338,11 +1336,11 @@ transmit_to_client_callback (void *cls, size_t size, void *buf) | |||
1338 | if (NULL != q) | 1336 | if (NULL != q) |
1339 | { | 1337 | { |
1340 | GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader)); | 1338 | GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader)); |
1341 | client->th = GNUNET_SERVER_notify_transmit_ready (client->client, | 1339 | client->th = |
1342 | msize, | 1340 | GNUNET_SERVER_notify_transmit_ready (client->client, msize, |
1343 | GNUNET_TIME_UNIT_FOREVER_REL, | 1341 | GNUNET_TIME_UNIT_FOREVER_REL, |
1344 | &transmit_to_client_callback, | 1342 | &transmit_to_client_callback, |
1345 | client); | 1343 | client); |
1346 | GNUNET_assert (client->th != NULL); | 1344 | GNUNET_assert (client->th != NULL); |
1347 | } | 1345 | } |
1348 | return tsize; | 1346 | return tsize; |
@@ -1419,11 +1417,10 @@ timeout_hello_validation (void *cls, | |||
1419 | 1417 | ||
1420 | va->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 1418 | va->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
1421 | GNUNET_STATISTICS_update (stats, | 1419 | GNUNET_STATISTICS_update (stats, |
1422 | gettext_noop ("# address validation timeouts"), | 1420 | gettext_noop ("# address validation timeouts"), 1, |
1423 | 1, GNUNET_NO); | 1421 | GNUNET_NO); |
1424 | GNUNET_CRYPTO_hash (&va->publicKey, | 1422 | GNUNET_CRYPTO_hash (&va->publicKey, |
1425 | sizeof (struct | 1423 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
1426 | GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
1427 | &pid.hashPubKey); | 1424 | &pid.hashPubKey); |
1428 | GNUNET_break (GNUNET_OK == | 1425 | GNUNET_break (GNUNET_OK == |
1429 | GNUNET_CONTAINER_multihashmap_remove (validation_map, | 1426 | GNUNET_CONTAINER_multihashmap_remove (validation_map, |
@@ -1464,8 +1461,8 @@ transmit_to_client (struct TransportClient *client, | |||
1464 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1461 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1465 | _ | 1462 | _ |
1466 | ("Dropping message of type %u and size %u, have %u messages pending (%u is the soft limit)\n"), | 1463 | ("Dropping message of type %u and size %u, have %u messages pending (%u is the soft limit)\n"), |
1467 | ntohs (msg->type), | 1464 | ntohs (msg->type), ntohs (msg->size), client->message_count, |
1468 | ntohs (msg->size), client->message_count, MAX_PENDING); | 1465 | MAX_PENDING); |
1469 | GNUNET_STATISTICS_update (stats, | 1466 | GNUNET_STATISTICS_update (stats, |
1470 | gettext_noop | 1467 | gettext_noop |
1471 | ("# messages dropped due to slow client"), 1, | 1468 | ("# messages dropped due to slow client"), 1, |
@@ -1481,11 +1478,11 @@ transmit_to_client (struct TransportClient *client, | |||
1481 | client->message_count++; | 1478 | client->message_count++; |
1482 | if (client->th == NULL) | 1479 | if (client->th == NULL) |
1483 | { | 1480 | { |
1484 | client->th = GNUNET_SERVER_notify_transmit_ready (client->client, | 1481 | client->th = |
1485 | msize, | 1482 | GNUNET_SERVER_notify_transmit_ready (client->client, msize, |
1486 | GNUNET_TIME_UNIT_FOREVER_REL, | 1483 | GNUNET_TIME_UNIT_FOREVER_REL, |
1487 | &transmit_to_client_callback, | 1484 | &transmit_to_client_callback, |
1488 | client); | 1485 | client); |
1489 | GNUNET_assert (client->th != NULL); | 1486 | GNUNET_assert (client->th != NULL); |
1490 | } | 1487 | } |
1491 | } | 1488 | } |
@@ -1501,8 +1498,7 @@ transmit_to_client (struct TransportClient *client, | |||
1501 | * @param result status code for the transmission request | 1498 | * @param result status code for the transmission request |
1502 | */ | 1499 | */ |
1503 | static void | 1500 | static void |
1504 | transmit_send_ok (struct TransportClient *client, | 1501 | transmit_send_ok (struct TransportClient *client, struct NeighbourMapEntry *n, |
1505 | struct NeighbourMapEntry *n, | ||
1506 | const struct GNUNET_PeerIdentity *target, int result) | 1502 | const struct GNUNET_PeerIdentity *target, int result) |
1507 | { | 1503 | { |
1508 | struct SendOkMessage send_ok_msg; | 1504 | struct SendOkMessage send_ok_msg; |
@@ -1561,8 +1557,7 @@ retry_transmission_task (void *cls, | |||
1561 | * more messages | 1557 | * more messages |
1562 | */ | 1558 | */ |
1563 | static void | 1559 | static void |
1564 | transmit_send_continuation (void *cls, | 1560 | transmit_send_continuation (void *cls, const struct GNUNET_PeerIdentity *target, |
1565 | const struct GNUNET_PeerIdentity *target, | ||
1566 | int result) | 1561 | int result) |
1567 | { | 1562 | { |
1568 | struct MessageQueue *mq = cls; | 1563 | struct MessageQueue *mq = cls; |
@@ -1606,8 +1601,7 @@ transmit_send_continuation (void *cls, | |||
1606 | mq->specific_address->addr, | 1601 | mq->specific_address->addr, |
1607 | mq->specific_address->addrlen)); | 1602 | mq->specific_address->addrlen)); |
1608 | #endif | 1603 | #endif |
1609 | GNUNET_STATISTICS_update (stats, | 1604 | GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), |
1610 | gettext_noop ("# connected addresses"), | ||
1611 | -1, GNUNET_NO); | 1605 | -1, GNUNET_NO); |
1612 | mq->specific_address->connected = GNUNET_NO; | 1606 | mq->specific_address->connected = GNUNET_NO; |
1613 | } | 1607 | } |
@@ -1698,13 +1692,13 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) | |||
1698 | GNUNET_NO); | 1692 | GNUNET_NO); |
1699 | if (n->retry_task != GNUNET_SCHEDULER_NO_TASK) | 1693 | if (n->retry_task != GNUNET_SCHEDULER_NO_TASK) |
1700 | GNUNET_SCHEDULER_cancel (n->retry_task); | 1694 | GNUNET_SCHEDULER_cancel (n->retry_task); |
1701 | n->retry_task = GNUNET_SCHEDULER_add_delayed (timeout, | 1695 | n->retry_task = |
1702 | &retry_transmission_task, n); | 1696 | GNUNET_SCHEDULER_add_delayed (timeout, &retry_transmission_task, n); |
1703 | #if DEBUG_TRANSPORT | 1697 | #if DEBUG_TRANSPORT |
1704 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1698 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1705 | "No validated destination address available to transmit message of size %u to peer `%4s', will wait %llums to find an address.\n", | 1699 | "No validated destination address available to transmit message of size %u to peer `%4s', will wait %llums to find an address.\n", |
1706 | mq->message_buf_size, | 1700 | mq->message_buf_size, GNUNET_i2s (&mq->neighbour_id), |
1707 | GNUNET_i2s (&mq->neighbour_id), timeout.rel_value); | 1701 | timeout.rel_value); |
1708 | #endif | 1702 | #endif |
1709 | /* FIXME: might want to trigger peerinfo lookup here | 1703 | /* FIXME: might want to trigger peerinfo lookup here |
1710 | * (unless that's already pending...) */ | 1704 | * (unless that's already pending...) */ |
@@ -1720,13 +1714,11 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) | |||
1720 | #if DEBUG_TRANSPORT | 1714 | #if DEBUG_TRANSPORT |
1721 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1715 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1722 | "Sending message of size %u for `%4s' to `%s' via plugin `%s'\n", | 1716 | "Sending message of size %u for `%4s' to `%s' via plugin `%s'\n", |
1723 | mq->message_buf_size, | 1717 | mq->message_buf_size, GNUNET_i2s (&n->id), |
1724 | GNUNET_i2s (&n->id), | 1718 | (mq->specific_address->addr != |
1725 | (mq->specific_address->addr != NULL) | 1719 | NULL) ? a2s (mq->plugin->short_name, mq->specific_address->addr, |
1726 | ? a2s (mq->plugin->short_name, | 1720 | mq->specific_address->addrlen) : "<inbound>", |
1727 | mq->specific_address->addr, | 1721 | rl->plugin->short_name); |
1728 | mq->specific_address->addrlen) | ||
1729 | : "<inbound>", rl->plugin->short_name); | ||
1730 | #endif | 1722 | #endif |
1731 | GNUNET_STATISTICS_update (stats, | 1723 | GNUNET_STATISTICS_update (stats, |
1732 | gettext_noop | 1724 | gettext_noop |
@@ -1738,16 +1730,15 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) | |||
1738 | 1730 | ||
1739 | GNUNET_CONTAINER_DLL_insert (n->cont_head, n->cont_tail, mq); | 1731 | GNUNET_CONTAINER_DLL_insert (n->cont_head, n->cont_tail, mq); |
1740 | 1732 | ||
1741 | ret = rl->plugin->api->send (rl->plugin->api->cls, | 1733 | ret = |
1742 | &mq->neighbour_id, | 1734 | rl->plugin->api->send (rl->plugin->api->cls, &mq->neighbour_id, |
1743 | mq->message_buf, | 1735 | mq->message_buf, mq->message_buf_size, |
1744 | mq->message_buf_size, | 1736 | mq->priority, |
1745 | mq->priority, | 1737 | GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, |
1746 | GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | 1738 | mq->specific_address->session, |
1747 | mq->specific_address->session, | 1739 | mq->specific_address->addr, |
1748 | mq->specific_address->addr, | 1740 | mq->specific_address->addrlen, force_address, |
1749 | mq->specific_address->addrlen, | 1741 | &transmit_send_continuation, mq); |
1750 | force_address, &transmit_send_continuation, mq); | ||
1751 | if (ret == -1) | 1742 | if (ret == -1) |
1752 | { | 1743 | { |
1753 | /* failure, but 'send' would not call continuation in this case, | 1744 | /* failure, but 'send' would not call continuation in this case, |
@@ -1773,10 +1764,8 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) | |||
1773 | static void | 1764 | static void |
1774 | transmit_to_peer (struct TransportClient *client, | 1765 | transmit_to_peer (struct TransportClient *client, |
1775 | struct ForeignAddressList *peer_address, | 1766 | struct ForeignAddressList *peer_address, |
1776 | unsigned int priority, | 1767 | unsigned int priority, struct GNUNET_TIME_Relative timeout, |
1777 | struct GNUNET_TIME_Relative timeout, | 1768 | const char *message_buf, size_t message_buf_size, |
1778 | const char *message_buf, | ||
1779 | size_t message_buf_size, | ||
1780 | int is_internal, struct NeighbourMapEntry *neighbour) | 1769 | int is_internal, struct NeighbourMapEntry *neighbour) |
1781 | { | 1770 | { |
1782 | struct MessageQueue *mq; | 1771 | struct MessageQueue *mq; |
@@ -1865,12 +1854,11 @@ transmit_plain_ping (struct NeighbourMapEntry *n) | |||
1865 | continue; | 1854 | continue; |
1866 | ve = GNUNET_malloc (sizeof (struct ValidationEntry)); | 1855 | ve = GNUNET_malloc (sizeof (struct ValidationEntry)); |
1867 | ve->transport_name = GNUNET_strdup (plugin->short_name); | 1856 | ve->transport_name = GNUNET_strdup (plugin->short_name); |
1868 | ve->challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, | 1857 | ve->challenge = |
1869 | UINT_MAX); | 1858 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT_MAX); |
1870 | ve->send_time = GNUNET_TIME_absolute_get (); | 1859 | ve->send_time = GNUNET_TIME_absolute_get (); |
1871 | ve->session = fal->session; | 1860 | ve->session = fal->session; |
1872 | memcpy (&ve->publicKey, | 1861 | memcpy (&ve->publicKey, &n->publicKey, |
1873 | &n->publicKey, | ||
1874 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); | 1862 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); |
1875 | ve->timeout_task = | 1863 | ve->timeout_task = |
1876 | GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT, | 1864 | GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT, |
@@ -1919,8 +1907,8 @@ mark_address_connected (struct ForeignAddressList *fal) | |||
1919 | while (pos != NULL) | 1907 | while (pos != NULL) |
1920 | { | 1908 | { |
1921 | /* Already have inbound address, and this is also an inbound address, don't switch!! */ | 1909 | /* Already have inbound address, and this is also an inbound address, don't switch!! */ |
1922 | if ((GNUNET_YES == pos->connected) && | 1910 | if ((GNUNET_YES == pos->connected) && (0 == pos->addrlen) && |
1923 | (0 == pos->addrlen) && (0 == fal->addrlen)) | 1911 | (0 == fal->addrlen)) |
1924 | return; | 1912 | return; |
1925 | if ((0 == pos->addrlen) && (GNUNET_YES == pos->connected)) | 1913 | if ((0 == pos->addrlen) && (GNUNET_YES == pos->connected)) |
1926 | inbound = pos; | 1914 | inbound = pos; |
@@ -1931,8 +1919,8 @@ mark_address_connected (struct ForeignAddressList *fal) | |||
1931 | while (pos != NULL) | 1919 | while (pos != NULL) |
1932 | { | 1920 | { |
1933 | /* Already have outbound address, and this is also an outbound address, don't switch!! */ | 1921 | /* Already have outbound address, and this is also an outbound address, don't switch!! */ |
1934 | if ((GNUNET_YES == pos->connected) && | 1922 | if ((GNUNET_YES == pos->connected) && (0 < pos->addrlen) && |
1935 | (0 < pos->addrlen) && (0 < fal->addrlen)) | 1923 | (0 < fal->addrlen)) |
1936 | return; | 1924 | return; |
1937 | if ((0 < pos->addrlen) && (GNUNET_YES == pos->connected)) | 1925 | if ((0 < pos->addrlen) && (GNUNET_YES == pos->connected)) |
1938 | outbound = pos; | 1926 | outbound = pos; |
@@ -1949,14 +1937,11 @@ mark_address_connected (struct ForeignAddressList *fal) | |||
1949 | #endif | 1937 | #endif |
1950 | 1938 | ||
1951 | /* Have an inbound connection to this peer which is valid; our id is lower, ignore outbound connection! */ | 1939 | /* Have an inbound connection to this peer which is valid; our id is lower, ignore outbound connection! */ |
1952 | if ((inbound != NULL) && (0 != fal->addrlen) && (1 | 1940 | if ((inbound != NULL) && (0 != fal->addrlen) && |
1953 | == | 1941 | (1 == |
1954 | GNUNET_CRYPTO_hash_xorcmp | 1942 | GNUNET_CRYPTO_hash_xorcmp (&inbound->ready_list->neighbour-> |
1955 | (&inbound-> | 1943 | id.hashPubKey, &my_identity.hashPubKey, |
1956 | ready_list->neighbour->id. | 1944 | &null_hash))) |
1957 | hashPubKey, | ||
1958 | &my_identity.hashPubKey, | ||
1959 | &null_hash))) | ||
1960 | { | 1945 | { |
1961 | #if DEBUG_INBOUND | 1946 | #if DEBUG_INBOUND |
1962 | fprintf (stderr, "Peer: %s, had inbound connection, ignoring outbound!\n", | 1947 | fprintf (stderr, "Peer: %s, had inbound connection, ignoring outbound!\n", |
@@ -1964,13 +1949,11 @@ mark_address_connected (struct ForeignAddressList *fal) | |||
1964 | #endif | 1949 | #endif |
1965 | return; | 1950 | return; |
1966 | } | 1951 | } |
1967 | else if ((outbound != NULL) && (0 == fal->addrlen) && ((-1 | 1952 | else if ((outbound != NULL) && (0 == fal->addrlen) && |
1968 | == | 1953 | ((-1 == |
1969 | GNUNET_CRYPTO_hash_xorcmp | 1954 | GNUNET_CRYPTO_hash_xorcmp (&outbound->ready_list->neighbour->id. |
1970 | (&outbound->ready_list->neighbour-> | 1955 | hashPubKey, &my_identity.hashPubKey, |
1971 | id.hashPubKey, | 1956 | &null_hash)))) |
1972 | &my_identity.hashPubKey, | ||
1973 | &null_hash)))) | ||
1974 | { | 1957 | { |
1975 | #if DEBUG_INBOUND | 1958 | #if DEBUG_INBOUND |
1976 | fprintf (stderr, "Peer: %s, have outbound connection, ignoring inbound!\n", | 1959 | fprintf (stderr, "Peer: %s, have outbound connection, ignoring inbound!\n", |
@@ -1991,22 +1974,20 @@ mark_address_connected (struct ForeignAddressList *fal) | |||
1991 | pos->addrlen)); | 1974 | pos->addrlen)); |
1992 | #endif | 1975 | #endif |
1993 | #if DEBUG_INBOUND | 1976 | #if DEBUG_INBOUND |
1994 | fprintf (stderr, | 1977 | fprintf (stderr, "Peer: %s, setting %s connection to disconnected.\n", |
1995 | "Peer: %s, setting %s connection to disconnected.\n", | ||
1996 | GNUNET_i2s (&my_identity), | 1978 | GNUNET_i2s (&my_identity), |
1997 | (0 == pos->addrlen) ? "INBOUND" : "OUTBOUND"); | 1979 | (0 == pos->addrlen) ? "INBOUND" : "OUTBOUND"); |
1998 | #endif | 1980 | #endif |
1999 | pos->connected = GNUNET_NO; | 1981 | pos->connected = GNUNET_NO; |
2000 | GNUNET_STATISTICS_update (stats, | 1982 | GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), |
2001 | gettext_noop ("# connected addresses"), -1, | 1983 | -1, GNUNET_NO); |
2002 | GNUNET_NO); | ||
2003 | } | 1984 | } |
2004 | pos = pos->next; | 1985 | pos = pos->next; |
2005 | } | 1986 | } |
2006 | GNUNET_assert (GNUNET_NO == fal->connected); | 1987 | GNUNET_assert (GNUNET_NO == fal->connected); |
2007 | fal->connected = GNUNET_YES; | 1988 | fal->connected = GNUNET_YES; |
2008 | GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), | 1989 | GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), 1, |
2009 | 1, GNUNET_NO); | 1990 | GNUNET_NO); |
2010 | } | 1991 | } |
2011 | 1992 | ||
2012 | 1993 | ||
@@ -2044,8 +2025,7 @@ find_ready_address (struct NeighbourMapEntry *neighbour) | |||
2044 | "Marking long-time inactive connection to `%4s' as down.\n", | 2025 | "Marking long-time inactive connection to `%4s' as down.\n", |
2045 | GNUNET_i2s (&neighbour->id)); | 2026 | GNUNET_i2s (&neighbour->id)); |
2046 | #endif | 2027 | #endif |
2047 | GNUNET_STATISTICS_update (stats, | 2028 | GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), |
2048 | gettext_noop ("# connected addresses"), | ||
2049 | -1, GNUNET_NO); | 2029 | -1, GNUNET_NO); |
2050 | addresses->connected = GNUNET_NO; | 2030 | addresses->connected = GNUNET_NO; |
2051 | } | 2031 | } |
@@ -2059,14 +2039,10 @@ find_ready_address (struct NeighbourMapEntry *neighbour) | |||
2059 | if (addresses->addr != NULL) | 2039 | if (addresses->addr != NULL) |
2060 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2040 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2061 | "Have address `%s' for peer `%4s' (status: %d, %d, %d, %u, %llums, %u)\n", | 2041 | "Have address `%s' for peer `%4s' (status: %d, %d, %d, %u, %llums, %u)\n", |
2062 | a2s (head->plugin->short_name, | 2042 | a2s (head->plugin->short_name, addresses->addr, |
2063 | addresses->addr, | 2043 | addresses->addrlen), GNUNET_i2s (&neighbour->id), |
2064 | addresses->addrlen), | 2044 | addresses->connected, addresses->in_transmit, |
2065 | GNUNET_i2s (&neighbour->id), | 2045 | addresses->validated, addresses->connect_attempts, |
2066 | addresses->connected, | ||
2067 | addresses->in_transmit, | ||
2068 | addresses->validated, | ||
2069 | addresses->connect_attempts, | ||
2070 | (unsigned long long) addresses->timeout.abs_value, | 2046 | (unsigned long long) addresses->timeout.abs_value, |
2071 | (unsigned int) addresses->distance); | 2047 | (unsigned int) addresses->distance); |
2072 | #endif | 2048 | #endif |
@@ -2077,12 +2053,13 @@ find_ready_address (struct NeighbourMapEntry *neighbour) | |||
2077 | (addresses->latency.rel_value < unix_address->latency.rel_value))) | 2053 | (addresses->latency.rel_value < unix_address->latency.rel_value))) |
2078 | unix_address = addresses; | 2054 | unix_address = addresses; |
2079 | } | 2055 | } |
2080 | if (((best_address == NULL) || | 2056 | if (((best_address == NULL) || (addresses->connected == GNUNET_YES) || |
2081 | (addresses->connected == GNUNET_YES) || | ||
2082 | (best_address->connected == GNUNET_NO)) && | 2057 | (best_address->connected == GNUNET_NO)) && |
2083 | (addresses->in_transmit == GNUNET_NO) && | 2058 | (addresses->in_transmit == GNUNET_NO) && ((best_address == NULL) || |
2084 | ((best_address == NULL) || | 2059 | (addresses->latency. |
2085 | (addresses->latency.rel_value < best_address->latency.rel_value))) | 2060 | rel_value < |
2061 | best_address->latency. | ||
2062 | rel_value))) | ||
2086 | best_address = addresses; | 2063 | best_address = addresses; |
2087 | /* FIXME: also give lower-latency addresses that are not | 2064 | /* FIXME: also give lower-latency addresses that are not |
2088 | * connected a chance some times... */ | 2065 | * connected a chance some times... */ |
@@ -2105,11 +2082,11 @@ find_ready_address (struct NeighbourMapEntry *neighbour) | |||
2105 | #if DEBUG_TRANSPORT | 2082 | #if DEBUG_TRANSPORT |
2106 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2083 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2107 | "Best address found (`%s') has latency of %llu ms.\n", | 2084 | "Best address found (`%s') has latency of %llu ms.\n", |
2108 | (best_address->addrlen > 0) | 2085 | (best_address->addrlen > |
2109 | ? a2s (best_address->ready_list->plugin->short_name, | 2086 | 0) ? a2s (best_address->ready_list->plugin->short_name, |
2110 | best_address->addr, | 2087 | best_address->addr, |
2111 | best_address->addrlen) | 2088 | best_address->addrlen) : "<inbound>", |
2112 | : "<inbound>", best_address->latency.rel_value); | 2089 | best_address->latency.rel_value); |
2113 | #endif | 2090 | #endif |
2114 | } | 2091 | } |
2115 | else | 2092 | else |
@@ -2154,10 +2131,10 @@ address_generator (void *cls, size_t max, void *buf) | |||
2154 | 2131 | ||
2155 | return 0; | 2132 | return 0; |
2156 | } | 2133 | } |
2157 | ret = GNUNET_HELLO_add_address (gc->plug_pos->short_name, | 2134 | ret = |
2158 | gc->expiration, | 2135 | GNUNET_HELLO_add_address (gc->plug_pos->short_name, gc->expiration, |
2159 | &gc->addr_pos[1], | 2136 | &gc->addr_pos[1], gc->addr_pos->addrlen, buf, |
2160 | gc->addr_pos->addrlen, buf, max); | 2137 | max); |
2161 | gc->addr_pos = gc->addr_pos->next; | 2138 | gc->addr_pos = gc->addr_pos->next; |
2162 | return ret; | 2139 | return ret; |
2163 | } | 2140 | } |
@@ -2173,8 +2150,8 @@ transmit_our_hello_if_pong (void *cls, const GNUNET_HashCode * key, void *value) | |||
2173 | return GNUNET_OK; | 2150 | return GNUNET_OK; |
2174 | #if DEBUG_TRANSPORT | 2151 | #if DEBUG_TRANSPORT |
2175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 2152 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
2176 | "Transmitting updated `%s' to neighbour `%4s'\n", | 2153 | "Transmitting updated `%s' to neighbour `%4s'\n", "HELLO", |
2177 | "HELLO", GNUNET_i2s (&npos->id)); | 2154 | GNUNET_i2s (&npos->id)); |
2178 | #endif | 2155 | #endif |
2179 | GNUNET_STATISTICS_update (stats, | 2156 | GNUNET_STATISTICS_update (stats, |
2180 | gettext_noop | 2157 | gettext_noop |
@@ -2211,15 +2188,14 @@ refresh_hello_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2211 | "Refreshed my `%s', new size is %d\n", "HELLO", | 2188 | "Refreshed my `%s', new size is %d\n", "HELLO", |
2212 | GNUNET_HELLO_size (hello)); | 2189 | GNUNET_HELLO_size (hello)); |
2213 | #endif | 2190 | #endif |
2214 | GNUNET_STATISTICS_update (stats, | 2191 | GNUNET_STATISTICS_update (stats, gettext_noop ("# refreshed my HELLO"), 1, |
2215 | gettext_noop ("# refreshed my HELLO"), | 2192 | GNUNET_NO); |
2216 | 1, GNUNET_NO); | ||
2217 | cpos = clients; | 2193 | cpos = clients; |
2218 | while (cpos != NULL) | 2194 | while (cpos != NULL) |
2219 | { | 2195 | { |
2220 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting my HELLO to client!\n"); | 2196 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting my HELLO to client!\n"); |
2221 | transmit_to_client (cpos, | 2197 | transmit_to_client (cpos, (const struct GNUNET_MessageHeader *) hello, |
2222 | (const struct GNUNET_MessageHeader *) hello, GNUNET_NO); | 2198 | GNUNET_NO); |
2223 | cpos = cpos->next; | 2199 | cpos = cpos->next; |
2224 | } | 2200 | } |
2225 | 2201 | ||
@@ -2320,9 +2296,8 @@ try_fast_reconnect (struct TransportPlugin *p, struct NeighbourMapEntry *nl) | |||
2320 | /* No reconnect, signal disconnect instead! */ | 2296 | /* No reconnect, signal disconnect instead! */ |
2321 | #if DEBUG_TRANSPORT | 2297 | #if DEBUG_TRANSPORT |
2322 | #endif | 2298 | #endif |
2323 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2299 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n", |
2324 | "Disconnecting peer `%4s', %s\n", GNUNET_i2s (&nl->id), | 2300 | GNUNET_i2s (&nl->id), "try_fast_reconnect"); |
2325 | "try_fast_reconnect"); | ||
2326 | 2301 | ||
2327 | GNUNET_STATISTICS_update (stats, | 2302 | GNUNET_STATISTICS_update (stats, |
2328 | gettext_noop | 2303 | gettext_noop |
@@ -2346,8 +2321,7 @@ try_fast_reconnect (struct TransportPlugin *p, struct NeighbourMapEntry *nl) | |||
2346 | * @param session which session is being destoyed | 2321 | * @param session which session is being destoyed |
2347 | */ | 2322 | */ |
2348 | static void | 2323 | static void |
2349 | plugin_env_session_end (void *cls, | 2324 | plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, |
2350 | const struct GNUNET_PeerIdentity *peer, | ||
2351 | struct Session *session) | 2325 | struct Session *session) |
2352 | { | 2326 | { |
2353 | struct TransportPlugin *p = cls; | 2327 | struct TransportPlugin *p = cls; |
@@ -2357,8 +2331,7 @@ plugin_env_session_end (void *cls, | |||
2357 | struct ForeignAddressList *prev; | 2331 | struct ForeignAddressList *prev; |
2358 | 2332 | ||
2359 | #if DEBUG_TRANSPORT | 2333 | #if DEBUG_TRANSPORT |
2360 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2334 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session ended with peer `%4s', %s\n", |
2361 | "Session ended with peer `%4s', %s\n", | ||
2362 | GNUNET_i2s (peer), "plugin_env_session_end"); | 2335 | GNUNET_i2s (peer), "plugin_env_session_end"); |
2363 | #endif | 2336 | #endif |
2364 | GNUNET_CONTAINER_multihashmap_iterate (validation_map, | 2337 | GNUNET_CONTAINER_multihashmap_iterate (validation_map, |
@@ -2435,9 +2408,8 @@ plugin_env_session_end (void *cls, | |||
2435 | if (GNUNET_YES == pos->connected) | 2408 | if (GNUNET_YES == pos->connected) |
2436 | { | 2409 | { |
2437 | pos->connected = GNUNET_NO; | 2410 | pos->connected = GNUNET_NO; |
2438 | GNUNET_STATISTICS_update (stats, | 2411 | GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), -1, |
2439 | gettext_noop ("# connected addresses"), | 2412 | GNUNET_NO); |
2440 | -1, GNUNET_NO); | ||
2441 | } | 2413 | } |
2442 | if (GNUNET_SCHEDULER_NO_TASK != pos->revalidate_task) | 2414 | if (GNUNET_SCHEDULER_NO_TASK != pos->revalidate_task) |
2443 | { | 2415 | { |
@@ -2491,16 +2463,15 @@ plugin_env_session_end (void *cls, | |||
2491 | return; | 2463 | return; |
2492 | } | 2464 | } |
2493 | pos->connected = GNUNET_NO; | 2465 | pos->connected = GNUNET_NO; |
2494 | GNUNET_STATISTICS_update (stats, | 2466 | GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), -1, |
2495 | gettext_noop ("# connected addresses"), | 2467 | GNUNET_NO); |
2496 | -1, GNUNET_NO); | ||
2497 | GNUNET_free (pos); | 2468 | GNUNET_free (pos); |
2498 | 2469 | ||
2499 | if (nl->received_pong == GNUNET_NO) | 2470 | if (nl->received_pong == GNUNET_NO) |
2500 | { | 2471 | { |
2501 | GNUNET_STATISTICS_update (stats, | 2472 | GNUNET_STATISTICS_update (stats, |
2502 | gettext_noop ("# disconnects due to NO pong"), | 2473 | gettext_noop ("# disconnects due to NO pong"), 1, |
2503 | 1, GNUNET_NO); | 2474 | GNUNET_NO); |
2504 | disconnect_neighbour (nl, GNUNET_YES); | 2475 | disconnect_neighbour (nl, GNUNET_YES); |
2505 | return; /* nothing to do, never connected... */ | 2476 | return; /* nothing to do, never connected... */ |
2506 | } | 2477 | } |
@@ -2522,8 +2493,7 @@ plugin_env_session_end (void *cls, | |||
2522 | /* no valid addresses left, signal disconnect! */ | 2493 | /* no valid addresses left, signal disconnect! */ |
2523 | 2494 | ||
2524 | #if DEBUG_TRANSPORT | 2495 | #if DEBUG_TRANSPORT |
2525 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2496 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n", |
2526 | "Disconnecting peer `%4s', %s\n", | ||
2527 | GNUNET_i2s (peer), "plugin_env_session_end"); | 2497 | GNUNET_i2s (peer), "plugin_env_session_end"); |
2528 | #endif | 2498 | #endif |
2529 | /* FIXME: This doesn't mean there are no addresses left for this PEER, | 2499 | /* FIXME: This doesn't mean there are no addresses left for this PEER, |
@@ -2553,8 +2523,8 @@ plugin_env_session_end (void *cls, | |||
2553 | * @param addrlen length of the address | 2523 | * @param addrlen length of the address |
2554 | */ | 2524 | */ |
2555 | static void | 2525 | static void |
2556 | plugin_env_notify_address (void *cls, | 2526 | plugin_env_notify_address (void *cls, int add_remove, const void *addr, |
2557 | int add_remove, const void *addr, size_t addrlen) | 2527 | size_t addrlen) |
2558 | { | 2528 | { |
2559 | struct TransportPlugin *p = cls; | 2529 | struct TransportPlugin *p = cls; |
2560 | struct OwnAddressList *al; | 2530 | struct OwnAddressList *al; |
@@ -2563,9 +2533,9 @@ plugin_env_notify_address (void *cls, | |||
2563 | GNUNET_assert (p->api != NULL); | 2533 | GNUNET_assert (p->api != NULL); |
2564 | #if DEBUG_TRANSPORT | 2534 | #if DEBUG_TRANSPORT |
2565 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2535 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2566 | (add_remove == GNUNET_YES) | 2536 | (add_remove == |
2567 | ? "Adding `%s':%s to the set of our addresses\n" | 2537 | GNUNET_YES) ? "Adding `%s':%s to the set of our addresses\n" : |
2568 | : "Removing `%s':%s from the set of our addresses\n", | 2538 | "Removing `%s':%s from the set of our addresses\n", |
2569 | a2s (p->short_name, addr, addrlen), p->short_name); | 2539 | a2s (p->short_name, addr, addrlen), p->short_name); |
2570 | #endif | 2540 | #endif |
2571 | GNUNET_assert (addr != NULL); | 2541 | GNUNET_assert (addr != NULL); |
@@ -2622,8 +2592,8 @@ notify_clients_connect (const struct GNUNET_PeerIdentity *peer, | |||
2622 | "Notifying clients about connection with `%s'\n", | 2592 | "Notifying clients about connection with `%s'\n", |
2623 | GNUNET_i2s (peer)); | 2593 | GNUNET_i2s (peer)); |
2624 | #endif | 2594 | #endif |
2625 | GNUNET_STATISTICS_update (stats, | 2595 | GNUNET_STATISTICS_update (stats, gettext_noop ("# peers connected"), 1, |
2626 | gettext_noop ("# peers connected"), 1, GNUNET_NO); | 2596 | GNUNET_NO); |
2627 | 2597 | ||
2628 | ats_count = 2; | 2598 | ats_count = 2; |
2629 | size = | 2599 | size = |
@@ -2679,8 +2649,8 @@ notify_clients_disconnect (const struct GNUNET_PeerIdentity *peer) | |||
2679 | "Notifying clients about lost connection to `%s'\n", | 2649 | "Notifying clients about lost connection to `%s'\n", |
2680 | GNUNET_i2s (peer)); | 2650 | GNUNET_i2s (peer)); |
2681 | #endif | 2651 | #endif |
2682 | GNUNET_STATISTICS_update (stats, | 2652 | GNUNET_STATISTICS_update (stats, gettext_noop ("# peers connected"), -1, |
2683 | gettext_noop ("# peers connected"), -1, GNUNET_NO); | 2653 | GNUNET_NO); |
2684 | dim.header.size = htons (sizeof (struct DisconnectInfoMessage)); | 2654 | dim.header.size = htons (sizeof (struct DisconnectInfoMessage)); |
2685 | dim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT); | 2655 | dim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT); |
2686 | dim.reserved = htonl (0); | 2656 | dim.reserved = htonl (0); |
@@ -2718,8 +2688,7 @@ notify_clients_disconnect (const struct GNUNET_PeerIdentity *peer) | |||
2718 | * @return NULL if no such entry exists | 2688 | * @return NULL if no such entry exists |
2719 | */ | 2689 | */ |
2720 | static struct ForeignAddressList * | 2690 | static struct ForeignAddressList * |
2721 | find_peer_address (struct NeighbourMapEntry *neighbour, | 2691 | find_peer_address (struct NeighbourMapEntry *neighbour, const char *tname, |
2722 | const char *tname, | ||
2723 | struct Session *session, const char *addr, uint16_t addrlen) | 2692 | struct Session *session, const char *addr, uint16_t addrlen) |
2724 | { | 2693 | { |
2725 | struct ReadyList *head; | 2694 | struct ReadyList *head; |
@@ -2761,8 +2730,7 @@ find_peer_address (struct NeighbourMapEntry *neighbour, | |||
2761 | * @return NULL if we do not have a transport plugin for 'tname' | 2730 | * @return NULL if we do not have a transport plugin for 'tname' |
2762 | */ | 2731 | */ |
2763 | static struct ForeignAddressList * | 2732 | static struct ForeignAddressList * |
2764 | add_peer_address (struct NeighbourMapEntry *neighbour, | 2733 | add_peer_address (struct NeighbourMapEntry *neighbour, const char *tname, |
2765 | const char *tname, | ||
2766 | struct Session *session, const char *addr, uint16_t addrlen) | 2734 | struct Session *session, const char *addr, uint16_t addrlen) |
2767 | { | 2735 | { |
2768 | struct ReadyList *head; | 2736 | struct ReadyList *head; |
@@ -2841,11 +2809,13 @@ add_peer_address (struct NeighbourMapEntry *neighbour, | |||
2841 | GNUNET_malloc (available_quality_metrics * | 2809 | GNUNET_malloc (available_quality_metrics * |
2842 | sizeof (struct ATS_quality_entry)); | 2810 | sizeof (struct ATS_quality_entry)); |
2843 | ret->addrlen = addrlen; | 2811 | ret->addrlen = addrlen; |
2844 | ret->expires = GNUNET_TIME_relative_to_absolute | 2812 | ret->expires = |
2813 | GNUNET_TIME_relative_to_absolute | ||
2845 | (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | 2814 | (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); |
2846 | ret->latency = GNUNET_TIME_relative_get_forever (); | 2815 | ret->latency = GNUNET_TIME_relative_get_forever (); |
2847 | ret->distance = -1; | 2816 | ret->distance = -1; |
2848 | ret->timeout = GNUNET_TIME_relative_to_absolute | 2817 | ret->timeout = |
2818 | GNUNET_TIME_relative_to_absolute | ||
2849 | (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | 2819 | (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); |
2850 | ret->ready_list = head; | 2820 | ret->ready_list = head; |
2851 | ret->next = head->addresses; | 2821 | ret->next = head->addresses; |
@@ -2950,8 +2920,7 @@ check_address_exists (void *cls, const GNUNET_HashCode * key, void *value) | |||
2950 | struct CheckAddressExistsClosure *caec = cls; | 2920 | struct CheckAddressExistsClosure *caec = cls; |
2951 | struct ValidationEntry *ve = value; | 2921 | struct ValidationEntry *ve = value; |
2952 | 2922 | ||
2953 | if ((0 == strcmp (caec->tname, | 2923 | if ((0 == strcmp (caec->tname, ve->transport_name)) && |
2954 | ve->transport_name)) && | ||
2955 | (caec->addrlen == ve->addrlen) && | 2924 | (caec->addrlen == ve->addrlen) && |
2956 | (0 == memcmp (caec->addr, ve->addr, caec->addrlen))) | 2925 | (0 == memcmp (caec->addr, ve->addr, caec->addrlen))) |
2957 | { | 2926 | { |
@@ -2978,8 +2947,8 @@ neighbour_timeout_task (void *cls, | |||
2978 | "Neighbour `%4s' has timed out!\n", GNUNET_i2s (&n->id)); | 2947 | "Neighbour `%4s' has timed out!\n", GNUNET_i2s (&n->id)); |
2979 | #endif | 2948 | #endif |
2980 | GNUNET_STATISTICS_update (stats, | 2949 | GNUNET_STATISTICS_update (stats, |
2981 | gettext_noop ("# disconnects due to timeout"), | 2950 | gettext_noop ("# disconnects due to timeout"), 1, |
2982 | 1, GNUNET_NO); | 2951 | GNUNET_NO); |
2983 | n->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 2952 | n->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
2984 | disconnect_neighbour (n, GNUNET_NO); | 2953 | disconnect_neighbour (n, GNUNET_NO); |
2985 | } | 2954 | } |
@@ -3006,8 +2975,7 @@ static void schedule_next_ping (struct ForeignAddressList *fal); | |||
3006 | * @return GNUNET_OK (always) | 2975 | * @return GNUNET_OK (always) |
3007 | */ | 2976 | */ |
3008 | static int | 2977 | static int |
3009 | add_to_foreign_address_list (void *cls, | 2978 | add_to_foreign_address_list (void *cls, const char *tname, |
3010 | const char *tname, | ||
3011 | struct GNUNET_TIME_Absolute expiration, | 2979 | struct GNUNET_TIME_Absolute expiration, |
3012 | const void *addr, uint16_t addrlen) | 2980 | const void *addr, uint16_t addrlen) |
3013 | { | 2981 | { |
@@ -3026,8 +2994,8 @@ add_to_foreign_address_list (void *cls, | |||
3026 | #if DEBUG_TRANSPORT_HELLO | 2994 | #if DEBUG_TRANSPORT_HELLO |
3027 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2995 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3028 | "Adding address `%s' (%s) for peer `%4s' due to PEERINFO data for %llums.\n", | 2996 | "Adding address `%s' (%s) for peer `%4s' due to PEERINFO data for %llums.\n", |
3029 | a2s (tname, addr, addrlen), | 2997 | a2s (tname, addr, addrlen), tname, GNUNET_i2s (&n->id), |
3030 | tname, GNUNET_i2s (&n->id), expiration.abs_value); | 2998 | expiration.abs_value); |
3031 | #endif | 2999 | #endif |
3032 | fal = add_peer_address (n, tname, NULL, addr, addrlen); | 3000 | fal = add_peer_address (n, tname, NULL, addr, addrlen); |
3033 | if (fal == NULL) | 3001 | if (fal == NULL) |
@@ -3086,8 +3054,7 @@ add_to_foreign_address_list (void *cls, | |||
3086 | * @param err_msg NULL if successful, otherwise contains error message | 3054 | * @param err_msg NULL if successful, otherwise contains error message |
3087 | */ | 3055 | */ |
3088 | static void | 3056 | static void |
3089 | add_hello_for_peer (void *cls, | 3057 | add_hello_for_peer (void *cls, const struct GNUNET_PeerIdentity *peer, |
3090 | const struct GNUNET_PeerIdentity *peer, | ||
3091 | const struct GNUNET_HELLO_Message *h, const char *err_msg) | 3058 | const struct GNUNET_HELLO_Message *h, const char *err_msg) |
3092 | { | 3059 | { |
3093 | struct NeighbourMapEntry *n = cls; | 3060 | struct NeighbourMapEntry *n = cls; |
@@ -3122,8 +3089,8 @@ add_hello_for_peer (void *cls, | |||
3122 | GNUNET_HELLO_get_key (h, &n->publicKey); | 3089 | GNUNET_HELLO_get_key (h, &n->publicKey); |
3123 | n->public_key_valid = GNUNET_YES; | 3090 | n->public_key_valid = GNUNET_YES; |
3124 | } | 3091 | } |
3125 | GNUNET_HELLO_iterate_addresses (h, | 3092 | GNUNET_HELLO_iterate_addresses (h, GNUNET_NO, &add_to_foreign_address_list, |
3126 | GNUNET_NO, &add_to_foreign_address_list, n); | 3093 | n); |
3127 | } | 3094 | } |
3128 | 3095 | ||
3129 | 3096 | ||
@@ -3143,15 +3110,15 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer, int do_hello) | |||
3143 | struct TransportPlugin *tp; | 3110 | struct TransportPlugin *tp; |
3144 | struct ReadyList *rl; | 3111 | struct ReadyList *rl; |
3145 | 3112 | ||
3146 | GNUNET_assert (0 != memcmp (peer, | 3113 | GNUNET_assert (0 != |
3147 | &my_identity, | 3114 | memcmp (peer, &my_identity, |
3148 | sizeof (struct GNUNET_PeerIdentity))); | 3115 | sizeof (struct GNUNET_PeerIdentity))); |
3149 | #if DEBUG_TRANSPORT | 3116 | #if DEBUG_TRANSPORT |
3150 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3117 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up state for neighbour `%4s'\n", |
3151 | "Setting up state for neighbour `%4s'\n", GNUNET_i2s (peer)); | 3118 | GNUNET_i2s (peer)); |
3152 | #endif | 3119 | #endif |
3153 | GNUNET_STATISTICS_update (stats, | 3120 | GNUNET_STATISTICS_update (stats, gettext_noop ("# active neighbours"), 1, |
3154 | gettext_noop ("# active neighbours"), 1, GNUNET_NO); | 3121 | GNUNET_NO); |
3155 | n = GNUNET_malloc (sizeof (struct NeighbourMapEntry)); | 3122 | n = GNUNET_malloc (sizeof (struct NeighbourMapEntry)); |
3156 | n->id = *peer; | 3123 | n->id = *peer; |
3157 | n->peer_timeout = | 3124 | n->peer_timeout = |
@@ -3199,8 +3166,7 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer, int do_hello) | |||
3199 | gettext_noop ("# HELLO's sent to new neighbors"), | 3166 | gettext_noop ("# HELLO's sent to new neighbors"), |
3200 | 1, GNUNET_NO); | 3167 | 1, GNUNET_NO); |
3201 | if (NULL != our_hello) | 3168 | if (NULL != our_hello) |
3202 | transmit_to_peer (NULL, NULL, 0, | 3169 | transmit_to_peer (NULL, NULL, 0, HELLO_ADDRESS_EXPIRATION, |
3203 | HELLO_ADDRESS_EXPIRATION, | ||
3204 | (const char *) our_hello, GNUNET_HELLO_size (our_hello), | 3170 | (const char *) our_hello, GNUNET_HELLO_size (our_hello), |
3205 | GNUNET_NO, n); | 3171 | GNUNET_NO, n); |
3206 | } | 3172 | } |
@@ -3329,8 +3295,8 @@ static struct BlacklistCheck *bc_tail; | |||
3329 | * @param cls the 'struct BlacklistCheck*' | 3295 | * @param cls the 'struct BlacklistCheck*' |
3330 | * @param tc unused | 3296 | * @param tc unused |
3331 | */ | 3297 | */ |
3332 | static void | 3298 | static void do_blacklist_check (void *cls, |
3333 | do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 3299 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
3334 | 3300 | ||
3335 | /** | 3301 | /** |
3336 | * Transmit blacklist query to the client. | 3302 | * Transmit blacklist query to the client. |
@@ -3401,12 +3367,11 @@ do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3401 | if (bl->bc == NULL) | 3367 | if (bl->bc == NULL) |
3402 | { | 3368 | { |
3403 | bl->bc = bc; | 3369 | bl->bc = bc; |
3404 | bc->th = GNUNET_SERVER_notify_transmit_ready (bl->client, | 3370 | bc->th = |
3405 | sizeof (struct | 3371 | GNUNET_SERVER_notify_transmit_ready (bl->client, |
3406 | BlacklistMessage), | 3372 | sizeof (struct BlacklistMessage), |
3407 | GNUNET_TIME_UNIT_FOREVER_REL, | 3373 | GNUNET_TIME_UNIT_FOREVER_REL, |
3408 | &transmit_blacklist_message, | 3374 | &transmit_blacklist_message, bc); |
3409 | bc); | ||
3410 | } | 3375 | } |
3411 | } | 3376 | } |
3412 | 3377 | ||
@@ -3425,8 +3390,8 @@ do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3425 | */ | 3390 | */ |
3426 | static void | 3391 | static void |
3427 | setup_peer_check_blacklist (const struct GNUNET_PeerIdentity *peer, | 3392 | setup_peer_check_blacklist (const struct GNUNET_PeerIdentity *peer, |
3428 | int do_hello, | 3393 | int do_hello, SetupContinuation cont, |
3429 | SetupContinuation cont, void *cont_cls) | 3394 | void *cont_cls) |
3430 | { | 3395 | { |
3431 | struct NeighbourMapEntry *n; | 3396 | struct NeighbourMapEntry *n; |
3432 | struct BlacklistCheck *bc; | 3397 | struct BlacklistCheck *bc; |
@@ -3476,9 +3441,8 @@ confirm_or_drop_neighbour (void *cls, struct NeighbourMapEntry *n) | |||
3476 | if (n == NULL) | 3441 | if (n == NULL) |
3477 | { | 3442 | { |
3478 | #if DEBUG_TRANSPORT | 3443 | #if DEBUG_TRANSPORT |
3479 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3444 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n", |
3480 | "Disconnecting peer `%4s', %s\n", GNUNET_i2s (&orig->id), | 3445 | GNUNET_i2s (&orig->id), "confirm_or_drop_neighboUr"); |
3481 | "confirm_or_drop_neighboUr"); | ||
3482 | #endif | 3446 | #endif |
3483 | GNUNET_STATISTICS_update (stats, | 3447 | GNUNET_STATISTICS_update (stats, |
3484 | gettext_noop ("# disconnects due to blacklist"), | 3448 | gettext_noop ("# disconnects due to blacklist"), |
@@ -3530,8 +3494,7 @@ test_connection_ok (void *cls, const GNUNET_HashCode * key, void *value) | |||
3530 | * @param message the actual message | 3494 | * @param message the actual message |
3531 | */ | 3495 | */ |
3532 | static void | 3496 | static void |
3533 | handle_blacklist_init (void *cls, | 3497 | handle_blacklist_init (void *cls, struct GNUNET_SERVER_Client *client, |
3534 | struct GNUNET_SERVER_Client *client, | ||
3535 | const struct GNUNET_MessageHeader *message) | 3498 | const struct GNUNET_MessageHeader *message) |
3536 | { | 3499 | { |
3537 | struct Blacklisters *bl; | 3500 | struct Blacklisters *bl; |
@@ -3567,8 +3530,7 @@ handle_blacklist_init (void *cls, | |||
3567 | * @param message the actual message | 3530 | * @param message the actual message |
3568 | */ | 3531 | */ |
3569 | static void | 3532 | static void |
3570 | handle_blacklist_reply (void *cls, | 3533 | handle_blacklist_reply (void *cls, struct GNUNET_SERVER_Client *client, |
3571 | struct GNUNET_SERVER_Client *client, | ||
3572 | const struct GNUNET_MessageHeader *message) | 3534 | const struct GNUNET_MessageHeader *message) |
3573 | { | 3535 | { |
3574 | const struct BlacklistMessage *msg = | 3536 | const struct BlacklistMessage *msg = |
@@ -3658,8 +3620,8 @@ send_periodic_ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3658 | caec.session = peer_address->session; | 3620 | caec.session = peer_address->session; |
3659 | caec.exists = GNUNET_NO; | 3621 | caec.exists = GNUNET_NO; |
3660 | 3622 | ||
3661 | GNUNET_CONTAINER_multihashmap_iterate (validation_map, | 3623 | GNUNET_CONTAINER_multihashmap_iterate (validation_map, &check_address_exists, |
3662 | &check_address_exists, &caec); | 3624 | &caec); |
3663 | if (caec.exists == GNUNET_YES) | 3625 | if (caec.exists == GNUNET_YES) |
3664 | { | 3626 | { |
3665 | /* During validation attempts we will likely trigger the other | 3627 | /* During validation attempts we will likely trigger the other |
@@ -3669,19 +3631,19 @@ send_periodic_ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3669 | #if DEBUG_TRANSPORT > 1 | 3631 | #if DEBUG_TRANSPORT > 1 |
3670 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3632 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3671 | "Some validation of address `%s' via `%s' for peer `%4s' already in progress.\n", | 3633 | "Some validation of address `%s' via `%s' for peer `%4s' already in progress.\n", |
3672 | (peer_address->addr != NULL) | 3634 | (peer_address->addr != NULL) ? a2s (tp->short_name, |
3673 | ? a2s (tp->short_name, | 3635 | peer_address->addr, |
3674 | peer_address->addr, | 3636 | peer_address-> |
3675 | peer_address->addrlen) | 3637 | addrlen) : "<inbound>", |
3676 | : "<inbound>", tp->short_name, GNUNET_i2s (&neighbour->id)); | 3638 | tp->short_name, GNUNET_i2s (&neighbour->id)); |
3677 | #endif | 3639 | #endif |
3678 | schedule_next_ping (peer_address); | 3640 | schedule_next_ping (peer_address); |
3679 | return; | 3641 | return; |
3680 | } | 3642 | } |
3681 | va = GNUNET_malloc (sizeof (struct ValidationEntry) + peer_address->addrlen); | 3643 | va = GNUNET_malloc (sizeof (struct ValidationEntry) + peer_address->addrlen); |
3682 | va->transport_name = GNUNET_strdup (tp->short_name); | 3644 | va->transport_name = GNUNET_strdup (tp->short_name); |
3683 | va->challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, | 3645 | va->challenge = |
3684 | UINT_MAX); | 3646 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT_MAX); |
3685 | va->send_time = GNUNET_TIME_absolute_get (); | 3647 | va->send_time = GNUNET_TIME_absolute_get (); |
3686 | va->session = peer_address->session; | 3648 | va->session = peer_address->session; |
3687 | if (peer_address->addr != NULL) | 3649 | if (peer_address->addr != NULL) |
@@ -3690,15 +3652,13 @@ send_periodic_ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3690 | memcpy (&va[1], peer_address->addr, peer_address->addrlen); | 3652 | memcpy (&va[1], peer_address->addr, peer_address->addrlen); |
3691 | va->addrlen = peer_address->addrlen; | 3653 | va->addrlen = peer_address->addrlen; |
3692 | } | 3654 | } |
3693 | memcpy (&va->publicKey, | 3655 | memcpy (&va->publicKey, &neighbour->publicKey, |
3694 | &neighbour->publicKey, | ||
3695 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); | 3656 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); |
3696 | 3657 | ||
3697 | va->timeout_task = GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT, | 3658 | va->timeout_task = |
3698 | &timeout_hello_validation, | 3659 | GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT, |
3699 | va); | 3660 | &timeout_hello_validation, va); |
3700 | GNUNET_CONTAINER_multihashmap_put (validation_map, | 3661 | GNUNET_CONTAINER_multihashmap_put (validation_map, &neighbour->id.hashPubKey, |
3701 | &neighbour->id.hashPubKey, | ||
3702 | va, | 3662 | va, |
3703 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 3663 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
3704 | 3664 | ||
@@ -3729,8 +3689,9 @@ send_periodic_ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3729 | 3689 | ||
3730 | if (peer_address->addr != NULL) | 3690 | if (peer_address->addr != NULL) |
3731 | { | 3691 | { |
3732 | ping.header.size = htons (sizeof (struct TransportPingMessage) + | 3692 | ping.header.size = |
3733 | peer_address->addrlen + slen); | 3693 | htons (sizeof (struct TransportPingMessage) + peer_address->addrlen + |
3694 | slen); | ||
3734 | memcpy (&message_buf[hello_size + sizeof (struct TransportPingMessage)], | 3695 | memcpy (&message_buf[hello_size + sizeof (struct TransportPingMessage)], |
3735 | tp->short_name, slen); | 3696 | tp->short_name, slen); |
3736 | memcpy (&message_buf | 3697 | memcpy (&message_buf |
@@ -3742,19 +3703,18 @@ send_periodic_ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
3742 | ping.header.size = htons (sizeof (struct TransportPingMessage)); | 3703 | ping.header.size = htons (sizeof (struct TransportPingMessage)); |
3743 | } | 3704 | } |
3744 | 3705 | ||
3745 | memcpy (&message_buf[hello_size], | 3706 | memcpy (&message_buf[hello_size], &ping, |
3746 | &ping, sizeof (struct TransportPingMessage)); | 3707 | sizeof (struct TransportPingMessage)); |
3747 | 3708 | ||
3748 | #if DEBUG_TRANSPORT_REVALIDATION | 3709 | #if DEBUG_TRANSPORT_REVALIDATION |
3749 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3710 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3750 | "Performing re-validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s'\n", | 3711 | "Performing re-validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s'\n", |
3751 | (peer_address->addr != NULL) | 3712 | (peer_address->addr != |
3752 | ? a2s (peer_address->plugin->short_name, | 3713 | NULL) ? a2s (peer_address->plugin->short_name, |
3753 | peer_address->addr, | 3714 | peer_address->addr, |
3754 | peer_address->addrlen) | 3715 | peer_address->addrlen) : "<inbound>", |
3755 | : "<inbound>", | 3716 | tp->short_name, GNUNET_i2s (&neighbour->id), "HELLO", hello_size, |
3756 | tp->short_name, | 3717 | "PING"); |
3757 | GNUNET_i2s (&neighbour->id), "HELLO", hello_size, "PING"); | ||
3758 | #endif | 3718 | #endif |
3759 | if (peer_address->validated != GNUNET_YES) | 3719 | if (peer_address->validated != GNUNET_YES) |
3760 | GNUNET_STATISTICS_update (stats, | 3720 | GNUNET_STATISTICS_update (stats, |
@@ -3804,8 +3764,9 @@ schedule_next_ping (struct ForeignAddressList *fal) | |||
3804 | 3764 | ||
3805 | if (GNUNET_YES == fal->connected) | 3765 | if (GNUNET_YES == fal->connected) |
3806 | { | 3766 | { |
3807 | delay = GNUNET_TIME_relative_min (delay, | 3767 | delay = |
3808 | CONNECTED_LATENCY_EVALUATION_MAX_DELAY); | 3768 | GNUNET_TIME_relative_min (delay, |
3769 | CONNECTED_LATENCY_EVALUATION_MAX_DELAY); | ||
3809 | } | 3770 | } |
3810 | /* FIXME: also adjust delay based on how close the last | 3771 | /* FIXME: also adjust delay based on how close the last |
3811 | * observed latency is to the latency of the best alternative */ | 3772 | * observed latency is to the latency of the best alternative */ |
@@ -3816,9 +3777,8 @@ schedule_next_ping (struct ForeignAddressList *fal) | |||
3816 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000); | 3777 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000); |
3817 | 3778 | ||
3818 | GNUNET_assert (fal->revalidate_task == GNUNET_SCHEDULER_NO_TASK); | 3779 | GNUNET_assert (fal->revalidate_task == GNUNET_SCHEDULER_NO_TASK); |
3819 | fal->revalidate_task = GNUNET_SCHEDULER_add_delayed (delay, | 3780 | fal->revalidate_task = |
3820 | &send_periodic_ping, | 3781 | GNUNET_SCHEDULER_add_delayed (delay, &send_periodic_ping, fal); |
3821 | fal); | ||
3822 | } | 3782 | } |
3823 | 3783 | ||
3824 | 3784 | ||
@@ -3845,8 +3805,8 @@ handle_payload_message (const struct GNUNET_MessageHeader *message, | |||
3845 | #if DEBUG_TRANSPORT | 3805 | #if DEBUG_TRANSPORT |
3846 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3806 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3847 | "Received message of type %u and size %u from `%4s', but no pong yet!\n", | 3807 | "Received message of type %u and size %u from `%4s', but no pong yet!\n", |
3848 | ntohs (message->type), | 3808 | ntohs (message->type), ntohs (message->size), |
3849 | ntohs (message->size), GNUNET_i2s (&n->id)); | 3809 | GNUNET_i2s (&n->id)); |
3850 | #endif | 3810 | #endif |
3851 | GNUNET_free_non_null (n->pre_connect_message_buffer); | 3811 | GNUNET_free_non_null (n->pre_connect_message_buffer); |
3852 | n->pre_connect_message_buffer = GNUNET_malloc (msize); | 3812 | n->pre_connect_message_buffer = GNUNET_malloc (msize); |
@@ -3857,11 +3817,11 @@ handle_payload_message (const struct GNUNET_MessageHeader *message, | |||
3857 | #if DEBUG_TRANSPORT | 3817 | #if DEBUG_TRANSPORT |
3858 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3818 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3859 | "Received message of type %u and size %u from `%4s', sending to all clients.\n", | 3819 | "Received message of type %u and size %u from `%4s', sending to all clients.\n", |
3860 | ntohs (message->type), | 3820 | ntohs (message->type), ntohs (message->size), |
3861 | ntohs (message->size), GNUNET_i2s (&n->id)); | 3821 | GNUNET_i2s (&n->id)); |
3862 | #endif | 3822 | #endif |
3863 | if (GNUNET_YES == GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, | 3823 | if (GNUNET_YES == |
3864 | (ssize_t) msize)) | 3824 | GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, (ssize_t) msize)) |
3865 | { | 3825 | { |
3866 | n->quota_violation_count++; | 3826 | n->quota_violation_count++; |
3867 | #if DEBUG_TRANSPORT | 3827 | #if DEBUG_TRANSPORT |
@@ -3956,12 +3916,10 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) | |||
3956 | addr = (const char *) &pong[1]; | 3916 | addr = (const char *) &pong[1]; |
3957 | slen = strlen (ve->transport_name) + 1; | 3917 | slen = strlen (ve->transport_name) + 1; |
3958 | if ((ps - sizeof (struct TransportPongMessage) < slen) || | 3918 | if ((ps - sizeof (struct TransportPongMessage) < slen) || |
3959 | (ve->challenge != challenge) || | 3919 | (ve->challenge != challenge) || (addr[slen - 1] != '\0') || |
3960 | (addr[slen - 1] != '\0') || | ||
3961 | (0 != strcmp (addr, ve->transport_name)) || | 3920 | (0 != strcmp (addr, ve->transport_name)) || |
3962 | (ntohl (pong->purpose.size) | 3921 | (ntohl (pong->purpose.size) != |
3963 | != sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + | 3922 | sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + sizeof (uint32_t) + |
3964 | sizeof (uint32_t) + | ||
3965 | sizeof (struct GNUNET_TIME_AbsoluteNBO) + | 3923 | sizeof (struct GNUNET_TIME_AbsoluteNBO) + |
3966 | sizeof (struct GNUNET_PeerIdentity) + ps - | 3924 | sizeof (struct GNUNET_PeerIdentity) + ps - |
3967 | sizeof (struct TransportPongMessage))) | 3925 | sizeof (struct TransportPongMessage))) |
@@ -3985,8 +3943,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) | |||
3985 | } | 3943 | } |
3986 | if (GNUNET_OK != | 3944 | if (GNUNET_OK != |
3987 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, | 3945 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, |
3988 | &pong->purpose, | 3946 | &pong->purpose, &pong->signature, |
3989 | &pong->signature, &ve->publicKey)) | 3947 | &ve->publicKey)) |
3990 | { | 3948 | { |
3991 | GNUNET_break_op (0); | 3949 | GNUNET_break_op (0); |
3992 | return GNUNET_NO; | 3950 | return GNUNET_NO; |
@@ -3995,15 +3953,14 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) | |||
3995 | #if DEBUG_TRANSPORT | 3953 | #if DEBUG_TRANSPORT |
3996 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3954 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3997 | "Confirmed validity of address, peer `%4s' has address `%s' (%s).\n", | 3955 | "Confirmed validity of address, peer `%4s' has address `%s' (%s).\n", |
3998 | GNUNET_h2s (key), | 3956 | GNUNET_h2s (key), a2s (ve->transport_name, |
3999 | a2s (ve->transport_name, | 3957 | (const struct sockaddr *) ve->addr, |
4000 | (const struct sockaddr *) ve->addr, | 3958 | ve->addrlen), ve->transport_name); |
4001 | ve->addrlen), ve->transport_name); | ||
4002 | #endif | 3959 | #endif |
4003 | break; | 3960 | break; |
4004 | case GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING: | 3961 | case GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING: |
4005 | if (0 != memcmp (&pong->pid, | 3962 | if (0 != |
4006 | &my_identity, sizeof (struct GNUNET_PeerIdentity))) | 3963 | memcmp (&pong->pid, &my_identity, sizeof (struct GNUNET_PeerIdentity))) |
4007 | { | 3964 | { |
4008 | char *peer; | 3965 | char *peer; |
4009 | 3966 | ||
@@ -4050,8 +4007,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) | |||
4050 | } | 4007 | } |
4051 | if (GNUNET_OK != | 4008 | if (GNUNET_OK != |
4052 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING, | 4009 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING, |
4053 | &pong->purpose, | 4010 | &pong->purpose, &pong->signature, |
4054 | &pong->signature, &ve->publicKey)) | 4011 | &ve->publicKey)) |
4055 | { | 4012 | { |
4056 | GNUNET_break_op (0); | 4013 | GNUNET_break_op (0); |
4057 | return GNUNET_NO; | 4014 | return GNUNET_NO; |
@@ -4060,9 +4017,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) | |||
4060 | #if DEBUG_TRANSPORT | 4017 | #if DEBUG_TRANSPORT |
4061 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4018 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4062 | "Confirmed that peer `%4s' is talking to us using address `%s' (%s) for us.\n", | 4019 | "Confirmed that peer `%4s' is talking to us using address `%s' (%s) for us.\n", |
4063 | GNUNET_h2s (key), | 4020 | GNUNET_h2s (key), a2s (ve->transport_name, &addr[slen], alen), |
4064 | a2s (ve->transport_name, | 4021 | ve->transport_name); |
4065 | &addr[slen], alen), ve->transport_name); | ||
4066 | #endif | 4022 | #endif |
4067 | break; | 4023 | break; |
4068 | default: | 4024 | default: |
@@ -4077,8 +4033,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) | |||
4077 | return GNUNET_NO; | 4033 | return GNUNET_NO; |
4078 | } | 4034 | } |
4079 | GNUNET_STATISTICS_update (stats, | 4035 | GNUNET_STATISTICS_update (stats, |
4080 | gettext_noop ("# address validation successes"), | 4036 | gettext_noop ("# address validation successes"), 1, |
4081 | 1, GNUNET_NO); | 4037 | GNUNET_NO); |
4082 | /* create the updated HELLO */ | 4038 | /* create the updated HELLO */ |
4083 | GNUNET_CRYPTO_hash (&ve->publicKey, | 4039 | GNUNET_CRYPTO_hash (&ve->publicKey, |
4084 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 4040 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
@@ -4096,9 +4052,9 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) | |||
4096 | { | 4052 | { |
4097 | n->publicKey = ve->publicKey; | 4053 | n->publicKey = ve->publicKey; |
4098 | n->public_key_valid = GNUNET_YES; | 4054 | n->public_key_valid = GNUNET_YES; |
4099 | fal = add_peer_address (n, | 4055 | fal = |
4100 | ve->transport_name, | 4056 | add_peer_address (n, ve->transport_name, ve->session, ve->addr, |
4101 | ve->session, ve->addr, ve->addrlen); | 4057 | ve->addrlen); |
4102 | GNUNET_assert (fal != NULL); | 4058 | GNUNET_assert (fal != NULL); |
4103 | fal->expires = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION); | 4059 | fal->expires = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION); |
4104 | fal->validated = GNUNET_YES; | 4060 | fal->validated = GNUNET_YES; |
@@ -4109,9 +4065,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) | |||
4109 | GNUNET_NO); | 4065 | GNUNET_NO); |
4110 | fal->latency = GNUNET_TIME_absolute_get_duration (ve->send_time); | 4066 | fal->latency = GNUNET_TIME_absolute_get_duration (ve->send_time); |
4111 | update_addr_value (fal, | 4067 | update_addr_value (fal, |
4112 | GNUNET_TIME_absolute_get_duration (ve-> | 4068 | GNUNET_TIME_absolute_get_duration (ve->send_time). |
4113 | send_time).rel_value, | 4069 | rel_value, GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY); |
4114 | GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY); | ||
4115 | 4070 | ||
4116 | schedule_next_ping (fal); | 4071 | schedule_next_ping (fal); |
4117 | if (n->latency.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) | 4072 | if (n->latency.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) |
@@ -4142,8 +4097,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) | |||
4142 | 4097 | ||
4143 | /* clean up validation entry */ | 4098 | /* clean up validation entry */ |
4144 | GNUNET_assert (GNUNET_YES == | 4099 | GNUNET_assert (GNUNET_YES == |
4145 | GNUNET_CONTAINER_multihashmap_remove (validation_map, | 4100 | GNUNET_CONTAINER_multihashmap_remove (validation_map, key, |
4146 | key, ve)); | 4101 | ve)); |
4147 | abort_validation (NULL, NULL, ve); | 4102 | abort_validation (NULL, NULL, ve); |
4148 | return GNUNET_NO; | 4103 | return GNUNET_NO; |
4149 | } | 4104 | } |
@@ -4166,26 +4121,24 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) | |||
4166 | */ | 4121 | */ |
4167 | static void | 4122 | static void |
4168 | handle_pong (void *cls, const struct GNUNET_MessageHeader *message, | 4123 | handle_pong (void *cls, const struct GNUNET_MessageHeader *message, |
4169 | const struct GNUNET_PeerIdentity *peer, | 4124 | const struct GNUNET_PeerIdentity *peer, const char *sender_address, |
4170 | const char *sender_address, size_t sender_address_len) | 4125 | size_t sender_address_len) |
4171 | { | 4126 | { |
4172 | if (0 == memcmp (peer, &my_identity, sizeof (struct GNUNET_PeerIdentity))) | 4127 | if (0 == memcmp (peer, &my_identity, sizeof (struct GNUNET_PeerIdentity))) |
4173 | { | 4128 | { |
4174 | /* PONG send to self, ignore */ | 4129 | /* PONG send to self, ignore */ |
4175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4130 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message from myself\n", |
4176 | "Receiving `%s' message from myself\n", "PONG"); | 4131 | "PONG"); |
4177 | return; | 4132 | return; |
4178 | } | 4133 | } |
4179 | #if DEBUG_TRANSPORT > 1 | 4134 | #if DEBUG_TRANSPORT > 1 |
4180 | /* we get tons of these that just get discarded, only log | 4135 | /* we get tons of these that just get discarded, only log |
4181 | * if we are quite verbose */ | 4136 | * if we are quite verbose */ |
4182 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4137 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message from `%4s'.\n", |
4183 | "Receiving `%s' message from `%4s'.\n", "PONG", | 4138 | "PONG", GNUNET_i2s (peer)); |
4184 | GNUNET_i2s (peer)); | ||
4185 | #endif | 4139 | #endif |
4186 | GNUNET_STATISTICS_update (stats, | 4140 | GNUNET_STATISTICS_update (stats, gettext_noop ("# PONG messages received"), 1, |
4187 | gettext_noop ("# PONG messages received"), | 4141 | GNUNET_NO); |
4188 | 1, GNUNET_NO); | ||
4189 | if (GNUNET_SYSERR != | 4142 | if (GNUNET_SYSERR != |
4190 | GNUNET_CONTAINER_multihashmap_get_multiple (validation_map, | 4143 | GNUNET_CONTAINER_multihashmap_get_multiple (validation_map, |
4191 | &peer->hashPubKey, | 4144 | &peer->hashPubKey, |
@@ -4241,9 +4194,9 @@ transmit_hello_and_ping (void *cls, struct NeighbourMapEntry *neighbour) | |||
4241 | } | 4194 | } |
4242 | neighbour->publicKey = va->publicKey; | 4195 | neighbour->publicKey = va->publicKey; |
4243 | neighbour->public_key_valid = GNUNET_YES; | 4196 | neighbour->public_key_valid = GNUNET_YES; |
4244 | peer_address = add_peer_address (neighbour, | 4197 | peer_address = |
4245 | va->transport_name, NULL, | 4198 | add_peer_address (neighbour, va->transport_name, NULL, |
4246 | (const void *) &va[1], va->addrlen); | 4199 | (const void *) &va[1], va->addrlen); |
4247 | if (peer_address == NULL) | 4200 | if (peer_address == NULL) |
4248 | { | 4201 | { |
4249 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 4202 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -4268,8 +4221,8 @@ transmit_hello_and_ping (void *cls, struct NeighbourMapEntry *neighbour) | |||
4268 | ping.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PING); | 4221 | ping.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PING); |
4269 | memcpy (&ping.target, &neighbour->id, sizeof (struct GNUNET_PeerIdentity)); | 4222 | memcpy (&ping.target, &neighbour->id, sizeof (struct GNUNET_PeerIdentity)); |
4270 | memcpy (message_buf, our_hello, hello_size); | 4223 | memcpy (message_buf, our_hello, hello_size); |
4271 | memcpy (&message_buf[hello_size], | 4224 | memcpy (&message_buf[hello_size], &ping, |
4272 | &ping, sizeof (struct TransportPingMessage)); | 4225 | sizeof (struct TransportPingMessage)); |
4273 | memcpy (&message_buf[hello_size + sizeof (struct TransportPingMessage)], | 4226 | memcpy (&message_buf[hello_size + sizeof (struct TransportPingMessage)], |
4274 | va->transport_name, slen); | 4227 | va->transport_name, slen); |
4275 | memcpy (&message_buf | 4228 | memcpy (&message_buf |
@@ -4278,14 +4231,11 @@ transmit_hello_and_ping (void *cls, struct NeighbourMapEntry *neighbour) | |||
4278 | #if DEBUG_TRANSPORT | 4231 | #if DEBUG_TRANSPORT |
4279 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4232 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4280 | "Performing validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s' (%u bytes)\n", | 4233 | "Performing validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s' (%u bytes)\n", |
4281 | (va->addrlen == 0) | 4234 | (va->addrlen == 0) ? "<inbound>" : a2s (va->transport_name, |
4282 | ? "<inbound>" | 4235 | (const void *) &va[1], |
4283 | : a2s (va->transport_name, | 4236 | va->addrlen), |
4284 | (const void *) &va[1], va->addrlen), | 4237 | va->transport_name, GNUNET_i2s (&neighbour->id), "HELLO", |
4285 | va->transport_name, | 4238 | hello_size, "PING", |
4286 | GNUNET_i2s (&neighbour->id), | ||
4287 | "HELLO", hello_size, | ||
4288 | "PING", | ||
4289 | sizeof (struct TransportPingMessage) + va->addrlen + slen); | 4239 | sizeof (struct TransportPingMessage) + va->addrlen + slen); |
4290 | #endif | 4240 | #endif |
4291 | 4241 | ||
@@ -4313,10 +4263,9 @@ transmit_hello_and_ping (void *cls, struct NeighbourMapEntry *neighbour) | |||
4313 | * @return GNUNET_OK (always) | 4263 | * @return GNUNET_OK (always) |
4314 | */ | 4264 | */ |
4315 | static int | 4265 | static int |
4316 | run_validation (void *cls, | 4266 | run_validation (void *cls, const char *tname, |
4317 | const char *tname, | 4267 | struct GNUNET_TIME_Absolute expiration, const void *addr, |
4318 | struct GNUNET_TIME_Absolute expiration, | 4268 | uint16_t addrlen) |
4319 | const void *addr, uint16_t addrlen) | ||
4320 | { | 4269 | { |
4321 | struct CheckHelloValidatedContext *chvc = cls; | 4270 | struct CheckHelloValidatedContext *chvc = cls; |
4322 | struct GNUNET_PeerIdentity id; | 4271 | struct GNUNET_PeerIdentity id; |
@@ -4335,8 +4284,7 @@ run_validation (void *cls, | |||
4335 | tp = find_transport (tname); | 4284 | tp = find_transport (tname); |
4336 | if (tp == NULL) | 4285 | if (tp == NULL) |
4337 | { | 4286 | { |
4338 | GNUNET_log (GNUNET_ERROR_TYPE_INFO | | 4287 | GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, |
4339 | GNUNET_ERROR_TYPE_BULK, | ||
4340 | _ | 4288 | _ |
4341 | ("Transport `%s' not loaded, will not try to validate peer address using this transport.\n"), | 4289 | ("Transport `%s' not loaded, will not try to validate peer address using this transport.\n"), |
4342 | tname); | 4290 | tname); |
@@ -4363,8 +4311,7 @@ run_validation (void *cls, | |||
4363 | } | 4311 | } |
4364 | GNUNET_HELLO_get_key (chvc->hello, &pk); | 4312 | GNUNET_HELLO_get_key (chvc->hello, &pk); |
4365 | GNUNET_CRYPTO_hash (&pk, | 4313 | GNUNET_CRYPTO_hash (&pk, |
4366 | sizeof (struct | 4314 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
4367 | GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
4368 | &id.hashPubKey); | 4315 | &id.hashPubKey); |
4369 | 4316 | ||
4370 | if (is_blacklisted (&id, tp)) | 4317 | if (is_blacklisted (&id, tp)) |
@@ -4382,8 +4329,8 @@ run_validation (void *cls, | |||
4382 | caec.session = NULL; | 4329 | caec.session = NULL; |
4383 | caec.tname = tname; | 4330 | caec.tname = tname; |
4384 | caec.exists = GNUNET_NO; | 4331 | caec.exists = GNUNET_NO; |
4385 | GNUNET_CONTAINER_multihashmap_iterate (validation_map, | 4332 | GNUNET_CONTAINER_multihashmap_iterate (validation_map, &check_address_exists, |
4386 | &check_address_exists, &caec); | 4333 | &caec); |
4387 | if (caec.exists == GNUNET_YES) | 4334 | if (caec.exists == GNUNET_YES) |
4388 | { | 4335 | { |
4389 | /* During validation attempts we will likely trigger the other | 4336 | /* During validation attempts we will likely trigger the other |
@@ -4405,19 +4352,17 @@ run_validation (void *cls, | |||
4405 | va->chvc = chvc; | 4352 | va->chvc = chvc; |
4406 | chvc->ve_count++; | 4353 | chvc->ve_count++; |
4407 | va->transport_name = GNUNET_strdup (tname); | 4354 | va->transport_name = GNUNET_strdup (tname); |
4408 | va->challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, | 4355 | va->challenge = |
4409 | UINT_MAX); | 4356 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT_MAX); |
4410 | va->send_time = GNUNET_TIME_absolute_get (); | 4357 | va->send_time = GNUNET_TIME_absolute_get (); |
4411 | va->addr = (const void *) &va[1]; | 4358 | va->addr = (const void *) &va[1]; |
4412 | memcpy (&va[1], addr, addrlen); | 4359 | memcpy (&va[1], addr, addrlen); |
4413 | va->addrlen = addrlen; | 4360 | va->addrlen = addrlen; |
4414 | GNUNET_HELLO_get_key (chvc->hello, &va->publicKey); | 4361 | GNUNET_HELLO_get_key (chvc->hello, &va->publicKey); |
4415 | va->timeout_task = GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT, | 4362 | va->timeout_task = |
4416 | &timeout_hello_validation, | 4363 | GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT, |
4417 | va); | 4364 | &timeout_hello_validation, va); |
4418 | GNUNET_CONTAINER_multihashmap_put (validation_map, | 4365 | GNUNET_CONTAINER_multihashmap_put (validation_map, &id.hashPubKey, va, |
4419 | &id.hashPubKey, | ||
4420 | va, | ||
4421 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 4366 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
4422 | setup_peer_check_blacklist (&id, GNUNET_NO, &transmit_hello_and_ping, va); | 4367 | setup_peer_check_blacklist (&id, GNUNET_NO, &transmit_hello_and_ping, va); |
4423 | return GNUNET_OK; | 4368 | return GNUNET_OK; |
@@ -4434,8 +4379,7 @@ run_validation (void *cls, | |||
4434 | * @param err_msg NULL if successful, otherwise contains error message | 4379 | * @param err_msg NULL if successful, otherwise contains error message |
4435 | */ | 4380 | */ |
4436 | static void | 4381 | static void |
4437 | check_hello_validated (void *cls, | 4382 | check_hello_validated (void *cls, const struct GNUNET_PeerIdentity *peer, |
4438 | const struct GNUNET_PeerIdentity *peer, | ||
4439 | const struct GNUNET_HELLO_Message *h, | 4383 | const struct GNUNET_HELLO_Message *h, |
4440 | const char *err_msg) | 4384 | const char *err_msg) |
4441 | { | 4385 | { |
@@ -4515,8 +4459,8 @@ check_hello_validated (void *cls, | |||
4515 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4459 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4516 | "Calling hello_iterate_addresses for %s!\n", GNUNET_i2s (peer)); | 4460 | "Calling hello_iterate_addresses for %s!\n", GNUNET_i2s (peer)); |
4517 | #endif | 4461 | #endif |
4518 | GNUNET_HELLO_iterate_addresses (h, | 4462 | GNUNET_HELLO_iterate_addresses (h, GNUNET_NO, &add_to_foreign_address_list, |
4519 | GNUNET_NO, &add_to_foreign_address_list, n); | 4463 | n); |
4520 | try_transmission_to_peer (n); | 4464 | try_transmission_to_peer (n); |
4521 | } | 4465 | } |
4522 | else | 4466 | else |
@@ -4533,8 +4477,7 @@ check_hello_validated (void *cls, | |||
4533 | GNUNET_STATISTICS_update (stats, | 4477 | GNUNET_STATISTICS_update (stats, |
4534 | gettext_noop ("# HELLO validations (update case)"), | 4478 | gettext_noop ("# HELLO validations (update case)"), |
4535 | 1, GNUNET_NO); | 4479 | 1, GNUNET_NO); |
4536 | GNUNET_HELLO_iterate_new_addresses (chvc->hello, | 4480 | GNUNET_HELLO_iterate_new_addresses (chvc->hello, h, |
4537 | h, | ||
4538 | GNUNET_TIME_relative_to_absolute | 4481 | GNUNET_TIME_relative_to_absolute |
4539 | (HELLO_REVALIDATION_START_TIME), | 4482 | (HELLO_REVALIDATION_START_TIME), |
4540 | &run_validation, chvc); | 4483 | &run_validation, chvc); |
@@ -4579,8 +4522,8 @@ process_hello (struct TransportPlugin *plugin, | |||
4579 | { | 4522 | { |
4580 | #if DEBUG_TRANSPORT_HELLO | 4523 | #if DEBUG_TRANSPORT_HELLO |
4581 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4524 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4582 | "Unable to get public key from `%s' for `%4s'!\n", | 4525 | "Unable to get public key from `%s' for `%4s'!\n", "HELLO", |
4583 | "HELLO", GNUNET_i2s (&target)); | 4526 | GNUNET_i2s (&target)); |
4584 | #endif | 4527 | #endif |
4585 | GNUNET_break_op (0); | 4528 | GNUNET_break_op (0); |
4586 | return GNUNET_SYSERR; | 4529 | return GNUNET_SYSERR; |
@@ -4590,8 +4533,7 @@ process_hello (struct TransportPlugin *plugin, | |||
4590 | &target.hashPubKey); | 4533 | &target.hashPubKey); |
4591 | 4534 | ||
4592 | #if DEBUG_TRANSPORT_HELLO | 4535 | #if DEBUG_TRANSPORT_HELLO |
4593 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4536 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message for `%4s'\n", |
4594 | "Received `%s' message for `%4s'\n", | ||
4595 | "HELLO", GNUNET_i2s (&target)); | 4537 | "HELLO", GNUNET_i2s (&target)); |
4596 | #endif | 4538 | #endif |
4597 | if (0 == memcmp (&my_identity, &target, sizeof (struct GNUNET_PeerIdentity))) | 4539 | if (0 == memcmp (&my_identity, &target, sizeof (struct GNUNET_PeerIdentity))) |
@@ -4619,8 +4561,8 @@ process_hello (struct TransportPlugin *plugin, | |||
4619 | GNUNET_NO); | 4561 | GNUNET_NO); |
4620 | #if DEBUG_TRANSPORT_HELLO | 4562 | #if DEBUG_TRANSPORT_HELLO |
4621 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4563 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4622 | "Ignoring `%s' for `%4s', load too high.\n", | 4564 | "Ignoring `%s' for `%4s', load too high.\n", "HELLO", |
4623 | "HELLO", GNUNET_i2s (&target)); | 4565 | GNUNET_i2s (&target)); |
4624 | #endif | 4566 | #endif |
4625 | return GNUNET_OK; | 4567 | return GNUNET_OK; |
4626 | } | 4568 | } |
@@ -4629,9 +4571,8 @@ process_hello (struct TransportPlugin *plugin, | |||
4629 | chvc = chvc_head; | 4571 | chvc = chvc_head; |
4630 | while (NULL != chvc) | 4572 | while (NULL != chvc) |
4631 | { | 4573 | { |
4632 | if (GNUNET_HELLO_equals (hello, | 4574 | if (GNUNET_HELLO_equals (hello, chvc->hello, GNUNET_TIME_absolute_get ()). |
4633 | chvc->hello, | 4575 | abs_value > 0) |
4634 | GNUNET_TIME_absolute_get ()).abs_value > 0) | ||
4635 | { | 4576 | { |
4636 | #if DEBUG_TRANSPORT_HELLO > 2 | 4577 | #if DEBUG_TRANSPORT_HELLO > 2 |
4637 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4578 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -4641,8 +4582,8 @@ process_hello (struct TransportPlugin *plugin, | |||
4641 | return GNUNET_OK; /* validation already pending */ | 4582 | return GNUNET_OK; /* validation already pending */ |
4642 | } | 4583 | } |
4643 | if (GNUNET_HELLO_size (hello) == GNUNET_HELLO_size (chvc->hello)) | 4584 | if (GNUNET_HELLO_size (hello) == GNUNET_HELLO_size (chvc->hello)) |
4644 | GNUNET_break (0 != memcmp (hello, chvc->hello, | 4585 | GNUNET_break (0 != |
4645 | GNUNET_HELLO_size (hello))); | 4586 | memcmp (hello, chvc->hello, GNUNET_HELLO_size (hello))); |
4646 | chvc = chvc->next; | 4587 | chvc = chvc->next; |
4647 | } | 4588 | } |
4648 | 4589 | ||
@@ -4663,10 +4604,8 @@ process_hello (struct TransportPlugin *plugin, | |||
4663 | my_id = GNUNET_strdup (GNUNET_i2s (plugin->env.my_identity)); | 4604 | my_id = GNUNET_strdup (GNUNET_i2s (plugin->env.my_identity)); |
4664 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4605 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4665 | "%s: Starting validation of `%s' message for `%4s' via '%s' of size %u\n", | 4606 | "%s: Starting validation of `%s' message for `%4s' via '%s' of size %u\n", |
4666 | my_id, | 4607 | my_id, "HELLO", GNUNET_i2s (&target), plugin->short_name, |
4667 | "HELLO", | 4608 | GNUNET_HELLO_size (hello)); |
4668 | GNUNET_i2s (&target), | ||
4669 | plugin->short_name, GNUNET_HELLO_size (hello)); | ||
4670 | GNUNET_free (my_id); | 4609 | GNUNET_free (my_id); |
4671 | #endif | 4610 | #endif |
4672 | } | 4611 | } |
@@ -4768,8 +4707,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n, int check) | |||
4768 | rpos->addresses = peer_pos->next; | 4707 | rpos->addresses = peer_pos->next; |
4769 | if (peer_pos->connected == GNUNET_YES) | 4708 | if (peer_pos->connected == GNUNET_YES) |
4770 | { | 4709 | { |
4771 | GNUNET_STATISTICS_update (stats, | 4710 | GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), |
4772 | gettext_noop ("# connected addresses"), | ||
4773 | -1, GNUNET_NO); | 4711 | -1, GNUNET_NO); |
4774 | peer_pos->connected = GNUNET_NO; | 4712 | peer_pos->connected = GNUNET_NO; |
4775 | } | 4713 | } |
@@ -4804,8 +4742,9 @@ disconnect_neighbour (struct NeighbourMapEntry *n, int check) | |||
4804 | ("# bytes discarded due to disconnect"), | 4742 | ("# bytes discarded due to disconnect"), |
4805 | mq->message_buf_size, GNUNET_NO); | 4743 | mq->message_buf_size, GNUNET_NO); |
4806 | GNUNET_CONTAINER_DLL_remove (n->messages_head, n->messages_tail, mq); | 4744 | GNUNET_CONTAINER_DLL_remove (n->messages_head, n->messages_tail, mq); |
4807 | GNUNET_assert (0 == memcmp (&mq->neighbour_id, | 4745 | GNUNET_assert (0 == |
4808 | &n->id, sizeof (struct GNUNET_PeerIdentity))); | 4746 | memcmp (&mq->neighbour_id, &n->id, |
4747 | sizeof (struct GNUNET_PeerIdentity))); | ||
4809 | GNUNET_free (mq); | 4748 | GNUNET_free (mq); |
4810 | } | 4749 | } |
4811 | 4750 | ||
@@ -4813,8 +4752,9 @@ disconnect_neighbour (struct NeighbourMapEntry *n, int check) | |||
4813 | { | 4752 | { |
4814 | 4753 | ||
4815 | GNUNET_CONTAINER_DLL_remove (n->cont_head, n->cont_tail, mq); | 4754 | GNUNET_CONTAINER_DLL_remove (n->cont_head, n->cont_tail, mq); |
4816 | GNUNET_assert (0 == memcmp (&mq->neighbour_id, | 4755 | GNUNET_assert (0 == |
4817 | &n->id, sizeof (struct GNUNET_PeerIdentity))); | 4756 | memcmp (&mq->neighbour_id, &n->id, |
4757 | sizeof (struct GNUNET_PeerIdentity))); | ||
4818 | GNUNET_free (mq); | 4758 | GNUNET_free (mq); |
4819 | } | 4759 | } |
4820 | 4760 | ||
@@ -4842,9 +4782,8 @@ disconnect_neighbour (struct NeighbourMapEntry *n, int check) | |||
4842 | GNUNET_CONTAINER_multihashmap_remove (neighbours, | 4782 | GNUNET_CONTAINER_multihashmap_remove (neighbours, |
4843 | &n->id.hashPubKey, n)); | 4783 | &n->id.hashPubKey, n)); |
4844 | /* finally, free n itself */ | 4784 | /* finally, free n itself */ |
4845 | GNUNET_STATISTICS_update (stats, | 4785 | GNUNET_STATISTICS_update (stats, gettext_noop ("# active neighbours"), -1, |
4846 | gettext_noop ("# active neighbours"), | 4786 | GNUNET_NO); |
4847 | -1, GNUNET_NO); | ||
4848 | GNUNET_free_non_null (n->pre_connect_message_buffer); | 4787 | GNUNET_free_non_null (n->pre_connect_message_buffer); |
4849 | GNUNET_free (n); | 4788 | GNUNET_free (n); |
4850 | } | 4789 | } |
@@ -4856,8 +4795,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n, int check) | |||
4856 | */ | 4795 | */ |
4857 | static int | 4796 | static int |
4858 | handle_ping (void *cls, const struct GNUNET_MessageHeader *message, | 4797 | handle_ping (void *cls, const struct GNUNET_MessageHeader *message, |
4859 | const struct GNUNET_PeerIdentity *peer, | 4798 | const struct GNUNET_PeerIdentity *peer, struct Session *session, |
4860 | struct Session *session, | ||
4861 | const char *sender_address, uint16_t sender_address_len) | 4799 | const char *sender_address, uint16_t sender_address_len) |
4862 | { | 4800 | { |
4863 | struct TransportPlugin *plugin = cls; | 4801 | struct TransportPlugin *plugin = cls; |
@@ -4880,9 +4818,9 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, | |||
4880 | } | 4818 | } |
4881 | 4819 | ||
4882 | ping = (struct TransportPingMessage *) message; | 4820 | ping = (struct TransportPingMessage *) message; |
4883 | if (0 != memcmp (&ping->target, | 4821 | if (0 != |
4884 | plugin->env.my_identity, | 4822 | memcmp (&ping->target, plugin->env.my_identity, |
4885 | sizeof (struct GNUNET_PeerIdentity))) | 4823 | sizeof (struct GNUNET_PeerIdentity))) |
4886 | { | 4824 | { |
4887 | #if DEBUG_TRANSPORT | 4825 | #if DEBUG_TRANSPORT |
4888 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4826 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -4898,16 +4836,15 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, | |||
4898 | } | 4836 | } |
4899 | #if DEBUG_PING_PONG | 4837 | #if DEBUG_PING_PONG |
4900 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 4838 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
4901 | "Processing `%s' from `%s'\n", | 4839 | "Processing `%s' from `%s'\n", "PING", |
4902 | "PING", | 4840 | (sender_address != NULL) ? a2s (plugin->short_name, |
4903 | (sender_address != NULL) | 4841 | (const struct sockaddr *) |
4904 | ? a2s (plugin->short_name, | 4842 | sender_address, |
4905 | (const struct sockaddr *) sender_address, | 4843 | sender_address_len) : |
4906 | sender_address_len) : "<inbound>"); | 4844 | "<inbound>"); |
4907 | #endif | 4845 | #endif |
4908 | GNUNET_STATISTICS_update (stats, | 4846 | GNUNET_STATISTICS_update (stats, gettext_noop ("# PING messages received"), 1, |
4909 | gettext_noop ("# PING messages received"), | 4847 | GNUNET_NO); |
4910 | 1, GNUNET_NO); | ||
4911 | addr = (const char *) &ping[1]; | 4848 | addr = (const char *) &ping[1]; |
4912 | alen = ntohs (message->size) - sizeof (struct TransportPingMessage); | 4849 | alen = ntohs (message->size) - sizeof (struct TransportPingMessage); |
4913 | slen = strlen (plugin->short_name) + 1; | 4850 | slen = strlen (plugin->short_name) + 1; |
@@ -4930,8 +4867,8 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, | |||
4930 | */ | 4867 | */ |
4931 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4868 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4932 | "Creating PONG indicating that we received a connection at our address `%s' from `%s'.\n", | 4869 | "Creating PONG indicating that we received a connection at our address `%s' from `%s'.\n", |
4933 | a2s (plugin->short_name, | 4870 | a2s (plugin->short_name, sender_address, sender_address_len), |
4934 | sender_address, sender_address_len), GNUNET_i2s (peer)); | 4871 | GNUNET_i2s (peer)); |
4935 | 4872 | ||
4936 | pong = | 4873 | pong = |
4937 | GNUNET_malloc (sizeof (struct TransportPongMessage) + | 4874 | GNUNET_malloc (sizeof (struct TransportPongMessage) + |
@@ -4942,8 +4879,7 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, | |||
4942 | pong->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PONG); | 4879 | pong->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PONG); |
4943 | pong->purpose.size = | 4880 | pong->purpose.size = |
4944 | htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + | 4881 | htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + |
4945 | sizeof (uint32_t) + | 4882 | sizeof (uint32_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + |
4946 | sizeof (struct GNUNET_TIME_AbsoluteNBO) + | ||
4947 | sizeof (struct GNUNET_PeerIdentity) + sender_address_len + slen); | 4883 | sizeof (struct GNUNET_PeerIdentity) + sender_address_len + slen); |
4948 | pong->purpose.purpose = | 4884 | pong->purpose.purpose = |
4949 | htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING); | 4885 | htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING); |
@@ -4953,9 +4889,8 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, | |||
4953 | memcpy (&pong[1], plugin->short_name, slen); | 4889 | memcpy (&pong[1], plugin->short_name, slen); |
4954 | if ((sender_address != NULL) && (sender_address_len > 0)) | 4890 | if ((sender_address != NULL) && (sender_address_len > 0)) |
4955 | memcpy (&((char *) &pong[1])[slen], sender_address, sender_address_len); | 4891 | memcpy (&((char *) &pong[1])[slen], sender_address, sender_address_len); |
4956 | if (GNUNET_TIME_absolute_get_remaining | 4892 | if (GNUNET_TIME_absolute_get_remaining (session_header->pong_sig_expires). |
4957 | (session_header->pong_sig_expires).rel_value < | 4893 | rel_value < PONG_SIGNATURE_LIFETIME.rel_value / 4) |
4958 | PONG_SIGNATURE_LIFETIME.rel_value / 4) | ||
4959 | { | 4894 | { |
4960 | /* create / update cached sig */ | 4895 | /* create / update cached sig */ |
4961 | #if DEBUG_TRANSPORT | 4896 | #if DEBUG_TRANSPORT |
@@ -4975,8 +4910,7 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, | |||
4975 | pong->expiration = | 4910 | pong->expiration = |
4976 | GNUNET_TIME_absolute_hton (session_header->pong_sig_expires); | 4911 | GNUNET_TIME_absolute_hton (session_header->pong_sig_expires); |
4977 | } | 4912 | } |
4978 | memcpy (&pong->signature, | 4913 | memcpy (&pong->signature, &session_header->pong_signature, |
4979 | &session_header->pong_signature, | ||
4980 | sizeof (struct GNUNET_CRYPTO_RsaSignature)); | 4914 | sizeof (struct GNUNET_CRYPTO_RsaSignature)); |
4981 | 4915 | ||
4982 | 4916 | ||
@@ -5007,8 +4941,7 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, | |||
5007 | pong->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PONG); | 4941 | pong->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PONG); |
5008 | pong->purpose.size = | 4942 | pong->purpose.size = |
5009 | htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + | 4943 | htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + |
5010 | sizeof (uint32_t) + | 4944 | sizeof (uint32_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + |
5011 | sizeof (struct GNUNET_TIME_AbsoluteNBO) + | ||
5012 | sizeof (struct GNUNET_PeerIdentity) + alen + slen); | 4945 | sizeof (struct GNUNET_PeerIdentity) + alen + slen); |
5013 | pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN); | 4946 | pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN); |
5014 | pong->challenge = ping->challenge; | 4947 | pong->challenge = ping->challenge; |
@@ -5029,11 +4962,10 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, | |||
5029 | GNUNET_TIME_relative_to_absolute (PONG_SIGNATURE_LIFETIME); | 4962 | GNUNET_TIME_relative_to_absolute (PONG_SIGNATURE_LIFETIME); |
5030 | pong->expiration = GNUNET_TIME_absolute_hton (oal->pong_sig_expires); | 4963 | pong->expiration = GNUNET_TIME_absolute_hton (oal->pong_sig_expires); |
5031 | GNUNET_assert (GNUNET_OK == | 4964 | GNUNET_assert (GNUNET_OK == |
5032 | GNUNET_CRYPTO_rsa_sign (my_private_key, | 4965 | GNUNET_CRYPTO_rsa_sign (my_private_key, &pong->purpose, |
5033 | &pong->purpose, | ||
5034 | &oal->pong_signature)); | 4966 | &oal->pong_signature)); |
5035 | memcpy (&pong->signature, | 4967 | memcpy (&pong->signature, &oal->pong_signature, |
5036 | &oal->pong_signature, sizeof (struct GNUNET_CRYPTO_RsaSignature)); | 4968 | sizeof (struct GNUNET_CRYPTO_RsaSignature)); |
5037 | } | 4969 | } |
5038 | else if (oal == NULL) | 4970 | else if (oal == NULL) |
5039 | { | 4971 | { |
@@ -5049,8 +4981,8 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, | |||
5049 | { | 4981 | { |
5050 | /* can used cached version */ | 4982 | /* can used cached version */ |
5051 | pong->expiration = GNUNET_TIME_absolute_hton (oal->pong_sig_expires); | 4983 | pong->expiration = GNUNET_TIME_absolute_hton (oal->pong_sig_expires); |
5052 | memcpy (&pong->signature, | 4984 | memcpy (&pong->signature, &oal->pong_signature, |
5053 | &oal->pong_signature, sizeof (struct GNUNET_CRYPTO_RsaSignature)); | 4985 | sizeof (struct GNUNET_CRYPTO_RsaSignature)); |
5054 | } | 4986 | } |
5055 | } | 4987 | } |
5056 | n = find_neighbour (peer); | 4988 | n = find_neighbour (peer); |
@@ -5063,15 +4995,13 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, | |||
5063 | fal = rl->addresses; | 4995 | fal = rl->addresses; |
5064 | while (fal != NULL) | 4996 | while (fal != NULL) |
5065 | { | 4997 | { |
5066 | if (-1 != rl->plugin->api->send (rl->plugin->api->cls, | 4998 | if (-1 != |
5067 | peer, | 4999 | rl->plugin->api->send (rl->plugin->api->cls, peer, |
5068 | (const char *) pong, | 5000 | (const char *) pong, ntohs (pong->header.size), |
5069 | ntohs (pong->header.size), | 5001 | TRANSPORT_PONG_PRIORITY, |
5070 | TRANSPORT_PONG_PRIORITY, | 5002 | HELLO_VERIFICATION_TIMEOUT, fal->session, |
5071 | HELLO_VERIFICATION_TIMEOUT, | 5003 | fal->addr, fal->addrlen, GNUNET_SYSERR, NULL, |
5072 | fal->session, | 5004 | NULL)) |
5073 | fal->addr, | ||
5074 | fal->addrlen, GNUNET_SYSERR, NULL, NULL)) | ||
5075 | { | 5005 | { |
5076 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5006 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5077 | "Transmitted PONG to `%s' via reliable mechanism\n", | 5007 | "Transmitted PONG to `%s' via reliable mechanism\n", |
@@ -5102,13 +5032,11 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, | |||
5102 | { | 5032 | { |
5103 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5033 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5104 | "Transmitting PONG to `%s' via unreliable mechanism `%s':%s\n", | 5034 | "Transmitting PONG to `%s' via unreliable mechanism `%s':%s\n", |
5105 | GNUNET_i2s (peer), | 5035 | GNUNET_i2s (peer), a2s (rl->plugin->short_name, fal->addr, |
5106 | a2s (rl->plugin->short_name, | 5036 | fal->addrlen), |
5107 | fal->addr, fal->addrlen), rl->plugin->short_name); | 5037 | rl->plugin->short_name); |
5108 | transmit_to_peer (NULL, fal, | 5038 | transmit_to_peer (NULL, fal, TRANSPORT_PONG_PRIORITY, |
5109 | TRANSPORT_PONG_PRIORITY, | 5039 | HELLO_VERIFICATION_TIMEOUT, (const char *) pong, |
5110 | HELLO_VERIFICATION_TIMEOUT, | ||
5111 | (const char *) pong, | ||
5112 | ntohs (pong->header.size), GNUNET_YES, n); | 5040 | ntohs (pong->header.size), GNUNET_YES, n); |
5113 | did_pong = GNUNET_YES; | 5041 | did_pong = GNUNET_YES; |
5114 | fal = fal->next; | 5042 | fal = fal->next; |
@@ -5146,8 +5074,7 @@ static struct GNUNET_TIME_Relative | |||
5146 | plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 5074 | plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
5147 | const struct GNUNET_MessageHeader *message, | 5075 | const struct GNUNET_MessageHeader *message, |
5148 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data, | 5076 | const struct GNUNET_TRANSPORT_ATS_Information *ats_data, |
5149 | uint32_t ats_count, | 5077 | uint32_t ats_count, struct Session *session, |
5150 | struct Session *session, | ||
5151 | const char *sender_address, uint16_t sender_address_len) | 5078 | const char *sender_address, uint16_t sender_address_len) |
5152 | { | 5079 | { |
5153 | struct TransportPlugin *plugin = cls; | 5080 | struct TransportPlugin *plugin = cls; |
@@ -5185,10 +5112,9 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5185 | if (message != NULL) | 5112 | if (message != NULL) |
5186 | { | 5113 | { |
5187 | if ((session != NULL) || (sender_address != NULL)) | 5114 | if ((session != NULL) || (sender_address != NULL)) |
5188 | peer_address = add_peer_address (n, | 5115 | peer_address = |
5189 | plugin->short_name, | 5116 | add_peer_address (n, plugin->short_name, session, sender_address, |
5190 | session, | 5117 | sender_address_len); |
5191 | sender_address, sender_address_len); | ||
5192 | if (peer_address != NULL) | 5118 | if (peer_address != NULL) |
5193 | { | 5119 | { |
5194 | update_addr_ats (peer_address, ats_data, ats_count); | 5120 | update_addr_ats (peer_address, ats_data, ats_count); |
@@ -5216,8 +5142,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5216 | GNUNET_SCHEDULER_add_now (&send_periodic_ping, peer_address); | 5142 | GNUNET_SCHEDULER_add_now (&send_periodic_ping, peer_address); |
5217 | 5143 | ||
5218 | } | 5144 | } |
5219 | peer_address->timeout | 5145 | peer_address->timeout = |
5220 | = | ||
5221 | GNUNET_TIME_relative_to_absolute | 5146 | GNUNET_TIME_relative_to_absolute |
5222 | (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | 5147 | (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); |
5223 | } | 5148 | } |
@@ -5239,8 +5164,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5239 | if (n->quota_violation_count > QUOTA_VIOLATION_DROP_THRESHOLD) | 5164 | if (n->quota_violation_count > QUOTA_VIOLATION_DROP_THRESHOLD) |
5240 | { | 5165 | { |
5241 | /* dropping message due to frequent inbound volume violations! */ | 5166 | /* dropping message due to frequent inbound volume violations! */ |
5242 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING | | 5167 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, |
5243 | GNUNET_ERROR_TYPE_BULK, | ||
5244 | _ | 5168 | _ |
5245 | ("Dropping incoming message due to repeated bandwidth quota (%u b/s) violations (total of %u).\n"), | 5169 | ("Dropping incoming message due to repeated bandwidth quota (%u b/s) violations (total of %u).\n"), |
5246 | n->in_tracker.available_bytes_per_s__, | 5170 | n->in_tracker.available_bytes_per_s__, |
@@ -5277,8 +5201,8 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5277 | #if DEBUG_PING_PONG | 5201 | #if DEBUG_PING_PONG |
5278 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5202 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5279 | "Received message of type %u and size %u from `%4s', sending to all clients.\n", | 5203 | "Received message of type %u and size %u from `%4s', sending to all clients.\n", |
5280 | ntohs (message->type), | 5204 | ntohs (message->type), ntohs (message->size), |
5281 | ntohs (message->size), GNUNET_i2s (peer)); | 5205 | GNUNET_i2s (peer)); |
5282 | #endif | 5206 | #endif |
5283 | switch (ntohs (message->type)) | 5207 | switch (ntohs (message->type)) |
5284 | { | 5208 | { |
@@ -5311,13 +5235,12 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5311 | #if DEBUG_TRANSPORT | 5235 | #if DEBUG_TRANSPORT |
5312 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5236 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5313 | "Throttling read (%llu bytes excess at %u b/s), waiting %llu ms before reading more.\n", | 5237 | "Throttling read (%llu bytes excess at %u b/s), waiting %llu ms before reading more.\n", |
5314 | (unsigned long long) n-> | 5238 | (unsigned long long) n->in_tracker. |
5315 | in_tracker.consumption_since_last_update__, | 5239 | consumption_since_last_update__, |
5316 | (unsigned int) n->in_tracker.available_bytes_per_s__, | 5240 | (unsigned int) n->in_tracker.available_bytes_per_s__, |
5317 | (unsigned long long) ret.rel_value); | 5241 | (unsigned long long) ret.rel_value); |
5318 | #endif | 5242 | #endif |
5319 | GNUNET_STATISTICS_update (stats, | 5243 | GNUNET_STATISTICS_update (stats, gettext_noop ("# ms throttling suggested"), |
5320 | gettext_noop ("# ms throttling suggested"), | ||
5321 | (int64_t) ret.rel_value, GNUNET_NO); | 5244 | (int64_t) ret.rel_value, GNUNET_NO); |
5322 | } | 5245 | } |
5323 | return ret; | 5246 | return ret; |
@@ -5325,8 +5248,8 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5325 | 5248 | ||
5326 | 5249 | ||
5327 | static int | 5250 | static int |
5328 | notify_client_about_neighbour (void *cls, | 5251 | notify_client_about_neighbour (void *cls, const GNUNET_HashCode * key, |
5329 | const GNUNET_HashCode * key, void *value) | 5252 | void *value) |
5330 | { | 5253 | { |
5331 | struct TransportClient *c = cls; | 5254 | struct TransportClient *c = cls; |
5332 | struct NeighbourMapEntry *n = value; | 5255 | struct NeighbourMapEntry *n = value; |
@@ -5371,8 +5294,7 @@ notify_client_about_neighbour (void *cls, | |||
5371 | * @param message the actual message | 5294 | * @param message the actual message |
5372 | */ | 5295 | */ |
5373 | static void | 5296 | static void |
5374 | handle_start (void *cls, | 5297 | handle_start (void *cls, struct GNUNET_SERVER_Client *client, |
5375 | struct GNUNET_SERVER_Client *client, | ||
5376 | const struct GNUNET_MessageHeader *message) | 5298 | const struct GNUNET_MessageHeader *message) |
5377 | { | 5299 | { |
5378 | const struct StartMessage *start; | 5300 | const struct StartMessage *start; |
@@ -5380,8 +5302,8 @@ handle_start (void *cls, | |||
5380 | 5302 | ||
5381 | start = (const struct StartMessage *) message; | 5303 | start = (const struct StartMessage *) message; |
5382 | #if DEBUG_TRANSPORT | 5304 | #if DEBUG_TRANSPORT |
5383 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5305 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' request from client\n", |
5384 | "Received `%s' request from client\n", "START"); | 5306 | "START"); |
5385 | #endif | 5307 | #endif |
5386 | c = clients; | 5308 | c = clients; |
5387 | while (c != NULL) | 5309 | while (c != NULL) |
@@ -5396,8 +5318,9 @@ handle_start (void *cls, | |||
5396 | c = c->next; | 5318 | c = c->next; |
5397 | } | 5319 | } |
5398 | if ((GNUNET_NO != ntohl (start->do_check)) && | 5320 | if ((GNUNET_NO != ntohl (start->do_check)) && |
5399 | (0 != memcmp (&start->self, | 5321 | (0 != |
5400 | &my_identity, sizeof (struct GNUNET_PeerIdentity)))) | 5322 | memcmp (&start->self, &my_identity, |
5323 | sizeof (struct GNUNET_PeerIdentity)))) | ||
5401 | { | 5324 | { |
5402 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 5325 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
5403 | _ | 5326 | _ |
@@ -5413,11 +5336,10 @@ handle_start (void *cls, | |||
5413 | if (our_hello != NULL) | 5336 | if (our_hello != NULL) |
5414 | { | 5337 | { |
5415 | #if DEBUG_TRANSPORT | 5338 | #if DEBUG_TRANSPORT |
5416 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5339 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending our own `%s' to new client\n", |
5417 | "Sending our own `%s' to new client\n", "HELLO"); | 5340 | "HELLO"); |
5418 | #endif | 5341 | #endif |
5419 | transmit_to_client (c, | 5342 | transmit_to_client (c, (const struct GNUNET_MessageHeader *) our_hello, |
5420 | (const struct GNUNET_MessageHeader *) our_hello, | ||
5421 | GNUNET_NO); | 5343 | GNUNET_NO); |
5422 | /* tell new client about all existing connections */ | 5344 | /* tell new client about all existing connections */ |
5423 | GNUNET_CONTAINER_multihashmap_iterate (neighbours, | 5345 | GNUNET_CONTAINER_multihashmap_iterate (neighbours, |
@@ -5443,15 +5365,14 @@ handle_start (void *cls, | |||
5443 | * @param message the actual message | 5365 | * @param message the actual message |
5444 | */ | 5366 | */ |
5445 | static void | 5367 | static void |
5446 | handle_hello (void *cls, | 5368 | handle_hello (void *cls, struct GNUNET_SERVER_Client *client, |
5447 | struct GNUNET_SERVER_Client *client, | ||
5448 | const struct GNUNET_MessageHeader *message) | 5369 | const struct GNUNET_MessageHeader *message) |
5449 | { | 5370 | { |
5450 | int ret; | 5371 | int ret; |
5451 | 5372 | ||
5452 | GNUNET_STATISTICS_update (stats, | 5373 | GNUNET_STATISTICS_update (stats, |
5453 | gettext_noop ("# HELLOs received from clients"), | 5374 | gettext_noop ("# HELLOs received from clients"), 1, |
5454 | 1, GNUNET_NO); | 5375 | GNUNET_NO); |
5455 | ret = process_hello (NULL, message); | 5376 | ret = process_hello (NULL, message); |
5456 | GNUNET_SERVER_receive_done (client, ret); | 5377 | GNUNET_SERVER_receive_done (client, ret); |
5457 | } | 5378 | } |
@@ -5521,8 +5442,7 @@ transmit_client_message (void *cls, struct NeighbourMapEntry *n) | |||
5521 | * @param message the actual message | 5442 | * @param message the actual message |
5522 | */ | 5443 | */ |
5523 | static void | 5444 | static void |
5524 | handle_send (void *cls, | 5445 | handle_send (void *cls, struct GNUNET_SERVER_Client *client, |
5525 | struct GNUNET_SERVER_Client *client, | ||
5526 | const struct GNUNET_MessageHeader *message) | 5446 | const struct GNUNET_MessageHeader *message) |
5527 | { | 5447 | { |
5528 | const struct OutboundMessage *obm; | 5448 | const struct OutboundMessage *obm; |
@@ -5560,8 +5480,8 @@ handle_send (void *cls, | |||
5560 | /* FIXME: this memcpy can be up to 7% of our total runtime */ | 5480 | /* FIXME: this memcpy can be up to 7% of our total runtime */ |
5561 | memcpy (&tcmc[1], obmm, msize); | 5481 | memcpy (&tcmc[1], obmm, msize); |
5562 | GNUNET_SERVER_client_keep (client); | 5482 | GNUNET_SERVER_client_keep (client); |
5563 | setup_peer_check_blacklist (&obm->peer, GNUNET_YES, | 5483 | setup_peer_check_blacklist (&obm->peer, GNUNET_YES, &transmit_client_message, |
5564 | &transmit_client_message, tcmc); | 5484 | tcmc); |
5565 | } | 5485 | } |
5566 | 5486 | ||
5567 | 5487 | ||
@@ -5573,8 +5493,7 @@ handle_send (void *cls, | |||
5573 | * @param message the actual message | 5493 | * @param message the actual message |
5574 | */ | 5494 | */ |
5575 | static void | 5495 | static void |
5576 | handle_request_connect (void *cls, | 5496 | handle_request_connect (void *cls, struct GNUNET_SERVER_Client *client, |
5577 | struct GNUNET_SERVER_Client *client, | ||
5578 | const struct GNUNET_MessageHeader *message) | 5497 | const struct GNUNET_MessageHeader *message) |
5579 | { | 5498 | { |
5580 | const struct TransportRequestConnectMessage *trcm = | 5499 | const struct TransportRequestConnectMessage *trcm = |
@@ -5602,16 +5521,15 @@ handle_request_connect (void *cls, | |||
5602 | * @param message the actual message | 5521 | * @param message the actual message |
5603 | */ | 5522 | */ |
5604 | static void | 5523 | static void |
5605 | handle_set_quota (void *cls, | 5524 | handle_set_quota (void *cls, struct GNUNET_SERVER_Client *client, |
5606 | struct GNUNET_SERVER_Client *client, | ||
5607 | const struct GNUNET_MessageHeader *message) | 5525 | const struct GNUNET_MessageHeader *message) |
5608 | { | 5526 | { |
5609 | const struct QuotaSetMessage *qsm = (const struct QuotaSetMessage *) message; | 5527 | const struct QuotaSetMessage *qsm = (const struct QuotaSetMessage *) message; |
5610 | struct NeighbourMapEntry *n; | 5528 | struct NeighbourMapEntry *n; |
5611 | 5529 | ||
5612 | GNUNET_STATISTICS_update (stats, | 5530 | GNUNET_STATISTICS_update (stats, |
5613 | gettext_noop ("# SET QUOTA messages received"), | 5531 | gettext_noop ("# SET QUOTA messages received"), 1, |
5614 | 1, GNUNET_NO); | 5532 | GNUNET_NO); |
5615 | n = find_neighbour (&qsm->peer); | 5533 | n = find_neighbour (&qsm->peer); |
5616 | if (n == NULL) | 5534 | if (n == NULL) |
5617 | { | 5535 | { |
@@ -5625,8 +5543,7 @@ handle_set_quota (void *cls, | |||
5625 | #if DEBUG_TRANSPORT | 5543 | #if DEBUG_TRANSPORT |
5626 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5544 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5627 | "Received `%s' request (new quota %u, old quota %u) from client for peer `%4s'\n", | 5545 | "Received `%s' request (new quota %u, old quota %u) from client for peer `%4s'\n", |
5628 | "SET_QUOTA", | 5546 | "SET_QUOTA", (unsigned int) ntohl (qsm->quota.value__), |
5629 | (unsigned int) ntohl (qsm->quota.value__), | ||
5630 | (unsigned int) n->in_tracker.available_bytes_per_s__, | 5547 | (unsigned int) n->in_tracker.available_bytes_per_s__, |
5631 | GNUNET_i2s (&qsm->peer)); | 5548 | GNUNET_i2s (&qsm->peer)); |
5632 | #endif | 5549 | #endif |
@@ -5634,9 +5551,8 @@ handle_set_quota (void *cls, | |||
5634 | if (0 == ntohl (qsm->quota.value__)) | 5551 | if (0 == ntohl (qsm->quota.value__)) |
5635 | { | 5552 | { |
5636 | #if DEBUG_TRANSPORT | 5553 | #if DEBUG_TRANSPORT |
5637 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5554 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n", |
5638 | "Disconnecting peer `%4s', %s\n", GNUNET_i2s (&n->id), | 5555 | GNUNET_i2s (&n->id), "SET_QUOTA"); |
5639 | "SET_QUOTA"); | ||
5640 | #endif | 5556 | #endif |
5641 | GNUNET_STATISTICS_update (stats, | 5557 | GNUNET_STATISTICS_update (stats, |
5642 | gettext_noop ("# disconnects due to quota of 0"), | 5558 | gettext_noop ("# disconnects due to quota of 0"), |
@@ -5683,8 +5599,7 @@ transmit_address_to_client (void *cls, const char *address) | |||
5683 | * @param message the actual message | 5599 | * @param message the actual message |
5684 | */ | 5600 | */ |
5685 | static void | 5601 | static void |
5686 | handle_address_lookup (void *cls, | 5602 | handle_address_lookup (void *cls, struct GNUNET_SERVER_Client *client, |
5687 | struct GNUNET_SERVER_Client *client, | ||
5688 | const struct GNUNET_MessageHeader *message) | 5603 | const struct GNUNET_MessageHeader *message) |
5689 | { | 5604 | { |
5690 | const struct AddressLookupMessage *alum; | 5605 | const struct AddressLookupMessage *alum; |
@@ -5734,11 +5649,8 @@ handle_address_lookup (void *cls, | |||
5734 | } | 5649 | } |
5735 | GNUNET_SERVER_disable_receive_done_warning (client); | 5650 | GNUNET_SERVER_disable_receive_done_warning (client); |
5736 | tc = GNUNET_SERVER_transmit_context_create (client); | 5651 | tc = GNUNET_SERVER_transmit_context_create (client); |
5737 | lsPlugin->api->address_pretty_printer (lsPlugin->api->cls, | 5652 | lsPlugin->api->address_pretty_printer (lsPlugin->api->cls, nameTransport, |
5738 | nameTransport, | 5653 | address, addressLen, numeric, rtimeout, |
5739 | address, addressLen, | ||
5740 | numeric, | ||
5741 | rtimeout, | ||
5742 | &transmit_address_to_client, tc); | 5654 | &transmit_address_to_client, tc); |
5743 | } | 5655 | } |
5744 | 5656 | ||
@@ -5750,8 +5662,7 @@ handle_address_lookup (void *cls, | |||
5750 | * @param message the actual message | 5662 | * @param message the actual message |
5751 | */ | 5663 | */ |
5752 | static void | 5664 | static void |
5753 | handle_peer_address_lookup (void *cls, | 5665 | handle_peer_address_lookup (void *cls, struct GNUNET_SERVER_Client *client, |
5754 | struct GNUNET_SERVER_Client *client, | ||
5755 | const struct GNUNET_MessageHeader *message) | 5666 | const struct GNUNET_MessageHeader *message) |
5756 | { | 5667 | { |
5757 | const struct PeerAddressLookupMessage *peer_address_lookup; | 5668 | const struct PeerAddressLookupMessage *peer_address_lookup; |
@@ -5804,22 +5715,20 @@ handle_peer_address_lookup (void *cls, | |||
5804 | a2s (transport_plugin->short_name, | 5715 | a2s (transport_plugin->short_name, |
5805 | foreign_address_iterator->addr, | 5716 | foreign_address_iterator->addr, |
5806 | foreign_address_iterator->addrlen), | 5717 | foreign_address_iterator->addrlen), |
5807 | (foreign_address_iterator->connected | 5718 | (foreign_address_iterator->connected == |
5808 | == GNUNET_YES) ? "CONNECTED" | 5719 | GNUNET_YES) ? "CONNECTED" : "DISCONNECTED", |
5809 | : "DISCONNECTED", | 5720 | (foreign_address_iterator->validated == |
5810 | (foreign_address_iterator->validated | 5721 | GNUNET_YES) ? "VALIDATED" : "UNVALIDATED"); |
5811 | == GNUNET_YES) ? "VALIDATED" : "UNVALIDATED"); | ||
5812 | transmit_address_to_client (tc, addr_buf); | 5722 | transmit_address_to_client (tc, addr_buf); |
5813 | GNUNET_free (addr_buf); | 5723 | GNUNET_free (addr_buf); |
5814 | } | 5724 | } |
5815 | else if (foreign_address_iterator->addrlen == 0) | 5725 | else if (foreign_address_iterator->addrlen == 0) |
5816 | { | 5726 | { |
5817 | GNUNET_asprintf (&addr_buf, "%s --- %s, %s", "<inbound>", | 5727 | GNUNET_asprintf (&addr_buf, "%s --- %s, %s", "<inbound>", |
5818 | (foreign_address_iterator->connected | 5728 | (foreign_address_iterator->connected == |
5819 | == GNUNET_YES) ? "CONNECTED" | 5729 | GNUNET_YES) ? "CONNECTED" : "DISCONNECTED", |
5820 | : "DISCONNECTED", | 5730 | (foreign_address_iterator->validated == |
5821 | (foreign_address_iterator->validated | 5731 | GNUNET_YES) ? "VALIDATED" : "UNVALIDATED"); |
5822 | == GNUNET_YES) ? "VALIDATED" : "UNVALIDATED"); | ||
5823 | transmit_address_to_client (tc, addr_buf); | 5732 | transmit_address_to_client (tc, addr_buf); |
5824 | GNUNET_free (addr_buf); | 5733 | GNUNET_free (addr_buf); |
5825 | } | 5734 | } |
@@ -5859,24 +5768,21 @@ output_addresses (void *cls, const GNUNET_HashCode * key, void *value) | |||
5859 | a2s (transport_plugin->short_name, | 5768 | a2s (transport_plugin->short_name, |
5860 | foreign_address_iterator->addr, | 5769 | foreign_address_iterator->addr, |
5861 | foreign_address_iterator->addrlen), | 5770 | foreign_address_iterator->addrlen), |
5862 | (foreign_address_iterator->connected | 5771 | (foreign_address_iterator->connected == |
5863 | == GNUNET_YES) ? "CONNECTED" | 5772 | GNUNET_YES) ? "CONNECTED" : "DISCONNECTED", |
5864 | : "DISCONNECTED", | 5773 | (foreign_address_iterator->validated == |
5865 | (foreign_address_iterator->validated | 5774 | GNUNET_YES) ? "VALIDATED" : "UNVALIDATED"); |
5866 | == GNUNET_YES) ? "VALIDATED" : "UNVALIDATED"); | ||
5867 | transmit_address_to_client (tc, addr_buf); | 5775 | transmit_address_to_client (tc, addr_buf); |
5868 | GNUNET_free (addr_buf); | 5776 | GNUNET_free (addr_buf); |
5869 | } | 5777 | } |
5870 | else if (foreign_address_iterator->addrlen == 0) | 5778 | else if (foreign_address_iterator->addrlen == 0) |
5871 | { | 5779 | { |
5872 | GNUNET_asprintf (&addr_buf, "%s:%s --- %s, %s", | 5780 | GNUNET_asprintf (&addr_buf, "%s:%s --- %s, %s", |
5873 | GNUNET_i2s (&neighbor_iterator->id), | 5781 | GNUNET_i2s (&neighbor_iterator->id), "<inbound>", |
5874 | "<inbound>", | 5782 | (foreign_address_iterator->connected == |
5875 | (foreign_address_iterator->connected | 5783 | GNUNET_YES) ? "CONNECTED" : "DISCONNECTED", |
5876 | == GNUNET_YES) ? "CONNECTED" | 5784 | (foreign_address_iterator->validated == |
5877 | : "DISCONNECTED", | 5785 | GNUNET_YES) ? "VALIDATED" : "UNVALIDATED"); |
5878 | (foreign_address_iterator->validated | ||
5879 | == GNUNET_YES) ? "VALIDATED" : "UNVALIDATED"); | ||
5880 | transmit_address_to_client (tc, addr_buf); | 5786 | transmit_address_to_client (tc, addr_buf); |
5881 | GNUNET_free (addr_buf); | 5787 | GNUNET_free (addr_buf); |
5882 | } | 5788 | } |
@@ -5897,8 +5803,7 @@ output_addresses (void *cls, const GNUNET_HashCode * key, void *value) | |||
5897 | * @param message the actual message | 5803 | * @param message the actual message |
5898 | */ | 5804 | */ |
5899 | static void | 5805 | static void |
5900 | handle_address_iterate (void *cls, | 5806 | handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client, |
5901 | struct GNUNET_SERVER_Client *client, | ||
5902 | const struct GNUNET_MessageHeader *message) | 5807 | const struct GNUNET_MessageHeader *message) |
5903 | { | 5808 | { |
5904 | struct GNUNET_SERVER_TransmitContext *tc; | 5809 | struct GNUNET_SERVER_TransmitContext *tc; |
@@ -5954,8 +5859,8 @@ start_transport (struct GNUNET_SERVER_Handle *server, const char *name) | |||
5954 | struct TransportPlugin *plug; | 5859 | struct TransportPlugin *plug; |
5955 | char *libname; | 5860 | char *libname; |
5956 | 5861 | ||
5957 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 5862 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' transport plugin\n"), |
5958 | _("Loading `%s' transport plugin\n"), name); | 5863 | name); |
5959 | GNUNET_asprintf (&libname, "libgnunet_plugin_transport_%s", name); | 5864 | GNUNET_asprintf (&libname, "libgnunet_plugin_transport_%s", name); |
5960 | plug = GNUNET_malloc (sizeof (struct TransportPlugin)); | 5865 | plug = GNUNET_malloc (sizeof (struct TransportPlugin)); |
5961 | create_environment (plug); | 5866 | create_environment (plug); |
@@ -6062,8 +5967,8 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client) | |||
6062 | GNUNET_free (mqe); | 5967 | GNUNET_free (mqe); |
6063 | } | 5968 | } |
6064 | if (NULL != neighbours) | 5969 | if (NULL != neighbours) |
6065 | GNUNET_CONTAINER_multihashmap_iterate (neighbours, | 5970 | GNUNET_CONTAINER_multihashmap_iterate (neighbours, &null_mq_client_pointers, |
6066 | &null_mq_client_pointers, pos); | 5971 | pos); |
6067 | if (prev == NULL) | 5972 | if (prev == NULL) |
6068 | clients = pos->next; | 5973 | clients = pos->next; |
6069 | else | 5974 | else |
@@ -6089,8 +5994,7 @@ disconnect_all_neighbours (void *cls, const GNUNET_HashCode * key, void *value) | |||
6089 | struct NeighbourMapEntry *n = value; | 5994 | struct NeighbourMapEntry *n = value; |
6090 | 5995 | ||
6091 | #if DEBUG_TRANSPORT | 5996 | #if DEBUG_TRANSPORT |
6092 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5997 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n", |
6093 | "Disconnecting peer `%4s', %s\n", | ||
6094 | GNUNET_i2s (&n->id), "SHUTDOWN_TASK"); | 5998 | GNUNET_i2s (&n->id), "SHUTDOWN_TASK"); |
6095 | #endif | 5999 | #endif |
6096 | disconnect_neighbour (n, GNUNET_NO); | 6000 | disconnect_neighbour (n, GNUNET_NO); |
@@ -6113,8 +6017,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
6113 | struct CheckHelloValidatedContext *chvc; | 6017 | struct CheckHelloValidatedContext *chvc; |
6114 | 6018 | ||
6115 | shutdown_in_progress = GNUNET_YES; | 6019 | shutdown_in_progress = GNUNET_YES; |
6116 | GNUNET_CONTAINER_multihashmap_iterate (neighbours, | 6020 | GNUNET_CONTAINER_multihashmap_iterate (neighbours, &disconnect_all_neighbours, |
6117 | &disconnect_all_neighbours, NULL); | 6021 | NULL); |
6118 | #if DEBUG_TRANSPORT | 6022 | #if DEBUG_TRANSPORT |
6119 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 6023 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
6120 | "Transport service is unloading plugins...\n"); | 6024 | "Transport service is unloading plugins...\n"); |
@@ -6141,8 +6045,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
6141 | GNUNET_CRYPTO_rsa_key_free (my_private_key); | 6045 | GNUNET_CRYPTO_rsa_key_free (my_private_key); |
6142 | GNUNET_free_non_null (our_hello); | 6046 | GNUNET_free_non_null (our_hello); |
6143 | 6047 | ||
6144 | GNUNET_CONTAINER_multihashmap_iterate (validation_map, | 6048 | GNUNET_CONTAINER_multihashmap_iterate (validation_map, &abort_validation, |
6145 | &abort_validation, NULL); | 6049 | NULL); |
6146 | GNUNET_CONTAINER_multihashmap_destroy (validation_map); | 6050 | GNUNET_CONTAINER_multihashmap_destroy (validation_map); |
6147 | validation_map = NULL; | 6051 | validation_map = NULL; |
6148 | 6052 | ||
@@ -6290,8 +6194,8 @@ setup_ats_problem (void *cls, const GNUNET_HashCode * key, void *value) | |||
6290 | 6194 | ||
6291 | 6195 | ||
6292 | static void | 6196 | static void |
6293 | create_ats_information (struct ATS_peer **p, | 6197 | create_ats_information (struct ATS_peer **p, int *c_p, struct ATS_mechanism **m, |
6294 | int *c_p, struct ATS_mechanism **m, int *c_m) | 6198 | int *c_m) |
6295 | { | 6199 | { |
6296 | struct AtsBuildContext abc; | 6200 | struct AtsBuildContext abc; |
6297 | 6201 | ||
@@ -6301,8 +6205,8 @@ create_ats_information (struct ATS_peer **p, | |||
6301 | #endif | 6205 | #endif |
6302 | abc.c_peers = 0; | 6206 | abc.c_peers = 0; |
6303 | abc.c_mechs = 0; | 6207 | abc.c_mechs = 0; |
6304 | GNUNET_CONTAINER_multihashmap_iterate (neighbours, | 6208 | GNUNET_CONTAINER_multihashmap_iterate (neighbours, &find_and_count_addresses, |
6305 | &find_and_count_addresses, &abc); | 6209 | &abc); |
6306 | #if VERBOSE_ATS | 6210 | #if VERBOSE_ATS |
6307 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 6211 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
6308 | "Found %u peers with % u transport mechanisms\n", c_peers, | 6212 | "Found %u peers with % u transport mechanisms\n", c_peers, |
@@ -6369,8 +6273,8 @@ schedule_ats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
6369 | #endif | 6273 | #endif |
6370 | last_ats_execution = GNUNET_TIME_absolute_get (); | 6274 | last_ats_execution = GNUNET_TIME_absolute_get (); |
6371 | 6275 | ||
6372 | ats_task = GNUNET_SCHEDULER_add_delayed (ats_regular_interval, | 6276 | ats_task = |
6373 | &schedule_ats, ats); | 6277 | GNUNET_SCHEDULER_add_delayed (ats_regular_interval, &schedule_ats, ats); |
6374 | } | 6278 | } |
6375 | #endif | 6279 | #endif |
6376 | 6280 | ||
@@ -6390,8 +6294,7 @@ get_preferred_ats_address (struct NeighbourMapEntry *n) | |||
6390 | * @param c configuration to use | 6294 | * @param c configuration to use |
6391 | */ | 6295 | */ |
6392 | static void | 6296 | static void |
6393 | run (void *cls, | 6297 | run (void *cls, struct GNUNET_SERVER_Handle *server, |
6394 | struct GNUNET_SERVER_Handle *server, | ||
6395 | const struct GNUNET_CONFIGURATION_Handle *c) | 6298 | const struct GNUNET_CONFIGURATION_Handle *c) |
6396 | { | 6299 | { |
6397 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | 6300 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { |
@@ -6436,14 +6339,11 @@ run (void *cls, | |||
6436 | neighbours = GNUNET_CONTAINER_multihashmap_create (256); | 6339 | neighbours = GNUNET_CONTAINER_multihashmap_create (256); |
6437 | /* parse configuration */ | 6340 | /* parse configuration */ |
6438 | if ((GNUNET_OK != | 6341 | if ((GNUNET_OK != |
6439 | GNUNET_CONFIGURATION_get_value_number (c, | 6342 | GNUNET_CONFIGURATION_get_value_number (c, "TRANSPORT", "NEIGHBOUR_LIMIT", |
6440 | "TRANSPORT", | ||
6441 | "NEIGHBOUR_LIMIT", | ||
6442 | &tneigh)) || | 6343 | &tneigh)) || |
6443 | (GNUNET_OK != | 6344 | (GNUNET_OK != |
6444 | GNUNET_CONFIGURATION_get_value_filename (c, | 6345 | GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY", |
6445 | "GNUNETD", | 6346 | &keyfile))) |
6446 | "HOSTKEY", &keyfile))) | ||
6447 | { | 6347 | { |
6448 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 6348 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
6449 | _ | 6349 | _ |
@@ -6499,18 +6399,18 @@ run (void *cls, | |||
6499 | return; | 6399 | return; |
6500 | } | 6400 | } |
6501 | GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); | 6401 | GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); |
6502 | GNUNET_CRYPTO_hash (&my_public_key, | 6402 | GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), |
6503 | sizeof (my_public_key), &my_identity.hashPubKey); | 6403 | &my_identity.hashPubKey); |
6504 | /* setup notification */ | 6404 | /* setup notification */ |
6505 | GNUNET_SERVER_disconnect_notify (server, | 6405 | GNUNET_SERVER_disconnect_notify (server, &client_disconnect_notification, |
6506 | &client_disconnect_notification, NULL); | 6406 | NULL); |
6507 | /* load plugins... */ | 6407 | /* load plugins... */ |
6508 | no_transports = 1; | 6408 | no_transports = 1; |
6509 | if (GNUNET_OK == | 6409 | if (GNUNET_OK == |
6510 | GNUNET_CONFIGURATION_get_value_string (c, "TRANSPORT", "PLUGINS", &plugs)) | 6410 | GNUNET_CONFIGURATION_get_value_string (c, "TRANSPORT", "PLUGINS", &plugs)) |
6511 | { | 6411 | { |
6512 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 6412 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Starting transport plugins `%s'\n"), |
6513 | _("Starting transport plugins `%s'\n"), plugs); | 6413 | plugs); |
6514 | pos = strtok (plugs, " "); | 6414 | pos = strtok (plugs, " "); |
6515 | while (pos != NULL) | 6415 | while (pos != NULL) |
6516 | { | 6416 | { |
@@ -6520,8 +6420,8 @@ run (void *cls, | |||
6520 | } | 6420 | } |
6521 | GNUNET_free (plugs); | 6421 | GNUNET_free (plugs); |
6522 | } | 6422 | } |
6523 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 6423 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, |
6524 | &shutdown_task, NULL); | 6424 | NULL); |
6525 | if (no_transports) | 6425 | if (no_transports) |
6526 | refresh_hello (); | 6426 | refresh_hello (); |
6527 | 6427 | ||
@@ -6547,9 +6447,9 @@ run (void *cls, | |||
6547 | GNUNET_asprintf (§ion, "%s_UP", ressources[co].cfg_param); | 6447 | GNUNET_asprintf (§ion, "%s_UP", ressources[co].cfg_param); |
6548 | if (GNUNET_CONFIGURATION_have_value (cfg, "transport", section)) | 6448 | if (GNUNET_CONFIGURATION_have_value (cfg, "transport", section)) |
6549 | { | 6449 | { |
6550 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, | 6450 | if (GNUNET_OK == |
6551 | "transport", | 6451 | GNUNET_CONFIGURATION_get_value_number (cfg, "transport", section, |
6552 | section, &value)) | 6452 | &value)) |
6553 | { | 6453 | { |
6554 | #if DEBUG_ATS | 6454 | #if DEBUG_ATS |
6555 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 6455 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -6562,9 +6462,9 @@ run (void *cls, | |||
6562 | GNUNET_asprintf (§ion, "%s_DOWN", ressources[co].cfg_param); | 6462 | GNUNET_asprintf (§ion, "%s_DOWN", ressources[co].cfg_param); |
6563 | if (GNUNET_CONFIGURATION_have_value (cfg, "transport", section)) | 6463 | if (GNUNET_CONFIGURATION_have_value (cfg, "transport", section)) |
6564 | { | 6464 | { |
6565 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, | 6465 | if (GNUNET_OK == |
6566 | "transport", | 6466 | GNUNET_CONFIGURATION_get_value_number (cfg, "transport", section, |
6567 | section, &value)) | 6467 | &value)) |
6568 | { | 6468 | { |
6569 | #if DEBUG_ATS | 6469 | #if DEBUG_ATS |
6570 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 6470 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -6576,18 +6476,16 @@ run (void *cls, | |||
6576 | GNUNET_free (section); | 6476 | GNUNET_free (section); |
6577 | } | 6477 | } |
6578 | #if HAVE_LIBGLPK | 6478 | #if HAVE_LIBGLPK |
6579 | ats = ats_init (D, U, R, v_b_min, v_n_min, | 6479 | ats = |
6580 | ATS_MAX_ITERATIONS, ATS_MAX_EXEC_DURATION, | 6480 | ats_init (D, U, R, v_b_min, v_n_min, ATS_MAX_ITERATIONS, |
6581 | &create_ats_information, ats_result_cb); | 6481 | ATS_MAX_EXEC_DURATION, &create_ats_information, ats_result_cb); |
6582 | ats_set_logging_options (ats, stats, cfg); | 6482 | ats_set_logging_options (ats, stats, cfg); |
6583 | GNUNET_break (GNUNET_OK == | 6483 | GNUNET_break (GNUNET_OK == |
6584 | GNUNET_CONFIGURATION_get_value_time (cfg, | 6484 | GNUNET_CONFIGURATION_get_value_time (cfg, "transport", |
6585 | "transport", | ||
6586 | "ATS_EXEC_INTERVAL", | 6485 | "ATS_EXEC_INTERVAL", |
6587 | &ats_regular_interval)); | 6486 | &ats_regular_interval)); |
6588 | GNUNET_break (GNUNET_OK == | 6487 | GNUNET_break (GNUNET_OK == |
6589 | GNUNET_CONFIGURATION_get_value_time (cfg, | 6488 | GNUNET_CONFIGURATION_get_value_time (cfg, "transport", |
6590 | "transport", | ||
6591 | "ATS_MIN_INTERVAL", | 6489 | "ATS_MIN_INTERVAL", |
6592 | &ats_minimum_interval)); | 6490 | &ats_minimum_interval)); |
6593 | if (ats != NULL) | 6491 | if (ats != NULL) |
@@ -6617,9 +6515,7 @@ main (int argc, char *const *argv) | |||
6617 | { | 6515 | { |
6618 | a2s (NULL, NULL, 0); /* make compiler happy */ | 6516 | a2s (NULL, NULL, 0); /* make compiler happy */ |
6619 | return (GNUNET_OK == | 6517 | return (GNUNET_OK == |
6620 | GNUNET_SERVICE_run (argc, | 6518 | GNUNET_SERVICE_run (argc, argv, "transport", |
6621 | argv, | ||
6622 | "transport", | ||
6623 | GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; | 6519 | GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; |
6624 | } | 6520 | } |
6625 | 6521 | ||