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_common.h"
30 #include "gnunet_util_lib.h"
36 struct GNUNET_VPN_Handle;
39 * Opaque redirection request handle.
41 struct GNUNET_VPN_RedirectionRequest;
45 * Callback invoked from the VPN service once a redirection is
46 * available. Provides the IP address that can now be used to
47 * reach the requested destination.
50 * @param af address family, AF_INET or AF_INET6; AF_UNSPEC on error
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 af address family, AF_INET or AF_INET6
80 * @param protocol protocol, IPPROTO_UDP or IPPROTO_TCP
81 * @param peer target peer for the redirection
82 * @param serv service descriptor to give to the peer
83 * @param nac GNUNET_YES to notify via callback only after completion of
84 * the MESH-level connection,
85 * GNUNET_NO to notify as soon as the IP has been reserved
86 * @param cb function to call with the IP
87 * @param cb_cls closure for cb
88 * @return handle to cancel the request (means the callback won't be
89 * invoked anymore; the mapping may or may not be established
92 struct GNUNET_VPN_RedirectionRequest *
93 GNUNET_VPN_redirect_to_peer (struct GNUNET_VPN_RequestHandle *rh,
96 const struct GNUNET_PeerIdentity *peer,
99 GNUNET_VPN_AllocationCallback cb,
104 * Tell the VPN that forwarding to the Internet via some exit node is
105 * requested. Note that both UDP and TCP traffic will be forwarded,
106 * but possibly to different exit nodes. The VPN is to reserve a
107 * particular IP for the redirection and return it. The VPN will
108 * begin the redirection as soon as possible and maintain it as long
109 * as it is actively used and keeping it is feasible. Given resource
110 * limitations, the longest inactive mappings will be destroyed.
112 * @param vh VPN handle
113 * @param af address family, AF_INET or AF_INET6
114 * @param addr destination IP address on the Internet; destination
115 * port is to be taken from the VPN packet itself
116 * @param nac GNUNET_YES to notify via callback only after completion of
117 * the MESH-level connection,
118 * GNUNET_NO to notify as soon as the IP has been reserved
119 * @param cb function to call with the IP
120 * @param cb_cls closure for cb
121 * @return handle to cancel the request (means the callback won't be
122 * invoked anymore; the mapping may or may not be established
125 struct GNUNET_VPN_RedirectionRequest *
126 GNUNET_VPN_redirect_to_ip (struct GNUNET_VPN_RequestHandle *rh,
130 GNUNET_VPN_AllocationCallback cb,
135 * Connect to the VPN service
137 * @param cfg configuration to use
140 struct GNUNET_VPN_Handle *
141 GNUNET_VPN_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
145 * Disconnect from the VPN service.
147 * @param vh VPN handle
150 GNUNET_VPN_disconnect (struct GNUNET_VPN_Handle *vh);