2 This file is part of GNUnet
3 (C) 2012 Christian Grothoff (and other contributing authors)
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 2, or (at your
8 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 General Public License for more details.
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file include/gnunet_vpn_service.h
23 * @brief API to access the VPN service.
24 * @author Christian Grothoff
26 #ifndef GNUNET_VPN_SERVICE_H
27 #define GNUNET_VPN_SERVICE_H
29 #include "gnunet_util_lib.h"
35 struct GNUNET_VPN_Handle;
38 * Opaque redirection request handle.
40 struct GNUNET_VPN_RedirectionRequest;
44 * Callback invoked from the VPN service once a redirection is
45 * available. Provides the IP address that can now be used to
46 * reach the requested destination.
49 * @param af address family, AF_INET or AF_INET6; AF_UNSPEC on error;
50 * will match 'result_af' from the request
51 * @param address IP address (struct in_addr or struct in_addr6, depending on 'af')
52 * that the VPN allocated for the redirection;
53 * traffic to this IP will now be redirected to the
54 * specified target peer; NULL on error
56 typedef void (*GNUNET_VPN_AllocationCallback)(void *cls,
62 * Cancel redirection request with the service.
64 * @param rr request to cancel
67 GNUNET_VPN_cancel_request (struct GNUNET_VPN_RedirectionRequest *rr);
71 * Tell the VPN that a forwarding to a particular peer offering a
72 * particular service is requested. The VPN is to reserve a
73 * particular IP for the redirection and return it. The VPN will
74 * begin the redirection as soon as possible and maintain it as long
75 * as it is actively used and keeping it is feasible. Given resource
76 * limitations, the longest inactive mappings will be destroyed.
78 * @param vh VPN handle
79 * @param result_af desired address family for the returned allocation
80 * can also be AF_UNSPEC
81 * @param protocol protocol, IPPROTO_UDP or IPPROTO_TCP
82 * @param peer target peer for the redirection
83 * @param serv service descriptor to give to the peer
84 * @param nac GNUNET_YES to notify via callback only after completion of
85 * the MESH-level connection,
86 * GNUNET_NO to notify as soon as the IP has been reserved
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 GNUNET_HashCode *serv,
102 struct GNUNET_TIME_Absolute expiration_time,
103 GNUNET_VPN_AllocationCallback cb,
108 * Tell the VPN that forwarding to the Internet via some exit node is
109 * requested. Note that both UDP and TCP traffic will be forwarded,
110 * but possibly to different exit nodes. The VPN is to reserve a
111 * particular IP for the redirection and return it. The VPN will
112 * begin the redirection as soon as possible and maintain it as long
113 * as it is actively used and keeping it is feasible. Given resource
114 * limitations, the longest inactive mappings will be destroyed.
116 * @param vh VPN handle
117 * @param result_af desired address family for the returned allocation,
118 * can also be AF_UNSPEC
119 * @param addr_af address family for 'addr', AF_INET or AF_INET6
120 * @param addr destination IP address on the Internet; destination
121 * port is to be taken from the VPN packet itself
122 * @param nac GNUNET_YES to notify via callback only after completion of
123 * the MESH-level connection,
124 * GNUNET_NO to notify as soon as the IP has been reserved
125 * @param expiration_time at what time should the redirection expire?
126 * (this should not impact connections that are active at that time)
127 * @param cb function to call with the IP
128 * @param cb_cls closure for cb
129 * @return handle to cancel the request (means the callback won't be
130 * invoked anymore; the mapping may or may not be established
133 struct GNUNET_VPN_RedirectionRequest *
134 GNUNET_VPN_redirect_to_ip (struct GNUNET_VPN_Handle *vh,
139 struct GNUNET_TIME_Absolute expiration_time,
140 GNUNET_VPN_AllocationCallback cb,
145 * Connect to the VPN service
147 * @param cfg configuration to use
150 struct GNUNET_VPN_Handle *
151 GNUNET_VPN_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
155 * Disconnect from the VPN service.
157 * @param vh VPN handle
160 GNUNET_VPN_disconnect (struct GNUNET_VPN_Handle *vh);