diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-01-07 05:14:12 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-01-07 05:14:12 +0000 |
commit | 9e0744da3a82cc7b68a9043272044584be98db44 (patch) | |
tree | 0d66dcff21faddda56c57f6768f7fee49649366a /src/include | |
parent | 1ab001d527da02fbf9a7212497c162a979aa8f6b (diff) | |
download | gnunet-9e0744da3a82cc7b68a9043272044584be98db44.tar.gz gnunet-9e0744da3a82cc7b68a9043272044584be98db44.zip |
-modify NAT API to return error messages about problems detected
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_nat_lib.h | 76 |
1 files changed, 55 insertions, 21 deletions
diff --git a/src/include/gnunet_nat_lib.h b/src/include/gnunet_nat_lib.h index 0c416d3d6..d012353b5 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, 2011, 2012 Christian Grothoff (and other contributing authors) | 3 | (C) 2007-2014 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 |
@@ -22,7 +22,7 @@ | |||
22 | * @file include/gnunet_nat_lib.h | 22 | * @file include/gnunet_nat_lib.h |
23 | * @brief Library handling UPnP and NAT-PMP port forwarding and | 23 | * @brief Library handling UPnP and NAT-PMP port forwarding and |
24 | * external IP address retrieval | 24 | * external IP address retrieval |
25 | * | 25 | * @author Christian Grothoff |
26 | * @author Milan Bouchet-Valat | 26 | * @author Milan Bouchet-Valat |
27 | */ | 27 | */ |
28 | 28 | ||
@@ -31,6 +31,7 @@ | |||
31 | 31 | ||
32 | #include "gnunet_util_lib.h" | 32 | #include "gnunet_util_lib.h" |
33 | 33 | ||
34 | |||
34 | /** | 35 | /** |
35 | * Signature of the callback passed to #GNUNET_NAT_register() for | 36 | * Signature of the callback passed to #GNUNET_NAT_register() for |
36 | * a function to call whenever our set of 'valid' addresses changes. | 37 | * a function to call whenever our set of 'valid' addresses changes. |
@@ -41,9 +42,11 @@ | |||
41 | * @param addr either the previous or the new public IP address | 42 | * @param addr either the previous or the new public IP address |
42 | * @param addrlen actual length of the @a addr | 43 | * @param addrlen actual length of the @a addr |
43 | */ | 44 | */ |
44 | typedef void (*GNUNET_NAT_AddressCallback) (void *cls, int add_remove, | 45 | typedef void |
45 | const struct sockaddr *addr, | 46 | (*GNUNET_NAT_AddressCallback) (void *cls, |
46 | socklen_t addrlen); | 47 | int add_remove, |
48 | const struct sockaddr *addr, | ||
49 | socklen_t addrlen); | ||
47 | 50 | ||
48 | 51 | ||
49 | /** | 52 | /** |
@@ -55,9 +58,10 @@ typedef void (*GNUNET_NAT_AddressCallback) (void *cls, int add_remove, | |||
55 | * @param addr public IP address of the other peer | 58 | * @param addr public IP address of the other peer |
56 | * @param addrlen actual lenght of the @a addr | 59 | * @param addrlen actual lenght of the @a addr |
57 | */ | 60 | */ |
58 | typedef void (*GNUNET_NAT_ReversalCallback) (void *cls, | 61 | typedef void |
59 | const struct sockaddr *addr, | 62 | (*GNUNET_NAT_ReversalCallback) (void *cls, |
60 | socklen_t addrlen); | 63 | const struct sockaddr *addr, |
64 | socklen_t addrlen); | ||
61 | 65 | ||
62 | 66 | ||
63 | /** | 67 | /** |
@@ -67,11 +71,12 @@ struct GNUNET_NAT_Handle; | |||
67 | 71 | ||
68 | 72 | ||
69 | /** | 73 | /** |
70 | * Attempt to enable port redirection and detect public IP address contacting | 74 | * Attempt to enable port redirection and detect public IP address |
71 | * UPnP or NAT-PMP routers on the local network. Use addr to specify to which | 75 | * contacting UPnP or NAT-PMP routers on the local network. Use addr |
72 | * of the local host's addresses should the external port be mapped. The port | 76 | * to specify to which of the local host's addresses should the |
73 | * is taken from the corresponding sockaddr_in[6] field. The NAT module | 77 | * external port be mapped. The port is taken from the corresponding |
74 | * should call the given callback for any 'plausible' external address. | 78 | * sockaddr_in[6] field. The NAT module should call the given |
79 | * callback for any 'plausible' external address. | ||
75 | * | 80 | * |
76 | * @param cfg configuration to use | 81 | * @param cfg configuration to use |
77 | * @param is_tcp #GNUNET_YES for TCP, #GNUNET_NO for UDP | 82 | * @param is_tcp #GNUNET_YES for TCP, #GNUNET_NO for UDP |
@@ -99,7 +104,8 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
99 | 104 | ||
100 | 105 | ||
101 | /** | 106 | /** |
102 | * Test if the given address is (currently) a plausible IP address for this peer. | 107 | * Test if the given address is (currently) a plausible IP address for |
108 | * this peer. | ||
103 | * | 109 | * |
104 | * @param h the handle returned by register | 110 | * @param h the handle returned by register |
105 | * @param addr IP address to test (IPv4 or IPv6) | 111 | * @param addr IP address to test (IPv4 or IPv6) |
@@ -154,8 +160,12 @@ struct GNUNET_NAT_Test; | |||
154 | * @param success #GNUNET_OK on success, #GNUNET_NO on failure, | 160 | * @param success #GNUNET_OK on success, #GNUNET_NO on failure, |
155 | * #GNUNET_SYSERR if the test could not be | 161 | * #GNUNET_SYSERR if the test could not be |
156 | * properly started (internal failure) | 162 | * properly started (internal failure) |
163 | * @param emsg NULL on success, otherwise may include an error message | ||
157 | */ | 164 | */ |
158 | typedef void (*GNUNET_NAT_TestCallback) (void *cls, int success); | 165 | typedef void (*GNUNET_NAT_TestCallback) (void *cls, |
166 | int success, | ||
167 | const char *emsg); | ||
168 | |||
159 | 169 | ||
160 | /** | 170 | /** |
161 | * Start testing if NAT traversal works using the | 171 | * Start testing if NAT traversal works using the |
@@ -192,9 +202,11 @@ GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst); | |||
192 | * | 202 | * |
193 | * @param cls closure | 203 | * @param cls closure |
194 | * @param addr the address, NULL on errors | 204 | * @param addr the address, NULL on errors |
205 | * @param emsg NULL on success, otherwise may include an error message | ||
195 | */ | 206 | */ |
196 | typedef void (*GNUNET_NAT_IPCallback) (void *cls, | 207 | typedef void (*GNUNET_NAT_IPCallback) (void *cls, |
197 | const struct in_addr * addr); | 208 | const struct in_addr *addr, |
209 | const char *emsg); | ||
198 | 210 | ||
199 | 211 | ||
200 | 212 | ||
@@ -234,6 +246,24 @@ struct GNUNET_NAT_MiniHandle; | |||
234 | 246 | ||
235 | 247 | ||
236 | /** | 248 | /** |
249 | * Signature of the callback passed to #GNUNET_NAT_register() for | ||
250 | * a function to call whenever our set of 'valid' addresses changes. | ||
251 | * | ||
252 | * @param cls closure | ||
253 | * @param add_remove #GNUNET_YES to mean the new public IP address, #GNUNET_NO to mean | ||
254 | * the previous (now invalid) one | ||
255 | * @param addr either the previous or the new public IP address | ||
256 | * @param addrlen actual length of the @a addr | ||
257 | */ | ||
258 | typedef void | ||
259 | (*GNUNET_NAT_MiniAddressCallback) (void *cls, | ||
260 | int add_remove, | ||
261 | const struct sockaddr *addr, | ||
262 | socklen_t addrlen, | ||
263 | const char *emsg); | ||
264 | |||
265 | |||
266 | /** | ||
237 | * Start mapping the given port using (mini)upnpc. This function | 267 | * Start mapping the given port using (mini)upnpc. This function |
238 | * should typically not be used directly (it is used within the | 268 | * should typically not be used directly (it is used within the |
239 | * general-purpose #GNUNET_NAT_register() code). However, it can be | 269 | * general-purpose #GNUNET_NAT_register() code). However, it can be |
@@ -247,14 +277,15 @@ struct GNUNET_NAT_MiniHandle; | |||
247 | * @return NULL on error | 277 | * @return NULL on error |
248 | */ | 278 | */ |
249 | struct GNUNET_NAT_MiniHandle * | 279 | struct GNUNET_NAT_MiniHandle * |
250 | GNUNET_NAT_mini_map_start (uint16_t port, int is_tcp, | 280 | GNUNET_NAT_mini_map_start (uint16_t port, |
251 | GNUNET_NAT_AddressCallback ac, | 281 | int is_tcp, |
282 | GNUNET_NAT_MiniAddressCallback ac, | ||
252 | void *ac_cls); | 283 | void *ac_cls); |
253 | 284 | ||
254 | 285 | ||
255 | /** | 286 | /** |
256 | * Remove a mapping created with (mini)upnpc. Calling | 287 | * Remove a mapping created with (mini)upnpc. Calling |
257 | * this function will give 'upnpc' 1s to remove tha mapping, | 288 | * this function will give 'upnpc' 1s to remove the mapping, |
258 | * so while this function is non-blocking, a task will be | 289 | * so while this function is non-blocking, a task will be |
259 | * left with the scheduler for up to 1s past this call. | 290 | * left with the scheduler for up to 1s past this call. |
260 | * | 291 | * |
@@ -276,9 +307,12 @@ struct GNUNET_NAT_AutoHandle; | |||
276 | * @param cls closure | 307 | * @param cls closure |
277 | * @param diff minimal suggested changes to the original configuration | 308 | * @param diff minimal suggested changes to the original configuration |
278 | * to make it work (as best as we can) | 309 | * to make it work (as best as we can) |
310 | * @param emsg NULL on success, otherwise may include an error message | ||
279 | */ | 311 | */ |
280 | typedef void (*GNUNET_NAT_AutoResultCallback)(void *cls, | 312 | typedef void |
281 | const struct GNUNET_CONFIGURATION_Handle *diff); | 313 | (*GNUNET_NAT_AutoResultCallback)(void *cls, |
314 | const struct GNUNET_CONFIGURATION_Handle *diff, | ||
315 | const char *emsg); | ||
282 | 316 | ||
283 | 317 | ||
284 | /** | 318 | /** |