diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-03-09 16:57:01 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-03-09 16:57:11 +0100 |
commit | fd58a3abc404e67e96901e48436922937ea1d629 (patch) | |
tree | aad2e3619fbac8ad881fde59a6d257a4779be998 /src/nat | |
parent | c0862506a76c168626ecfd32989fd6718c67ff89 (diff) | |
download | gnunet-fd58a3abc404e67e96901e48436922937ea1d629.tar.gz gnunet-fd58a3abc404e67e96901e48436922937ea1d629.zip |
fix issue with NAT logic overwriting port specified by user in manual hole punch; adding some logging
Diffstat (limited to 'src/nat')
-rw-r--r-- | src/nat/gnunet-nat.c | 30 | ||||
-rw-r--r-- | src/nat/gnunet-service-nat.c | 70 | ||||
-rw-r--r-- | src/nat/gnunet-service-nat_helper.c | 29 | ||||
-rw-r--r-- | src/nat/nat_api.c | 24 |
4 files changed, 96 insertions, 57 deletions
diff --git a/src/nat/gnunet-nat.c b/src/nat/gnunet-nat.c index 80bfb5726..1c5850592 100644 --- a/src/nat/gnunet-nat.c +++ b/src/nat/gnunet-nat.c | |||
@@ -34,9 +34,9 @@ | |||
34 | static int global_ret; | 34 | static int global_ret; |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Name of section in configuration file to use for | 37 | * Name of section in configuration file to use for |
38 | * additional options. | 38 | * additional options. |
39 | */ | 39 | */ |
40 | static char *section_name; | 40 | static char *section_name; |
41 | 41 | ||
42 | /** | 42 | /** |
@@ -81,7 +81,7 @@ static struct GNUNET_NAT_Handle *nh; | |||
81 | 81 | ||
82 | /** | 82 | /** |
83 | * Listen socket for STUN processing. | 83 | * Listen socket for STUN processing. |
84 | */ | 84 | */ |
85 | static struct GNUNET_NETWORK_Handle *ls; | 85 | static struct GNUNET_NETWORK_Handle *ls; |
86 | 86 | ||
87 | /** | 87 | /** |
@@ -110,7 +110,7 @@ test_finished () | |||
110 | * a function to call whenever our set of 'valid' addresses changes. | 110 | * a function to call whenever our set of 'valid' addresses changes. |
111 | * | 111 | * |
112 | * @param cls closure, NULL | 112 | * @param cls closure, NULL |
113 | * @param add_remove #GNUNET_YES to add a new public IP address, | 113 | * @param add_remove #GNUNET_YES to add a new public IP address, |
114 | * #GNUNET_NO to remove a previous (now invalid) one | 114 | * #GNUNET_NO to remove a previous (now invalid) one |
115 | * @param ac address class the address belongs to | 115 | * @param ac address class the address belongs to |
116 | * @param addr either the previous or the new public IP address | 116 | * @param addr either the previous or the new public IP address |
@@ -123,12 +123,12 @@ address_cb (void *cls, | |||
123 | const struct sockaddr *addr, | 123 | const struct sockaddr *addr, |
124 | socklen_t addrlen) | 124 | socklen_t addrlen) |
125 | { | 125 | { |
126 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 126 | fprintf (stdout, |
127 | "%s %s (%d)\n", | 127 | "%s %s (%d)\n", |
128 | add_remove ? "+" : "-", | 128 | add_remove ? "+" : "-", |
129 | GNUNET_a2s (addr, | 129 | GNUNET_a2s (addr, |
130 | addrlen), | 130 | addrlen), |
131 | (int) ac); | 131 | (int) ac); |
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
@@ -186,7 +186,7 @@ static void | |||
186 | stun_read_task (void *cls) | 186 | stun_read_task (void *cls) |
187 | { | 187 | { |
188 | ssize_t size; | 188 | ssize_t size; |
189 | 189 | ||
190 | rtask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 190 | rtask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
191 | ls, | 191 | ls, |
192 | &stun_read_task, | 192 | &stun_read_task, |
@@ -204,7 +204,7 @@ stun_read_task (void *cls) | |||
204 | struct sockaddr_storage sa; | 204 | struct sockaddr_storage sa; |
205 | socklen_t salen = sizeof (sa); | 205 | socklen_t salen = sizeof (sa); |
206 | ssize_t ret; | 206 | ssize_t ret; |
207 | 207 | ||
208 | ret = GNUNET_NETWORK_socket_recvfrom (ls, | 208 | ret = GNUNET_NETWORK_socket_recvfrom (ls, |
209 | buf, | 209 | buf, |
210 | size + 1, | 210 | size + 1, |
@@ -318,7 +318,7 @@ run (void *cls, | |||
318 | else if (listen_reversal) | 318 | else if (listen_reversal) |
319 | { | 319 | { |
320 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 320 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, |
321 | "Use of `-W` only effective in combination with `-i`\n"); | 321 | "Use of `-W` only effective in combination with `-i`\n"); |
322 | global_ret = 1; | 322 | global_ret = 1; |
323 | GNUNET_SCHEDULER_shutdown (); | 323 | GNUNET_SCHEDULER_shutdown (); |
324 | return; | 324 | return; |
@@ -327,7 +327,7 @@ run (void *cls, | |||
327 | if (NULL != remote_addr) | 327 | if (NULL != remote_addr) |
328 | { | 328 | { |
329 | int ret; | 329 | int ret; |
330 | 330 | ||
331 | if ( (NULL == nh) || | 331 | if ( (NULL == nh) || |
332 | (sizeof (struct sockaddr_in) != local_len) ) | 332 | (sizeof (struct sockaddr_in) != local_len) ) |
333 | { | 333 | { |
@@ -365,7 +365,7 @@ run (void *cls, | |||
365 | break; | 365 | break; |
366 | } | 366 | } |
367 | } | 367 | } |
368 | 368 | ||
369 | if (do_stun) | 369 | if (do_stun) |
370 | { | 370 | { |
371 | if (NULL == local_addr) | 371 | if (NULL == local_addr) |
diff --git a/src/nat/gnunet-service-nat.c b/src/nat/gnunet-service-nat.c index bfe212308..0695c7ac7 100644 --- a/src/nat/gnunet-service-nat.c +++ b/src/nat/gnunet-service-nat.c | |||
@@ -662,6 +662,11 @@ notify_client (enum GNUNET_NAT_AddressClass ac, | |||
662 | struct GNUNET_MQ_Envelope *env; | 662 | struct GNUNET_MQ_Envelope *env; |
663 | struct GNUNET_NAT_AddressChangeNotificationMessage *msg; | 663 | struct GNUNET_NAT_AddressChangeNotificationMessage *msg; |
664 | 664 | ||
665 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
666 | "Notifying client about %s of IP %s\n", | ||
667 | add ? "addition" : "removal", | ||
668 | GNUNET_a2s (addr, | ||
669 | addr_len)); | ||
665 | env = GNUNET_MQ_msg_extra (msg, | 670 | env = GNUNET_MQ_msg_extra (msg, |
666 | addr_len, | 671 | addr_len, |
667 | GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE); | 672 | GNUNET_MESSAGE_TYPE_NAT_ADDRESS_CHANGE); |
@@ -693,7 +698,11 @@ check_notify_client (struct LocalAddressList *delta, | |||
693 | struct sockaddr_in6 v6; | 698 | struct sockaddr_in6 v6; |
694 | 699 | ||
695 | if (0 == (ch->flags & GNUNET_NAT_RF_ADDRESSES)) | 700 | if (0 == (ch->flags & GNUNET_NAT_RF_ADDRESSES)) |
701 | { | ||
702 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
703 | "Not notifying client as it does not care about addresses\n"); | ||
696 | return; | 704 | return; |
705 | } | ||
697 | switch (delta->af) | 706 | switch (delta->af) |
698 | { | 707 | { |
699 | case AF_INET: | 708 | case AF_INET: |
@@ -715,25 +724,24 @@ check_notify_client (struct LocalAddressList *delta, | |||
715 | (! match_ipv4 ("127.0.0.1", &v4.sin_addr, 8)) ) | 724 | (! match_ipv4 ("127.0.0.1", &v4.sin_addr, 8)) ) |
716 | continue; /* bound to loopback, but this is not loopback */ | 725 | continue; /* bound to loopback, but this is not loopback */ |
717 | if ( (! match_ipv4 ("127.0.0.1", &c4->sin_addr, 8) ) && | 726 | if ( (! match_ipv4 ("127.0.0.1", &c4->sin_addr, 8) ) && |
718 | (0 != c4->sin_addr.s_addr) && | ||
719 | match_ipv4 ("127.0.0.1", &v4.sin_addr, 8) ) | 727 | match_ipv4 ("127.0.0.1", &v4.sin_addr, 8) ) |
720 | continue; /* bound to non-loopback, but this is loopback */ | 728 | continue; /* bound to non-loopback, but this is loopback */ |
721 | if ( (0 != (ch->flags & GNUNET_NAT_AC_EXTERN)) && | 729 | if ( (0 != (delta->ac & GNUNET_NAT_AC_EXTERN)) && |
722 | (0 != c4->sin_addr.s_addr) && | 730 | (0 != c4->sin_addr.s_addr) && |
723 | (! is_nat_v4 (&v4.sin_addr)) ) | 731 | (! is_nat_v4 (&v4.sin_addr)) ) |
724 | continue; /* based on external-IP, but this IP is not | 732 | continue; /* based on external-IP, but this IP is not |
725 | from private address range. */ | 733 | from private address range. */ |
726 | if ( (0 != memcmp (&v4.sin_addr, | 734 | if ( (0 != memcmp (&v4.sin_addr, |
727 | &c4->sin_addr, | 735 | &c4->sin_addr, |
728 | sizeof (struct in_addr))) && | 736 | sizeof (struct in_addr))) && |
729 | (0 != c4->sin_addr.s_addr) && | 737 | (0 != c4->sin_addr.s_addr) && |
730 | ( (! is_nat_v4 (&c4->sin_addr)) || | 738 | (! is_nat_v4 (&c4->sin_addr)) ) |
731 | (0 == (ch->flags & GNUNET_NAT_AC_EXTERN))) ) | ||
732 | continue; /* this IP is not from private address range, | 739 | continue; /* this IP is not from private address range, |
733 | and IP does not match. */ | 740 | and IP does not match. */ |
734 | 741 | ||
735 | /* OK, IP seems relevant, notify client */ | 742 | /* OK, IP seems relevant, notify client */ |
736 | v4.sin_port = c4->sin_port; | 743 | if (0 == htons (v4.sin_port)) |
744 | v4.sin_port = c4->sin_port; | ||
737 | notify_client (delta->ac, | 745 | notify_client (delta->ac, |
738 | ch, | 746 | ch, |
739 | add, | 747 | add, |
@@ -760,13 +768,10 @@ check_notify_client (struct LocalAddressList *delta, | |||
760 | (! match_ipv6 ("::1", &v6.sin6_addr, 128)) ) | 768 | (! match_ipv6 ("::1", &v6.sin6_addr, 128)) ) |
761 | continue; /* bound to loopback, but this is not loopback */ | 769 | continue; /* bound to loopback, but this is not loopback */ |
762 | if ( (! match_ipv6 ("::1", &c6->sin6_addr, 128) ) && | 770 | if ( (! match_ipv6 ("::1", &c6->sin6_addr, 128) ) && |
763 | (0 != memcmp (&c6->sin6_addr, | ||
764 | &in6addr_any, | ||
765 | sizeof (struct in6_addr))) && | ||
766 | match_ipv6 ("::1", &v6.sin6_addr, 128) ) | 771 | match_ipv6 ("::1", &v6.sin6_addr, 128) ) |
767 | continue; /* bound to non-loopback, but this is loopback */ | 772 | continue; /* bound to non-loopback, but this is loopback */ |
768 | if ( (0 != (ch->flags & GNUNET_NAT_AC_EXTERN)) && | 773 | if ( (0 != (delta->ac & GNUNET_NAT_AC_EXTERN)) && |
769 | (0 != memcmp (&c6->sin6_addr, | 774 | (0 != memcmp (&c6->sin6_addr, |
770 | &in6addr_any, | 775 | &in6addr_any, |
771 | sizeof (struct in6_addr))) && | 776 | sizeof (struct in6_addr))) && |
772 | (! is_nat_v6 (&v6.sin6_addr)) ) | 777 | (! is_nat_v6 (&v6.sin6_addr)) ) |
@@ -793,7 +798,8 @@ check_notify_client (struct LocalAddressList *delta, | |||
793 | does not match and is not an external IP */ | 798 | does not match and is not an external IP */ |
794 | 799 | ||
795 | /* OK, IP seems relevant, notify client */ | 800 | /* OK, IP seems relevant, notify client */ |
796 | v6.sin6_port = c6->sin6_port; | 801 | if (0 == htons (v6.sin6_port)) |
802 | v6.sin6_port = c6->sin6_port; | ||
797 | notify_client (delta->ac, | 803 | notify_client (delta->ac, |
798 | ch, | 804 | ch, |
799 | add, | 805 | add, |
@@ -853,6 +859,10 @@ notify_client_external_ipv4_change (void *cls, | |||
853 | struct LocalAddressList lal; | 859 | struct LocalAddressList lal; |
854 | struct sockaddr_in *s4; | 860 | struct sockaddr_in *s4; |
855 | 861 | ||
862 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
863 | "Detected eternal IP, can now back-fill AUTO:%u in hole punching specification of `%s'\n", | ||
864 | (unsigned int) ch->ext_dns_port, | ||
865 | ch->section_name); | ||
856 | memset (&lal, 0, sizeof (lal)); | 866 | memset (&lal, 0, sizeof (lal)); |
857 | s4 = (struct sockaddr_in *) &lal.addr; | 867 | s4 = (struct sockaddr_in *) &lal.addr; |
858 | s4->sin_family = AF_INET; | 868 | s4->sin_family = AF_INET; |
@@ -868,8 +878,6 @@ notify_client_external_ipv4_change (void *cls, | |||
868 | /* (1) check if client cares. */ | 878 | /* (1) check if client cares. */ |
869 | if (! ch->natted_address) | 879 | if (! ch->natted_address) |
870 | return; | 880 | return; |
871 | if (0 == (GNUNET_NAT_RF_ADDRESSES & ch->flags)) | ||
872 | return; | ||
873 | have_v4 = GNUNET_NO; | 881 | have_v4 = GNUNET_NO; |
874 | for (unsigned int i=0;i<ch->num_caddrs;i++) | 882 | for (unsigned int i=0;i<ch->num_caddrs;i++) |
875 | { | 883 | { |
@@ -891,6 +899,10 @@ notify_client_external_ipv4_change (void *cls, | |||
891 | sa.sin_addr = *v4; | 899 | sa.sin_addr = *v4; |
892 | sa.sin_port = htons (0); | 900 | sa.sin_port = htons (0); |
893 | 901 | ||
902 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
903 | "Detected eternal IP %s, notifying client of external IP (without port)\n", | ||
904 | GNUNET_a2s ((const struct sockaddr *) &sa, | ||
905 | sizeof (sa))); | ||
894 | /* (3) notify client of change */ | 906 | /* (3) notify client of change */ |
895 | notify_client (is_nat_v4 (v4) | 907 | notify_client (is_nat_v4 (v4) |
896 | ? GNUNET_NAT_AC_EXTERN | GNUNET_NAT_AC_LAN | 908 | ? GNUNET_NAT_AC_EXTERN | GNUNET_NAT_AC_LAN |
@@ -1055,7 +1067,8 @@ run_scan (void *cls) | |||
1055 | 1067 | ||
1056 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1068 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1057 | "Found NATed local address %s, starting NAT server\n", | 1069 | "Found NATed local address %s, starting NAT server\n", |
1058 | GNUNET_a2s ((void *) &pos->addr, sizeof (*s4))); | 1070 | GNUNET_a2s ((const struct sockaddr *) &pos->addr, |
1071 | sizeof (*s4))); | ||
1059 | pos->hc = GN_start_gnunet_nat_server_ (&s4->sin_addr, | 1072 | pos->hc = GN_start_gnunet_nat_server_ (&s4->sin_addr, |
1060 | &reversal_callback, | 1073 | &reversal_callback, |
1061 | pos); | 1074 | pos); |
@@ -1280,6 +1293,11 @@ dyndns_lookup (void *cls) | |||
1280 | struct ClientHandle *ch = cls; | 1293 | struct ClientHandle *ch = cls; |
1281 | struct LocalAddressList *lal; | 1294 | struct LocalAddressList *lal; |
1282 | 1295 | ||
1296 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1297 | "Performing DNS lookup for punched hole given for `%s' as `%s:%u'\n", | ||
1298 | ch->section_name, | ||
1299 | ch->hole_external, | ||
1300 | (unsigned int) ch->ext_dns_port); | ||
1283 | for (lal = ch->ext_addr_head; NULL != lal; lal = lal->next) | 1301 | for (lal = ch->ext_addr_head; NULL != lal; lal = lal->next) |
1284 | lal->old = GNUNET_YES; | 1302 | lal->old = GNUNET_YES; |
1285 | ch->ext_dns_task = NULL; | 1303 | ch->ext_dns_task = NULL; |
@@ -1374,6 +1392,11 @@ lookup_hole_external (struct ClientHandle *ch) | |||
1374 | ch->hole_external, | 1392 | ch->hole_external, |
1375 | &s4->sin_addr)) | 1393 | &s4->sin_addr)) |
1376 | { | 1394 | { |
1395 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1396 | "IPv4 punched hole given for `%s' via `%s:%u'\n", | ||
1397 | ch->section_name, | ||
1398 | ch->hole_external, | ||
1399 | (unsigned int) ch->ext_dns_port); | ||
1377 | s4->sin_port = htons (ch->ext_dns_port); | 1400 | s4->sin_port = htons (ch->ext_dns_port); |
1378 | lal->af = AF_INET; | 1401 | lal->af = AF_INET; |
1379 | lal->ac = GNUNET_NAT_AC_GLOBAL | GNUNET_NAT_AC_MANUAL; | 1402 | lal->ac = GNUNET_NAT_AC_GLOBAL | GNUNET_NAT_AC_MANUAL; |
@@ -1423,8 +1446,6 @@ handle_register (void *cls, | |||
1423 | GNUNET_SERVICE_client_drop (ch->client); | 1446 | GNUNET_SERVICE_client_drop (ch->client); |
1424 | return; | 1447 | return; |
1425 | } | 1448 | } |
1426 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1427 | "Received REGISTER message from client\n"); | ||
1428 | ch->flags = message->flags; | 1449 | ch->flags = message->flags; |
1429 | ch->proto = message->proto; | 1450 | ch->proto = message->proto; |
1430 | ch->num_caddrs = ntohs (message->num_addrs); | 1451 | ch->num_caddrs = ntohs (message->num_addrs); |
@@ -1512,6 +1533,9 @@ handle_register (void *cls, | |||
1512 | ch->section_name | 1533 | ch->section_name |
1513 | = GNUNET_strndup (off, | 1534 | = GNUNET_strndup (off, |
1514 | ntohs (message->str_len)); | 1535 | ntohs (message->str_len)); |
1536 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1537 | "Received REGISTER message from client for subsystem `%s'\n", | ||
1538 | ch->section_name); | ||
1515 | if (GNUNET_OK == | 1539 | if (GNUNET_OK == |
1516 | GNUNET_CONFIGURATION_get_value_string (cfg, | 1540 | GNUNET_CONFIGURATION_get_value_string (cfg, |
1517 | ch->section_name, | 1541 | ch->section_name, |
diff --git a/src/nat/gnunet-service-nat_helper.c b/src/nat/gnunet-service-nat_helper.c index e91f63beb..de6531fa8 100644 --- a/src/nat/gnunet-service-nat_helper.c +++ b/src/nat/gnunet-service-nat_helper.c | |||
@@ -221,6 +221,26 @@ restart_nat_server (void *cls) | |||
221 | char ia[INET_ADDRSTRLEN]; | 221 | char ia[INET_ADDRSTRLEN]; |
222 | 222 | ||
223 | h->server_read_task = NULL; | 223 | h->server_read_task = NULL; |
224 | GNUNET_assert (NULL != | ||
225 | inet_ntop (AF_INET, | ||
226 | &h->internal_address, | ||
227 | ia, | ||
228 | sizeof (ia))); | ||
229 | /* Start the server process */ | ||
230 | binary | ||
231 | = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-server"); | ||
232 | if (GNUNET_YES != | ||
233 | GNUNET_OS_check_helper_binary (binary, | ||
234 | GNUNET_YES, | ||
235 | ia)) | ||
236 | { | ||
237 | /* move instantly to max delay, as this is unlikely to be fixed */ | ||
238 | h->server_retry_delay | ||
239 | = GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD; | ||
240 | GNUNET_free (binary); | ||
241 | try_again (h); | ||
242 | return; | ||
243 | } | ||
224 | h->server_stdout | 244 | h->server_stdout |
225 | = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, | 245 | = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, |
226 | GNUNET_NO, GNUNET_YES); | 246 | GNUNET_NO, GNUNET_YES); |
@@ -228,21 +248,14 @@ restart_nat_server (void *cls) | |||
228 | { | 248 | { |
229 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | 249 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, |
230 | "pipe"); | 250 | "pipe"); |
251 | GNUNET_free (binary); | ||
231 | try_again (h); | 252 | try_again (h); |
232 | return; | 253 | return; |
233 | } | 254 | } |
234 | GNUNET_assert (NULL != | ||
235 | inet_ntop (AF_INET, | ||
236 | &h->internal_address, | ||
237 | ia, | ||
238 | sizeof (ia))); | ||
239 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 255 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
240 | "Starting `%s' at `%s'\n", | 256 | "Starting `%s' at `%s'\n", |
241 | "gnunet-helper-nat-server", | 257 | "gnunet-helper-nat-server", |
242 | ia); | 258 | ia); |
243 | /* Start the server process */ | ||
244 | binary | ||
245 | = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-server"); | ||
246 | h->server_proc | 259 | h->server_proc |
247 | = GNUNET_OS_start_process (GNUNET_NO, | 260 | = GNUNET_OS_start_process (GNUNET_NO, |
248 | 0, | 261 | 0, |
diff --git a/src/nat/nat_api.c b/src/nat/nat_api.c index eec5d3968..dfe7defc9 100644 --- a/src/nat/nat_api.c +++ b/src/nat/nat_api.c | |||
@@ -52,7 +52,7 @@ struct AddrEntry | |||
52 | * Address class of the address. | 52 | * Address class of the address. |
53 | */ | 53 | */ |
54 | enum GNUNET_NAT_AddressClass ac; | 54 | enum GNUNET_NAT_AddressClass ac; |
55 | 55 | ||
56 | /** | 56 | /** |
57 | * Number of bytes that follow. | 57 | * Number of bytes that follow. |
58 | */ | 58 | */ |
@@ -70,7 +70,7 @@ struct GNUNET_NAT_Handle | |||
70 | * Configuration we use. | 70 | * Configuration we use. |
71 | */ | 71 | */ |
72 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 72 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * Message queue for communicating with the NAT service. | 75 | * Message queue for communicating with the NAT service. |
76 | */ | 76 | */ |
@@ -80,7 +80,7 @@ struct GNUNET_NAT_Handle | |||
80 | * Our registration message. | 80 | * Our registration message. |
81 | */ | 81 | */ |
82 | struct GNUNET_MessageHeader *reg; | 82 | struct GNUNET_MessageHeader *reg; |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * Head of address DLL. | 85 | * Head of address DLL. |
86 | */ | 86 | */ |
@@ -95,12 +95,12 @@ struct GNUNET_NAT_Handle | |||
95 | * Function to call when our addresses change. | 95 | * Function to call when our addresses change. |
96 | */ | 96 | */ |
97 | GNUNET_NAT_AddressCallback address_callback; | 97 | GNUNET_NAT_AddressCallback address_callback; |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * Function to call when another peer requests connection reversal. | 100 | * Function to call when another peer requests connection reversal. |
101 | */ | 101 | */ |
102 | GNUNET_NAT_ReversalCallback reversal_callback; | 102 | GNUNET_NAT_ReversalCallback reversal_callback; |
103 | 103 | ||
104 | /** | 104 | /** |
105 | * Closure for the various callbacks. | 105 | * Closure for the various callbacks. |
106 | */ | 106 | */ |
@@ -136,7 +136,7 @@ static void | |||
136 | reconnect (struct GNUNET_NAT_Handle *nh) | 136 | reconnect (struct GNUNET_NAT_Handle *nh) |
137 | { | 137 | { |
138 | struct AddrEntry *ae; | 138 | struct AddrEntry *ae; |
139 | 139 | ||
140 | if (NULL != nh->mq) | 140 | if (NULL != nh->mq) |
141 | { | 141 | { |
142 | GNUNET_MQ_destroy (nh->mq); | 142 | GNUNET_MQ_destroy (nh->mq); |
@@ -184,7 +184,7 @@ check_connection_reversal_request (void *cls, | |||
184 | return GNUNET_OK; | 184 | return GNUNET_OK; |
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||
188 | /** | 188 | /** |
189 | * Handle connection reversal request. | 189 | * Handle connection reversal request. |
190 | * | 190 | * |
@@ -247,7 +247,7 @@ check_address_change_notification (void *cls, | |||
247 | return GNUNET_OK; | 247 | return GNUNET_OK; |
248 | } | 248 | } |
249 | 249 | ||
250 | 250 | ||
251 | /** | 251 | /** |
252 | * Handle connection reversal request. | 252 | * Handle connection reversal request. |
253 | * | 253 | * |
@@ -264,6 +264,8 @@ handle_address_change_notification (void *cls, | |||
264 | enum GNUNET_NAT_AddressClass ac; | 264 | enum GNUNET_NAT_AddressClass ac; |
265 | struct AddrEntry *ae; | 265 | struct AddrEntry *ae; |
266 | 266 | ||
267 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
268 | "Received address change notification\n"); | ||
267 | ac = (enum GNUNET_NAT_AddressClass) ntohl (acn->addr_class); | 269 | ac = (enum GNUNET_NAT_AddressClass) ntohl (acn->addr_class); |
268 | if (GNUNET_YES == ntohl (acn->add_remove)) | 270 | if (GNUNET_YES == ntohl (acn->add_remove)) |
269 | { | 271 | { |
@@ -395,7 +397,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
395 | size_t len; | 397 | size_t len; |
396 | size_t str_len; | 398 | size_t str_len; |
397 | char *off; | 399 | char *off; |
398 | 400 | ||
399 | len = 0; | 401 | len = 0; |
400 | for (unsigned int i=0;i<num_addrs;i++) | 402 | for (unsigned int i=0;i<num_addrs;i++) |
401 | len += addrlens[i]; | 403 | len += addrlens[i]; |
@@ -569,7 +571,7 @@ test_stun_packet (const void *data, | |||
569 | * | 571 | * |
570 | * The function does some basic sanity checks on packet size and | 572 | * The function does some basic sanity checks on packet size and |
571 | * content, try to extract a bit of information. | 573 | * content, try to extract a bit of information. |
572 | * | 574 | * |
573 | * At the moment this only processes BIND requests, and returns the | 575 | * At the moment this only processes BIND requests, and returns the |
574 | * externally visible address of the request to the rest of the | 576 | * externally visible address of the request to the rest of the |
575 | * NAT logic. | 577 | * NAT logic. |
@@ -663,7 +665,7 @@ GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *nh, | |||
663 | * @param nh handle (used for configuration) | 665 | * @param nh handle (used for configuration) |
664 | * @param local_sa our local address of the peer (IPv4-only) | 666 | * @param local_sa our local address of the peer (IPv4-only) |
665 | * @param remote_sa the remote address of the peer (IPv4-only) | 667 | * @param remote_sa the remote address of the peer (IPv4-only) |
666 | * @return #GNUNET_SYSERR on error, | 668 | * @return #GNUNET_SYSERR on error, |
667 | * #GNUNET_NO if connection reversal is unavailable, | 669 | * #GNUNET_NO if connection reversal is unavailable, |
668 | * #GNUNET_OK otherwise (presumably in progress) | 670 | * #GNUNET_OK otherwise (presumably in progress) |
669 | */ | 671 | */ |