aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-07-01 10:38:08 +0000
committerChristian Grothoff <christian@grothoff.org>2011-07-01 10:38:08 +0000
commit34679adf5a4d083ddd39da805e7509429fed7f45 (patch)
tree239e80ae7083771dcfc484edc68d846471a11ba5 /src
parentc3cc0ccbc05fb74d7c744dd3482e8cbb5726315b (diff)
downloadgnunet-34679adf5a4d083ddd39da805e7509429fed7f45.tar.gz
gnunet-34679adf5a4d083ddd39da805e7509429fed7f45.zip
draft for NAT_test API
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_nat_lib.h50
-rw-r--r--src/nat/Makefile.am2
-rw-r--r--src/nat/gnunet-nat-server.c1
-rw-r--r--src/nat/nat_test.c78
4 files changed, 128 insertions, 3 deletions
diff --git a/src/include/gnunet_nat_lib.h b/src/include/gnunet_nat_lib.h
index 9550bb1e3..07f6ca5e8 100644
--- a/src/include/gnunet_nat_lib.h
+++ b/src/include/gnunet_nat_lib.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2007, 2008, 2009, 2010 Christian Grothoff (and other contributing authors) 3 (C) 2007, 2008, 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -138,6 +138,54 @@ GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h,
138void 138void
139GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h); 139GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h);
140 140
141
142/**
143 * Handle to a NAT test.
144 */
145struct GNUNET_NAT_Test;
146
147/**
148 * Function called to report success or failure for
149 * NAT configuration test.
150 *
151 * @param cls closure
152 * @param success GNUNET_OK on success, GNUNET_NO on failure,
153 * GNUNET_SYSERR if the test could not be
154 * properly started (internal failure)
155 */
156typedef void (*GNUNET_NAT_TestCallback)(void *cls,
157 int success);
158
159/**
160 * Start testing if NAT traversal works using the
161 * given configuration (IPv4-only).
162 *
163 * @param cfg configuration for the NAT traversal
164 * @param is_tcp GNUNET_YES to test TCP, GNUNET_NO to test UDP
165 * @param bnd_port port to bind to
166 * @param adv_port externally advertised port to use
167 * @param report function to call with the result of the test
168 * @param report_cls closure for report
169 * @return handle to cancel NAT test
170 */
171struct GNUNET_NAT_Test *
172GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
173 int is_tcp,
174 uint16_t bnd_port,
175 uint16_t adv_port,
176 GNUNET_NAT_TestCallback report,
177 void *report_cls);
178
179
180/**
181 * Stop an active NAT test.
182 *
183 * @param tst test to stop.
184 */
185void
186GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst);
187
188
141#endif 189#endif
142 190
143/* end of gnunet_nat_lib.h */ 191/* end of gnunet_nat_lib.h */
diff --git a/src/nat/Makefile.am b/src/nat/Makefile.am
index 75798a252..7b738df4e 100644
--- a/src/nat/Makefile.am
+++ b/src/nat/Makefile.am
@@ -43,7 +43,7 @@ endif
43lib_LTLIBRARIES = libgnunetnat.la 43lib_LTLIBRARIES = libgnunetnat.la
44 44
45libgnunetnat_la_SOURCES = \ 45libgnunetnat_la_SOURCES = \
46 nat.c 46 nat.c nat_test.c nat.h
47 47
48libgnunetnat_la_LIBADD = \ 48libgnunetnat_la_LIBADD = \
49 $(top_builddir)/src/util/libgnunetutil.la \ 49 $(top_builddir)/src/util/libgnunetutil.la \
diff --git a/src/nat/gnunet-nat-server.c b/src/nat/gnunet-nat-server.c
index ae831db08..f2508a94a 100644
--- a/src/nat/gnunet-nat-server.c
+++ b/src/nat/gnunet-nat-server.c
@@ -22,7 +22,6 @@
22 * @file src/nat/gnunet-nat-server.c 22 * @file src/nat/gnunet-nat-server.c
23 * @brief Daemon to run on 'gnunet.org' to help test NAT traversal code 23 * @brief Daemon to run on 'gnunet.org' to help test NAT traversal code
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 *
26 */ 25 */
27#include "platform.h" 26#include "platform.h"
28#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
diff --git a/src/nat/nat_test.c b/src/nat/nat_test.c
new file mode 100644
index 000000000..f31c5059d
--- /dev/null
+++ b/src/nat/nat_test.c
@@ -0,0 +1,78 @@
1/*
2 This file is part of GNUnet.
3 (C) 2011 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file nat/nat_test.c
23 * @brief functions to test if the NAT configuration is successful at achieving NAT traversal (with the help of a gnunet-nat-server)
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_nat_lib.h"
29#include "nat.h"
30
31
32/**
33 * Handle to a NAT test.
34 */
35struct GNUNET_NAT_Test
36{
37 GNUNET_NAT_TestCallback report;
38
39 void *report_cls;
40};
41
42
43/**
44 * Start testing if NAT traversal works using the
45 * given configuration (IPv4-only).
46 *
47 * @param cfg configuration for the NAT traversal
48 * @param is_tcp GNUNET_YES to test TCP, GNUNET_NO to test UDP
49 * @param bnd_port port to bind to
50 * @param adv_port externally advertised port to use
51 * @param report function to call with the result of the test
52 * @param report_cls closure for report
53 * @return handle to cancel NAT test
54 */
55struct GNUNET_NAT_Test *
56GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
57 int is_tcp,
58 uint16_t bnd_port,
59 uint16_t adv_port,
60 GNUNET_NAT_TestCallback report,
61 void *report_cls)
62{
63 return NULL;
64}
65
66
67/**
68 * Stop an active NAT test.
69 *
70 * @param tst test to stop.
71 */
72void
73GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst)
74{
75 GNUNET_free (tst);
76}
77
78/* end of nat_test.c */