diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-06 22:51:43 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-06 22:51:43 +0000 |
commit | 9e4ffd173145ed63e458a6f3c1dbe80c3ff43da6 (patch) | |
tree | 830fee64e394e25d850d0682ac2ed9f045eefafb /src/include/gnunet_vpn_service.h | |
parent | d60e4e83476b14448b249509cdc8dff9e63b5863 (diff) | |
download | gnunet-9e4ffd173145ed63e458a6f3c1dbe80c3ff43da6.tar.gz gnunet-9e4ffd173145ed63e458a6f3c1dbe80c3ff43da6.zip |
-draft for service API to new VPN
Diffstat (limited to 'src/include/gnunet_vpn_service.h')
-rw-r--r-- | src/include/gnunet_vpn_service.h | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/src/include/gnunet_vpn_service.h b/src/include/gnunet_vpn_service.h new file mode 100644 index 000000000..740e05500 --- /dev/null +++ b/src/include/gnunet_vpn_service.h | |||
@@ -0,0 +1,152 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
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. | ||
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 | General Public License for more details. | ||
14 | |||
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. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file include/gnunet_vpn_service.h | ||
23 | * @brief API to access the VPN service. | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #ifndef GNUNET_VPN_SERVICE_H | ||
27 | #define GNUNET_VPN_SERVICE_H | ||
28 | |||
29 | #include "gnunet_common.h" | ||
30 | #include "gnunet_util_lib.h" | ||
31 | |||
32 | |||
33 | /** | ||
34 | * Opaque VPN handle | ||
35 | */ | ||
36 | struct GNUNET_VPN_Handle; | ||
37 | |||
38 | /** | ||
39 | * Opaque redirection request handle. | ||
40 | */ | ||
41 | struct GNUNET_VPN_RedirectionRequest; | ||
42 | |||
43 | |||
44 | /** | ||
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. | ||
48 | * | ||
49 | * @param cls closure | ||
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 | ||
55 | */ | ||
56 | typedef void (*GNUNET_VPN_AllocationCallback)(void *cls, | ||
57 | int af, | ||
58 | const void *address); | ||
59 | |||
60 | |||
61 | /** | ||
62 | * Cancel redirection request with the service. | ||
63 | * | ||
64 | * @param rr request to cancel | ||
65 | */ | ||
66 | void | ||
67 | GNUNET_VPN_cancel_request (struct GNUNET_VPN_RedirectionRequest *rr); | ||
68 | |||
69 | |||
70 | /** | ||
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. | ||
77 | * | ||
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 | ||
90 | * anyway) | ||
91 | */ | ||
92 | struct GNUNET_VPN_RedirectionRequest * | ||
93 | GNUNET_VPN_redirect_to_peer (struct GNUNET_VPN_RequestHandle *rh, | ||
94 | int af, | ||
95 | uint8_t protocol, | ||
96 | const struct GNUNET_PeerIdentity *peer, | ||
97 | const HashCode *serv, | ||
98 | int nac, | ||
99 | GNUNET_VPN_AllocationCallback cb, | ||
100 | void *cb_cls); | ||
101 | |||
102 | |||
103 | /** | ||
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. | ||
111 | * | ||
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 | ||
123 | * anyway) | ||
124 | */ | ||
125 | struct GNUNET_VPN_RedirectionRequest * | ||
126 | GNUNET_VPN_redirect_to_ip (struct GNUNET_VPN_RequestHandle *rh, | ||
127 | int af, | ||
128 | const void *addr, | ||
129 | int nac, | ||
130 | GNUNET_VPN_AllocationCallback cb, | ||
131 | void *cb_cls); | ||
132 | |||
133 | |||
134 | /** | ||
135 | * Connect to the VPN service | ||
136 | * | ||
137 | * @param cfg configuration to use | ||
138 | * @return VPN handle | ||
139 | */ | ||
140 | struct GNUNET_VPN_Handle * | ||
141 | GNUNET_VPN_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
142 | |||
143 | |||
144 | /** | ||
145 | * Disconnect from the VPN service. | ||
146 | * | ||
147 | * @param vh VPN handle | ||
148 | */ | ||
149 | void | ||
150 | GNUNET_VPN_disconnect (struct GNUNET_VPN_Handle *vh); | ||
151 | |||
152 | #endif | ||