aboutsummaryrefslogtreecommitdiff
path: root/src/service/nat/gnunet-service-nat_mini.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/nat/gnunet-service-nat_mini.h')
-rw-r--r--src/service/nat/gnunet-service-nat_mini.h128
1 files changed, 128 insertions, 0 deletions
diff --git a/src/service/nat/gnunet-service-nat_mini.h b/src/service/nat/gnunet-service-nat_mini.h
new file mode 100644
index 000000000..dffc9758a
--- /dev/null
+++ b/src/service/nat/gnunet-service-nat_mini.h
@@ -0,0 +1,128 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2011-2014, 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_mini.c
23 * @brief functions for interaction with miniupnp; tested with miniupnpc 1.5
24 * @author Christian Grothoff
25 */
26#ifndef GNUNET_SERVICE_NAT_MINI_H
27#define GNUNET_SERVICE_NAT_MINI_H
28
29
30/**
31 * Signature of a callback that is given an IP address.
32 *
33 * @param cls closure
34 * @param addr the address, NULL on errors
35 * @param result #GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code
36 */
37typedef void
38(*GNUNET_NAT_IPCallback) (void *cls,
39 const struct in_addr *addr,
40 enum GNUNET_NAT_StatusCode result);
41
42
43/**
44 * Opaque handle to cancel #GNUNET_NAT_mini_get_external_ipv4() operation.
45 */
46struct GNUNET_NAT_ExternalHandle;
47
48
49/**
50 * Try to get the external IPv4 address of this peer.
51 *
52 * @param cb function to call with result
53 * @param cb_cls closure for @a cb
54 * @return handle for cancellation (can only be used until @a cb is called), NULL on error
55 */
56struct GNUNET_NAT_ExternalHandle *
57GNUNET_NAT_mini_get_external_ipv4_ (GNUNET_NAT_IPCallback cb,
58 void *cb_cls);
59
60
61/**
62 * Cancel operation.
63 *
64 * @param eh operation to cancel
65 */
66void
67GNUNET_NAT_mini_get_external_ipv4_cancel_ (struct
68 GNUNET_NAT_ExternalHandle *eh);
69
70
71/**
72 * Handle to a mapping created with upnpc.
73 */
74struct GNUNET_NAT_MiniHandle;
75
76
77/**
78 * Signature of the callback passed to #GNUNET_NAT_register() for
79 * a function to call whenever our set of 'valid' addresses changes.
80 *
81 * @param cls closure
82 * @param add_remove #GNUNET_YES to mean the new public IP address, #GNUNET_NO to mean
83 * the previous (now invalid) one, #GNUNET_SYSERR indicates an error
84 * @param addr either the previous or the new public IP address
85 * @param addrlen actual length of the @a addr
86 * @param result #GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code
87 */
88typedef void
89(*GNUNET_NAT_MiniAddressCallback) (void *cls,
90 int add_remove,
91 const struct sockaddr *addr,
92 socklen_t addrlen,
93 enum GNUNET_NAT_StatusCode result);
94
95
96/**
97 * Start mapping the given port using (mini)upnpc. This function
98 * should typically not be used directly (it is used within the
99 * general-purpose #GNUNET_NAT_register() code). However, it can be
100 * used if specifically UPnP-based NAT traversal is to be used or
101 * tested.
102 *
103 * @param port port to map
104 * @param is_tcp #GNUNET_YES to map TCP, #GNUNET_NO for UDP
105 * @param ac function to call with mapping result
106 * @param ac_cls closure for @a ac
107 * @return NULL on error
108 */
109struct GNUNET_NAT_MiniHandle *
110GNUNET_NAT_mini_map_start (uint16_t port,
111 int is_tcp,
112 GNUNET_NAT_MiniAddressCallback ac,
113 void *ac_cls);
114
115
116/**
117 * Remove a mapping created with (mini)upnpc. Calling
118 * this function will give 'upnpc' 1s to remove the mapping,
119 * so while this function is non-blocking, a task will be
120 * left with the scheduler for up to 1s past this call.
121 *
122 * @param mini the handle
123 */
124void
125GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini);
126
127
128#endif