summaryrefslogtreecommitdiff
path: root/src/nat-auto
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-01-07 16:36:36 +0100
committerChristian Grothoff <christian@grothoff.org>2017-01-07 16:36:36 +0100
commit659e270f9e023112ca864065a22db5e484ba5ef6 (patch)
tree80ba6279b3e584a208b74b4a84956dfda92e390b /src/nat-auto
parentaf3af9eee2a0e4b2791d8c5f6b60d3eb943a1be2 (diff)
migrate gnunet-nat-server to new NAT lib
Diffstat (limited to 'src/nat-auto')
-rw-r--r--src/nat-auto/Makefile.am2
-rw-r--r--src/nat-auto/gnunet-nat-server.c39
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 = \
gnunet_nat_server_SOURCES = \
gnunet-nat-server.c nat-auto.h
gnunet_nat_server_LDADD = \
- $(top_builddir)/src/nat/libgnunetnat.la \
+ $(top_builddir)/src/nat/libgnunetnatnew.la \
$(top_builddir)/src/util/libgnunetutil.la
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 @@
*/
#include "platform.h"
#include "gnunet_util_lib.h"
-#include "gnunet_nat_lib.h"
+#include "gnunet_nat_service.h"
#include "gnunet_protocols.h"
#include "nat-auto.h"
@@ -54,24 +54,39 @@ try_anat (uint32_t dst_ipv4,
int is_tcp)
{
struct GNUNET_NAT_Handle *h;
- struct sockaddr_in sa;
+ struct sockaddr_in lsa;
+ struct sockaddr_in rsa;
+ socklen_t sa_len;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asking for connection reversal with %x and code %u\n",
(unsigned int) dst_ipv4,
(unsigned int) dport);
- h = GNUNET_NAT_register (cfg,
- is_tcp,
- dport,
- 0,
- NULL, NULL, NULL, NULL, NULL, NULL);
- memset (&sa, 0, sizeof (sa));
- sa.sin_family = AF_INET;
+ memset (&lsa, 0, sizeof (lsa));
+ lsa.sin_family = AF_INET;
#if HAVE_SOCKADDR_IN_SIN_LEN
- sa.sin_len = sizeof (sa);
+ lsa.sin_len = sizeof (sa);
#endif
- sa.sin_addr.s_addr = dst_ipv4;
- GNUNET_NAT_run_client (h, &sa);
+ lsa.sin_addr.s_addr = 0;
+ lsa.sin_port = htons (dport);
+ memset (&rsa, 0, sizeof (rsa));
+ rsa.sin_family = AF_INET;
+#if HAVE_SOCKADDR_IN_SIN_LEN
+ rsa.sin_len = sizeof (sa);
+#endif
+ rsa.sin_addr.s_addr = dst_ipv4;
+ rsa.sin_port = htons (dport);
+ sa_len = sizeof (lsa);
+ h = GNUNET_NAT_register (cfg,
+ "none",
+ is_tcp ? IPPROTO_TCP : IPPROTO_UDP,
+ 1,
+ (const struct sockaddr **) &lsa,
+ &sa_len,
+ NULL, NULL, NULL);
+ GNUNET_NAT_request_reversal (h,
+ &lsa,
+ &rsa);
GNUNET_NAT_unregister (h);
}