glitch in the license text detected by hyazinthe, thank you!
[oweals/gnunet.git] / src / include / gnunet_nat_auto_service.h
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 it
6      under the terms of the GNU Affero General Public License as published
7      by the Free Software Foundation, either version 3 of the License,
8      or (at your 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      Affero General Public License for more details.
14 */
15
16 /**
17  * @author Christian Grothoff
18  * @author Milan Bouchet-Valat
19  *
20  * @file
21  * Service for testing and autoconfiguration of
22  * NAT traversal functionality
23  *
24  * @defgroup nat  NAT testing library
25  *
26  * @{
27  */
28
29 #ifndef GNUNET_NAT_AUTO_SERVICE_H
30 #define GNUNET_NAT_AUTO_SERVICE_H
31
32 #include "gnunet_util_lib.h"
33 #include "gnunet_nat_service.h"
34
35
36 /**
37  * Handle to a NAT test.
38  */
39 struct GNUNET_NAT_AUTO_Test;
40
41
42 /**
43  * Start testing if NAT traversal works using the given configuration.
44  *  The transport adapters should be down while using this function.
45  *
46  * @param cfg configuration for the NAT traversal
47  * @param proto protocol to test, i.e. IPPROTO_TCP or IPPROTO_UDP
48  * @param section_name configuration section to use for configuration
49  * @param report function to call with the result of the test
50  * @param report_cls closure for @a report
51  * @return handle to cancel NAT test
52  */
53 struct GNUNET_NAT_AUTO_Test *
54 GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
55                             uint8_t proto,
56                             const char *section_name,
57                             GNUNET_NAT_TestCallback report,
58                             void *report_cls);
59
60
61 /**
62  * Stop an active NAT test.
63  *
64  * @param tst test to stop.
65  */
66 void
67 GNUNET_NAT_AUTO_test_stop (struct GNUNET_NAT_AUTO_Test *tst);
68
69
70 /**
71  * Handle to auto-configuration in progress.
72  */
73 struct GNUNET_NAT_AUTO_AutoHandle;
74
75
76 /**
77  * Converts `enum GNUNET_NAT_StatusCode` to string
78  *
79  * @param err error code to resolve to a string
80  * @return point to a static string containing the error code
81  */
82 const char *
83 GNUNET_NAT_AUTO_status2string (enum GNUNET_NAT_StatusCode err);
84
85
86 /**
87  * Function called with the result from the autoconfiguration.
88  *
89  * @param cls closure
90  * @param diff minimal suggested changes to the original configuration
91  *             to make it work (as best as we can)
92  * @param result #GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code
93  * @param type what the situation of the NAT
94  */
95 typedef void
96 (*GNUNET_NAT_AUTO_AutoResultCallback)(void *cls,
97                                       const struct GNUNET_CONFIGURATION_Handle *diff,
98                                       enum GNUNET_NAT_StatusCode result,
99                                       enum GNUNET_NAT_Type type);
100
101
102 /**
103  * Start auto-configuration routine.  The transport adapters should
104  * be stopped while this function is called.
105  *
106  * @param cfg initial configuration
107  * @param cb function to call with autoconfiguration result
108  * @param cb_cls closure for @a cb
109  * @return handle to cancel operation
110  */
111 struct GNUNET_NAT_AUTO_AutoHandle *
112 GNUNET_NAT_AUTO_autoconfig_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
113                                   GNUNET_NAT_AUTO_AutoResultCallback cb,
114                                   void *cb_cls);
115
116
117 /**
118  * Abort autoconfiguration.
119  *
120  * @param ah handle for operation to abort
121  */
122 void
123 GNUNET_NAT_AUTO_autoconfig_cancel (struct GNUNET_NAT_AUTO_AutoHandle *ah);
124
125
126 #endif
127
128 /** @} */  /* end of group */
129
130 /* end of gnunet_nat_auto_service.h */