diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_transport_plugin.h | 3 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport.c | 18 | ||||
-rw-r--r-- | src/transport/plugin_transport_http.c | 21 | ||||
-rw-r--r-- | src/transport/plugin_transport_tcp.c | 10 | ||||
-rw-r--r-- | src/transport/plugin_transport_udp.c | 9 | ||||
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 9 | ||||
-rw-r--r-- | src/transport/test_plugin_transport_http.c | 14 | ||||
-rw-r--r-- | src/transport/test_plugin_transport_https.c | 14 |
8 files changed, 75 insertions, 23 deletions
diff --git a/src/include/gnunet_transport_plugin.h b/src/include/gnunet_transport_plugin.h index 31138e8f5..79103172f 100644 --- a/src/include/gnunet_transport_plugin.h +++ b/src/include/gnunet_transport_plugin.h | |||
@@ -111,7 +111,8 @@ typedef struct GNUNET_TIME_Relative (*GNUNET_TRANSPORT_PluginReceiveCallback) (v | |||
111 | const struct | 111 | const struct |
112 | GNUNET_MessageHeader * | 112 | GNUNET_MessageHeader * |
113 | message, | 113 | message, |
114 | uint32_t distance, | 114 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
115 | uint32_t ats_count, | ||
115 | struct Session *session, | 116 | struct Session *session, |
116 | const char *sender_address, | 117 | const char *sender_address, |
117 | uint16_t sender_address_len); | 118 | uint16_t sender_address_len); |
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index a6797aed5..e1f6793b2 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -4703,9 +4703,10 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message, | |||
4703 | static struct GNUNET_TIME_Relative | 4703 | static struct GNUNET_TIME_Relative |
4704 | plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 4704 | plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
4705 | const struct GNUNET_MessageHeader *message, | 4705 | const struct GNUNET_MessageHeader *message, |
4706 | uint32_t distance, | 4706 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
4707 | struct Session *session, | 4707 | uint32_t ats_count, |
4708 | const char *sender_address, | 4708 | struct Session *session, |
4709 | const char *sender_address, | ||
4709 | uint16_t sender_address_len) | 4710 | uint16_t sender_address_len) |
4710 | { | 4711 | { |
4711 | struct TransportPlugin *plugin = cls; | 4712 | struct TransportPlugin *plugin = cls; |
@@ -4716,6 +4717,8 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4716 | struct GNUNET_TIME_Relative ret; | 4717 | struct GNUNET_TIME_Relative ret; |
4717 | if (is_blacklisted (peer, plugin)) | 4718 | if (is_blacklisted (peer, plugin)) |
4718 | return GNUNET_TIME_UNIT_FOREVER_REL; | 4719 | return GNUNET_TIME_UNIT_FOREVER_REL; |
4720 | uint32_t distance; | ||
4721 | int c; | ||
4719 | 4722 | ||
4720 | n = find_neighbour (peer); | 4723 | n = find_neighbour (peer); |
4721 | if (n == NULL) | 4724 | if (n == NULL) |
@@ -4725,6 +4728,15 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4725 | service_context = service_context->next; | 4728 | service_context = service_context->next; |
4726 | GNUNET_assert ((plugin->api->send == NULL) || (service_context != NULL)); | 4729 | GNUNET_assert ((plugin->api->send == NULL) || (service_context != NULL)); |
4727 | peer_address = NULL; | 4730 | peer_address = NULL; |
4731 | distance = 1; | ||
4732 | for (c=0; c<ats_count; c++) | ||
4733 | { | ||
4734 | if (ntohl(ats[c].type) == GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE) | ||
4735 | { | ||
4736 | distance = ntohl(ats[c].value); | ||
4737 | } | ||
4738 | } | ||
4739 | |||
4728 | if (message != NULL) | 4740 | if (message != NULL) |
4729 | { | 4741 | { |
4730 | if ( (session != NULL) || | 4742 | if ( (session != NULL) || |
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index d94740654..a39893a86 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c | |||
@@ -873,9 +873,18 @@ static void mhd_write_mst_cb (void *cls, | |||
873 | ntohs(message->size), | 873 | ntohs(message->size), |
874 | GNUNET_i2s(&(ps->peercontext)->identity),http_plugin_address_to_string(NULL,ps->addr,ps->addrlen)); | 874 | GNUNET_i2s(&(ps->peercontext)->identity),http_plugin_address_to_string(NULL,ps->addr,ps->addrlen)); |
875 | #endif | 875 | #endif |
876 | struct GNUNET_TRANSPORT_ATS_Information distance[2]; | ||
877 | distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); | ||
878 | distance[0].value = htonl (1); | ||
879 | distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); | ||
880 | distance[1].value = htonl (0); | ||
881 | |||
876 | delay = pc->plugin->env->receive (ps->peercontext->plugin->env->cls, | 882 | delay = pc->plugin->env->receive (ps->peercontext->plugin->env->cls, |
877 | &pc->identity, | 883 | &pc->identity, |
878 | message, 1, ps, | 884 | message, |
885 | (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, | ||
886 | 2, | ||
887 | ps, | ||
879 | NULL, | 888 | NULL, |
880 | 0); | 889 | 0); |
881 | pc->delay = delay; | 890 | pc->delay = delay; |
@@ -1576,9 +1585,17 @@ static void curl_receive_mst_cb (void *cls, | |||
1576 | ntohs(message->size), | 1585 | ntohs(message->size), |
1577 | GNUNET_i2s(&(pc->identity)),http_plugin_address_to_string(NULL,ps->addr,ps->addrlen)); | 1586 | GNUNET_i2s(&(pc->identity)),http_plugin_address_to_string(NULL,ps->addr,ps->addrlen)); |
1578 | #endif | 1587 | #endif |
1588 | struct GNUNET_TRANSPORT_ATS_Information distance[2]; | ||
1589 | distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); | ||
1590 | distance[0].value = htonl (1); | ||
1591 | distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); | ||
1592 | distance[1].value = htonl (0); | ||
1593 | |||
1579 | delay = pc->plugin->env->receive (pc->plugin->env->cls, | 1594 | delay = pc->plugin->env->receive (pc->plugin->env->cls, |
1580 | &pc->identity, | 1595 | &pc->identity, |
1581 | message, 1, ps, | 1596 | message, |
1597 | (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, 2, | ||
1598 | ps, | ||
1582 | ps->addr, | 1599 | ps->addr, |
1583 | ps->addrlen); | 1600 | ps->addrlen); |
1584 | 1601 | ||
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 627cb6b9b..df442c71f 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -2020,6 +2020,7 @@ delayed_done (void *cls, | |||
2020 | session->receive_delay_task = GNUNET_SCHEDULER_NO_TASK; | 2020 | session->receive_delay_task = GNUNET_SCHEDULER_NO_TASK; |
2021 | delay = session->plugin->env->receive (session->plugin->env->cls, | 2021 | delay = session->plugin->env->receive (session->plugin->env->cls, |
2022 | &session->target, | 2022 | &session->target, |
2023 | NULL, | ||
2023 | NULL, 0, | 2024 | NULL, 0, |
2024 | session, | 2025 | session, |
2025 | NULL, 0); | 2026 | NULL, 0); |
@@ -2076,7 +2077,14 @@ handle_tcp_data (void *cls, | |||
2076 | gettext_noop ("# bytes received via TCP"), | 2077 | gettext_noop ("# bytes received via TCP"), |
2077 | ntohs (message->size), | 2078 | ntohs (message->size), |
2078 | GNUNET_NO); | 2079 | GNUNET_NO); |
2079 | delay = plugin->env->receive (plugin->env->cls, &session->target, message, 1, | 2080 | struct GNUNET_TRANSPORT_ATS_Information distance[2]; |
2081 | distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); | ||
2082 | distance[0].value = htonl (1); | ||
2083 | distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); | ||
2084 | distance[1].value = htonl (0); | ||
2085 | delay = plugin->env->receive (plugin->env->cls, &session->target, message, | ||
2086 | (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, | ||
2087 | 2, | ||
2080 | session, | 2088 | session, |
2081 | (GNUNET_YES == session->inbound) ? NULL : session->connect_addr, | 2089 | (GNUNET_YES == session->inbound) ? NULL : session->connect_addr, |
2082 | (GNUNET_YES == session->inbound) ? 0 : session->connect_alen); | 2090 | (GNUNET_YES == session->inbound) ? 0 : session->connect_alen); |
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 4bf66f206..169e161e2 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -1474,7 +1474,14 @@ udp_demultiplexer(struct Plugin *plugin, struct GNUNET_PeerIdentity *sender, | |||
1474 | "Sending message type %d to transport!\n", | 1474 | "Sending message type %d to transport!\n", |
1475 | ntohs(currhdr->type)); | 1475 | ntohs(currhdr->type)); |
1476 | #endif | 1476 | #endif |
1477 | plugin->env->receive (plugin->env->cls, sender, currhdr, UDP_DIRECT_DISTANCE, | 1477 | struct GNUNET_TRANSPORT_ATS_Information distance[2]; |
1478 | distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); | ||
1479 | distance[0].value = htonl (UDP_DIRECT_DISTANCE); | ||
1480 | distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); | ||
1481 | distance[1].value = htonl (0); | ||
1482 | |||
1483 | plugin->env->receive (plugin->env->cls, sender, currhdr, | ||
1484 | (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, 2, | ||
1478 | NULL, sender_addr, fromlen); | 1485 | NULL, sender_addr, fromlen); |
1479 | } | 1486 | } |
1480 | 1487 | ||
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index de868a427..98caaa4f1 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -1750,8 +1750,15 @@ wlan_process_helper (void *cls, | |||
1750 | } | 1750 | } |
1751 | } | 1751 | } |
1752 | //"receive" the message | 1752 | //"receive" the message |
1753 | struct GNUNET_TRANSPORT_ATS_Information distance[2]; | ||
1754 | distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE); | ||
1755 | distance[0].value = htonl (1); | ||
1756 | distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); | ||
1757 | distance[1].value = htonl (0); | ||
1758 | |||
1753 | plugin->env->receive(plugin, &session->target, | 1759 | plugin->env->receive(plugin, &session->target, |
1754 | temp_hdr, 1, session, session->addr, sizeof(session->addr)); | 1760 | temp_hdr, (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, 2, |
1761 | session, session->addr, sizeof(session->addr)); | ||
1755 | } | 1762 | } |
1756 | 1763 | ||
1757 | else if (ntohs(hdr->type) == GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT) | 1764 | else if (ntohs(hdr->type) == GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT) |
diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index 6b6463f1a..3c127a950 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c | |||
@@ -505,13 +505,13 @@ static void run_connection_tests( int phase , void * cls); | |||
505 | * Recieves messages from plugin, in real world transport | 505 | * Recieves messages from plugin, in real world transport |
506 | */ | 506 | */ |
507 | static struct GNUNET_TIME_Relative | 507 | static struct GNUNET_TIME_Relative |
508 | receive (void *cls, | 508 | receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
509 | const struct GNUNET_PeerIdentity * peer, | 509 | const struct GNUNET_MessageHeader *message, |
510 | const struct GNUNET_MessageHeader * message, | 510 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
511 | uint32_t distance, | 511 | uint32_t ats_count, |
512 | struct Session *session, | 512 | struct Session *session, |
513 | const char *sender_address, | 513 | const char *sender_address, |
514 | uint16_t sender_address_len) | 514 | uint16_t sender_address_len) |
515 | { | 515 | { |
516 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n", GNUNET_i2s(peer), ntohs(message->type), ntohs(message->size),session); | 516 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n", GNUNET_i2s(peer), ntohs(message->type), ntohs(message->size),session); |
517 | 517 | ||
diff --git a/src/transport/test_plugin_transport_https.c b/src/transport/test_plugin_transport_https.c index beda4c749..61aea1fa7 100644 --- a/src/transport/test_plugin_transport_https.c +++ b/src/transport/test_plugin_transport_https.c | |||
@@ -528,13 +528,13 @@ static void run_connection_tests( int phase , void * cls); | |||
528 | * Recieves messages from plugin, in real world transport | 528 | * Recieves messages from plugin, in real world transport |
529 | */ | 529 | */ |
530 | static struct GNUNET_TIME_Relative | 530 | static struct GNUNET_TIME_Relative |
531 | receive (void *cls, | 531 | receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
532 | const struct GNUNET_PeerIdentity * peer, | 532 | const struct GNUNET_MessageHeader *message, |
533 | const struct GNUNET_MessageHeader * message, | 533 | const struct GNUNET_TRANSPORT_ATS_Information *ats, |
534 | uint32_t distance, | 534 | uint32_t ats_count, |
535 | struct Session *session, | 535 | struct Session *session, |
536 | const char *sender_address, | 536 | const char *sender_address, |
537 | uint16_t sender_address_len) | 537 | uint16_t sender_address_len) |
538 | { | 538 | { |
539 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n", GNUNET_i2s(peer), ntohs(message->type), ntohs(message->size),session); | 539 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n", GNUNET_i2s(peer), ntohs(message->type), ntohs(message->size),session); |
540 | 540 | ||