aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2014-05-19 12:03:26 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2014-05-19 12:03:26 +0000
commit7528bcf5a5af0d90c06aeab964e5c6471900ae06 (patch)
tree24d181f1ae50e2cca9a2dcd49e90278e0a4389d7 /src/include
parent26c076220f09adcbb79ba296985b78deeb53dd9a (diff)
downloadgnunet-7528bcf5a5af0d90c06aeab964e5c6471900ae06.tar.gz
gnunet-7528bcf5a5af0d90c06aeab964e5c6471900ae06.zip
- updated NAT callback function defintion to no longer carry around strings,
- NAT lib now uses error-code enums to signal success and errors - reworked related code to return errorcodes - added and updated a missing doxygen documention - todo next: testcases
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_nat_lib.h69
1 files changed, 58 insertions, 11 deletions
diff --git a/src/include/gnunet_nat_lib.h b/src/include/gnunet_nat_lib.h
index d012353b5..40a5135bd 100644
--- a/src/include/gnunet_nat_lib.h
+++ b/src/include/gnunet_nat_lib.h
@@ -71,6 +71,56 @@ struct GNUNET_NAT_Handle;
71 71
72 72
73/** 73/**
74 * Error Types for the NAT subsystem (which can then later be converted/resolved to a string)
75 */
76enum GNUNET_NAT_FailureCode {
77 /**
78 * Just the default
79 */
80 GNUNET_NAT_ERROR_SUCCESS = 0,
81
82 /**
83 * `upnpc` command not found
84 */
85 GNUNET_NAT_ERROR_UPNPC_NOT_FOUND,
86
87 /**
88 * Failed to run `upnpc` command
89 */
90 GNUNET_NAT_ERROR_UPNPC_FAILED,
91
92 /**
93 * `upnpc' command took too long, process killed
94 */
95 GNUNET_NAT_ERROR_UPNPC_TIMEOUT,
96
97 /**
98 * `upnpc' command failed to establish port mapping
99 */
100 GNUNET_NAT_ERROR_UPNPC_PORTMAP_FAILED,
101
102 /**
103 * `external-ip' command not found
104 */
105 GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_NOT_FOUND,
106
107 /**
108 * "no valid address was returned by `external-ip'"
109 */
110 GNUNET_NAT_ERROR_EXTERNAL_IP_NO_VALID_ADDRESS_FOUND,
111
112
113
114 /**
115 *
116 */
117 GNUNET_NAT_ERROR_,
118
119
120};
121
122
123/**
74 * Attempt to enable port redirection and detect public IP address 124 * Attempt to enable port redirection and detect public IP address
75 * contacting UPnP or NAT-PMP routers on the local network. Use addr 125 * contacting UPnP or NAT-PMP routers on the local network. Use addr
76 * to specify to which of the local host's addresses should the 126 * to specify to which of the local host's addresses should the
@@ -157,14 +207,10 @@ struct GNUNET_NAT_Test;
157 * NAT configuration test. 207 * NAT configuration test.
158 * 208 *
159 * @param cls closure 209 * @param cls closure
160 * @param success #GNUNET_OK on success, #GNUNET_NO on failure, 210 * @param result GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code
161 * #GNUNET_SYSERR if the test could not be
162 * properly started (internal failure)
163 * @param emsg NULL on success, otherwise may include an error message
164 */ 211 */
165typedef void (*GNUNET_NAT_TestCallback) (void *cls, 212typedef void (*GNUNET_NAT_TestCallback) (void *cls,
166 int success, 213 enum GNUNET_NAT_FailureCode result);
167 const char *emsg);
168 214
169 215
170/** 216/**
@@ -202,11 +248,11 @@ GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst);
202 * 248 *
203 * @param cls closure 249 * @param cls closure
204 * @param addr the address, NULL on errors 250 * @param addr the address, NULL on errors
205 * @param emsg NULL on success, otherwise may include an error message 251 * @param result GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code
206 */ 252 */
207typedef void (*GNUNET_NAT_IPCallback) (void *cls, 253typedef void (*GNUNET_NAT_IPCallback) (void *cls,
208 const struct in_addr *addr, 254 const struct in_addr *addr,
209 const char *emsg); 255 enum GNUNET_NAT_FailureCode result);
210 256
211 257
212 258
@@ -254,13 +300,14 @@ struct GNUNET_NAT_MiniHandle;
254 * the previous (now invalid) one 300 * the previous (now invalid) one
255 * @param addr either the previous or the new public IP address 301 * @param addr either the previous or the new public IP address
256 * @param addrlen actual length of the @a addr 302 * @param addrlen actual length of the @a addr
303 * @param result GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code
257 */ 304 */
258typedef void 305typedef void
259(*GNUNET_NAT_MiniAddressCallback) (void *cls, 306(*GNUNET_NAT_MiniAddressCallback) (void *cls,
260 int add_remove, 307 int add_remove,
261 const struct sockaddr *addr, 308 const struct sockaddr *addr,
262 socklen_t addrlen, 309 socklen_t addrlen,
263 const char *emsg); 310 enum GNUNET_NAT_FailureCode result);
264 311
265 312
266/** 313/**
@@ -307,12 +354,12 @@ struct GNUNET_NAT_AutoHandle;
307 * @param cls closure 354 * @param cls closure
308 * @param diff minimal suggested changes to the original configuration 355 * @param diff minimal suggested changes to the original configuration
309 * to make it work (as best as we can) 356 * to make it work (as best as we can)
310 * @param emsg NULL on success, otherwise may include an error message 357 * @param result GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code
311 */ 358 */
312typedef void 359typedef void
313(*GNUNET_NAT_AutoResultCallback)(void *cls, 360(*GNUNET_NAT_AutoResultCallback)(void *cls,
314 const struct GNUNET_CONFIGURATION_Handle *diff, 361 const struct GNUNET_CONFIGURATION_Handle *diff,
315 const char *emsg); 362 enum GNUNET_NAT_FailureCode result);
316 363
317 364
318/** 365/**