gnunet_vpn_service.h (5754B)
1 /* 2 This file is part of GNUnet 3 Copyright (C) 2012 GNUnet e.V. 4 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. 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 Affero General Public License for more details. 14 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/>. 17 18 SPDX-License-Identifier: AGPL3.0-or-later 19 */ 20 21 /** 22 * @addtogroup vpn_suite VPN services and libraries 23 * @{ 24 * 25 * @author Christian Grothoff 26 * 27 * @file 28 * API to access the VPN service. 29 * 30 * @defgroup vpn VPN service 31 * 32 * @{ 33 */ 34 #ifndef GNUNET_VPN_SERVICE_H 35 #define GNUNET_VPN_SERVICE_H 36 37 38 #include "gnunet_util_lib.h" 39 40 41 /** 42 * Opaque VPN handle 43 */ 44 struct GNUNET_VPN_Handle; 45 46 /** 47 * Opaque redirection request handle. 48 */ 49 struct GNUNET_VPN_RedirectionRequest; 50 51 52 /** 53 * Callback invoked from the VPN service once a redirection is 54 * available. Provides the IP address that can now be used to 55 * reach the requested destination. 56 * 57 * @param cls closure 58 * @param af address family, AF_INET or AF_INET6; AF_UNSPEC on error; 59 * will match 'result_af' from the request 60 * @param address IP address (struct in_addr or struct in_addr6, depending on 'af') 61 * that the VPN allocated for the redirection; 62 * traffic to this IP will now be redirected to the 63 * specified target peer; NULL on error 64 */ 65 typedef void (*GNUNET_VPN_AllocationCallback)(void *cls, 66 int af, 67 const void *address); 68 69 70 /** 71 * Cancel redirection request with the service. 72 * 73 * @param rr request to cancel 74 */ 75 void 76 GNUNET_VPN_cancel_request (struct GNUNET_VPN_RedirectionRequest *rr); 77 78 79 /** 80 * Tell the VPN that a forwarding to a particular peer offering a 81 * particular service is requested. The VPN is to reserve a 82 * particular IP for the redirection and return it. The VPN will 83 * begin the redirection as soon as possible and maintain it as long 84 * as it is actively used and keeping it is feasible. Given resource 85 * limitations, the longest inactive mappings will be destroyed. 86 * 87 * @param vh VPN handle 88 * @param result_af desired address family for the returned allocation 89 * can also be AF_UNSPEC 90 * @param protocol protocol, IPPROTO_UDP or IPPROTO_TCP 91 * @param peer target peer for the redirection 92 * @param serv service descriptor to give to the peer 93 * @param expiration_time at what time should the redirection expire? 94 * (this should not impact connections that are active at that time) 95 * @param cb function to call with the IP 96 * @param cb_cls closure for cb 97 * @return handle to cancel the request (means the callback won't be 98 * invoked anymore; the mapping may or may not be established 99 * anyway) 100 */ 101 struct GNUNET_VPN_RedirectionRequest * 102 GNUNET_VPN_redirect_to_peer (struct GNUNET_VPN_Handle *vh, 103 int result_af, 104 uint8_t protocol, 105 const struct GNUNET_PeerIdentity *peer, 106 const struct GNUNET_HashCode *serv, 107 struct GNUNET_TIME_Absolute expiration_time, 108 GNUNET_VPN_AllocationCallback cb, 109 void *cb_cls); 110 111 112 /** 113 * Tell the VPN that forwarding to the Internet via some exit node is 114 * requested. Note that both UDP and TCP traffic will be forwarded, 115 * but possibly to different exit nodes. The VPN is to reserve a 116 * particular IP for the redirection and return it. The VPN will 117 * begin the redirection as soon as possible and maintain it as long 118 * as it is actively used and keeping it is feasible. Given resource 119 * limitations, the longest inactive mappings will be destroyed. 120 * 121 * @param vh VPN handle 122 * @param result_af desired address family for the returned allocation, 123 * can also be AF_UNSPEC 124 * @param addr_af address family for 'addr', AF_INET or AF_INET6 125 * @param addr destination IP address on the Internet; destination 126 * port is to be taken from the VPN packet itself 127 * @param expiration_time at what time should the redirection expire? 128 * (this should not impact connections that are active at that time) 129 * @param cb function to call with the IP 130 * @param cb_cls closure for cb 131 * @return handle to cancel the request (means the callback won't be 132 * invoked anymore; the mapping may or may not be established 133 * anyway) 134 */ 135 struct GNUNET_VPN_RedirectionRequest * 136 GNUNET_VPN_redirect_to_ip (struct GNUNET_VPN_Handle *vh, 137 int result_af, 138 int addr_af, 139 const void *addr, 140 struct GNUNET_TIME_Absolute expiration_time, 141 GNUNET_VPN_AllocationCallback cb, 142 void *cb_cls); 143 144 145 /** 146 * Connect to the VPN service 147 * 148 * @param cfg configuration to use 149 * @return VPN handle 150 */ 151 struct GNUNET_VPN_Handle * 152 GNUNET_VPN_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); 153 154 155 /** 156 * Disconnect from the VPN service. 157 * 158 * @param vh VPN handle 159 */ 160 void 161 GNUNET_VPN_disconnect (struct GNUNET_VPN_Handle *vh); 162 163 #endif 164 165 /** @} */ /* end of group */ 166 167 /** @} */ /* end of group addition */