aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2024-04-08 11:44:05 +0200
committert3sserakt <t3ss@posteo.de>2024-04-08 14:23:19 +0200
commit5e15dc4f37a25a5098783a12b96fbfdc2d9b8b49 (patch)
tree8f4bdd58c488e087d60b832c527ec9d698295731 /src
parent19d2dd133c22de9d58972289ebe10eb6f2e29692 (diff)
downloadgnunet-5e15dc4f37a25a5098783a12b96fbfdc2d9b8b49.tar.gz
gnunet-5e15dc4f37a25a5098783a12b96fbfdc2d9b8b49.zip
Add functionality to exchange global external IPs for natted peers.
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_nat_service.h13
-rw-r--r--src/include/gnunet_protocols.h5
-rw-r--r--src/service/nat/gnunet-service-nat.c130
-rw-r--r--src/service/nat/nat.h19
-rw-r--r--src/service/nat/nat_api.c53
-rw-r--r--src/service/topology/gnunet-daemon-topology.c23
-rw-r--r--src/service/transport/Makefile.am1
-rw-r--r--src/service/transport/gnunet-service-transport.c465
8 files changed, 671 insertions, 38 deletions
diff --git a/src/include/gnunet_nat_service.h b/src/include/gnunet_nat_service.h
index f2854a0be..ba9f252a0 100644
--- a/src/include/gnunet_nat_service.h
+++ b/src/include/gnunet_nat_service.h
@@ -345,6 +345,19 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
345 345
346 346
347/** 347/**
348 * Add global address to the list of addresses and notify clients.
349 *
350 * @param nh the handle returned by register
351 * @param addr IP address to add.
352 * @param address_length number of bytes in @a addr
353 */
354void
355GNUNET_NAT_add_global_address (struct GNUNET_NAT_Handle *nh,
356 char *addr,
357 unsigned int address_length);
358
359
360/**
348 * Test if the given address is (currently) a plausible IP address for 361 * Test if the given address is (currently) a plausible IP address for
349 * this peer. Mostly a convenience function so that clients do not 362 * this peer. Mostly a convenience function so that clients do not
350 * have to explicitly track all IPs that the #GNUNET_NAT_AddressCallback 363 * have to explicitly track all IPs that the #GNUNET_NAT_AddressCallback
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 8638703db..6ab008d16 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -3216,6 +3216,11 @@ extern "C" {
3216#define GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE 1064 3216#define GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE 1064
3217 3217
3218/** 3218/**
3219 * Message to ask NAT service to notify all clients about a new global address.
3220 */
3221#define GNUNET_MESSAGE_TYPE_NAT_ADD_GLOBAL_ADDRESS 1065
3222
3223/**
3219 * Message to ask NAT service to request autoconfiguration. 3224 * Message to ask NAT service to request autoconfiguration.
3220 */ 3225 */
3221#define GNUNET_MESSAGE_TYPE_NAT_AUTO_REQUEST_CFG 1067 3226#define GNUNET_MESSAGE_TYPE_NAT_AUTO_REQUEST_CFG 1067
diff --git a/src/service/nat/gnunet-service-nat.c b/src/service/nat/gnunet-service-nat.c
index 08c87d0be..00584ab8a 100644
--- a/src/service/nat/gnunet-service-nat.c
+++ b/src/service/nat/gnunet-service-nat.c
@@ -1864,6 +1864,132 @@ handle_request_connection_reversal (void *cls,
1864 1864
1865 1865
1866/** 1866/**
1867 * Check validity of #GNUNET_MESSAGE_TYPE_NAT_ADD_GLOBAL_ADDRESS message from
1868 * client.
1869 *
1870 * @param cls client who sent the message
1871 * @param message the message received
1872 * @return #GNUNET_OK if message is well-formed
1873 */
1874static int
1875check_add_global_address(void *cls,
1876 const struct GNUNET_NAT_AddGlobalAddressMessage *message)
1877{
1878 char *addr = GNUNET_malloc (ntohs (message->address_length));
1879 size_t left = ntohs (message->header.size) - sizeof(*message);
1880
1881 GNUNET_memcpy (addr, (const char *) &message[1], ntohs (message->address_length));
1882 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1883 "message size %u natting address %s length %u left %u\n",
1884 ntohs (message->header.size),
1885 addr,
1886 ntohs (message->address_length),
1887 left);
1888
1889 if (left != ntohs (message->address_length))
1890 {
1891 GNUNET_break (0);
1892 return GNUNET_SYSERR;
1893 }
1894 GNUNET_free (addr);
1895 return GNUNET_OK;
1896}
1897
1898
1899static int
1900is_nat_v4 (const struct in_addr *ip);
1901
1902
1903static int
1904is_nat_v6 (const struct in6_addr *ip);
1905
1906
1907static void
1908notify_client (enum GNUNET_NAT_AddressClass ac,
1909 struct ClientHandle *ch,
1910 int add,
1911 const void *addr,
1912 size_t addr_len);
1913
1914
1915/**
1916 * Handle #GNUNET_MESSAGE_TYPE_NAT_ADD_GLOBAL_ADDRESS message from
1917 * client.
1918 *
1919 * @param cls client who sent the message
1920 * @param message the message received
1921 */
1922static void
1923handle_add_global_address(void *cls,
1924 const struct GNUNET_NAT_AddGlobalAddressMessage *message)
1925{
1926 struct ClientHandle *ch = cls;
1927 char *buf = GNUNET_malloc (ntohs (message->address_length));
1928 //= (const char *) &message[1];
1929 struct sockaddr *sockaddr = NULL;
1930 socklen_t addr_len;
1931 struct sockaddr_in *sockaddr_ipv4 = GNUNET_malloc(sizeof(struct sockaddr_in));
1932 enum GNUNET_NAT_AddressClass ac;
1933
1934 GNUNET_memcpy (buf, (const char *) &message[1], ntohs (message->address_length));
1935 memset(sockaddr_ipv4, 0, sizeof(struct sockaddr_in));
1936 sockaddr_ipv4->sin_family = AF_INET;
1937
1938 if (1 == inet_pton(AF_INET, buf, &(sockaddr_ipv4->sin_addr)))
1939 {
1940 sockaddr = (struct sockaddr *)sockaddr_ipv4;
1941 addr_len = sizeof(struct sockaddr_in);
1942 ac = is_nat_v4 (&((const struct sockaddr_in *)sockaddr_ipv4)->sin_addr)
1943 ? GNUNET_NAT_AC_LAN
1944 : GNUNET_NAT_AC_EXTERN;
1945 }
1946 else
1947 {
1948 GNUNET_free(sockaddr_ipv4);
1949 sockaddr_ipv4 = NULL;
1950 }
1951
1952 if (NULL == sockaddr)
1953 {
1954 struct sockaddr_in6 *sockaddr_ipv6 = malloc(sizeof(struct sockaddr_in6));
1955
1956 if (sockaddr_ipv6 != NULL)
1957 {
1958 memset(sockaddr_ipv6, 0, sizeof(struct sockaddr_in6));
1959 sockaddr_ipv6->sin6_family = AF_INET6;
1960
1961 if (1 == inet_pton(AF_INET6, buf, &(sockaddr_ipv6->sin6_addr)))
1962 {
1963 GNUNET_break (0);
1964 GNUNET_SERVICE_client_continue (ch->client);
1965 GNUNET_free (buf);
1966 return;
1967 }
1968 else
1969 {
1970 GNUNET_free(sockaddr_ipv6);
1971 sockaddr_ipv6 = NULL;
1972 }
1973 }
1974 }
1975
1976 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1977 "3 natting address %s\n",
1978 buf);
1979 if (NULL == sockaddr)
1980 {
1981 GNUNET_break (0);
1982 GNUNET_SERVICE_client_continue (ch->client);
1983 GNUNET_free (buf);
1984 return;
1985 }
1986 notify_clients_stun_change (sockaddr_ipv4, GNUNET_YES);
1987 GNUNET_SERVICE_client_continue (ch->client);
1988 GNUNET_free (buf);
1989}
1990
1991
1992/**
1867 * Task run during shutdown. 1993 * Task run during shutdown.
1868 * 1994 *
1869 * @param cls unused 1995 * @param cls unused
@@ -2060,6 +2186,10 @@ GNUNET_SERVICE_MAIN
2060 GNUNET_MESSAGE_TYPE_NAT_REQUEST_CONNECTION_REVERSAL, 2186 GNUNET_MESSAGE_TYPE_NAT_REQUEST_CONNECTION_REVERSAL,
2061 struct GNUNET_NAT_RequestConnectionReversalMessage, 2187 struct GNUNET_NAT_RequestConnectionReversalMessage,
2062 NULL), 2188 NULL),
2189 GNUNET_MQ_hd_var_size (add_global_address,
2190 GNUNET_MESSAGE_TYPE_NAT_ADD_GLOBAL_ADDRESS,
2191 struct GNUNET_NAT_AddGlobalAddressMessage,
2192 NULL),
2063 GNUNET_MQ_handler_end ()); 2193 GNUNET_MQ_handler_end ());
2064 2194
2065 2195
diff --git a/src/service/nat/nat.h b/src/service/nat/nat.h
index 1d8648aaf..30e6f0901 100644
--- a/src/service/nat/nat.h
+++ b/src/service/nat/nat.h
@@ -218,6 +218,25 @@ struct GNUNET_NAT_AddressChangeNotificationMessage
218}; 218};
219 219
220 220
221/**
222 * Message sent by client to add a global address.
223 */
224struct GNUNET_NAT_AddGlobalAddressMessage
225{
226 /**
227 * Header with type #GNUNET_MESSAGE_TYPE_NAT_ADD_GLOBAL_ADDRESS
228 */
229 struct GNUNET_MessageHeader header;
230
231 /**
232 * Length of the address following the struct, in NBO.
233 */
234 unsigned int address_length;
235
236 /* Followed by the address to add */
237};
238
239
221GNUNET_NETWORK_STRUCT_END 240GNUNET_NETWORK_STRUCT_END
222 241
223#endif 242#endif
diff --git a/src/service/nat/nat_api.c b/src/service/nat/nat_api.c
index 31f8f388d..219a11e81 100644
--- a/src/service/nat/nat_api.c
+++ b/src/service/nat/nat_api.c
@@ -457,6 +457,59 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
457 457
458 458
459/** 459/**
460 * Get the IP address without the port number.
461 *
462 * @param address The string contains a communicator prefix, IP address and port
463 * like this 'tcp-92.68.150.1:55452'.
464 * @return String with prefix and IP address only.
465 */
466static char *
467get_address_without_port (const char *address)
468{
469 const char *colon;
470 char *colon_rest;
471 size_t colon_rest_length;
472 char *address_without_port;
473
474 colon = strchr (address,':');
475 colon_rest = GNUNET_strndup (address, colon - address);
476 colon_rest_length = strlen (colon_rest);
477 address_without_port = GNUNET_strndup (&colon_rest[4], colon_rest_length - 4);
478 GNUNET_free (colon_rest);
479
480 return address_without_port;
481}
482
483void
484GNUNET_NAT_add_global_address (struct GNUNET_NAT_Handle *nh,
485 char *addr,
486 unsigned int address_length)
487{
488 struct GNUNET_NAT_AddGlobalAddressMessage *aam;
489 struct GNUNET_MQ_Envelope *env;
490 //char *address_without_port = get_address_without_port (addr);
491 //unsigned int address_len_without_port = strlen (address_without_port);
492 char *off;
493
494 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
495 "natting address %s length %u\n",
496 addr,
497 address_length);
498
499 env = GNUNET_MQ_msg_extra (aam,
500 address_length,
501 GNUNET_MESSAGE_TYPE_NAT_ADD_GLOBAL_ADDRESS);
502 aam->address_length = htons (address_length);
503 off = (char *) &aam[1];
504 GNUNET_memcpy (off, addr, address_length);
505 GNUNET_MQ_send (nh->mq,
506 env);
507 //GNUNET_free (address_without_port);
508}
509
510
511
512/**
460 * Check if an incoming message is a STUN message. 513 * Check if an incoming message is a STUN message.
461 * 514 *
462 * @param data the packet 515 * @param data the packet
diff --git a/src/service/topology/gnunet-daemon-topology.c b/src/service/topology/gnunet-daemon-topology.c
index c706e826d..159ba2a07 100644
--- a/src/service/topology/gnunet-daemon-topology.c
+++ b/src/service/topology/gnunet-daemon-topology.c
@@ -452,18 +452,13 @@ schedule_next_hello (void *cls)
452 fah.max_size = GNUNET_MAX_MESSAGE_SIZE - 1; 452 fah.max_size = GNUNET_MAX_MESSAGE_SIZE - 1;
453 fah.next_adv = GNUNET_TIME_UNIT_FOREVER_REL; 453 fah.next_adv = GNUNET_TIME_UNIT_FOREVER_REL;
454 GNUNET_CONTAINER_multipeermap_iterate (peers, &find_advertisable_hello, &fah); 454 GNUNET_CONTAINER_multipeermap_iterate (peers, &find_advertisable_hello, &fah);
455 pl->hello_delay_task =
456 GNUNET_SCHEDULER_add_delayed (fah.next_adv, &schedule_next_hello, pl);
457 if (NULL == fah.result) 455 if (NULL == fah.result)
458 return; 456 {
459 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 457 pl->hello_delay_task =
460 "schedule_next_hello 2\n"); 458 GNUNET_SCHEDULER_add_delayed (fah.next_adv, &schedule_next_hello, pl);
461 delay = GNUNET_TIME_absolute_get_remaining (pl->next_hello_allowed);
462 if (0 != delay.rel_value_us)
463 return;
464 459
465 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 460 return;
466 "schedule_next_hello 3\n"); 461 }
467 want = ntohs (fah.result->hello->size); 462 want = ntohs (fah.result->hello->size);
468 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 463 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
469 "Sending HELLO with %u bytes for peer %s\n", 464 "Sending HELLO with %u bytes for peer %s\n",
@@ -483,9 +478,8 @@ schedule_next_hello (void *cls)
483 /* prepare to send the next one */ 478 /* prepare to send the next one */
484 pl->next_hello_allowed = 479 pl->next_hello_allowed =
485 GNUNET_TIME_relative_to_absolute (HELLO_ADVERTISEMENT_MIN_FREQUENCY); 480 GNUNET_TIME_relative_to_absolute (HELLO_ADVERTISEMENT_MIN_FREQUENCY);
486 if (NULL != pl->hello_delay_task) 481 delay = GNUNET_TIME_absolute_get_remaining (pl->next_hello_allowed);
487 GNUNET_SCHEDULER_cancel (pl->hello_delay_task); 482 pl->hello_delay_task = GNUNET_SCHEDULER_add_delayed (delay, &schedule_next_hello, pl);
488 pl->hello_delay_task = GNUNET_SCHEDULER_add_now (&schedule_next_hello, pl);
489} 483}
490 484
491 485
@@ -937,7 +931,7 @@ handle_hello (void *cls, const struct GNUNET_MessageHeader *message)
937 message); 931 message);
938 932
939 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 933 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
940 "Received encrypted HELLO from peer `%s'", 934 "Received encrypted HELLO from peer `%s'\n",
941 GNUNET_i2s (other)); 935 GNUNET_i2s (other));
942 GNUNET_STATISTICS_update (stats, 936 GNUNET_STATISTICS_update (stats,
943 gettext_noop ("# HELLO messages received"), 937 gettext_noop ("# HELLO messages received"),
@@ -1012,6 +1006,7 @@ cleaning_task (void *cls)
1012 GNUNET_STATISTICS_destroy (stats, GNUNET_NO); 1006 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
1013 stats = NULL; 1007 stats = NULL;
1014 } 1008 }
1009 GNUNET_free (my_private_key);
1015} 1010}
1016 1011
1017 1012
diff --git a/src/service/transport/Makefile.am b/src/service/transport/Makefile.am
index af7ea8771..56ed8fc13 100644
--- a/src/service/transport/Makefile.am
+++ b/src/service/transport/Makefile.am
@@ -184,6 +184,7 @@ gnunet_service_transport_LDADD = \
184 $(top_builddir)/src/service/peerstore/libgnunetpeerstore.la \ 184 $(top_builddir)/src/service/peerstore/libgnunetpeerstore.la \
185 $(top_builddir)/src/lib/hello/libgnunethello.la \ 185 $(top_builddir)/src/lib/hello/libgnunethello.la \
186 $(top_builddir)/src/service/statistics/libgnunetstatistics.la \ 186 $(top_builddir)/src/service/statistics/libgnunetstatistics.la \
187 $(top_builddir)/src/service/nat/libgnunetnatnew.la \
187 $(top_builddir)/src/lib/util/libgnunetutil.la \ 188 $(top_builddir)/src/lib/util/libgnunetutil.la \
188 $(LIBGCRYPT_LIBS) \ 189 $(LIBGCRYPT_LIBS) \
189 $(GN_LIBINTL) 190 $(GN_LIBINTL)
diff --git a/src/service/transport/gnunet-service-transport.c b/src/service/transport/gnunet-service-transport.c
index ca191d49d..f4be5e759 100644
--- a/src/service/transport/gnunet-service-transport.c
+++ b/src/service/transport/gnunet-service-transport.c
@@ -77,6 +77,7 @@
77#include "gnunet_statistics_service.h" 77#include "gnunet_statistics_service.h"
78#include "gnunet_transport_monitor_service.h" 78#include "gnunet_transport_monitor_service.h"
79#include "gnunet_peerstore_service.h" 79#include "gnunet_peerstore_service.h"
80#include "gnunet_nat_service.h"
80#include "gnunet_hello_uri_lib.h" 81#include "gnunet_hello_uri_lib.h"
81#include "gnunet_signatures.h" 82#include "gnunet_signatures.h"
82#include "transport.h" 83#include "transport.h"
@@ -916,6 +917,15 @@ struct TransportValidationResponseMessage
916 struct GNUNET_TIME_RelativeNBO validity_duration; 917 struct GNUNET_TIME_RelativeNBO validity_duration;
917}; 918};
918 919
920struct TransportGlobalNattedAddress
921{
922 /**
923 * Length of the address following the struct.
924 */
925 unsigned int address_length;
926
927 /* Followed by @e address_length bytes of the address. */
928};
919 929
920/** 930/**
921 * Message for Transport-to-Transport Flow control. Specifies the size 931 * Message for Transport-to-Transport Flow control. Specifies the size
@@ -973,9 +983,21 @@ struct TransportFlowControlMessage
973 * reset the counters for the number of bytes sent! 983 * reset the counters for the number of bytes sent!
974 */ 984 */
975 struct GNUNET_TIME_AbsoluteNBO sender_time; 985 struct GNUNET_TIME_AbsoluteNBO sender_time;
976};
977 986
978 987
988 /**
989 * Number of TransportGlobalNattedAddress following the struct.
990 */
991 unsigned int number_of_addresses;
992
993 /**
994 * Size of all the addresses attached to all TransportGlobalNattedAddress.
995 */
996 size_t size_of_addresses;
997
998 /* Followed by @e number_of_addresses struct TransportGlobalNattedAddress. */
999};
1000
979GNUNET_NETWORK_STRUCT_END 1001GNUNET_NETWORK_STRUCT_END
980 1002
981 1003
@@ -1921,6 +1943,12 @@ struct Queue
1921 struct PerformanceData pd; 1943 struct PerformanceData pd;
1922 1944
1923 /** 1945 /**
1946 * Handle for an operation to iterate through all hellos to compare the hello
1947 * addresses with @e address which might be a natted one.
1948 */
1949 struct GNUNET_PEERSTORE_Monitor *mo;
1950
1951 /**
1924 * Message ID generator for transmissions on this queue to the 1952 * Message ID generator for transmissions on this queue to the
1925 * communicator. 1953 * communicator.
1926 */ 1954 */
@@ -1976,6 +2004,11 @@ struct Queue
1976 * virtual link to give it a pending message. 2004 * virtual link to give it a pending message.
1977 */ 2005 */
1978 int idle; 2006 int idle;
2007
2008 /**
2009 * Set to GNUNET_yes, if this queues address is not a global natted one.
2010 */
2011 enum GNUNET_GenericReturnValue is_global_natted;
1979}; 2012};
1980 2013
1981 2014
@@ -2040,6 +2073,26 @@ struct Neighbour
2040 * PEERSTORE yet, or are we still waiting for a reply of PEERSTORE? 2073 * PEERSTORE yet, or are we still waiting for a reply of PEERSTORE?
2041 */ 2074 */
2042 int dv_monotime_available; 2075 int dv_monotime_available;
2076
2077 /**
2078 * Map of struct TransportGlobalNattedAddress for this neighbour.
2079 */
2080 struct GNUNET_CONTAINER_MultiPeerMap *natted_addresses;
2081
2082 /**
2083 * Number of global natted addresses for this neighbour.
2084 */
2085 unsigned int number_of_addresses;
2086
2087 /**
2088 * Size of all global natted addresses for this neighbour.
2089 */
2090 size_t size_of_global_addresses;
2091
2092 /**
2093 * A queue of this neighbour has a global natted address.
2094 */
2095 enum GNUNET_GenericReturnValue is_global_natted;
2043}; 2096};
2044 2097
2045 2098
@@ -2760,7 +2813,6 @@ struct Backtalker
2760 size_t body_size; 2813 size_t body_size;
2761}; 2814};
2762 2815
2763
2764/** 2816/**
2765 * Ring buffer for a CORE message we did not deliver to CORE, because of missing virtual link to sender. 2817 * Ring buffer for a CORE message we did not deliver to CORE, because of missing virtual link to sender.
2766 */ 2818 */
@@ -2897,6 +2949,11 @@ static struct LearnLaunchEntry *lle_tail = NULL;
2897static struct GNUNET_CONTAINER_Heap *validation_heap; 2949static struct GNUNET_CONTAINER_Heap *validation_heap;
2898 2950
2899/** 2951/**
2952 * Handle for connect to the NAT service.
2953 */
2954struct GNUNET_NAT_Handle *nh;
2955
2956/**
2900 * Database for peer's HELLOs. 2957 * Database for peer's HELLOs.
2901 */ 2958 */
2902static struct GNUNET_PEERSTORE_Handle *peerstore; 2959static struct GNUNET_PEERSTORE_Handle *peerstore;
@@ -3591,6 +3648,18 @@ client_connect_cb (void *cls,
3591} 3648}
3592 3649
3593 3650
3651static enum GNUNET_GenericReturnValue
3652remove_global_addresses (void *cls,
3653 const struct GNUNET_PeerIdentity *pid,
3654 void *value)
3655{
3656 (void) cls;
3657 struct TransportGlobalNattedAddress *tgna = value;
3658
3659 GNUNET_free (tgna);
3660}
3661
3662
3594/** 3663/**
3595 * Release memory used by @a neighbour. 3664 * Release memory used by @a neighbour.
3596 * 3665 *
@@ -3609,6 +3678,9 @@ free_neighbour (struct Neighbour *neighbour)
3609 neighbour)); 3678 neighbour));
3610 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3679 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3611 "Freeing neighbour\n"); 3680 "Freeing neighbour\n");
3681 GNUNET_CONTAINER_multipeermap_iterate (neighbour->natted_addresses,
3682 &remove_global_addresses,
3683 NULL);
3612 while (NULL != (dvh = neighbour->dv_head)) 3684 while (NULL != (dvh = neighbour->dv_head))
3613 { 3685 {
3614 struct DistanceVector *dv = dvh->dv; 3686 struct DistanceVector *dv = dvh->dv;
@@ -3878,6 +3950,11 @@ free_queue (struct Queue *queue)
3878 3950
3879 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3951 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3880 "Cleaning up queue %u\n", queue->qid); 3952 "Cleaning up queue %u\n", queue->qid);
3953 if (NULL != queue->mo)
3954 {
3955 GNUNET_PEERSTORE_monitor_stop (queue->mo);
3956 queue->mo = NULL;
3957 }
3881 if (NULL != queue->transmit_task) 3958 if (NULL != queue->transmit_task)
3882 { 3959 {
3883 GNUNET_SCHEDULER_cancel (queue->transmit_task); 3960 GNUNET_SCHEDULER_cancel (queue->transmit_task);
@@ -5263,6 +5340,34 @@ task_consider_sending_fc (void *cls)
5263} 5340}
5264 5341
5265 5342
5343static char *
5344get_address_without_port (const char *address);
5345
5346
5347static enum GNUNET_GenericReturnValue
5348add_global_addresses (void *cls,
5349 const struct GNUNET_PeerIdentity *pid,
5350 void *value)
5351{
5352 char *tgnas = cls;
5353 struct TransportGlobalNattedAddress *tgna = value;
5354 char *addr = (char *) &tgna[1];
5355 size_t address_len = strlen (addr);
5356 unsigned int off = 0;
5357
5358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5359 "sending address %s length %u\n",
5360 addr,
5361 address_len);
5362 tgna = GNUNET_malloc (sizeof (struct TransportGlobalNattedAddress) + address_len);
5363 tgna->address_length = htonl (address_len);
5364 GNUNET_memcpy (&tgna[1], addr, address_len);
5365 GNUNET_memcpy (&tgnas[off], tgna, sizeof (struct TransportGlobalNattedAddress) + address_len);
5366 GNUNET_free (tgna);
5367 off += sizeof(struct TransportGlobalNattedAddress) + address_len;
5368}
5369
5370
5266/** 5371/**
5267 * Something changed on the virtual link with respect to flow 5372 * Something changed on the virtual link with respect to flow
5268 * control. Consider retransmitting the FC window size. 5373 * control. Consider retransmitting the FC window size.
@@ -5274,9 +5379,32 @@ consider_sending_fc (void *cls)
5274{ 5379{
5275 struct VirtualLink *vl = cls; 5380 struct VirtualLink *vl = cls;
5276 struct GNUNET_TIME_Absolute monotime; 5381 struct GNUNET_TIME_Absolute monotime;
5277 struct TransportFlowControlMessage fc; 5382 struct TransportFlowControlMessage *fc;
5278 struct GNUNET_TIME_Relative duration; 5383 struct GNUNET_TIME_Relative duration;
5279 struct GNUNET_TIME_Relative rtt; 5384 struct GNUNET_TIME_Relative rtt;
5385 struct Neighbour *n = vl->n;
5386
5387 if (0 < n->number_of_addresses)
5388 {
5389 char *tgnas = GNUNET_malloc (n->number_of_addresses * sizeof (struct TransportGlobalNattedAddress) + n->size_of_global_addresses);
5390 size_t addresses_size;
5391
5392 addresses_size = n->number_of_addresses * sizeof (struct TransportGlobalNattedAddress) + n->size_of_global_addresses;
5393 fc = GNUNET_malloc (sizeof (struct TransportFlowControlMessage) + addresses_size);
5394 fc->header.size = htons (sizeof(struct TransportFlowControlMessage) + addresses_size);
5395 fc->size_of_addresses = htonl (n->size_of_global_addresses);
5396 fc->number_of_addresses = htonl (n->number_of_addresses);
5397 GNUNET_CONTAINER_multipeermap_iterate (n->natted_addresses,
5398 &add_global_addresses,
5399 tgnas);
5400 GNUNET_memcpy (&fc[1], tgnas, addresses_size);
5401 GNUNET_free (tgnas);
5402 }
5403 else
5404 {
5405 fc = GNUNET_malloc (sizeof (struct TransportFlowControlMessage));
5406 fc->header.size = htons (sizeof(struct TransportFlowControlMessage));
5407 }
5280 5408
5281 duration = GNUNET_TIME_absolute_get_duration (vl->last_fc_transmission); 5409 duration = GNUNET_TIME_absolute_get_duration (vl->last_fc_transmission);
5282 /* OPTIMIZE-FC-BDP: decide sane criteria on when to do this, instead of doing 5410 /* OPTIMIZE-FC-BDP: decide sane criteria on when to do this, instead of doing
@@ -5295,16 +5423,15 @@ consider_sending_fc (void *cls)
5295 (unsigned long long) vl->incoming_fc_window_size); 5423 (unsigned long long) vl->incoming_fc_window_size);
5296 monotime = GNUNET_TIME_absolute_get_monotonic (GST_cfg); 5424 monotime = GNUNET_TIME_absolute_get_monotonic (GST_cfg);
5297 vl->last_fc_transmission = monotime; 5425 vl->last_fc_transmission = monotime;
5298 fc.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL); 5426 fc->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL);
5299 fc.header.size = htons (sizeof(fc)); 5427 fc->seq = htonl (vl->fc_seq_gen++);
5300 fc.seq = htonl (vl->fc_seq_gen++); 5428 fc->inbound_window_size = GNUNET_htonll (vl->incoming_fc_window_size
5301 fc.inbound_window_size = GNUNET_htonll (vl->incoming_fc_window_size
5302 + vl->incoming_fc_window_size_used 5429 + vl->incoming_fc_window_size_used
5303 + vl->incoming_fc_window_size_loss); 5430 + vl->incoming_fc_window_size_loss);
5304 fc.outbound_sent = GNUNET_htonll (vl->outbound_fc_window_size_used); 5431 fc->outbound_sent = GNUNET_htonll (vl->outbound_fc_window_size_used);
5305 fc.outbound_window_size = GNUNET_htonll (vl->outbound_fc_window_size); 5432 fc->outbound_window_size = GNUNET_htonll (vl->outbound_fc_window_size);
5306 fc.sender_time = GNUNET_TIME_absolute_hton (monotime); 5433 fc->sender_time = GNUNET_TIME_absolute_hton (monotime);
5307 rtt = route_control_message_without_fc (vl, &fc.header, RMO_DV_ALLOWED); 5434 rtt = route_control_message_without_fc (vl, &fc->header, RMO_DV_ALLOWED);
5308 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == rtt.rel_value_us) 5435 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == rtt.rel_value_us)
5309 { 5436 {
5310 rtt = GNUNET_TIME_UNIT_SECONDS; 5437 rtt = GNUNET_TIME_UNIT_SECONDS;
@@ -5329,6 +5456,7 @@ consider_sending_fc (void *cls)
5329 vl->fc_retransmit_task = 5456 vl->fc_retransmit_task =
5330 GNUNET_SCHEDULER_add_delayed (rtt, &task_consider_sending_fc, vl); 5457 GNUNET_SCHEDULER_add_delayed (rtt, &task_consider_sending_fc, vl);
5331 vl->fc_retransmit_count++; 5458 vl->fc_retransmit_count++;
5459 GNUNET_free (fc);
5332} 5460}
5333 5461
5334 5462
@@ -5775,6 +5903,29 @@ store_pi (void *cls)
5775} 5903}
5776 5904
5777 5905
5906static struct AddressListEntry *
5907create_address_entry (struct TransportClient *tc,
5908 struct GNUNET_TIME_Relative expiration,
5909 enum GNUNET_NetworkType nt,
5910 const char *address,
5911 uint32_t aid,
5912 size_t slen)
5913{
5914 struct AddressListEntry *ale;
5915
5916 ale = GNUNET_malloc (sizeof(struct AddressListEntry) + slen);
5917 ale->tc = tc;
5918 ale->address = (const char *) &ale[1];
5919 ale->expiration = expiration;
5920 ale->aid = aid;
5921 ale->nt = nt;
5922 memcpy (&ale[1], address, slen);
5923 ale->st = GNUNET_SCHEDULER_add_now (&store_pi, ale);
5924
5925 return ale;
5926}
5927
5928
5778/** 5929/**
5779 * Address of our peer added. Process the request. 5930 * Address of our peer added. Process the request.
5780 * 5931 *
@@ -5788,23 +5939,24 @@ handle_add_address (void *cls,
5788 struct TransportClient *tc = cls; 5939 struct TransportClient *tc = cls;
5789 struct AddressListEntry *ale; 5940 struct AddressListEntry *ale;
5790 size_t slen; 5941 size_t slen;
5942 char *address;
5791 5943
5792 /* 0-termination of &aam[1] was checked in #check_add_address */ 5944 /* 0-termination of &aam[1] was checked in #check_add_address */
5793 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 5945 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5794 "Communicator added address `%s'!\n", 5946 "Communicator added address `%s'!\n",
5795 (const char *) &aam[1]); 5947 (const char *) &aam[1]);
5796 slen = ntohs (aam->header.size) - sizeof(*aam); 5948 slen = ntohs (aam->header.size) - sizeof(*aam);
5797 ale = GNUNET_malloc (sizeof(struct AddressListEntry) + slen); 5949 address = GNUNET_malloc (slen);
5798 ale->tc = tc; 5950 memcpy (address, &aam[1], slen);
5799 ale->address = (const char *) &ale[1]; 5951 ale = create_address_entry (tc,
5800 ale->expiration = GNUNET_TIME_relative_ntoh (aam->expiration); 5952 GNUNET_TIME_relative_ntoh (aam->expiration),
5801 ale->aid = aam->aid; 5953 (enum GNUNET_NetworkType) ntohl (aam->nt),
5802 ale->nt = (enum GNUNET_NetworkType) ntohl (aam->nt); 5954 address,
5803 memcpy (&ale[1], &aam[1], slen); 5955 aam->aid,
5956 slen);
5804 GNUNET_CONTAINER_DLL_insert (tc->details.communicator.addr_head, 5957 GNUNET_CONTAINER_DLL_insert (tc->details.communicator.addr_head,
5805 tc->details.communicator.addr_tail, 5958 tc->details.communicator.addr_tail,
5806 ale); 5959 ale);
5807 ale->st = GNUNET_SCHEDULER_add_now (&store_pi, ale);
5808 GNUNET_SERVICE_client_continue (tc->client); 5960 GNUNET_SERVICE_client_continue (tc->client);
5809} 5961}
5810 5962
@@ -9446,6 +9598,37 @@ handle_incoming_msg (void *cls,
9446 demultiplex_with_cmc (cmc); 9598 demultiplex_with_cmc (cmc);
9447} 9599}
9448 9600
9601/**
9602 * Communicator gave us a transport address validation response. Check the
9603 * request.
9604 *
9605 * @param cls a `struct CommunicatorMessageContext`
9606 * @param fc the message that was received
9607 * @return #GNUNET_YES if message is well-formed
9608 */
9609static int
9610check_flow_control (void *cls, const struct TransportFlowControlMessage *fc)
9611{
9612 (void) cls;
9613 struct TransportGlobalNattedAddress *addresses = (struct TransportGlobalNattedAddress *) &fc[1];
9614 unsigned int number_of_addresses = ntohl (fc->number_of_addresses);
9615
9616 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
9617 "Flow control header size %u size of addresses %u number of addresses %u size of message struct %u second struct %u\n",
9618 ntohs (fc->header.size),
9619 ntohl (fc->size_of_addresses),
9620 ntohl (fc->number_of_addresses),
9621 sizeof(struct TransportFlowControlMessage),
9622 sizeof (struct TransportGlobalNattedAddress));
9623
9624 if (0 == number_of_addresses || ntohs (fc->header.size) == sizeof(struct TransportFlowControlMessage) + ntohl (fc->number_of_addresses) * sizeof (struct TransportGlobalNattedAddress) + ntohl (fc->size_of_addresses))
9625 return GNUNET_OK;
9626 else
9627 {
9628 GNUNET_break_op (0);
9629 return GNUNET_SYSERR;
9630 }
9631}
9449 9632
9450/** 9633/**
9451 * Communicator gave us a transport address validation response. Process the 9634 * Communicator gave us a transport address validation response. Process the
@@ -9490,6 +9673,31 @@ handle_flow_control (void *cls, const struct TransportFlowControlMessage *fc)
9490 vl, 9673 vl,
9491 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 9674 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
9492 } 9675 }
9676 if (0 != ntohl (fc->number_of_addresses))
9677 {
9678 unsigned int number_of_addresses = ntohl (fc->number_of_addresses);
9679 const char *tgnas;
9680 unsigned int off = 0;
9681
9682 tgnas = (const char *) &fc[1];
9683
9684 for (int i = 1; i <= number_of_addresses; i++)
9685 {
9686 struct TransportGlobalNattedAddress *tgna = (struct TransportGlobalNattedAddress *) &tgnas[off];
9687 char *addr = (char *) &tgna[1];
9688 unsigned int address_length;
9689
9690 address_length = ntohl (tgna->address_length);
9691 off += sizeof(struct TransportGlobalNattedAddress) + address_length;
9692
9693 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
9694 "received address %s length %u\n",
9695 addr,
9696 ntohl (tgna->address_length));
9697
9698 GNUNET_NAT_add_global_address (nh, addr, ntohl (tgna->address_length));
9699 }
9700 }
9493 st = GNUNET_TIME_absolute_ntoh (fc->sender_time); 9701 st = GNUNET_TIME_absolute_ntoh (fc->sender_time);
9494 if (st.abs_value_us < vl->last_fc_timestamp.abs_value_us) 9702 if (st.abs_value_us < vl->last_fc_timestamp.abs_value_us)
9495 { 9703 {
@@ -9596,15 +9804,15 @@ demultiplex_with_cmc (struct CommunicatorMessageContext *cmc)
9596 GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX, 9804 GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX,
9597 struct TransportDVBoxMessage, 9805 struct TransportDVBoxMessage,
9598 cmc), 9806 cmc),
9807 GNUNET_MQ_hd_var_size (flow_control,
9808 GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL,
9809 struct TransportFlowControlMessage,
9810 cmc),
9599 GNUNET_MQ_hd_fixed_size ( 9811 GNUNET_MQ_hd_fixed_size (
9600 validation_challenge, 9812 validation_challenge,
9601 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE, 9813 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE,
9602 struct TransportValidationChallengeMessage, 9814 struct TransportValidationChallengeMessage,
9603 cmc), 9815 cmc),
9604 GNUNET_MQ_hd_fixed_size (flow_control,
9605 GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL,
9606 struct TransportFlowControlMessage,
9607 cmc),
9608 GNUNET_MQ_hd_fixed_size ( 9816 GNUNET_MQ_hd_fixed_size (
9609 validation_response, 9817 validation_response,
9610 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE, 9818 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE,
@@ -11317,6 +11525,7 @@ check_validation_request_pending (void *cls,
11317 char *address_without_port_q; 11525 char *address_without_port_q;
11318 int success = GNUNET_YES; 11526 int success = GNUNET_YES;
11319 11527
11528 //TODO Check if this is really necessary.
11320 address_without_port_vs = get_address_without_port (vs->address); 11529 address_without_port_vs = get_address_without_port (vs->address);
11321 address_without_port_q = get_address_without_port (q->address); 11530 address_without_port_q = get_address_without_port (q->address);
11322 11531
@@ -11380,6 +11589,192 @@ neighbour_dv_monotime_cb (void *cls,
11380} 11589}
11381 11590
11382 11591
11592static void
11593iterate_address_and_compare_cb (void *cls,
11594 const struct GNUNET_PeerIdentity *pid,
11595 const char *uri)
11596{
11597 struct Queue *queue = cls;
11598 struct Neighbour *neighbour = queue->neighbour;
11599 const char *dash;
11600 const char *slash;
11601 char *address_uri;
11602 char *prefix;
11603 char *uri_without_port;
11604 char *address_uri_without_port = get_address_without_port (queue->address);
11605
11606 slash = strrchr (uri, '/');
11607 prefix = GNUNET_strndup (uri, (slash - uri) - 2);
11608 GNUNET_assert (NULL != slash);
11609 slash++;
11610 GNUNET_asprintf (&address_uri,
11611 "%s-%s",
11612 prefix,
11613 slash);
11614
11615 address_uri_without_port = get_address_without_port (queue->address);
11616 uri_without_port = get_address_without_port (address_uri);
11617 if (0 == strcmp (uri_without_port, address_uri_without_port))
11618 {
11619 queue->is_global_natted = GNUNET_NO;
11620 }
11621
11622 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
11623 "not global natted %u %s %s %s %s %s %u\n",
11624 queue->is_global_natted,
11625 uri,
11626 queue->address,
11627 uri_without_port,
11628 address_uri_without_port,
11629 prefix,
11630 GNUNET_NO);
11631 GNUNET_free (prefix);
11632 GNUNET_free (address_uri);
11633 GNUNET_free (address_uri_without_port);
11634 GNUNET_free (uri_without_port);
11635}
11636
11637
11638static void
11639check_for_global_natted_error_cb (void *cls)
11640{
11641 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
11642 "Error in PEERSTORE monitoring for checking global natted\n");
11643}
11644
11645
11646static void
11647check_for_global_natted_sync_cb (void *cls)
11648{
11649 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
11650 "Done with initial PEERSTORE iteration during monitoring for checking global natted\n");
11651}
11652
11653
11654struct TransportGlobalNattedAddressClosure
11655{
11656 /**
11657 * The address to search for.
11658 */
11659 char *addr;
11660
11661 /**
11662 * The struct TransportGlobalNattedAddress to set.
11663 */
11664 struct TransportGlobalNattedAddress *tgna;
11665};
11666
11667
11668static enum GNUNET_GenericReturnValue
11669contains_address (void *cls,
11670 const struct GNUNET_PeerIdentity *pid,
11671 void *value)
11672{
11673 struct TransportGlobalNattedAddressClosure *tgna_cls = cls;
11674 struct TransportGlobalNattedAddress *tgna = value;
11675 char *addr = (char *) &tgna[1];
11676
11677 if (0 == GNUNET_memcmp (addr, tgna_cls->addr))
11678 {
11679 tgna_cls->tgna = tgna;
11680 return GNUNET_NO;
11681 }
11682 return GNUNET_YES;
11683}
11684
11685
11686static void
11687check_for_global_natted (void *cls,
11688 const struct GNUNET_PEERSTORE_Record *record,
11689 const char *emsg)
11690{
11691 struct Queue *queue = cls;
11692 struct Neighbour *neighbour = queue->neighbour;
11693 struct GNUNET_HELLO_Builder *builder;
11694 struct GNUNET_MessageHeader *hello;
11695 struct TransportGlobalNattedAddressClosure tgna_cls;
11696 size_t address_len_without_port;
11697
11698 if (NULL != emsg)
11699 {
11700 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
11701 "Got failure from PEERSTORE: %s\n",
11702 emsg);
11703 return;
11704 }
11705 if (NULL == record)
11706 {
11707 queue->mo = NULL;
11708 return;
11709 }
11710 if (0 == record->value_size)
11711 {
11712 GNUNET_PEERSTORE_monitor_next (queue->mo, 1);
11713 GNUNET_break (0);
11714 return;
11715 }
11716 queue->is_global_natted = GNUNET_YES;
11717 hello = record->value;
11718 builder = GNUNET_HELLO_builder_from_msg (hello);
11719 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
11720 "before not global natted %u\n",
11721 queue->is_global_natted);
11722 GNUNET_HELLO_builder_iterate (builder,
11723 &iterate_address_and_compare_cb,
11724 queue);
11725 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
11726 "after not global natted %u\n",
11727 queue->is_global_natted);
11728 GNUNET_HELLO_builder_free (builder);
11729
11730 tgna_cls.addr = get_address_without_port (queue->address);
11731 address_len_without_port = strlen (tgna_cls.addr);
11732 GNUNET_CONTAINER_multipeermap_get_multiple (neighbour->natted_addresses,
11733 &neighbour->pid,
11734 &contains_address,
11735 &tgna_cls);
11736 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
11737 " tgna_cls.tgna tgna %p %u %u %u\n",
11738 tgna_cls.tgna,
11739 neighbour->size_of_global_addresses,
11740 tgna_cls.tgna->address_length,
11741 neighbour->number_of_addresses);
11742 if (0 == tgna_cls.tgna->address_length && GNUNET_YES == queue->is_global_natted)
11743 {
11744 struct TransportGlobalNattedAddress *tgna;
11745
11746 tgna = GNUNET_malloc (sizeof (struct TransportGlobalNattedAddress) + address_len_without_port);
11747 tgna->address_length = htonl (address_len_without_port);
11748 GNUNET_memcpy (&tgna[1], tgna_cls.addr, address_len_without_port);
11749 GNUNET_CONTAINER_multipeermap_put (neighbour->natted_addresses,
11750 &neighbour->pid,
11751 tgna,
11752 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
11753 neighbour->number_of_addresses++;
11754 neighbour->size_of_global_addresses += address_len_without_port;
11755 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
11756 "Created tgna %p\n",
11757 tgna);
11758 }
11759 else if (0 != tgna_cls.tgna->address_length && GNUNET_NO == queue->is_global_natted)
11760 {
11761 GNUNET_CONTAINER_multipeermap_remove (neighbour->natted_addresses,
11762 &neighbour->pid,
11763 tgna_cls.tgna);
11764 GNUNET_assert (neighbour->size_of_global_addresses >= ntohl (tgna_cls.tgna->address_length));
11765 neighbour->size_of_global_addresses -= ntohl (tgna_cls.tgna->address_length);
11766 GNUNET_assert (0 < neighbour->number_of_addresses);
11767 neighbour->number_of_addresses--;
11768 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
11769 "removed tgna %p\n",
11770 tgna_cls.tgna);
11771 GNUNET_free (tgna_cls.tgna);
11772 }
11773 GNUNET_free (tgna_cls.addr);
11774 GNUNET_PEERSTORE_monitor_next (queue->mo, 1);
11775}
11776
11777
11383/** 11778/**
11384 * New queue became available. Process the request. 11779 * New queue became available. Process the request.
11385 * 11780 *
@@ -11426,6 +11821,7 @@ handle_add_queue_message (void *cls,
11426 if (NULL == neighbour) 11821 if (NULL == neighbour)
11427 { 11822 {
11428 neighbour = GNUNET_new (struct Neighbour); 11823 neighbour = GNUNET_new (struct Neighbour);
11824 neighbour->natted_addresses = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES);
11429 neighbour->pid = aqm->receiver; 11825 neighbour->pid = aqm->receiver;
11430 GNUNET_assert (GNUNET_OK == 11826 GNUNET_assert (GNUNET_OK ==
11431 GNUNET_CONTAINER_multipeermap_put ( 11827 GNUNET_CONTAINER_multipeermap_put (
@@ -11488,6 +11884,17 @@ handle_add_queue_message (void *cls,
11488 queue->nt = (enum GNUNET_NetworkType) ntohl (aqm->nt); 11884 queue->nt = (enum GNUNET_NetworkType) ntohl (aqm->nt);
11489 queue->cs = (enum GNUNET_TRANSPORT_ConnectionStatus) ntohl (aqm->cs); 11885 queue->cs = (enum GNUNET_TRANSPORT_ConnectionStatus) ntohl (aqm->cs);
11490 queue->idle = GNUNET_YES; 11886 queue->idle = GNUNET_YES;
11887 queue->mo = GNUNET_PEERSTORE_monitor_start (GST_cfg,
11888 GNUNET_YES,
11889 "peerstore",
11890 &neighbour->pid,
11891 GNUNET_PEERSTORE_HELLO_KEY,
11892 &check_for_global_natted_error_cb,
11893 NULL,
11894 &check_for_global_natted_sync_cb,
11895 NULL,
11896 &check_for_global_natted,
11897 queue);
11491 /* check if valdiations are waiting for the queue */ 11898 /* check if valdiations are waiting for the queue */
11492 if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (validation_map, 11899 if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (validation_map,
11493 &aqm->receiver)) 11900 &aqm->receiver))
@@ -11977,10 +12384,11 @@ static void
11977do_shutdown (void *cls) 12384do_shutdown (void *cls)
11978{ 12385{
11979 struct LearnLaunchEntry *lle; 12386 struct LearnLaunchEntry *lle;
12387 (void) cls;
11980 12388
11981 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 12389 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
11982 "shutdown logic\n"); 12390 "shutdown logic\n");
11983 (void) cls; 12391 GNUNET_NAT_unregister (nh);
11984 GNUNET_CONTAINER_multipeermap_iterate (neighbours, 12392 GNUNET_CONTAINER_multipeermap_iterate (neighbours,
11985 &free_neighbour_cb, NULL); 12393 &free_neighbour_cb, NULL);
11986 if (NULL != validation_task) 12394 if (NULL != validation_task)
@@ -12134,6 +12542,15 @@ run (void *cls,
12134 GST_stats = GNUNET_STATISTICS_create ("transport", GST_cfg); 12542 GST_stats = GNUNET_STATISTICS_create ("transport", GST_cfg);
12135 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); 12543 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
12136 peerstore = GNUNET_PEERSTORE_connect (GST_cfg); 12544 peerstore = GNUNET_PEERSTORE_connect (GST_cfg);
12545 nh = GNUNET_NAT_register (GST_cfg,
12546 "transport",
12547 0,
12548 0,
12549 NULL,
12550 0,
12551 NULL,
12552 NULL,
12553 NULL);
12137 if (NULL == peerstore) 12554 if (NULL == peerstore)
12138 { 12555 {
12139 GNUNET_break (0); 12556 GNUNET_break (0);