diff options
-rw-r--r-- | src/hello/hello-ng.c | 20 | ||||
-rw-r--r-- | src/include/gnunet_hello_lib.h | 10 | ||||
-rw-r--r-- | src/include/gnunet_transport_communication_service.h | 2 | ||||
-rw-r--r-- | src/transport/gnunet-communicator-unix.c | 1 | ||||
-rw-r--r-- | src/transport/gnunet-service-tng.c | 87 | ||||
-rw-r--r-- | src/transport/transport.h | 5 | ||||
-rw-r--r-- | src/transport/transport_api2_communication.c | 9 |
7 files changed, 104 insertions, 30 deletions
diff --git a/src/hello/hello-ng.c b/src/hello/hello-ng.c index c088abf35..2d60b04f3 100644 --- a/src/hello/hello-ng.c +++ b/src/hello/hello-ng.c | |||
@@ -194,3 +194,23 @@ GNUNET_HELLO_extract_address (const void *raw, | |||
194 | *nt = (enum GNUNET_NetworkType) raw_nt; | 194 | *nt = (enum GNUNET_NetworkType) raw_nt; |
195 | return GNUNET_strdup (raw_addr); | 195 | return GNUNET_strdup (raw_addr); |
196 | } | 196 | } |
197 | |||
198 | |||
199 | /** | ||
200 | * Given an address as a string, extract the prefix that identifies | ||
201 | * the communicator offering transmissions to that address. | ||
202 | * | ||
203 | * @param address a peer's address | ||
204 | * @return NULL if the address is mal-formed, otherwise the prefix | ||
205 | */ | ||
206 | char * | ||
207 | GNUNET_HELLO_address_to_prefix (const char *address) | ||
208 | { | ||
209 | const char *dash; | ||
210 | |||
211 | dash = strchr (address, '-'); | ||
212 | if (NULL == dash) | ||
213 | return NULL; | ||
214 | return GNUNET_strndup (address, | ||
215 | dash - address); | ||
216 | } | ||
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h index a1b97809e..c2256fd0a 100644 --- a/src/include/gnunet_hello_lib.h +++ b/src/include/gnunet_hello_lib.h | |||
@@ -520,6 +520,16 @@ GNUNET_HELLO_extract_address (const void *raw, | |||
520 | struct GNUNET_TIME_Absolute *expiration); | 520 | struct GNUNET_TIME_Absolute *expiration); |
521 | 521 | ||
522 | 522 | ||
523 | /** | ||
524 | * Given an address as a string, extract the prefix that identifies | ||
525 | * the communicator offering transmissions to that address. | ||
526 | * | ||
527 | * @param address a peer's address | ||
528 | * @return NULL if the address is mal-formed, otherwise the prefix | ||
529 | */ | ||
530 | char * | ||
531 | GNUNET_HELLO_address_to_prefix (const char *address); | ||
532 | |||
523 | 533 | ||
524 | #if 0 /* keep Emacsens' auto-indent happy */ | 534 | #if 0 /* keep Emacsens' auto-indent happy */ |
525 | { | 535 | { |
diff --git a/src/include/gnunet_transport_communication_service.h b/src/include/gnunet_transport_communication_service.h index 2997c1860..307f6688a 100644 --- a/src/include/gnunet_transport_communication_service.h +++ b/src/include/gnunet_transport_communication_service.h | |||
@@ -243,7 +243,6 @@ enum GNUNET_TRANSPORT_ConnectionStatus { | |||
243 | * @param mtu maximum message size supported by queue, 0 if | 243 | * @param mtu maximum message size supported by queue, 0 if |
244 | * sending is not supported, SIZE_MAX for no MTU | 244 | * sending is not supported, SIZE_MAX for no MTU |
245 | * @param nt which network type does the @a address belong to? | 245 | * @param nt which network type does the @a address belong to? |
246 | * @param distance how many hops does this queue use (DV-only)? | ||
247 | * @param cs what is the connection status of the queue? | 246 | * @param cs what is the connection status of the queue? |
248 | * @param mq message queue of the @a peer | 247 | * @param mq message queue of the @a peer |
249 | * @return API handle identifying the new MQ | 248 | * @return API handle identifying the new MQ |
@@ -254,7 +253,6 @@ GNUNET_TRANSPORT_communicator_mq_add (struct GNUNET_TRANSPORT_CommunicatorHandle | |||
254 | const char *address, | 253 | const char *address, |
255 | uint32_t mtu, | 254 | uint32_t mtu, |
256 | enum GNUNET_NetworkType nt, | 255 | enum GNUNET_NetworkType nt, |
257 | uint32_t distance, | ||
258 | enum GNUNET_TRANSPORT_ConnectionStatus cs, | 256 | enum GNUNET_TRANSPORT_ConnectionStatus cs, |
259 | struct GNUNET_MQ_Handle *mq); | 257 | struct GNUNET_MQ_Handle *mq); |
260 | 258 | ||
diff --git a/src/transport/gnunet-communicator-unix.c b/src/transport/gnunet-communicator-unix.c index 5d4032834..08f02b66d 100644 --- a/src/transport/gnunet-communicator-unix.c +++ b/src/transport/gnunet-communicator-unix.c | |||
@@ -685,7 +685,6 @@ setup_queue (const struct GNUNET_PeerIdentity *target, | |||
685 | foreign_addr, | 685 | foreign_addr, |
686 | UNIX_MTU, | 686 | UNIX_MTU, |
687 | GNUNET_NT_LOOPBACK, | 687 | GNUNET_NT_LOOPBACK, |
688 | 0 /* distance */, | ||
689 | cs, | 688 | cs, |
690 | queue->mq); | 689 | queue->mq); |
691 | GNUNET_free (foreign_addr); | 690 | GNUNET_free (foreign_addr); |
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index 5a335f447..0a129af80 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -39,7 +39,7 @@ | |||
39 | * - use ATS bandwidth allocation callback and schedule transmissions! | 39 | * - use ATS bandwidth allocation callback and schedule transmissions! |
40 | * | 40 | * |
41 | * Plan: | 41 | * Plan: |
42 | * - inform ATS about RTT, goodput/loss, overheads, etc. | 42 | * - inform ATS about RTT, goodput/loss, overheads, etc. (GNUNET_ATS_session_update()) |
43 | * | 43 | * |
44 | * Later: | 44 | * Later: |
45 | * - change transport-core API to provide proper flow control in both | 45 | * - change transport-core API to provide proper flow control in both |
@@ -333,6 +333,11 @@ struct GNUNET_ATS_Session | |||
333 | const char *address; | 333 | const char *address; |
334 | 334 | ||
335 | /** | 335 | /** |
336 | * Handle by which we inform ATS about this queue. | ||
337 | */ | ||
338 | struct GNUNET_ATS_SessionRecord *sr; | ||
339 | |||
340 | /** | ||
336 | * Our current RTT estimate for this ATS session. | 341 | * Our current RTT estimate for this ATS session. |
337 | */ | 342 | */ |
338 | struct GNUNET_TIME_Relative rtt; | 343 | struct GNUNET_TIME_Relative rtt; |
@@ -996,20 +1001,20 @@ free_queue (struct GNUNET_ATS_Session *queue) | |||
996 | GNUNET_CONTAINER_MDLL_remove (client, | 1001 | GNUNET_CONTAINER_MDLL_remove (client, |
997 | tc->details.communicator.session_head, | 1002 | tc->details.communicator.session_head, |
998 | tc->details.communicator.session_tail, | 1003 | tc->details.communicator.session_tail, |
999 | queue); | 1004 | queue); |
1000 | |||
1001 | notify_monitors (&neighbour->pid, | 1005 | notify_monitors (&neighbour->pid, |
1002 | queue->address, | 1006 | queue->address, |
1003 | queue->nt, | 1007 | queue->nt, |
1004 | &me); | 1008 | &me); |
1009 | GNUNET_ATS_session_del (queue->sr); | ||
1005 | GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_in); | 1010 | GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_in); |
1006 | GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_out); | 1011 | GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_out); |
1007 | GNUNET_free (queue); | 1012 | GNUNET_free (queue); |
1008 | if (NULL == neighbour->session_head) | 1013 | if (NULL == neighbour->session_head) |
1009 | { | 1014 | { |
1010 | cores_send_disconnect_info (&neighbour->pid); | 1015 | cores_send_disconnect_info (&neighbour->pid); |
1011 | free_neighbour (neighbour); | 1016 | free_neighbour (neighbour); |
1012 | } | 1017 | } |
1013 | } | 1018 | } |
1014 | 1019 | ||
1015 | 1020 | ||
@@ -1650,7 +1655,6 @@ handle_add_queue_message (void *cls, | |||
1650 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 1655 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
1651 | cores_send_connect_info (&neighbour->pid, | 1656 | cores_send_connect_info (&neighbour->pid, |
1652 | GNUNET_BANDWIDTH_ZERO); | 1657 | GNUNET_BANDWIDTH_ZERO); |
1653 | // FIXME: notify ATS! | ||
1654 | } | 1658 | } |
1655 | addr_len = ntohs (aqm->header.size) - sizeof (*aqm); | 1659 | addr_len = ntohs (aqm->header.size) - sizeof (*aqm); |
1656 | addr = (const char *) &aqm[1]; | 1660 | addr = (const char *) &aqm[1]; |
@@ -1661,7 +1665,6 @@ handle_add_queue_message (void *cls, | |||
1661 | queue->rtt = GNUNET_TIME_UNIT_FOREVER_REL; | 1665 | queue->rtt = GNUNET_TIME_UNIT_FOREVER_REL; |
1662 | queue->qid = aqm->qid; | 1666 | queue->qid = aqm->qid; |
1663 | queue->mtu = ntohl (aqm->mtu); | 1667 | queue->mtu = ntohl (aqm->mtu); |
1664 | queue->distance = ntohl (aqm->distance); | ||
1665 | queue->nt = (enum GNUNET_NetworkType) ntohl (aqm->nt); | 1668 | queue->nt = (enum GNUNET_NetworkType) ntohl (aqm->nt); |
1666 | queue->cs = (enum GNUNET_TRANSPORT_ConnectionStatus) ntohl (aqm->cs); | 1669 | queue->cs = (enum GNUNET_TRANSPORT_ConnectionStatus) ntohl (aqm->cs); |
1667 | queue->neighbour = neighbour; | 1670 | queue->neighbour = neighbour; |
@@ -1682,6 +1685,38 @@ handle_add_queue_message (void *cls, | |||
1682 | memcpy (&queue[1], | 1685 | memcpy (&queue[1], |
1683 | addr, | 1686 | addr, |
1684 | addr_len); | 1687 | addr_len); |
1688 | /* notify ATS about new queue */ | ||
1689 | { | ||
1690 | struct GNUNET_ATS_Properties prop = { | ||
1691 | .delay = GNUNET_TIME_UNIT_FOREVER_REL, | ||
1692 | .mtu = queue->mtu, | ||
1693 | .nt = queue->nt, | ||
1694 | .cc = tc->details.communicator.cc | ||
1695 | }; | ||
1696 | |||
1697 | queue->sr = GNUNET_ATS_session_add (ats, | ||
1698 | &neighbour->pid, | ||
1699 | queue->address, | ||
1700 | queue, | ||
1701 | &prop); | ||
1702 | if (NULL == queue->sr) | ||
1703 | { | ||
1704 | /* This can only happen if the 'address' was way too long for ATS | ||
1705 | (approaching 64k in strlen()!). In this case, the communicator | ||
1706 | must be buggy and we drop it. */ | ||
1707 | GNUNET_break (0); | ||
1708 | GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_in); | ||
1709 | GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_out); | ||
1710 | GNUNET_free (queue); | ||
1711 | if (NULL == neighbour->session_head) | ||
1712 | { | ||
1713 | cores_send_disconnect_info (&neighbour->pid); | ||
1714 | free_neighbour (neighbour); | ||
1715 | } | ||
1716 | GNUNET_SERVICE_client_drop (tc->client); | ||
1717 | return; | ||
1718 | } | ||
1719 | } | ||
1685 | /* notify monitors about new queue */ | 1720 | /* notify monitors about new queue */ |
1686 | { | 1721 | { |
1687 | struct MonitorEvent me = { | 1722 | struct MonitorEvent me = { |
@@ -1702,7 +1737,6 @@ handle_add_queue_message (void *cls, | |||
1702 | tc->details.communicator.session_head, | 1737 | tc->details.communicator.session_head, |
1703 | tc->details.communicator.session_tail, | 1738 | tc->details.communicator.session_tail, |
1704 | queue); | 1739 | queue); |
1705 | // FIXME: possibly transmit queued messages? | ||
1706 | GNUNET_SERVICE_client_continue (tc->client); | 1740 | GNUNET_SERVICE_client_continue (tc->client); |
1707 | } | 1741 | } |
1708 | 1742 | ||
@@ -1763,6 +1797,12 @@ handle_send_message_ack (void *cls, | |||
1763 | GNUNET_SERVICE_client_drop (tc->client); | 1797 | GNUNET_SERVICE_client_drop (tc->client); |
1764 | return; | 1798 | return; |
1765 | } | 1799 | } |
1800 | // FIXME: react to communicator status about transmission request. We got: | ||
1801 | sma->status; // OK success, SYSERR failure | ||
1802 | sma->mid; // message ID of original message | ||
1803 | sma->receiver; // receiver of original message | ||
1804 | |||
1805 | |||
1766 | GNUNET_SERVICE_client_continue (tc->client); | 1806 | GNUNET_SERVICE_client_continue (tc->client); |
1767 | } | 1807 | } |
1768 | 1808 | ||
@@ -1870,7 +1910,19 @@ ats_allocation_cb (void *cls, | |||
1870 | static struct TransportClient * | 1910 | static struct TransportClient * |
1871 | lookup_communicator (const char *prefix) | 1911 | lookup_communicator (const char *prefix) |
1872 | { | 1912 | { |
1873 | GNUNET_break (0); // FIXME: implement | 1913 | for (struct TransportClient *tc = clients_head; |
1914 | NULL != tc; | ||
1915 | tc = tc->next) | ||
1916 | { | ||
1917 | if (CT_COMMUNICATOR != tc->type) | ||
1918 | continue; | ||
1919 | if (0 == strcmp (prefix, | ||
1920 | tc->details.communicator.address_prefix)) | ||
1921 | return tc; | ||
1922 | } | ||
1923 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1924 | "ATS suggested use of communicator for `%s', but we do not have such a communicator!\n", | ||
1925 | prefix); | ||
1874 | return NULL; | 1926 | return NULL; |
1875 | } | 1927 | } |
1876 | 1928 | ||
@@ -1892,11 +1944,20 @@ ats_suggestion_cb (void *cls, | |||
1892 | char *prefix; | 1944 | char *prefix; |
1893 | 1945 | ||
1894 | (void) cls; | 1946 | (void) cls; |
1895 | prefix = NULL; // FIXME | 1947 | prefix = GNUNET_HELLO_address_to_prefix (address); |
1948 | if (NULL == prefix) | ||
1949 | { | ||
1950 | GNUNET_break (0); /* ATS gave invalid address!? */ | ||
1951 | return; | ||
1952 | } | ||
1896 | tc = lookup_communicator (prefix); | 1953 | tc = lookup_communicator (prefix); |
1897 | if (NULL == tc) | 1954 | if (NULL == tc) |
1898 | { | 1955 | { |
1899 | // STATS... | 1956 | GNUNET_STATISTICS_update (GST_stats, |
1957 | "# ATS suggestions ignored due to missing communicator", | ||
1958 | 1, | ||
1959 | GNUNET_NO); | ||
1960 | |||
1900 | return; | 1961 | return; |
1901 | } | 1962 | } |
1902 | // FIXME: forward suggestion to tc | 1963 | // FIXME: forward suggestion to tc |
diff --git a/src/transport/transport.h b/src/transport/transport.h index 670a8d32d..88656a012 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h | |||
@@ -817,11 +817,6 @@ struct GNUNET_TRANSPORT_AddQueueMessage | |||
817 | */ | 817 | */ |
818 | uint32_t cs; | 818 | uint32_t cs; |
819 | 819 | ||
820 | /** | ||
821 | * Hops to the target (DV-only), in NBO. | ||
822 | */ | ||
823 | uint32_t distance; | ||
824 | |||
825 | /* followed by UTF-8 encoded, 0-terminated human-readable address */ | 820 | /* followed by UTF-8 encoded, 0-terminated human-readable address */ |
826 | }; | 821 | }; |
827 | 822 | ||
diff --git a/src/transport/transport_api2_communication.c b/src/transport/transport_api2_communication.c index 1a176e68f..a816ecb67 100644 --- a/src/transport/transport_api2_communication.c +++ b/src/transport/transport_api2_communication.c | |||
@@ -274,11 +274,6 @@ struct GNUNET_TRANSPORT_QueueHandle | |||
274 | enum GNUNET_TRANSPORT_ConnectionStatus cs; | 274 | enum GNUNET_TRANSPORT_ConnectionStatus cs; |
275 | 275 | ||
276 | /** | 276 | /** |
277 | * How many hops is the target away (DV-only) | ||
278 | */ | ||
279 | uint32_t distance; | ||
280 | |||
281 | /** | ||
282 | * ID for this queue when talking to the transport service. | 277 | * ID for this queue when talking to the transport service. |
283 | */ | 278 | */ |
284 | uint32_t queue_id; | 279 | uint32_t queue_id; |
@@ -418,7 +413,6 @@ send_add_queue (struct GNUNET_TRANSPORT_QueueHandle *qh) | |||
418 | aqm->nt = htonl ((uint32_t) qh->nt); | 413 | aqm->nt = htonl ((uint32_t) qh->nt); |
419 | aqm->mtu = htonl (qh->mtu); | 414 | aqm->mtu = htonl (qh->mtu); |
420 | aqm->cs = htonl ((uint32_t) qh->cs); | 415 | aqm->cs = htonl ((uint32_t) qh->cs); |
421 | aqm->distance = htonl (qh->distance); | ||
422 | memcpy (&aqm[1], | 416 | memcpy (&aqm[1], |
423 | qh->address, | 417 | qh->address, |
424 | strlen (qh->address) + 1); | 418 | strlen (qh->address) + 1); |
@@ -956,7 +950,6 @@ GNUNET_TRANSPORT_communicator_receive (struct GNUNET_TRANSPORT_CommunicatorHandl | |||
956 | * sending is not supported, SIZE_MAX for no MTU | 950 | * sending is not supported, SIZE_MAX for no MTU |
957 | * @param nt which network type does the @a address belong to? | 951 | * @param nt which network type does the @a address belong to? |
958 | * @param cc what characteristics does the communicator have? | 952 | * @param cc what characteristics does the communicator have? |
959 | * @param distance how many hops does this queue use (DV-only)? | ||
960 | * @param cs what is the connection status of the queue? | 953 | * @param cs what is the connection status of the queue? |
961 | * @param mq message queue of the @a peer | 954 | * @param mq message queue of the @a peer |
962 | * @return API handle identifying the new MQ | 955 | * @return API handle identifying the new MQ |
@@ -967,7 +960,6 @@ GNUNET_TRANSPORT_communicator_mq_add (struct GNUNET_TRANSPORT_CommunicatorHandle | |||
967 | const char *address, | 960 | const char *address, |
968 | uint32_t mtu, | 961 | uint32_t mtu, |
969 | enum GNUNET_NetworkType nt, | 962 | enum GNUNET_NetworkType nt, |
970 | uint32_t distance, | ||
971 | enum GNUNET_TRANSPORT_ConnectionStatus cs, | 963 | enum GNUNET_TRANSPORT_ConnectionStatus cs, |
972 | struct GNUNET_MQ_Handle *mq) | 964 | struct GNUNET_MQ_Handle *mq) |
973 | { | 965 | { |
@@ -979,7 +971,6 @@ GNUNET_TRANSPORT_communicator_mq_add (struct GNUNET_TRANSPORT_CommunicatorHandle | |||
979 | qh->address = GNUNET_strdup (address); | 971 | qh->address = GNUNET_strdup (address); |
980 | qh->nt = nt; | 972 | qh->nt = nt; |
981 | qh->mtu = mtu; | 973 | qh->mtu = mtu; |
982 | qh->distance = distance; | ||
983 | qh->cs = cs; | 974 | qh->cs = cs; |
984 | qh->mq = mq; | 975 | qh->mq = mq; |
985 | qh->queue_id = ch->queue_gen++; | 976 | qh->queue_id = ch->queue_gen++; |