2 This file is part of GNUnet
3 Copyright (C) 2012 GNUnet e.V.
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.
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.
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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @author Christian Grothoff
25 * API to access the VPN service.
27 * @defgroup vpn VPN service
31 #ifndef GNUNET_VPN_SERVICE_H
32 #define GNUNET_VPN_SERVICE_H
34 #include "gnunet_util_lib.h"
40 struct GNUNET_VPN_Handle;
43 * Opaque redirection request handle.
45 struct GNUNET_VPN_RedirectionRequest;
49 * Callback invoked from the VPN service once a redirection is
50 * available. Provides the IP address that can now be used to
51 * reach the requested destination.
54 * @param af address family, AF_INET or AF_INET6; AF_UNSPEC on error;
55 * will match 'result_af' from the request
56 * @param address IP address (struct in_addr or struct in_addr6, depending on 'af')
57 * that the VPN allocated for the redirection;
58 * traffic to this IP will now be redirected to the
59 * specified target peer; NULL on error
61 typedef void (*GNUNET_VPN_AllocationCallback)(void *cls,
67 * Cancel redirection request with the service.
69 * @param rr request to cancel
72 GNUNET_VPN_cancel_request (struct GNUNET_VPN_RedirectionRequest *rr);
76 * Tell the VPN that a forwarding to a particular peer offering a
77 * particular service is requested. The VPN is to reserve a
78 * particular IP for the redirection and return it. The VPN will
79 * begin the redirection as soon as possible and maintain it as long
80 * as it is actively used and keeping it is feasible. Given resource
81 * limitations, the longest inactive mappings will be destroyed.
83 * @param vh VPN handle
84 * @param result_af desired address family for the returned allocation
85 * can also be AF_UNSPEC
86 * @param protocol protocol, IPPROTO_UDP or IPPROTO_TCP
87 * @param peer target peer for the redirection
88 * @param serv service descriptor to give to the peer
89 * @param expiration_time at what time should the redirection expire?
90 * (this should not impact connections that are active at that time)
91 * @param cb function to call with the IP
92 * @param cb_cls closure for cb
93 * @return handle to cancel the request (means the callback won't be
94 * invoked anymore; the mapping may or may not be established
97 struct GNUNET_VPN_RedirectionRequest *
98 GNUNET_VPN_redirect_to_peer (struct GNUNET_VPN_Handle *vh,
101 const struct GNUNET_PeerIdentity *peer,
102 const struct GNUNET_HashCode *serv,
103 struct GNUNET_TIME_Absolute expiration_time,
104 GNUNET_VPN_AllocationCallback cb,
109 * Tell the VPN that forwarding to the Internet via some exit node is
110 * requested. Note that both UDP and TCP traffic will be forwarded,
111 * but possibly to different exit nodes. The VPN is to reserve a
112 * particular IP for the redirection and return it. The VPN will
113 * begin the redirection as soon as possible and maintain it as long
114 * as it is actively used and keeping it is feasible. Given resource
115 * limitations, the longest inactive mappings will be destroyed.
117 * @param vh VPN handle
118 * @param result_af desired address family for the returned allocation,
119 * can also be AF_UNSPEC
120 * @param addr_af address family for 'addr', AF_INET or AF_INET6
121 * @param addr destination IP address on the Internet; destination
122 * port is to be taken from the VPN packet itself
123 * @param expiration_time at what time should the redirection expire?
124 * (this should not impact connections that are active at that time)
125 * @param cb function to call with the IP
126 * @param cb_cls closure for cb
127 * @return handle to cancel the request (means the callback won't be
128 * invoked anymore; the mapping may or may not be established
131 struct GNUNET_VPN_RedirectionRequest *
132 GNUNET_VPN_redirect_to_ip (struct GNUNET_VPN_Handle *vh,
136 struct GNUNET_TIME_Absolute expiration_time,
137 GNUNET_VPN_AllocationCallback cb,
142 * Connect to the VPN service
144 * @param cfg configuration to use
147 struct GNUNET_VPN_Handle *
148 GNUNET_VPN_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
152 * Disconnect from the VPN service.
154 * @param vh VPN handle
157 GNUNET_VPN_disconnect (struct GNUNET_VPN_Handle *vh);
161 /** @} */ /* end of group */