diff options
author | jospaeth <spaethj@in.tum.de> | 2020-09-10 14:52:33 +0200 |
---|---|---|
committer | jospaeth <spaethj@in.tum.de> | 2020-09-10 14:52:33 +0200 |
commit | 8ba80868ff3bbe1d8fb6c35663f36cc89f3720da (patch) | |
tree | 262977a2c4aad3f44e60f4e62992f57854eb12fe /src/transport | |
parent | c11faa7df18e14f447872adda3107a1083f5f127 (diff) | |
parent | 72331deb3bfed2e82f1d5c87eb185ab67d783308 (diff) | |
download | gnunet-8ba80868ff3bbe1d8fb6c35663f36cc89f3720da.tar.gz gnunet-8ba80868ff3bbe1d8fb6c35663f36cc89f3720da.zip |
Merge branch 'master' into spaeth/escrow_plugins
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-communicator-tcp.c | 455 | ||||
-rw-r--r-- | src/transport/test_communicator_basic.c | 24 | ||||
-rw-r--r-- | src/transport/test_communicator_tcp_rekey_peer2.conf | 4 | ||||
-rw-r--r-- | src/transport/test_communicator_unix_basic_peer1.conf | 2 | ||||
-rw-r--r-- | src/transport/test_communicator_unix_basic_peer2.conf | 2 | ||||
-rw-r--r-- | src/transport/transport-testing2.c | 154 | ||||
-rw-r--r-- | src/transport/transport-testing2.h | 144 | ||||
-rw-r--r-- | src/transport/transport_api2_communication.c | 15 |
8 files changed, 535 insertions, 265 deletions
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c index 880145424..59f42496a 100644 --- a/src/transport/gnunet-communicator-tcp.c +++ b/src/transport/gnunet-communicator-tcp.c | |||
@@ -308,6 +308,38 @@ struct TCPRekey | |||
308 | struct GNUNET_TIME_AbsoluteNBO monotonic_time; | 308 | struct GNUNET_TIME_AbsoluteNBO monotonic_time; |
309 | }; | 309 | }; |
310 | 310 | ||
311 | /** | ||
312 | * Signature we use to verify that the ephemeral key was really chosen by | ||
313 | * the specified sender. | ||
314 | */ | ||
315 | struct TcpRekeySignature | ||
316 | { | ||
317 | /** | ||
318 | * Purpose must be #GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY | ||
319 | */ | ||
320 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | ||
321 | |||
322 | /** | ||
323 | * Identity of the inititor of the TCP connection (TCP client). | ||
324 | */ | ||
325 | struct GNUNET_PeerIdentity sender; | ||
326 | |||
327 | /** | ||
328 | * Presumed identity of the target of the TCP connection (TCP server) | ||
329 | */ | ||
330 | struct GNUNET_PeerIdentity receiver; | ||
331 | |||
332 | /** | ||
333 | * Ephemeral key used by the @e sender. | ||
334 | */ | ||
335 | struct GNUNET_CRYPTO_EcdhePublicKey ephemeral; | ||
336 | |||
337 | /** | ||
338 | * Monotonic time of @e sender, to possibly help detect replay attacks | ||
339 | * (if receiver persists times by sender). | ||
340 | */ | ||
341 | struct GNUNET_TIME_AbsoluteNBO monotonic_time; | ||
342 | }; | ||
311 | 343 | ||
312 | /** | 344 | /** |
313 | * TCP finish. Sender asks for the connection to be closed. | 345 | * TCP finish. Sender asks for the connection to be closed. |
@@ -362,11 +394,6 @@ struct Queue | |||
362 | struct GNUNET_PeerIdentity target; | 394 | struct GNUNET_PeerIdentity target; |
363 | 395 | ||
364 | /** | 396 | /** |
365 | * ID of listen task | ||
366 | */ | ||
367 | struct GNUNET_SCHEDULER_Task *listen_task; | ||
368 | |||
369 | /** | ||
370 | * Listen socket. | 397 | * Listen socket. |
371 | */ | 398 | */ |
372 | struct GNUNET_NETWORK_Handle *listen_sock; | 399 | struct GNUNET_NETWORK_Handle *listen_sock; |
@@ -606,11 +633,6 @@ struct ProtoQueue | |||
606 | struct ProtoQueue *prev; | 633 | struct ProtoQueue *prev; |
607 | 634 | ||
608 | /** | 635 | /** |
609 | * ID of listen task | ||
610 | */ | ||
611 | struct GNUNET_SCHEDULER_Task *listen_task; | ||
612 | |||
613 | /** | ||
614 | * Listen socket. | 636 | * Listen socket. |
615 | */ | 637 | */ |
616 | struct GNUNET_NETWORK_Handle *listen_sock; | 638 | struct GNUNET_NETWORK_Handle *listen_sock; |
@@ -729,6 +751,11 @@ static struct GNUNET_TRANSPORT_CommunicatorHandle *ch; | |||
729 | static struct GNUNET_CONTAINER_MultiPeerMap *queue_map; | 751 | static struct GNUNET_CONTAINER_MultiPeerMap *queue_map; |
730 | 752 | ||
731 | /** | 753 | /** |
754 | * ListenTasks (map from socket to `struct ListenTask`) | ||
755 | */ | ||
756 | static struct GNUNET_CONTAINER_MultiHashMap *lt_map; | ||
757 | |||
758 | /** | ||
732 | * Our public key. | 759 | * Our public key. |
733 | */ | 760 | */ |
734 | static struct GNUNET_PeerIdentity my_identity; | 761 | static struct GNUNET_PeerIdentity my_identity; |
@@ -784,6 +811,16 @@ struct Addresses *addrs_head; | |||
784 | struct Addresses *addrs_tail; | 811 | struct Addresses *addrs_tail; |
785 | 812 | ||
786 | /** | 813 | /** |
814 | * Head of DLL with ListenTasks. | ||
815 | */ | ||
816 | struct ListenTask *lts_head; | ||
817 | |||
818 | /** | ||
819 | * Head of DLL with ListenTask. | ||
820 | */ | ||
821 | struct ListenTask *lts_tail; | ||
822 | |||
823 | /** | ||
787 | * Number of addresses in the DLL for register at NAT service. | 824 | * Number of addresses in the DLL for register at NAT service. |
788 | */ | 825 | */ |
789 | int addrs_lens; | 826 | int addrs_lens; |
@@ -799,6 +836,16 @@ size_t unverified_size; | |||
799 | static struct GNUNET_PEERSTORE_Handle *peerstore; | 836 | static struct GNUNET_PEERSTORE_Handle *peerstore; |
800 | 837 | ||
801 | /** | 838 | /** |
839 | * A flag indicating we are already doing a shutdown. | ||
840 | */ | ||
841 | int shutdown_running = GNUNET_NO; | ||
842 | |||
843 | /** | ||
844 | * The port the communicator should be assigned to. | ||
845 | */ | ||
846 | unsigned int bind_port; | ||
847 | |||
848 | /** | ||
802 | * We have been notified that our listen socket has something to | 849 | * We have been notified that our listen socket has something to |
803 | * read. Do the read and reschedule this function to be called again | 850 | * read. Do the read and reschedule this function to be called again |
804 | * once more is available. | 851 | * once more is available. |
@@ -808,7 +855,6 @@ static struct GNUNET_PEERSTORE_Handle *peerstore; | |||
808 | static void | 855 | static void |
809 | listen_cb (void *cls); | 856 | listen_cb (void *cls); |
810 | 857 | ||
811 | |||
812 | /** | 858 | /** |
813 | * Functions with this signature are called whenever we need | 859 | * Functions with this signature are called whenever we need |
814 | * to close a queue due to a disconnect or failure to | 860 | * to close a queue due to a disconnect or failure to |
@@ -819,11 +865,14 @@ listen_cb (void *cls); | |||
819 | static void | 865 | static void |
820 | queue_destroy (struct Queue *queue) | 866 | queue_destroy (struct Queue *queue) |
821 | { | 867 | { |
822 | struct GNUNET_MQ_Handle *mq; | 868 | struct ListenTask *lt = NULL; |
823 | struct ListenTask *lt; | 869 | struct GNUNET_HashCode h_sock; |
824 | lt = GNUNET_new (struct ListenTask); | 870 | |
825 | lt->listen_sock = queue->listen_sock; | 871 | GNUNET_CRYPTO_hash (queue->listen_sock, |
826 | lt->listen_task = queue->listen_task; | 872 | sizeof(queue->listen_sock), |
873 | &h_sock); | ||
874 | |||
875 | lt = GNUNET_CONTAINER_multihashmap_get (lt_map, &h_sock); | ||
827 | 876 | ||
828 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 877 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
829 | "Disconnecting queue for peer `%s'\n", | 878 | "Disconnecting queue for peer `%s'\n", |
@@ -858,11 +907,6 @@ queue_destroy (struct Queue *queue) | |||
858 | GNUNET_PEERSTORE_iterate_cancel (queue->handshake_ack_monotime_get); | 907 | GNUNET_PEERSTORE_iterate_cancel (queue->handshake_ack_monotime_get); |
859 | queue->handshake_ack_monotime_get = NULL; | 908 | queue->handshake_ack_monotime_get = NULL; |
860 | } | 909 | } |
861 | if (NULL != (mq = queue->mq)) | ||
862 | { | ||
863 | queue->mq = NULL; | ||
864 | GNUNET_MQ_destroy (mq); | ||
865 | } | ||
866 | if (NULL != queue->qh) | 910 | if (NULL != queue->qh) |
867 | { | 911 | { |
868 | GNUNET_TRANSPORT_communicator_mq_del (queue->qh); | 912 | GNUNET_TRANSPORT_communicator_mq_del (queue->qh); |
@@ -885,7 +929,11 @@ queue_destroy (struct Queue *queue) | |||
885 | GNUNET_SCHEDULER_cancel (queue->write_task); | 929 | GNUNET_SCHEDULER_cancel (queue->write_task); |
886 | queue->write_task = NULL; | 930 | queue->write_task = NULL; |
887 | } | 931 | } |
888 | GNUNET_NETWORK_socket_close (queue->sock); | 932 | if (GNUNET_SYSERR == GNUNET_NETWORK_socket_close (queue->sock)) |
933 | { | ||
934 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
935 | "closing socket failed\n"); | ||
936 | } | ||
889 | gcry_cipher_close (queue->in_cipher); | 937 | gcry_cipher_close (queue->in_cipher); |
890 | gcry_cipher_close (queue->out_cipher); | 938 | gcry_cipher_close (queue->out_cipher); |
891 | GNUNET_free (queue->address); | 939 | GNUNET_free (queue->address); |
@@ -894,12 +942,18 @@ queue_destroy (struct Queue *queue) | |||
894 | else | 942 | else |
895 | GNUNET_free (queue); | 943 | GNUNET_free (queue); |
896 | 944 | ||
897 | if (NULL == lt->listen_task) | 945 | if ((! shutdown_running) && (NULL == lt->listen_task)) |
946 | { | ||
947 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
948 | "add read net listen\n"); | ||
898 | lt->listen_task = GNUNET_SCHEDULER_add_read_net ( | 949 | lt->listen_task = GNUNET_SCHEDULER_add_read_net ( |
899 | GNUNET_TIME_UNIT_FOREVER_REL, | 950 | GNUNET_TIME_UNIT_FOREVER_REL, |
900 | lt->listen_sock, | 951 | lt->listen_sock, |
901 | &listen_cb, | 952 | &listen_cb, |
902 | lt); | 953 | lt); |
954 | } | ||
955 | else | ||
956 | GNUNET_free (lt); | ||
903 | } | 957 | } |
904 | 958 | ||
905 | 959 | ||
@@ -1001,6 +1055,13 @@ core_read_finished_cb (void *cls, int success) | |||
1001 | "# messages lost in communicator API towards CORE", | 1055 | "# messages lost in communicator API towards CORE", |
1002 | 1, | 1056 | 1, |
1003 | GNUNET_NO); | 1057 | GNUNET_NO); |
1058 | if (NULL == queue) | ||
1059 | return; | ||
1060 | |||
1061 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1062 | "backpressure %u\n", | ||
1063 | queue->backpressure); | ||
1064 | |||
1004 | queue->backpressure--; | 1065 | queue->backpressure--; |
1005 | /* handle deferred queue destruction */ | 1066 | /* handle deferred queue destruction */ |
1006 | if ((queue->destroyed) && (0 == queue->backpressure)) | 1067 | if ((queue->destroyed) && (0 == queue->backpressure)) |
@@ -1008,15 +1069,18 @@ core_read_finished_cb (void *cls, int success) | |||
1008 | GNUNET_free (queue); | 1069 | GNUNET_free (queue); |
1009 | return; | 1070 | return; |
1010 | } | 1071 | } |
1011 | reschedule_queue_timeout (queue); | 1072 | else if (GNUNET_YES != queue->destroyed) |
1012 | /* possibly unchoke reading, now that CORE made progress */ | 1073 | { |
1013 | if (NULL == queue->read_task) | 1074 | reschedule_queue_timeout (queue); |
1014 | queue->read_task = | 1075 | /* possibly unchoke reading, now that CORE made progress */ |
1015 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining ( | 1076 | if (NULL == queue->read_task) |
1016 | queue->timeout), | 1077 | queue->read_task = |
1017 | queue->sock, | 1078 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining ( |
1018 | &queue_read, | 1079 | queue->timeout), |
1019 | queue); | 1080 | queue->sock, |
1081 | &queue_read, | ||
1082 | queue); | ||
1083 | } | ||
1020 | } | 1084 | } |
1021 | 1085 | ||
1022 | 1086 | ||
@@ -1219,13 +1283,34 @@ rekey_monotime_cb (void *cls, | |||
1219 | static void | 1283 | static void |
1220 | do_rekey (struct Queue *queue, const struct TCPRekey *rekey) | 1284 | do_rekey (struct Queue *queue, const struct TCPRekey *rekey) |
1221 | { | 1285 | { |
1222 | struct TcpHandshakeSignature thp; | 1286 | struct TcpRekeySignature thp; |
1287 | |||
1223 | thp.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY); | 1288 | thp.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY); |
1224 | thp.purpose.size = htonl (sizeof(thp)); | 1289 | thp.purpose.size = htonl (sizeof(thp)); |
1290 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1291 | "do_rekey size %u\n", | ||
1292 | thp.purpose.size); | ||
1225 | thp.sender = queue->target; | 1293 | thp.sender = queue->target; |
1294 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1295 | "sender %s\n", | ||
1296 | GNUNET_p2s (&thp.sender.public_key)); | ||
1297 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1298 | "sender %s\n", | ||
1299 | GNUNET_p2s (&queue->target.public_key)); | ||
1226 | thp.receiver = my_identity; | 1300 | thp.receiver = my_identity; |
1301 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1302 | "receiver %s\n", | ||
1303 | GNUNET_p2s (&thp.receiver.public_key)); | ||
1227 | thp.ephemeral = rekey->ephemeral; | 1304 | thp.ephemeral = rekey->ephemeral; |
1305 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1306 | "ephemeral %s\n", | ||
1307 | GNUNET_e2s (&thp.ephemeral)); | ||
1228 | thp.monotonic_time = rekey->monotonic_time; | 1308 | thp.monotonic_time = rekey->monotonic_time; |
1309 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1310 | "time %s\n", | ||
1311 | GNUNET_STRINGS_absolute_time_to_string ( | ||
1312 | GNUNET_TIME_absolute_ntoh (thp.monotonic_time))); | ||
1313 | GNUNET_assert (ntohl ((&thp)->purpose.size) == sizeof (*(&thp))); | ||
1229 | if (GNUNET_OK != | 1314 | if (GNUNET_OK != |
1230 | GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY, | 1315 | GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY, |
1231 | &thp, | 1316 | &thp, |
@@ -1359,7 +1444,7 @@ try_handle_plaintext (struct Queue *queue) | |||
1359 | if ((-1 != unverified_size) && (unverified_size > INITIAL_CORE_KX_SIZE)) | 1444 | if ((-1 != unverified_size) && (unverified_size > INITIAL_CORE_KX_SIZE)) |
1360 | { | 1445 | { |
1361 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1446 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1362 | "Already received data of size %u bigger than KX size %u!\n", | 1447 | "Already received data of size %lu bigger than KX size %lu!\n", |
1363 | unverified_size, | 1448 | unverified_size, |
1364 | INITIAL_CORE_KX_SIZE); | 1449 | INITIAL_CORE_KX_SIZE); |
1365 | GNUNET_break_op (0); | 1450 | GNUNET_break_op (0); |
@@ -1636,6 +1721,8 @@ tcp_address_to_sockaddr_numeric_v6 (socklen_t *sock_len, struct sockaddr_in6 v6, | |||
1636 | #if HAVE_SOCKADDR_IN_SIN_LEN | 1721 | #if HAVE_SOCKADDR_IN_SIN_LEN |
1637 | v6.sin6_len = sizeof(sizeof(struct sockaddr_in6)); | 1722 | v6.sin6_len = sizeof(sizeof(struct sockaddr_in6)); |
1638 | #endif | 1723 | #endif |
1724 | v6.sin6_flowinfo = 0; | ||
1725 | v6.sin6_scope_id = 0; | ||
1639 | in = GNUNET_memdup (&v6, sizeof(v6)); | 1726 | in = GNUNET_memdup (&v6, sizeof(v6)); |
1640 | *sock_len = sizeof(struct sockaddr_in6); | 1727 | *sock_len = sizeof(struct sockaddr_in6); |
1641 | 1728 | ||
@@ -1739,11 +1826,19 @@ extract_address (const char *bindto) | |||
1739 | char *cp; | 1826 | char *cp; |
1740 | char *rest = NULL; | 1827 | char *rest = NULL; |
1741 | 1828 | ||
1829 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1830 | "extract address with bindto %s\n", | ||
1831 | bindto); | ||
1832 | |||
1742 | if (NULL == bindto) | 1833 | if (NULL == bindto) |
1743 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1834 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1744 | "bindto is NULL\n"); | 1835 | "bindto is NULL\n"); |
1745 | 1836 | ||
1746 | cp = GNUNET_strdup (bindto); | 1837 | cp = GNUNET_strdup (bindto); |
1838 | |||
1839 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1840 | "extract address 2\n"); | ||
1841 | |||
1747 | start = cp; | 1842 | start = cp; |
1748 | if (('[' == *cp) && (']' == cp[strlen (cp) - 1])) | 1843 | if (('[' == *cp) && (']' == cp[strlen (cp) - 1])) |
1749 | { | 1844 | { |
@@ -1763,7 +1858,11 @@ extract_address (const char *bindto) | |||
1763 | } | 1858 | } |
1764 | } | 1859 | } |
1765 | 1860 | ||
1766 | GNUNET_free (cp); | 1861 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1862 | "extract address 3\n"); | ||
1863 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1864 | "extract address with start %s\n", | ||
1865 | start); | ||
1767 | 1866 | ||
1768 | return start; | 1867 | return start; |
1769 | } | 1868 | } |
@@ -1865,10 +1964,25 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) | |||
1865 | // cp = GNUNET_strdup (bindto); | 1964 | // cp = GNUNET_strdup (bindto); |
1866 | start = extract_address (bindto); | 1965 | start = extract_address (bindto); |
1867 | 1966 | ||
1967 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1968 | "start %s\n", | ||
1969 | start); | ||
1970 | |||
1971 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1972 | "!bindto %s\n", | ||
1973 | bindto); | ||
1974 | |||
1975 | |||
1976 | |||
1868 | if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) | 1977 | if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) |
1869 | { | 1978 | { |
1870 | // colon = strrchr (cp, ':'); | 1979 | // colon = strrchr (cp, ':'); |
1871 | port = extract_port (bindto); | 1980 | port = extract_port (bindto); |
1981 | |||
1982 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1983 | "port %u\n", | ||
1984 | port); | ||
1985 | |||
1872 | in = tcp_address_to_sockaddr_numeric_v4 (sock_len, v4, port); | 1986 | in = tcp_address_to_sockaddr_numeric_v4 (sock_len, v4, port); |
1873 | } | 1987 | } |
1874 | else if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr)) | 1988 | else if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr)) |
@@ -1877,6 +1991,11 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) | |||
1877 | port = extract_port (bindto); | 1991 | port = extract_port (bindto); |
1878 | in = tcp_address_to_sockaddr_numeric_v6 (sock_len, v6, port); | 1992 | in = tcp_address_to_sockaddr_numeric_v6 (sock_len, v6, port); |
1879 | } | 1993 | } |
1994 | else{ | ||
1995 | GNUNET_assert (0); | ||
1996 | } | ||
1997 | |||
1998 | // GNUNET_free (start); | ||
1880 | 1999 | ||
1881 | return in; | 2000 | return in; |
1882 | } | 2001 | } |
@@ -1913,7 +2032,7 @@ static void | |||
1913 | inject_rekey (struct Queue *queue) | 2032 | inject_rekey (struct Queue *queue) |
1914 | { | 2033 | { |
1915 | struct TCPRekey rekey; | 2034 | struct TCPRekey rekey; |
1916 | struct TcpHandshakeSignature thp; | 2035 | struct TcpRekeySignature thp; |
1917 | 2036 | ||
1918 | GNUNET_assert (0 == queue->pwrite_off); | 2037 | GNUNET_assert (0 == queue->pwrite_off); |
1919 | memset (&rekey, 0, sizeof(rekey)); | 2038 | memset (&rekey, 0, sizeof(rekey)); |
@@ -1925,10 +2044,26 @@ inject_rekey (struct Queue *queue) | |||
1925 | GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (cfg)); | 2044 | GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (cfg)); |
1926 | thp.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY); | 2045 | thp.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_TCP_REKEY); |
1927 | thp.purpose.size = htonl (sizeof(thp)); | 2046 | thp.purpose.size = htonl (sizeof(thp)); |
2047 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2048 | "inject_rekey size %u\n", | ||
2049 | thp.purpose.size); | ||
1928 | thp.sender = my_identity; | 2050 | thp.sender = my_identity; |
2051 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2052 | "sender %s\n", | ||
2053 | GNUNET_p2s (&thp.sender.public_key)); | ||
1929 | thp.receiver = queue->target; | 2054 | thp.receiver = queue->target; |
2055 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2056 | "receiver %s\n", | ||
2057 | GNUNET_p2s (&thp.receiver.public_key)); | ||
1930 | thp.ephemeral = rekey.ephemeral; | 2058 | thp.ephemeral = rekey.ephemeral; |
2059 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2060 | "ephemeral %s\n", | ||
2061 | GNUNET_e2s (&thp.ephemeral)); | ||
1931 | thp.monotonic_time = rekey.monotonic_time; | 2062 | thp.monotonic_time = rekey.monotonic_time; |
2063 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2064 | "time %s\n", | ||
2065 | GNUNET_STRINGS_absolute_time_to_string ( | ||
2066 | GNUNET_TIME_absolute_ntoh (thp.monotonic_time))); | ||
1932 | GNUNET_CRYPTO_eddsa_sign (my_private_key, | 2067 | GNUNET_CRYPTO_eddsa_sign (my_private_key, |
1933 | &thp, | 2068 | &thp, |
1934 | &rekey.sender_sig); | 2069 | &rekey.sender_sig); |
@@ -2004,10 +2139,11 @@ queue_write (void *cls) | |||
2004 | queue->cwrite_off += queue->pwrite_off; | 2139 | queue->cwrite_off += queue->pwrite_off; |
2005 | queue->pwrite_off = 0; | 2140 | queue->pwrite_off = 0; |
2006 | } | 2141 | } |
2007 | if ((0 == queue->pwrite_off) && | 2142 | if ((-1 != unverified_size)&& ((0 == queue->pwrite_off) && |
2008 | ((0 == queue->rekey_left_bytes) || | 2143 | ((0 == queue->rekey_left_bytes) || |
2009 | (0 == | 2144 | (0 == |
2010 | GNUNET_TIME_absolute_get_remaining (queue->rekey_time).rel_value_us))) | 2145 | GNUNET_TIME_absolute_get_remaining ( |
2146 | queue->rekey_time).rel_value_us)))) | ||
2011 | { | 2147 | { |
2012 | inject_rekey (queue); | 2148 | inject_rekey (queue); |
2013 | } | 2149 | } |
@@ -2403,11 +2539,6 @@ decrypt_and_check_tc (struct Queue *queue, | |||
2403 | static void | 2539 | static void |
2404 | free_proto_queue (struct ProtoQueue *pq) | 2540 | free_proto_queue (struct ProtoQueue *pq) |
2405 | { | 2541 | { |
2406 | if (NULL != pq->listen_task) | ||
2407 | { | ||
2408 | GNUNET_SCHEDULER_cancel (pq->listen_task); | ||
2409 | pq->listen_task = NULL; | ||
2410 | } | ||
2411 | if (NULL != pq->listen_sock) | 2542 | if (NULL != pq->listen_sock) |
2412 | { | 2543 | { |
2413 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pq->listen_sock)); | 2544 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pq->listen_sock)); |
@@ -2526,7 +2657,6 @@ proto_read_kx (void *cls) | |||
2526 | queue->address = pq->address; /* steals reference */ | 2657 | queue->address = pq->address; /* steals reference */ |
2527 | queue->address_len = pq->address_len; | 2658 | queue->address_len = pq->address_len; |
2528 | queue->target = tc.sender; | 2659 | queue->target = tc.sender; |
2529 | queue->listen_task = pq->listen_task; | ||
2530 | queue->listen_sock = pq->listen_sock; | 2660 | queue->listen_sock = pq->listen_sock; |
2531 | queue->sock = pq->sock; | 2661 | queue->sock = pq->sock; |
2532 | 2662 | ||
@@ -2569,6 +2699,9 @@ listen_cb (void *cls) | |||
2569 | struct ProtoQueue *pq; | 2699 | struct ProtoQueue *pq; |
2570 | struct ListenTask *lt; | 2700 | struct ListenTask *lt; |
2571 | 2701 | ||
2702 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2703 | "listen_cb\n"); | ||
2704 | |||
2572 | lt = cls; | 2705 | lt = cls; |
2573 | 2706 | ||
2574 | lt->listen_task = NULL; | 2707 | lt->listen_task = NULL; |
@@ -2707,7 +2840,7 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) | |||
2707 | struct Queue *queue; | 2840 | struct Queue *queue; |
2708 | const char *path; | 2841 | const char *path; |
2709 | struct sockaddr *in; | 2842 | struct sockaddr *in; |
2710 | socklen_t in_len; | 2843 | socklen_t in_len = 0; |
2711 | struct GNUNET_NETWORK_Handle *sock; | 2844 | struct GNUNET_NETWORK_Handle *sock; |
2712 | 2845 | ||
2713 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2846 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2729,6 +2862,10 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) | |||
2729 | return GNUNET_SYSERR; | 2862 | return GNUNET_SYSERR; |
2730 | } | 2863 | } |
2731 | 2864 | ||
2865 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2866 | "in %s\n", | ||
2867 | GNUNET_a2s (in, in_len)); | ||
2868 | |||
2732 | sock = GNUNET_NETWORK_socket_create (in->sa_family, SOCK_STREAM, IPPROTO_TCP); | 2869 | sock = GNUNET_NETWORK_socket_create (in->sa_family, SOCK_STREAM, IPPROTO_TCP); |
2733 | if (NULL == sock) | 2870 | if (NULL == sock) |
2734 | { | 2871 | { |
@@ -2778,6 +2915,36 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) | |||
2778 | } | 2915 | } |
2779 | 2916 | ||
2780 | /** | 2917 | /** |
2918 | * Iterator over all ListenTasks to clean up. | ||
2919 | * | ||
2920 | * @param cls NULL | ||
2921 | * @param key unused | ||
2922 | * @param value the ListenTask to cancel. | ||
2923 | * @return #GNUNET_OK to continue to iterate | ||
2924 | */ | ||
2925 | static int | ||
2926 | get_lt_delete_it (void *cls, | ||
2927 | const struct GNUNET_HashCode *key, | ||
2928 | void *value) | ||
2929 | { | ||
2930 | struct ListenTask *lt = value; | ||
2931 | |||
2932 | (void) cls; | ||
2933 | (void) key; | ||
2934 | if (NULL != lt->listen_task) | ||
2935 | { | ||
2936 | GNUNET_SCHEDULER_cancel (lt->listen_task); | ||
2937 | lt->listen_task = NULL; | ||
2938 | } | ||
2939 | if (NULL != lt->listen_sock) | ||
2940 | { | ||
2941 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (lt->listen_sock)); | ||
2942 | lt->listen_sock = NULL; | ||
2943 | } | ||
2944 | return GNUNET_OK; | ||
2945 | } | ||
2946 | |||
2947 | /** | ||
2781 | * Iterator over all message queues to clean up. | 2948 | * Iterator over all message queues to clean up. |
2782 | * | 2949 | * |
2783 | * @param cls NULL | 2950 | * @param cls NULL |
@@ -2798,7 +2965,6 @@ get_queue_delete_it (void *cls, | |||
2798 | return GNUNET_OK; | 2965 | return GNUNET_OK; |
2799 | } | 2966 | } |
2800 | 2967 | ||
2801 | |||
2802 | /** | 2968 | /** |
2803 | * Shutdown the UNIX communicator. | 2969 | * Shutdown the UNIX communicator. |
2804 | * | 2970 | * |
@@ -2807,6 +2973,15 @@ get_queue_delete_it (void *cls, | |||
2807 | static void | 2973 | static void |
2808 | do_shutdown (void *cls) | 2974 | do_shutdown (void *cls) |
2809 | { | 2975 | { |
2976 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2977 | "Shutdown %s!\n", | ||
2978 | shutdown_running ? "running" : "not running"); | ||
2979 | |||
2980 | if (GNUNET_YES == shutdown_running) | ||
2981 | return; | ||
2982 | else | ||
2983 | shutdown_running = GNUNET_YES; | ||
2984 | |||
2810 | while (NULL != proto_head) | 2985 | while (NULL != proto_head) |
2811 | free_proto_queue (proto_head); | 2986 | free_proto_queue (proto_head); |
2812 | if (NULL != nat) | 2987 | if (NULL != nat) |
@@ -2814,8 +2989,10 @@ do_shutdown (void *cls) | |||
2814 | GNUNET_NAT_unregister (nat); | 2989 | GNUNET_NAT_unregister (nat); |
2815 | nat = NULL; | 2990 | nat = NULL; |
2816 | } | 2991 | } |
2992 | GNUNET_CONTAINER_multihashmap_iterate (lt_map, &get_lt_delete_it, NULL); | ||
2817 | GNUNET_CONTAINER_multipeermap_iterate (queue_map, &get_queue_delete_it, NULL); | 2993 | GNUNET_CONTAINER_multipeermap_iterate (queue_map, &get_queue_delete_it, NULL); |
2818 | GNUNET_CONTAINER_multipeermap_destroy (queue_map); | 2994 | GNUNET_CONTAINER_multipeermap_destroy (queue_map); |
2995 | GNUNET_TRANSPORT_communicator_address_remove_all (ch); | ||
2819 | if (NULL != ch) | 2996 | if (NULL != ch) |
2820 | { | 2997 | { |
2821 | GNUNET_TRANSPORT_communicator_disconnect (ch); | 2998 | GNUNET_TRANSPORT_communicator_disconnect (ch); |
@@ -2836,6 +3013,18 @@ do_shutdown (void *cls) | |||
2836 | GNUNET_NT_scanner_done (is); | 3013 | GNUNET_NT_scanner_done (is); |
2837 | is = NULL; | 3014 | is = NULL; |
2838 | } | 3015 | } |
3016 | if (NULL != peerstore) | ||
3017 | { | ||
3018 | GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_NO); | ||
3019 | peerstore = NULL; | ||
3020 | } | ||
3021 | if (NULL != resolve_request_handle) | ||
3022 | { | ||
3023 | GNUNET_RESOLVER_request_cancel (resolve_request_handle); | ||
3024 | resolve_request_handle = NULL; | ||
3025 | } | ||
3026 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3027 | "Shutdown done!\n"); | ||
2839 | } | 3028 | } |
2840 | 3029 | ||
2841 | 3030 | ||
@@ -2886,6 +3075,11 @@ nat_address_cb (void *cls, | |||
2886 | char *my_addr; | 3075 | char *my_addr; |
2887 | struct GNUNET_TRANSPORT_AddressIdentifier *ai; | 3076 | struct GNUNET_TRANSPORT_AddressIdentifier *ai; |
2888 | 3077 | ||
3078 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3079 | "nat address cb %s %s\n", | ||
3080 | add_remove ? "add" : "remove", | ||
3081 | GNUNET_a2s (addr, addrlen)); | ||
3082 | |||
2889 | if (GNUNET_YES == add_remove) | 3083 | if (GNUNET_YES == add_remove) |
2890 | { | 3084 | { |
2891 | enum GNUNET_NetworkType nt; | 3085 | enum GNUNET_NetworkType nt; |
@@ -2912,6 +3106,35 @@ nat_address_cb (void *cls, | |||
2912 | } | 3106 | } |
2913 | 3107 | ||
2914 | /** | 3108 | /** |
3109 | * This method adds addresses to the DLL, that are later register at the NAT service. | ||
3110 | */ | ||
3111 | static void | ||
3112 | add_addr (struct sockaddr *in, socklen_t in_len) | ||
3113 | { | ||
3114 | |||
3115 | struct Addresses *saddrs; | ||
3116 | |||
3117 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3118 | "add address %s\n", | ||
3119 | GNUNET_a2s (in, in_len)); | ||
3120 | |||
3121 | saddrs = GNUNET_new (struct Addresses); | ||
3122 | saddrs->addr = in; | ||
3123 | saddrs->addr_len = in_len; | ||
3124 | GNUNET_CONTAINER_DLL_insert (addrs_head, addrs_tail, saddrs); | ||
3125 | |||
3126 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3127 | "after add address %s\n", | ||
3128 | GNUNET_a2s (in, in_len)); | ||
3129 | |||
3130 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3131 | "add address %s\n", | ||
3132 | GNUNET_a2s (saddrs->addr, saddrs->addr_len)); | ||
3133 | |||
3134 | addrs_lens++; | ||
3135 | } | ||
3136 | |||
3137 | /** | ||
2915 | * This method launch network interactions for each address we like to bind to. | 3138 | * This method launch network interactions for each address we like to bind to. |
2916 | * | 3139 | * |
2917 | * @param addr The address we will listen to. | 3140 | * @param addr The address we will listen to. |
@@ -2919,13 +3142,14 @@ nat_address_cb (void *cls, | |||
2919 | * @return GNUNET_SYSERR in case of error. GNUNET_OK in case we are successfully listen to the address. | 3142 | * @return GNUNET_SYSERR in case of error. GNUNET_OK in case we are successfully listen to the address. |
2920 | */ | 3143 | */ |
2921 | static int | 3144 | static int |
2922 | init_socket (const struct sockaddr *addr, | 3145 | init_socket (struct sockaddr *addr, |
2923 | socklen_t in_len) | 3146 | socklen_t in_len) |
2924 | { | 3147 | { |
2925 | struct sockaddr_storage in_sto; | 3148 | struct sockaddr_storage in_sto; |
2926 | socklen_t sto_len; | 3149 | socklen_t sto_len; |
2927 | struct GNUNET_NETWORK_Handle *listen_sock; | 3150 | struct GNUNET_NETWORK_Handle *listen_sock; |
2928 | struct ListenTask *lt; | 3151 | struct ListenTask *lt; |
3152 | struct GNUNET_HashCode h_sock; | ||
2929 | 3153 | ||
2930 | if (NULL == addr) | 3154 | if (NULL == addr) |
2931 | { | 3155 | { |
@@ -2977,13 +3201,12 @@ init_socket (const struct sockaddr *addr, | |||
2977 | sto_len = in_len; | 3201 | sto_len = in_len; |
2978 | } | 3202 | } |
2979 | 3203 | ||
2980 | addr = (struct sockaddr *) &in_sto; | 3204 | // addr = (struct sockaddr *) &in_sto; |
2981 | in_len = sto_len; | 3205 | in_len = sto_len; |
2982 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3206 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2983 | "Bound to `%s'\n", | 3207 | "Bound to `%s'\n", |
2984 | GNUNET_a2s ((const struct sockaddr *) &in_sto, sto_len)); | 3208 | GNUNET_a2s ((const struct sockaddr *) &in_sto, sto_len)); |
2985 | stats = GNUNET_STATISTICS_create ("C-TCP", cfg); | 3209 | stats = GNUNET_STATISTICS_create ("C-TCP", cfg); |
2986 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | ||
2987 | 3210 | ||
2988 | if (NULL == is) | 3211 | if (NULL == is) |
2989 | is = GNUNET_NT_scanner_init (); | 3212 | is = GNUNET_NT_scanner_init (); |
@@ -3012,6 +3235,27 @@ init_socket (const struct sockaddr *addr, | |||
3012 | &listen_cb, | 3235 | &listen_cb, |
3013 | lt); | 3236 | lt); |
3014 | 3237 | ||
3238 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3239 | "creating hash\n"); | ||
3240 | GNUNET_CRYPTO_hash (lt->listen_sock, | ||
3241 | sizeof(lt->listen_sock), | ||
3242 | &h_sock); | ||
3243 | |||
3244 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3245 | "creating map\n"); | ||
3246 | if (NULL == lt_map) | ||
3247 | lt_map = GNUNET_CONTAINER_multihashmap_create (2, GNUNET_NO); | ||
3248 | |||
3249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3250 | "creating map entry\n"); | ||
3251 | GNUNET_CONTAINER_multihashmap_put (lt_map, | ||
3252 | &h_sock, | ||
3253 | lt, | ||
3254 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | ||
3255 | |||
3256 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3257 | "map entry created\n"); | ||
3258 | |||
3015 | if (NULL == queue_map) | 3259 | if (NULL == queue_map) |
3016 | queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); | 3260 | queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); |
3017 | 3261 | ||
@@ -3034,6 +3278,7 @@ init_socket (const struct sockaddr *addr, | |||
3034 | return GNUNET_SYSERR; | 3278 | return GNUNET_SYSERR; |
3035 | } | 3279 | } |
3036 | 3280 | ||
3281 | add_addr (addr, in_len); | ||
3037 | return GNUNET_OK; | 3282 | return GNUNET_OK; |
3038 | 3283 | ||
3039 | } | 3284 | } |
@@ -3050,6 +3295,10 @@ nat_register () | |||
3050 | int i; | 3295 | int i; |
3051 | struct Addresses *pos; | 3296 | struct Addresses *pos; |
3052 | 3297 | ||
3298 | |||
3299 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3300 | "starting nat register!\n"); | ||
3301 | |||
3053 | i = 0; | 3302 | i = 0; |
3054 | saddrs = GNUNET_malloc ((addrs_lens + 1) * sizeof(struct sockaddr *)); | 3303 | saddrs = GNUNET_malloc ((addrs_lens + 1) * sizeof(struct sockaddr *)); |
3055 | 3304 | ||
@@ -3058,9 +3307,12 @@ nat_register () | |||
3058 | for (pos = addrs_head; NULL != pos; pos = pos->next) | 3307 | for (pos = addrs_head; NULL != pos; pos = pos->next) |
3059 | { | 3308 | { |
3060 | 3309 | ||
3310 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3311 | "registering address %s\n", | ||
3312 | GNUNET_a2s (addrs_head->addr, addrs_head->addr_len)); | ||
3313 | |||
3061 | saddr_lens[i] = addrs_head->addr_len; | 3314 | saddr_lens[i] = addrs_head->addr_len; |
3062 | saddrs[i] = GNUNET_malloc (saddr_lens[i]); | 3315 | saddrs[i] = GNUNET_memdup (addrs_head->addr, saddr_lens[i]); |
3063 | saddrs[i] = addrs_head->addr; | ||
3064 | 3316 | ||
3065 | i++; | 3317 | i++; |
3066 | 3318 | ||
@@ -3078,8 +3330,8 @@ nat_register () | |||
3078 | 3330 | ||
3079 | i = 0; | 3331 | i = 0; |
3080 | 3332 | ||
3081 | /*for (i = addrs_lens - 1; i >= 0; i--) | 3333 | for (i = addrs_lens - 1; i >= 0; i--) |
3082 | GNUNET_free (saddrs[i]);*/ | 3334 | GNUNET_free (saddrs[i]); |
3083 | GNUNET_free (saddrs); | 3335 | GNUNET_free (saddrs); |
3084 | GNUNET_free (saddr_lens); | 3336 | GNUNET_free (saddr_lens); |
3085 | 3337 | ||
@@ -3093,22 +3345,6 @@ nat_register () | |||
3093 | } | 3345 | } |
3094 | 3346 | ||
3095 | /** | 3347 | /** |
3096 | * This method adds addresses to the DLL, that are later register at the NAT service. | ||
3097 | */ | ||
3098 | static void | ||
3099 | add_addr (struct sockaddr *in, socklen_t in_len) | ||
3100 | { | ||
3101 | |||
3102 | struct Addresses *saddrs; | ||
3103 | |||
3104 | saddrs = GNUNET_new (struct Addresses); | ||
3105 | saddrs->addr = in; | ||
3106 | saddrs->addr_len = in_len; | ||
3107 | GNUNET_CONTAINER_DLL_insert (addrs_head, addrs_tail, saddrs); | ||
3108 | addrs_lens++; | ||
3109 | } | ||
3110 | |||
3111 | /** | ||
3112 | * This method is the callback called by the resolver API, and wraps method init_socket. | 3348 | * This method is the callback called by the resolver API, and wraps method init_socket. |
3113 | * | 3349 | * |
3114 | * @param cls The port we will bind to. | 3350 | * @param cls The port we will bind to. |
@@ -3123,22 +3359,19 @@ init_socket_resolv (void *cls, | |||
3123 | struct sockaddr_in *v4; | 3359 | struct sockaddr_in *v4; |
3124 | struct sockaddr_in6 *v6; | 3360 | struct sockaddr_in6 *v6; |
3125 | struct sockaddr *in; | 3361 | struct sockaddr *in; |
3126 | unsigned int *port; | ||
3127 | 3362 | ||
3128 | port = cls; | 3363 | (void) cls; |
3129 | if (NULL != addr) | 3364 | if (NULL != addr) |
3130 | { | 3365 | { |
3131 | if (AF_INET == addr->sa_family) | 3366 | if (AF_INET == addr->sa_family) |
3132 | { | 3367 | { |
3133 | v4 = (struct sockaddr_in *) addr; | 3368 | v4 = (struct sockaddr_in *) addr; |
3134 | in = tcp_address_to_sockaddr_numeric_v4 (&in_len, *v4, *port);// _global); | 3369 | in = tcp_address_to_sockaddr_numeric_v4 (&in_len, *v4, bind_port);// _global); |
3135 | add_addr (in, in_len); | ||
3136 | } | 3370 | } |
3137 | else if (AF_INET6 == addr->sa_family) | 3371 | else if (AF_INET6 == addr->sa_family) |
3138 | { | 3372 | { |
3139 | v6 = (struct sockaddr_in6 *) addr; | 3373 | v6 = (struct sockaddr_in6 *) addr; |
3140 | in = tcp_address_to_sockaddr_numeric_v6 (&in_len, *v6, *port);// _global); | 3374 | in = tcp_address_to_sockaddr_numeric_v6 (&in_len, *v6, bind_port);// _global); |
3141 | add_addr (in, in_len); | ||
3142 | } | 3375 | } |
3143 | else | 3376 | else |
3144 | { | 3377 | { |
@@ -3149,14 +3382,20 @@ init_socket_resolv (void *cls, | |||
3149 | AF_INET6); | 3382 | AF_INET6); |
3150 | return; | 3383 | return; |
3151 | } | 3384 | } |
3152 | init_socket (in, | 3385 | init_socket (in, in_len); |
3153 | in_len); | ||
3154 | } | 3386 | } |
3155 | else | 3387 | else |
3156 | { | 3388 | { |
3157 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 3389 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3158 | "Address is NULL. This might be an error or the resolver finished resolving.\n"); | 3390 | "Address is NULL. This might be an error or the resolver finished resolving.\n"); |
3391 | if (NULL == addrs_head) | ||
3392 | { | ||
3393 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
3394 | "Resolver finished resolving, but we do not listen to an address!.\n"); | ||
3395 | return; | ||
3396 | } | ||
3159 | nat_register (); | 3397 | nat_register (); |
3398 | |||
3160 | } | 3399 | } |
3161 | } | 3400 | } |
3162 | 3401 | ||
@@ -3221,12 +3460,11 @@ run (void *cls, | |||
3221 | return; | 3460 | return; |
3222 | } | 3461 | } |
3223 | 3462 | ||
3224 | // cp = GNUNET_strdup (bindto); | 3463 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
3225 | start = extract_address (bindto); | ||
3226 | 3464 | ||
3227 | if (1 == sscanf (bindto, "%u%1s", &port, dummy)) | 3465 | if (1 == sscanf (bindto, "%u%1s", &bind_port, dummy)) |
3228 | { | 3466 | { |
3229 | po = tcp_address_to_sockaddr_port_only (bindto, &port); | 3467 | po = tcp_address_to_sockaddr_port_only (bindto, &bind_port); |
3230 | 3468 | ||
3231 | addr_len_ipv4 = po->addr_len_ipv4; | 3469 | addr_len_ipv4 = po->addr_len_ipv4; |
3232 | 3470 | ||
@@ -3238,46 +3476,55 @@ run (void *cls, | |||
3238 | if (NULL != po->addr_ipv4) | 3476 | if (NULL != po->addr_ipv4) |
3239 | { | 3477 | { |
3240 | init_socket (po->addr_ipv4, addr_len_ipv4); | 3478 | init_socket (po->addr_ipv4, addr_len_ipv4); |
3241 | add_addr (po->addr_ipv4, addr_len_ipv4); | ||
3242 | } | 3479 | } |
3243 | 3480 | ||
3244 | if (NULL != po->addr_ipv6) | 3481 | if (NULL != po->addr_ipv6) |
3245 | { | 3482 | { |
3246 | addr_len_ipv6 = po->addr_len_ipv6; | 3483 | addr_len_ipv6 = po->addr_len_ipv6; |
3247 | init_socket (po->addr_ipv6, addr_len_ipv6); | 3484 | init_socket (po->addr_ipv6, addr_len_ipv6); |
3248 | add_addr (po->addr_ipv6, addr_len_ipv6); | ||
3249 | } | 3485 | } |
3250 | 3486 | ||
3487 | GNUNET_free (po); | ||
3251 | nat_register (); | 3488 | nat_register (); |
3489 | GNUNET_free (bindto); | ||
3490 | |||
3491 | return; | ||
3252 | } | 3492 | } |
3253 | else if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) | 3493 | |
3494 | start = extract_address (bindto); | ||
3495 | |||
3496 | if (1 == inet_pton (AF_INET, start, &v4.sin_addr)) | ||
3254 | { | 3497 | { |
3255 | port = extract_port (bindto); | 3498 | bind_port = extract_port (bindto); |
3256 | 3499 | ||
3257 | in = tcp_address_to_sockaddr_numeric_v4 (&in_len, v4, port); | 3500 | in = tcp_address_to_sockaddr_numeric_v4 (&in_len, v4, bind_port); |
3258 | init_socket (in, in_len); | 3501 | init_socket (in, in_len); |
3259 | add_addr (in, in_len); | ||
3260 | nat_register (); | 3502 | nat_register (); |
3503 | GNUNET_free (bindto); | ||
3504 | |||
3505 | return; | ||
3261 | } | 3506 | } |
3262 | else if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr)) | 3507 | |
3508 | if (1 == inet_pton (AF_INET6, start, &v6.sin6_addr)) | ||
3263 | { | 3509 | { |
3264 | port = extract_port (bindto); | 3510 | bind_port = extract_port (bindto); |
3265 | in = tcp_address_to_sockaddr_numeric_v6 (&in_len, v6, port); | 3511 | in = tcp_address_to_sockaddr_numeric_v6 (&in_len, v6, bind_port); |
3266 | init_socket (in, in_len); | 3512 | init_socket (in, in_len); |
3267 | add_addr (in, in_len); | ||
3268 | nat_register (); | 3513 | nat_register (); |
3269 | } | 3514 | GNUNET_free (bindto); |
3270 | else | ||
3271 | { | ||
3272 | port = extract_port (bindto); | ||
3273 | 3515 | ||
3274 | resolve_request_handle = GNUNET_RESOLVER_ip_get (strtok_r (bindto, ":", | 3516 | return; |
3275 | &rest), | ||
3276 | AF_UNSPEC, | ||
3277 | GNUNET_TIME_UNIT_MINUTES, | ||
3278 | &init_socket_resolv, | ||
3279 | &port); | ||
3280 | } | 3517 | } |
3518 | |||
3519 | |||
3520 | bind_port = extract_port (bindto); | ||
3521 | |||
3522 | resolve_request_handle = GNUNET_RESOLVER_ip_get (strtok_r (bindto, ":", | ||
3523 | &rest), | ||
3524 | AF_UNSPEC, | ||
3525 | GNUNET_TIME_UNIT_MINUTES, | ||
3526 | &init_socket_resolv, | ||
3527 | &port); | ||
3281 | GNUNET_free (bindto); | 3528 | GNUNET_free (bindto); |
3282 | } | 3529 | } |
3283 | 3530 | ||
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c index e2d2eb73c..aa02bda93 100644 --- a/src/transport/test_communicator_basic.c +++ b/src/transport/test_communicator_basic.c | |||
@@ -124,6 +124,25 @@ communicator_available_cb (void *cls, | |||
124 | address_prefix); | 124 | address_prefix); |
125 | } | 125 | } |
126 | 126 | ||
127 | static void | ||
128 | open_queue (void *cls) | ||
129 | { | ||
130 | char *address = cls; | ||
131 | |||
132 | if (NULL != tc_hs[PEER_A]->c_mq) | ||
133 | { | ||
134 | queue_est = GNUNET_YES; | ||
135 | GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (tc_hs[PEER_A], | ||
136 | &peer_id[PEER_B], | ||
137 | address); | ||
138 | } | ||
139 | else | ||
140 | { | ||
141 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
142 | &open_queue, | ||
143 | address); | ||
144 | } | ||
145 | } | ||
127 | 146 | ||
128 | static void | 147 | static void |
129 | add_address_cb (void *cls, | 148 | add_address_cb (void *cls, |
@@ -144,10 +163,7 @@ add_address_cb (void *cls, | |||
144 | if ((0 == strcmp ((char*) cls, cfg_peers_name[PEER_B])) && | 163 | if ((0 == strcmp ((char*) cls, cfg_peers_name[PEER_B])) && |
145 | (GNUNET_NO == queue_est)) | 164 | (GNUNET_NO == queue_est)) |
146 | { | 165 | { |
147 | queue_est = GNUNET_YES; | 166 | open_queue (address); |
148 | GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (tc_hs[PEER_A], | ||
149 | &peer_id[PEER_B], | ||
150 | address); | ||
151 | } | 167 | } |
152 | } | 168 | } |
153 | 169 | ||
diff --git a/src/transport/test_communicator_tcp_rekey_peer2.conf b/src/transport/test_communicator_tcp_rekey_peer2.conf index 138650a3b..643b037b2 100644 --- a/src/transport/test_communicator_tcp_rekey_peer2.conf +++ b/src/transport/test_communicator_tcp_rekey_peer2.conf | |||
@@ -31,10 +31,10 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock | |||
31 | UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock | 31 | UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock |
32 | 32 | ||
33 | [communicator-tcp] | 33 | [communicator-tcp] |
34 | #PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args | 34 | #PREFIX = xterm -geometry 100x85 -T peer2 -e gdb --args |
35 | #PREFIX = valgrind --leak-check=full --track-origins=yes | 35 | #PREFIX = valgrind --leak-check=full --track-origins=yes |
36 | BINDTO = 60003 | 36 | BINDTO = 60003 |
37 | DISABLE_V6 = YES | 37 | DISABLE_V6 = NO |
38 | REKEY_INTERVAL = 100ms | 38 | REKEY_INTERVAL = 100ms |
39 | 39 | ||
40 | [communicator-udp] | 40 | [communicator-udp] |
diff --git a/src/transport/test_communicator_unix_basic_peer1.conf b/src/transport/test_communicator_unix_basic_peer1.conf index 71283e381..8e9700108 100644 --- a/src/transport/test_communicator_unix_basic_peer1.conf +++ b/src/transport/test_communicator_unix_basic_peer1.conf | |||
@@ -28,6 +28,8 @@ PORT = 62089 | |||
28 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_1.sock | 28 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_1.sock |
29 | 29 | ||
30 | [communicator-unix] | 30 | [communicator-unix] |
31 | #PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args | ||
32 | #PREFIX = valgrind --leak-check=full --track-origins=yes | ||
31 | UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-1.sock | 33 | UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-1.sock |
32 | 34 | ||
33 | [communicator-tcp] | 35 | [communicator-tcp] |
diff --git a/src/transport/test_communicator_unix_basic_peer2.conf b/src/transport/test_communicator_unix_basic_peer2.conf index ac95845b2..c12cc9111 100644 --- a/src/transport/test_communicator_unix_basic_peer2.conf +++ b/src/transport/test_communicator_unix_basic_peer2.conf | |||
@@ -28,6 +28,8 @@ PORT = 62090 | |||
28 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock | 28 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-resolver_test_2.sock |
29 | 29 | ||
30 | [communicator-unix] | 30 | [communicator-unix] |
31 | #PREFIX = xterm -geometry 100x85 -T peer2 -e gdb --args | ||
32 | #PREFIX = valgrind --leak-check=full --track-origins=yes | ||
31 | UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-2.sock | 33 | UNIXPATH = $GNUNET_RUNTIME_DIR/communicator-unix-2.sock |
32 | 34 | ||
33 | [communicator-tcp] | 35 | [communicator-tcp] |
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c index 13944e9f0..98cfd5e29 100644 --- a/src/transport/transport-testing2.c +++ b/src/transport/transport-testing2.c | |||
@@ -59,145 +59,6 @@ struct MyClient | |||
59 | }; | 59 | }; |
60 | 60 | ||
61 | /** | 61 | /** |
62 | * @brief Handle to a transport communicator | ||
63 | */ | ||
64 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle | ||
65 | { | ||
66 | /** | ||
67 | * Clients | ||
68 | */ | ||
69 | struct MyClient *client_head; | ||
70 | struct MyClient *client_tail; | ||
71 | |||
72 | /** | ||
73 | * @brief Handle to the client | ||
74 | */ | ||
75 | struct GNUNET_MQ_Handle *c_mq; | ||
76 | |||
77 | /** | ||
78 | * @brief Handle to the configuration | ||
79 | */ | ||
80 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
81 | |||
82 | /** | ||
83 | * @brief File name of configuration file | ||
84 | */ | ||
85 | char *cfg_filename; | ||
86 | |||
87 | struct GNUNET_PeerIdentity peer_id; | ||
88 | |||
89 | /** | ||
90 | * @brief Handle to the transport service | ||
91 | */ | ||
92 | struct GNUNET_SERVICE_Handle *tsh; | ||
93 | |||
94 | /** | ||
95 | * @brief Task that will be run on shutdown to stop and clean transport | ||
96 | * service | ||
97 | */ | ||
98 | struct GNUNET_SCHEDULER_Task *ts_shutdown_task; | ||
99 | |||
100 | |||
101 | /** | ||
102 | * @brief Process of the communicator | ||
103 | */ | ||
104 | struct GNUNET_OS_Process *c_proc; | ||
105 | |||
106 | /** | ||
107 | * NAT process | ||
108 | */ | ||
109 | struct GNUNET_OS_Process *nat_proc; | ||
110 | |||
111 | /** | ||
112 | * resolver service process | ||
113 | */ | ||
114 | struct GNUNET_OS_Process *resolver_proc; | ||
115 | |||
116 | /** | ||
117 | * peerstore service process | ||
118 | */ | ||
119 | struct GNUNET_OS_Process *ps_proc; | ||
120 | |||
121 | /** | ||
122 | * @brief Task that will be run on shutdown to stop and clean communicator | ||
123 | */ | ||
124 | struct GNUNET_SCHEDULER_Task *c_shutdown_task; | ||
125 | |||
126 | /** | ||
127 | * @brief Characteristics of the communicator | ||
128 | */ | ||
129 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics c_characteristics; | ||
130 | |||
131 | /** | ||
132 | * @brief Specifies supported addresses | ||
133 | */ | ||
134 | char *c_addr_prefix; | ||
135 | |||
136 | /** | ||
137 | * @brief Specifies supported addresses | ||
138 | */ | ||
139 | char *c_address; | ||
140 | |||
141 | /** | ||
142 | * @brief Head of the DLL of queues associated with this communicator | ||
143 | */ | ||
144 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_head; | ||
145 | |||
146 | /** | ||
147 | * @brief Tail of the DLL of queues associated with this communicator | ||
148 | */ | ||
149 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_tail; | ||
150 | |||
151 | /* Callbacks + Closures */ | ||
152 | /** | ||
153 | * @brief Callback called when a new communicator connects | ||
154 | */ | ||
155 | GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback | ||
156 | communicator_available_cb; | ||
157 | |||
158 | /** | ||
159 | * @brief Callback called when a new communicator connects | ||
160 | */ | ||
161 | GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb; | ||
162 | |||
163 | /** | ||
164 | * @brief Callback called when a new communicator connects | ||
165 | */ | ||
166 | GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb; | ||
167 | |||
168 | /** | ||
169 | * @brief Callback called when a new communicator connects | ||
170 | */ | ||
171 | GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb; | ||
172 | |||
173 | /** | ||
174 | * @brief Callback called when a new communicator connects | ||
175 | */ | ||
176 | GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_msg_cb; | ||
177 | |||
178 | /** | ||
179 | * @brief Backchannel callback | ||
180 | */ | ||
181 | GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb; | ||
182 | |||
183 | /** | ||
184 | * Our service handle | ||
185 | */ | ||
186 | struct GNUNET_SERVICE_Handle *sh; | ||
187 | |||
188 | /** | ||
189 | * @brief Closure to the callback | ||
190 | */ | ||
191 | void *cb_cls; | ||
192 | |||
193 | /** | ||
194 | * Backchannel supported | ||
195 | */ | ||
196 | int bc_enabled; | ||
197 | }; | ||
198 | |||
199 | |||
200 | /** | ||
201 | * @brief Queue of a communicator and some context | 62 | * @brief Queue of a communicator and some context |
202 | */ | 63 | */ |
203 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue | 64 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue |
@@ -707,6 +568,9 @@ shutdown_service (void *cls) | |||
707 | { | 568 | { |
708 | struct GNUNET_SERVICE_Handle *h = cls; | 569 | struct GNUNET_SERVICE_Handle *h = cls; |
709 | 570 | ||
571 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
572 | "Shutting down service!\n"); | ||
573 | |||
710 | GNUNET_SERVICE_stop (h); | 574 | GNUNET_SERVICE_stop (h); |
711 | } | 575 | } |
712 | 576 | ||
@@ -897,7 +761,6 @@ shutdown_process (struct GNUNET_OS_Process *proc) | |||
897 | GNUNET_OS_process_destroy (proc); | 761 | GNUNET_OS_process_destroy (proc); |
898 | } | 762 | } |
899 | 763 | ||
900 | |||
901 | static void | 764 | static void |
902 | shutdown_peerstore (void *cls) | 765 | shutdown_peerstore (void *cls) |
903 | { | 766 | { |
@@ -905,7 +768,6 @@ shutdown_peerstore (void *cls) | |||
905 | shutdown_process (proc); | 768 | shutdown_process (proc); |
906 | } | 769 | } |
907 | 770 | ||
908 | |||
909 | static void | 771 | static void |
910 | shutdown_communicator (void *cls) | 772 | shutdown_communicator (void *cls) |
911 | { | 773 | { |
@@ -941,8 +803,7 @@ communicator_start ( | |||
941 | 803 | ||
942 | 804 | ||
943 | binary = GNUNET_OS_get_libexec_binary_path (binary_name); | 805 | binary = GNUNET_OS_get_libexec_binary_path (binary_name); |
944 | tc_h->c_proc = GNUNET_OS_start_process_s (GNUNET_OS_USE_PIPE_CONTROL | 806 | tc_h->c_proc = GNUNET_OS_start_process_s (GNUNET_OS_INHERIT_STD_OUT_AND_ERR, |
945 | | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, | ||
946 | NULL, | 807 | NULL, |
947 | loprefix, | 808 | loprefix, |
948 | binary, | 809 | binary, |
@@ -1026,10 +887,8 @@ peerstore_start ( | |||
1026 | { | 887 | { |
1027 | char *binary; | 888 | char *binary; |
1028 | 889 | ||
1029 | LOG (GNUNET_ERROR_TYPE_DEBUG, "peerstore_start\n"); | ||
1030 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-peerstore"); | 890 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-peerstore"); |
1031 | tc_h->ps_proc = GNUNET_OS_start_process (GNUNET_OS_USE_PIPE_CONTROL | 891 | tc_h->ps_proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_OUT_AND_ERR, |
1032 | | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, | ||
1033 | NULL, | 892 | NULL, |
1034 | NULL, | 893 | NULL, |
1035 | NULL, | 894 | NULL, |
@@ -1047,7 +906,6 @@ peerstore_start ( | |||
1047 | GNUNET_free (binary); | 906 | GNUNET_free (binary); |
1048 | } | 907 | } |
1049 | 908 | ||
1050 | |||
1051 | /** | 909 | /** |
1052 | * @brief Start NAT | 910 | * @brief Start NAT |
1053 | * | 911 | * |
@@ -1208,6 +1066,8 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue ( | |||
1208 | memcpy (&msg[1], address, alen); | 1066 | memcpy (&msg[1], address, alen); |
1209 | if (NULL != tc_h->c_mq) | 1067 | if (NULL != tc_h->c_mq) |
1210 | { | 1068 | { |
1069 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1070 | "Sending queue create immediately\n"); | ||
1211 | GNUNET_MQ_send (tc_h->c_mq, env); | 1071 | GNUNET_MQ_send (tc_h->c_mq, env); |
1212 | } | 1072 | } |
1213 | else | 1073 | else |
diff --git a/src/transport/transport-testing2.h b/src/transport/transport-testing2.h index b77125e82..04f75fc88 100644 --- a/src/transport/transport-testing2.h +++ b/src/transport/transport-testing2.h | |||
@@ -29,13 +29,6 @@ | |||
29 | #include "gnunet_ats_transport_service.h" | 29 | #include "gnunet_ats_transport_service.h" |
30 | #include "transport.h" | 30 | #include "transport.h" |
31 | 31 | ||
32 | |||
33 | /** | ||
34 | * @brief Handle to a transport communicator | ||
35 | */ | ||
36 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle; | ||
37 | |||
38 | |||
39 | /** | 32 | /** |
40 | * @brief Queue of a communicator and some context | 33 | * @brief Queue of a communicator and some context |
41 | */ | 34 | */ |
@@ -151,6 +144,143 @@ typedef void | |||
151 | const char*payload, | 144 | const char*payload, |
152 | size_t payload_len); | 145 | size_t payload_len); |
153 | 146 | ||
147 | /** | ||
148 | * @brief Handle to a transport communicator | ||
149 | */ | ||
150 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle | ||
151 | { | ||
152 | /** | ||
153 | * Clients | ||
154 | */ | ||
155 | struct MyClient *client_head; | ||
156 | struct MyClient *client_tail; | ||
157 | |||
158 | /** | ||
159 | * @brief Handle to the client | ||
160 | */ | ||
161 | struct GNUNET_MQ_Handle *c_mq; | ||
162 | |||
163 | /** | ||
164 | * @brief Handle to the configuration | ||
165 | */ | ||
166 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
167 | |||
168 | /** | ||
169 | * @brief File name of configuration file | ||
170 | */ | ||
171 | char *cfg_filename; | ||
172 | |||
173 | struct GNUNET_PeerIdentity peer_id; | ||
174 | |||
175 | /** | ||
176 | * @brief Handle to the transport service | ||
177 | */ | ||
178 | struct GNUNET_SERVICE_Handle *tsh; | ||
179 | |||
180 | /** | ||
181 | * @brief Task that will be run on shutdown to stop and clean transport | ||
182 | * service | ||
183 | */ | ||
184 | struct GNUNET_SCHEDULER_Task *ts_shutdown_task; | ||
185 | |||
186 | |||
187 | /** | ||
188 | * @brief Process of the communicator | ||
189 | */ | ||
190 | struct GNUNET_OS_Process *c_proc; | ||
191 | |||
192 | /** | ||
193 | * NAT process | ||
194 | */ | ||
195 | struct GNUNET_OS_Process *nat_proc; | ||
196 | |||
197 | /** | ||
198 | * resolver service process | ||
199 | */ | ||
200 | struct GNUNET_OS_Process *resolver_proc; | ||
201 | |||
202 | /** | ||
203 | * peerstore service process | ||
204 | */ | ||
205 | struct GNUNET_OS_Process *ps_proc; | ||
206 | |||
207 | /** | ||
208 | * @brief Task that will be run on shutdown to stop and clean communicator | ||
209 | */ | ||
210 | struct GNUNET_SCHEDULER_Task *c_shutdown_task; | ||
211 | |||
212 | /** | ||
213 | * @brief Characteristics of the communicator | ||
214 | */ | ||
215 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics c_characteristics; | ||
216 | |||
217 | /** | ||
218 | * @brief Specifies supported addresses | ||
219 | */ | ||
220 | char *c_addr_prefix; | ||
221 | |||
222 | /** | ||
223 | * @brief Specifies supported addresses | ||
224 | */ | ||
225 | char *c_address; | ||
226 | |||
227 | /** | ||
228 | * @brief Head of the DLL of queues associated with this communicator | ||
229 | */ | ||
230 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_head; | ||
231 | |||
232 | /** | ||
233 | * @brief Tail of the DLL of queues associated with this communicator | ||
234 | */ | ||
235 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_tail; | ||
236 | |||
237 | /* Callbacks + Closures */ | ||
238 | /** | ||
239 | * @brief Callback called when a new communicator connects | ||
240 | */ | ||
241 | GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback | ||
242 | communicator_available_cb; | ||
243 | |||
244 | /** | ||
245 | * @brief Callback called when a new communicator connects | ||
246 | */ | ||
247 | GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb; | ||
248 | |||
249 | /** | ||
250 | * @brief Callback called when a new communicator connects | ||
251 | */ | ||
252 | GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb; | ||
253 | |||
254 | /** | ||
255 | * @brief Callback called when a new communicator connects | ||
256 | */ | ||
257 | GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb; | ||
258 | |||
259 | /** | ||
260 | * @brief Callback called when a new communicator connects | ||
261 | */ | ||
262 | GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_msg_cb; | ||
263 | |||
264 | /** | ||
265 | * @brief Backchannel callback | ||
266 | */ | ||
267 | GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb; | ||
268 | |||
269 | /** | ||
270 | * Our service handle | ||
271 | */ | ||
272 | struct GNUNET_SERVICE_Handle *sh; | ||
273 | |||
274 | /** | ||
275 | * @brief Closure to the callback | ||
276 | */ | ||
277 | void *cb_cls; | ||
278 | |||
279 | /** | ||
280 | * Backchannel supported | ||
281 | */ | ||
282 | int bc_enabled; | ||
283 | }; | ||
154 | 284 | ||
155 | /** | 285 | /** |
156 | * @brief Start communicator part of transport service and communicator | 286 | * @brief Start communicator part of transport service and communicator |
diff --git a/src/transport/transport_api2_communication.c b/src/transport/transport_api2_communication.c index d1e28cc36..b048ad851 100644 --- a/src/transport/transport_api2_communication.c +++ b/src/transport/transport_api2_communication.c | |||
@@ -1081,7 +1081,6 @@ GNUNET_TRANSPORT_communicator_address_add ( | |||
1081 | return ai; | 1081 | return ai; |
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | |||
1085 | /** | 1084 | /** |
1086 | * Notify transport service about an address that this communicator no | 1085 | * Notify transport service about an address that this communicator no |
1087 | * longer provides for this peer. | 1086 | * longer provides for this peer. |
@@ -1100,6 +1099,20 @@ GNUNET_TRANSPORT_communicator_address_remove ( | |||
1100 | GNUNET_free (ai); | 1099 | GNUNET_free (ai); |
1101 | } | 1100 | } |
1102 | 1101 | ||
1102 | /** | ||
1103 | * Notify transport service that this communicator no longer provides all its addresses for this peer. | ||
1104 | * | ||
1105 | * @param ch The communicator handle. | ||
1106 | */ | ||
1107 | void | ||
1108 | GNUNET_TRANSPORT_communicator_address_remove_all ( | ||
1109 | struct GNUNET_TRANSPORT_CommunicatorHandle *ch) | ||
1110 | { | ||
1111 | for (struct GNUNET_TRANSPORT_AddressIdentifier *ai = ch->ai_head; NULL != ai; | ||
1112 | ai = ai->next) | ||
1113 | GNUNET_TRANSPORT_communicator_address_remove (ai); | ||
1114 | } | ||
1115 | |||
1103 | 1116 | ||
1104 | /* ************************* Backchannel *************************** */ | 1117 | /* ************************* Backchannel *************************** */ |
1105 | 1118 | ||