diff options
Diffstat (limited to 'src/service/nat/gnunet-service-nat_helper.h')
-rw-r--r-- | src/service/nat/gnunet-service-nat_helper.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/service/nat/gnunet-service-nat_helper.h b/src/service/nat/gnunet-service-nat_helper.h new file mode 100644 index 000000000..dc6b9ae61 --- /dev/null +++ b/src/service/nat/gnunet-service-nat_helper.h | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2009, 2010, 2011, 2016 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 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file nat/gnunet-service-nat_helper.h | ||
23 | * @brief runs the gnunet-helper-nat-server | ||
24 | * @author Milan Bouchet-Valat | ||
25 | * @author Christian Grothoff | ||
26 | */ | ||
27 | #include "platform.h" | ||
28 | #include "gnunet_util_lib.h" | ||
29 | |||
30 | |||
31 | /** | ||
32 | * Information we keep per NAT helper process. | ||
33 | */ | ||
34 | struct HelperContext; | ||
35 | |||
36 | |||
37 | /** | ||
38 | * Function called whenever we get a connection reversal | ||
39 | * request from another peer. | ||
40 | * | ||
41 | * @param cls closure | ||
42 | * @param ra IP address of the peer who wants us to connect to it | ||
43 | */ | ||
44 | typedef void | ||
45 | (*GN_ReversalCallback) (void *cls, | ||
46 | const struct sockaddr_in *ra); | ||
47 | |||
48 | |||
49 | /** | ||
50 | * Start the gnunet-helper-nat-server and process incoming | ||
51 | * requests. | ||
52 | * | ||
53 | * @param internal_address | ||
54 | * @param cb function to call if we receive a request | ||
55 | * @param cb_cls closure for @a cb | ||
56 | * @param cfg handle to the GNUnet configuration | ||
57 | * @return NULL on error | ||
58 | */ | ||
59 | struct HelperContext * | ||
60 | GN_start_gnunet_nat_server_ (const struct in_addr *internal_address, | ||
61 | GN_ReversalCallback cb, | ||
62 | void *cb_cls, | ||
63 | const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
64 | |||
65 | |||
66 | /** | ||
67 | * Start the gnunet-helper-nat-server and process incoming | ||
68 | * requests. | ||
69 | * | ||
70 | * @param h helper context to stop | ||
71 | */ | ||
72 | void | ||
73 | GN_stop_gnunet_nat_server_ (struct HelperContext *h); | ||
74 | |||
75 | |||
76 | /** | ||
77 | * We want to connect to a peer that is behind NAT. Run the | ||
78 | * gnunet-helper-nat-client to send dummy ICMP responses to cause | ||
79 | * that peer to connect to us (connection reversal). | ||
80 | * | ||
81 | * @param internal_address out internal address to use | ||
82 | * @param internal_port internal port to use | ||
83 | * @param remote_v4 the address of the peer (IPv4-only) | ||
84 | * @param cfg handle to the GNUnet configuration | ||
85 | * @return #GNUNET_SYSERR on error, | ||
86 | * #GNUNET_OK otherwise | ||
87 | */ | ||
88 | int | ||
89 | GN_request_connection_reversal (const struct in_addr *internal_address, | ||
90 | uint16_t internal_port, | ||
91 | const struct in_addr *remote_v4, | ||
92 | const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
93 | |||
94 | |||
95 | /* end of gnunet-service-nat_helper.h */ | ||