diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nat-auto/Makefile.am | 2 | ||||
-rw-r--r-- | src/nat-auto/gnunet-nat-server.c | 39 |
2 files changed, 28 insertions, 13 deletions
diff --git a/src/nat-auto/Makefile.am b/src/nat-auto/Makefile.am index dbe910306..19695fabd 100644 --- a/src/nat-auto/Makefile.am +++ b/src/nat-auto/Makefile.am | |||
@@ -18,7 +18,7 @@ libexec_PROGRAMS = \ | |||
18 | gnunet_nat_server_SOURCES = \ | 18 | gnunet_nat_server_SOURCES = \ |
19 | gnunet-nat-server.c nat-auto.h | 19 | gnunet-nat-server.c nat-auto.h |
20 | gnunet_nat_server_LDADD = \ | 20 | gnunet_nat_server_LDADD = \ |
21 | $(top_builddir)/src/nat/libgnunetnat.la \ | 21 | $(top_builddir)/src/nat/libgnunetnatnew.la \ |
22 | $(top_builddir)/src/util/libgnunetutil.la | 22 | $(top_builddir)/src/util/libgnunetutil.la |
23 | 23 | ||
24 | gnunet_nat_auto_SOURCES = \ | 24 | gnunet_nat_auto_SOURCES = \ |
diff --git a/src/nat-auto/gnunet-nat-server.c b/src/nat-auto/gnunet-nat-server.c index d98a7a55e..dd08f8d36 100644 --- a/src/nat-auto/gnunet-nat-server.c +++ b/src/nat-auto/gnunet-nat-server.c | |||
@@ -25,7 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_nat_lib.h" | 28 | #include "gnunet_nat_service.h" |
29 | #include "gnunet_protocols.h" | 29 | #include "gnunet_protocols.h" |
30 | #include "nat-auto.h" | 30 | #include "nat-auto.h" |
31 | 31 | ||
@@ -54,24 +54,39 @@ try_anat (uint32_t dst_ipv4, | |||
54 | int is_tcp) | 54 | int is_tcp) |
55 | { | 55 | { |
56 | struct GNUNET_NAT_Handle *h; | 56 | struct GNUNET_NAT_Handle *h; |
57 | struct sockaddr_in sa; | 57 | struct sockaddr_in lsa; |
58 | struct sockaddr_in rsa; | ||
59 | socklen_t sa_len; | ||
58 | 60 | ||
59 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 61 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
60 | "Asking for connection reversal with %x and code %u\n", | 62 | "Asking for connection reversal with %x and code %u\n", |
61 | (unsigned int) dst_ipv4, | 63 | (unsigned int) dst_ipv4, |
62 | (unsigned int) dport); | 64 | (unsigned int) dport); |
63 | h = GNUNET_NAT_register (cfg, | 65 | memset (&lsa, 0, sizeof (lsa)); |
64 | is_tcp, | 66 | lsa.sin_family = AF_INET; |
65 | dport, | ||
66 | 0, | ||
67 | NULL, NULL, NULL, NULL, NULL, NULL); | ||
68 | memset (&sa, 0, sizeof (sa)); | ||
69 | sa.sin_family = AF_INET; | ||
70 | #if HAVE_SOCKADDR_IN_SIN_LEN | 67 | #if HAVE_SOCKADDR_IN_SIN_LEN |
71 | sa.sin_len = sizeof (sa); | 68 | lsa.sin_len = sizeof (sa); |
72 | #endif | 69 | #endif |
73 | sa.sin_addr.s_addr = dst_ipv4; | 70 | lsa.sin_addr.s_addr = 0; |
74 | GNUNET_NAT_run_client (h, &sa); | 71 | lsa.sin_port = htons (dport); |
72 | memset (&rsa, 0, sizeof (rsa)); | ||
73 | rsa.sin_family = AF_INET; | ||
74 | #if HAVE_SOCKADDR_IN_SIN_LEN | ||
75 | rsa.sin_len = sizeof (sa); | ||
76 | #endif | ||
77 | rsa.sin_addr.s_addr = dst_ipv4; | ||
78 | rsa.sin_port = htons (dport); | ||
79 | sa_len = sizeof (lsa); | ||
80 | h = GNUNET_NAT_register (cfg, | ||
81 | "none", | ||
82 | is_tcp ? IPPROTO_TCP : IPPROTO_UDP, | ||
83 | 1, | ||
84 | (const struct sockaddr **) &lsa, | ||
85 | &sa_len, | ||
86 | NULL, NULL, NULL); | ||
87 | GNUNET_NAT_request_reversal (h, | ||
88 | &lsa, | ||
89 | &rsa); | ||
75 | GNUNET_NAT_unregister (h); | 90 | GNUNET_NAT_unregister (h); |
76 | } | 91 | } |
77 | 92 | ||