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/>.
20 * @author Christian Grothoff
23 * API to access the VPN service.
25 * @defgroup vpn VPN service
29 #ifndef GNUNET_VPN_SERVICE_H
30 #define GNUNET_VPN_SERVICE_H
32 #include "gnunet_util_lib.h"
38 struct GNUNET_VPN_Handle;
41 * Opaque redirection request handle.
43 struct GNUNET_VPN_RedirectionRequest;
47 * Callback invoked from the VPN service once a redirection is
48 * available. Provides the IP address that can now be used to
49 * reach the requested destination.
52 * @param af address family, AF_INET or AF_INET6; AF_UNSPEC on error;
53 * will match 'result_af' from the request
54 * @param address IP address (struct in_addr or struct in_addr6, depending on 'af')
55 * that the VPN allocated for the redirection;
56 * traffic to this IP will now be redirected to the
57 * specified target peer; NULL on error
59 typedef void (*GNUNET_VPN_AllocationCallback)(void *cls,
65 * Cancel redirection request with the service.
67 * @param rr request to cancel
70 GNUNET_VPN_cancel_request (struct GNUNET_VPN_RedirectionRequest *rr);
74 * Tell the VPN that a forwarding to a particular peer offering a
75 * particular service is requested. The VPN is to reserve a
76 * particular IP for the redirection and return it. The VPN will
77 * begin the redirection as soon as possible and maintain it as long
78 * as it is actively used and keeping it is feasible. Given resource
79 * limitations, the longest inactive mappings will be destroyed.
81 * @param vh VPN handle
82 * @param result_af desired address family for the returned allocation
83 * can also be AF_UNSPEC
84 * @param protocol protocol, IPPROTO_UDP or IPPROTO_TCP
85 * @param peer target peer for the redirection
86 * @param serv service descriptor to give to the peer
87 * @param expiration_time at what time should the redirection expire?
88 * (this should not impact connections that are active at that time)
89 * @param cb function to call with the IP
90 * @param cb_cls closure for cb
91 * @return handle to cancel the request (means the callback won't be
92 * invoked anymore; the mapping may or may not be established
95 struct GNUNET_VPN_RedirectionRequest *
96 GNUNET_VPN_redirect_to_peer (struct GNUNET_VPN_Handle *vh,
99 const struct GNUNET_PeerIdentity *peer,
100 const struct GNUNET_HashCode *serv,
101 struct GNUNET_TIME_Absolute expiration_time,
102 GNUNET_VPN_AllocationCallback cb,
107 * Tell the VPN that forwarding to the Internet via some exit node is
108 * requested. Note that both UDP and TCP traffic will be forwarded,
109 * but possibly to different exit nodes. The VPN is to reserve a
110 * particular IP for the redirection and return it. The VPN will
111 * begin the redirection as soon as possible and maintain it as long
112 * as it is actively used and keeping it is feasible. Given resource
113 * limitations, the longest inactive mappings will be destroyed.
115 * @param vh VPN handle
116 * @param result_af desired address family for the returned allocation,
117 * can also be AF_UNSPEC
118 * @param addr_af address family for 'addr', AF_INET or AF_INET6
119 * @param addr destination IP address on the Internet; destination
120 * port is to be taken from the VPN packet itself
121 * @param expiration_time at what time should the redirection expire?
122 * (this should not impact connections that are active at that time)
123 * @param cb function to call with the IP
124 * @param cb_cls closure for cb
125 * @return handle to cancel the request (means the callback won't be
126 * invoked anymore; the mapping may or may not be established
129 struct GNUNET_VPN_RedirectionRequest *
130 GNUNET_VPN_redirect_to_ip (struct GNUNET_VPN_Handle *vh,
134 struct GNUNET_TIME_Absolute expiration_time,
135 GNUNET_VPN_AllocationCallback cb,
140 * Connect to the VPN service
142 * @param cfg configuration to use
145 struct GNUNET_VPN_Handle *
146 GNUNET_VPN_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
150 * Disconnect from the VPN service.
152 * @param vh VPN handle
155 GNUNET_VPN_disconnect (struct GNUNET_VPN_Handle *vh);
159 /** @} */ /* end of group */