aboutsummaryrefslogtreecommitdiff
path: root/src/nat/gnunet-service-nat_mini.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-12-17 08:00:29 +0100
committerChristian Grothoff <christian@grothoff.org>2016-12-17 08:00:29 +0100
commit545faeda8f7fb7e03bb39602df6142f630157050 (patch)
tree26aac9f044212d5f492b4ac3d0522af136aab58e /src/nat/gnunet-service-nat_mini.h
parenta1e76003ca590ea8d3e9387da35d87419417abb8 (diff)
downloadgnunet-545faeda8f7fb7e03bb39602df6142f630157050.tar.gz
gnunet-545faeda8f7fb7e03bb39602df6142f630157050.zip
misc. improvements to new NAT service, starting with autoconfiguration logic
Diffstat (limited to 'src/nat/gnunet-service-nat_mini.h')
-rw-r--r--src/nat/gnunet-service-nat_mini.h127
1 files changed, 127 insertions, 0 deletions
diff --git a/src/nat/gnunet-service-nat_mini.h b/src/nat/gnunet-service-nat_mini.h
new file mode 100644
index 000000000..2c0dd3445
--- /dev/null
+++ b/src/nat/gnunet-service-nat_mini.h
@@ -0,0 +1,127 @@
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
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
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 GNUNET_NAT_ExternalHandle *eh);
68
69
70/**
71 * Handle to a mapping created with upnpc.
72 */
73struct GNUNET_NAT_MiniHandle;
74
75
76/**
77 * Signature of the callback passed to #GNUNET_NAT_register() for
78 * a function to call whenever our set of 'valid' addresses changes.
79 *
80 * @param cls closure
81 * @param add_remove #GNUNET_YES to mean the new public IP address, #GNUNET_NO to mean
82 * the previous (now invalid) one, #GNUNET_SYSERR indicates an error
83 * @param addr either the previous or the new public IP address
84 * @param addrlen actual length of the @a addr
85 * @param result #GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code
86 */
87typedef void
88(*GNUNET_NAT_MiniAddressCallback) (void *cls,
89 int add_remove,
90 const struct sockaddr *addr,
91 socklen_t addrlen,
92 enum GNUNET_NAT_StatusCode result);
93
94
95/**
96 * Start mapping the given port using (mini)upnpc. This function
97 * should typically not be used directly (it is used within the
98 * general-purpose #GNUNET_NAT_register() code). However, it can be
99 * used if specifically UPnP-based NAT traversal is to be used or
100 * tested.
101 *
102 * @param port port to map
103 * @param is_tcp #GNUNET_YES to map TCP, #GNUNET_NO for UDP
104 * @param ac function to call with mapping result
105 * @param ac_cls closure for @a ac
106 * @return NULL on error
107 */
108struct GNUNET_NAT_MiniHandle *
109GNUNET_NAT_mini_map_start (uint16_t port,
110 int is_tcp,
111 GNUNET_NAT_MiniAddressCallback ac,
112 void *ac_cls);
113
114
115/**
116 * Remove a mapping created with (mini)upnpc. Calling
117 * this function will give 'upnpc' 1s to remove the mapping,
118 * so while this function is non-blocking, a task will be
119 * left with the scheduler for up to 1s past this call.
120 *
121 * @param mini the handle
122 */
123void
124GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini);
125
126
127#endif