summaryrefslogtreecommitdiff
path: root/src/include/gnunet_nat_auto_service.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_nat_auto_service.h')
-rw-r--r--src/include/gnunet_nat_auto_service.h135
1 files changed, 135 insertions, 0 deletions
diff --git a/src/include/gnunet_nat_auto_service.h b/src/include/gnunet_nat_auto_service.h
new file mode 100644
index 000000000..a369c49e0
--- /dev/null
+++ b/src/include/gnunet_nat_auto_service.h
@@ -0,0 +1,135 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2007-2017 GNUnet e.V.
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21/**
22 * @author Christian Grothoff
23 * @author Milan Bouchet-Valat
24 *
25 * @file
26 * Service for testing and autoconfiguration of
27 * NAT traversal functionality
28 *
29 * @defgroup nat NAT testing library
30 *
31 * @{
32 */
33
34#ifndef GNUNET_NAT_AUTO_SERVICE_H
35#define GNUNET_NAT_AUTO_SERVICE_H
36
37#include "gnunet_util_lib.h"
38#include "gnunet_nat_service.h"
39
40
41/**
42 * Handle to a NAT test.
43 */
44struct GNUNET_NAT_AUTO_Test;
45
46
47/**
48 * Start testing if NAT traversal works using the given configuration.
49 * The transport adapters should be down while using this function.
50 *
51 * @param cfg configuration for the NAT traversal
52 * @param proto protocol to test, i.e. IPPROTO_TCP or IPPROTO_UDP
53 * @param section_name configuration section to use for configuration
54 * @param report function to call with the result of the test
55 * @param report_cls closure for @a report
56 * @return handle to cancel NAT test
57 */
58struct GNUNET_NAT_AUTO_Test *
59GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
60 uint8_t proto,
61 const char *section_name,
62 GNUNET_NAT_TestCallback report,
63 void *report_cls);
64
65
66/**
67 * Stop an active NAT test.
68 *
69 * @param tst test to stop.
70 */
71void
72GNUNET_NAT_AUTO_test_stop (struct GNUNET_NAT_AUTO_Test *tst);
73
74
75/**
76 * Handle to auto-configuration in progress.
77 */
78struct GNUNET_NAT_AUTO_AutoHandle;
79
80
81/**
82 * Converts `enum GNUNET_NAT_StatusCode` to string
83 *
84 * @param err error code to resolve to a string
85 * @return point to a static string containing the error code
86 */
87const char *
88GNUNET_NAT_AUTO_status2string (enum GNUNET_NAT_StatusCode err);
89
90
91/**
92 * Function called with the result from the autoconfiguration.
93 *
94 * @param cls closure
95 * @param diff minimal suggested changes to the original configuration
96 * to make it work (as best as we can)
97 * @param result #GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code
98 * @param type what the situation of the NAT
99 */
100typedef void
101(*GNUNET_NAT_AUTO_AutoResultCallback)(void *cls,
102 const struct GNUNET_CONFIGURATION_Handle *diff,
103 enum GNUNET_NAT_StatusCode result,
104 enum GNUNET_NAT_Type type);
105
106
107/**
108 * Start auto-configuration routine. The transport adapters should
109 * be stopped while this function is called.
110 *
111 * @param cfg initial configuration
112 * @param cb function to call with autoconfiguration result
113 * @param cb_cls closure for @a cb
114 * @return handle to cancel operation
115 */
116struct GNUNET_NAT_AUTO_AutoHandle *
117GNUNET_NAT_AUTO_autoconfig_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
118 GNUNET_NAT_AUTO_AutoResultCallback cb,
119 void *cb_cls);
120
121
122/**
123 * Abort autoconfiguration.
124 *
125 * @param ah handle for operation to abort
126 */
127void
128GNUNET_NAT_AUTO_autoconfig_cancel (struct GNUNET_NAT_AUTO_AutoHandle *ah);
129
130
131#endif
132
133/** @} */ /* end of group */
134
135/* end of gnunet_nat_auto_service.h */