fix #3284: support lib/MULTIARCH/ paths in installation, use GNUNET_PREFIX=@libdir...
[oweals/gnunet.git] / src / exit / exit.h
1 /*
2      This file is part of GNUnet.
3      (C) 2012 Christian Grothoff
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 3, 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 exit/exit.h
23  * @brief format for mesh messages exchanged between VPN service and exit daemon
24  * @author Christian Grothoff
25  */
26 #ifndef EXIT_H
27 #define EXIT_H
28
29 #include "gnunet_util_lib.h"
30
31 GNUNET_NETWORK_STRUCT_BEGIN
32
33 /**
34  * Message send via mesh to an exit daemon to initiate forwarding of
35  * TCP data to a local service.
36  */
37 struct GNUNET_EXIT_TcpServiceStartMessage
38 {
39   /**
40    * Type is GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START
41    */
42   struct GNUNET_MessageHeader header;
43
44   /**
45    * Always 0.
46    */
47   uint32_t reserved GNUNET_PACKED;
48
49   /**
50    * Identification for the desired service.
51    */
52   struct GNUNET_HashCode service_descriptor;
53
54   /**
55    * Skeleton of the TCP header to send.  Port numbers are to
56    * be replaced and the checksum may be updated as necessary.
57    */
58   struct GNUNET_TUN_TcpHeader tcp_header;
59
60   /* followed by TCP payload */
61 };
62
63
64 /**
65  * Message send via mesh to an exit daemon to initiate forwarding of
66  * TCP data to the Internet.
67  */
68 struct GNUNET_EXIT_TcpInternetStartMessage
69 {
70   /**
71    * Type is GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START
72    */
73   struct GNUNET_MessageHeader header;
74
75   /**
76    * Address family, AF_INET or AF_INET6, in network byte order.
77    */
78   int32_t af GNUNET_PACKED;
79
80   /**
81    * Skeleton of the TCP header to send.  Port numbers are to
82    * be replaced and the checksum may be updated as necessary.
83    */
84   struct GNUNET_TUN_TcpHeader tcp_header;
85
86   /* followed by IP address of the destination; either
87      'struct in_addr' or 'struct in6_addr', depending on af */
88
89   /* followed by TCP payload */
90 };
91
92
93 /**
94  * Message send via mesh between VPN and entry and an exit daemon to
95  * transmit TCP data between the VPN entry and an exit session.  This
96  * format is used for both Internet-exits and service-exits and
97  * in both directions (VPN to exit and exit to VPN).
98  */
99 struct GNUNET_EXIT_TcpDataMessage
100 {
101   /**
102    * Type is GNUNET_MESSAGE_TYPE_VPN_TCP_DATA
103    */
104   struct GNUNET_MessageHeader header;
105
106   /**
107    * Always 0.
108    */
109   uint32_t reserved GNUNET_PACKED;
110
111   /**
112    * Skeleton of the TCP header to send.  Port numbers are to
113    * be replaced and the checksum may be updated as necessary.  (The destination port number should not be changed, as it contains the desired destination port.)
114    */
115   struct GNUNET_TUN_TcpHeader tcp_header;
116
117   /* followed by TCP payload */
118 };
119
120
121 /**
122  * Message send via mesh to an exit daemon to send
123  * UDP data to a local service.
124  */
125 struct GNUNET_EXIT_UdpServiceMessage
126 {
127   /**
128    * Type is GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE
129    */
130   struct GNUNET_MessageHeader header;
131
132   /**
133    * Source port to use for the UDP request (0 to use a random port).  In NBO.
134    */
135   uint16_t source_port GNUNET_PACKED;
136
137   /**
138    * Destination port to use for the UDP request.  In NBO.
139    */
140   uint16_t destination_port GNUNET_PACKED;
141
142   /**
143    * Identification for the desired service.
144    */
145   struct GNUNET_HashCode service_descriptor;
146
147   /* followed by UDP payload */
148 };
149
150
151 /**
152  * Message send via mesh to an exit daemon to forward
153  * UDP data to the Internet.
154  */
155 struct GNUNET_EXIT_UdpInternetMessage
156 {
157   /**
158    * Type is GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET
159    */
160   struct GNUNET_MessageHeader header;
161
162   /**
163    * Address family, AF_INET or AF_INET6, in network byte order.
164    */
165   int32_t af GNUNET_PACKED;
166
167   /**
168    * Source port to use for the UDP request (0 to use a random port).  In NBO.
169    */
170   uint16_t source_port GNUNET_PACKED;
171
172   /**
173    * Destination port to use for the UDP request.  In NBO.
174    */
175   uint16_t destination_port GNUNET_PACKED;
176
177   /* followed by IP address of the destination; either
178      'struct in_addr' or 'struct in6_addr', depending on af */
179
180   /* followed by UDP payload */
181 };
182
183
184 /**
185  * Message send from exit daemon back to the UDP entry point
186  * (used for both Internet and Service exit replies).
187  */
188 struct GNUNET_EXIT_UdpReplyMessage
189 {
190   /**
191    * Type is GNUNET_MESSAGE_TYPE_VPN_UDP_REPLY
192    */
193   struct GNUNET_MessageHeader header;
194
195   /**
196    * Source port to use for the UDP reply (0 to use the same
197    * port as for the original request).  In NBO.
198    */
199   uint16_t source_port GNUNET_PACKED;
200
201   /**
202    * Destination port to use for the UDP reply (0 to use the same
203    * port as for the original request).  In NBO.
204    */
205   uint16_t destination_port GNUNET_PACKED;
206
207   /* followed by UDP payload */
208 };
209
210
211 /**
212  * Message send via mesh to an exit daemon to send
213  * ICMP data to a local service.
214  */
215 struct GNUNET_EXIT_IcmpServiceMessage
216 {
217   /**
218    * Type is GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE
219    */
220   struct GNUNET_MessageHeader header;
221
222   /**
223    * Address family, AF_INET or AF_INET6, in network byte order.  This
224    * AF value determines if the 'icmp_header' is ICMPv4 or ICMPv6.
225    * The receiver (exit) may still have to translate (PT) to the services'
226    * ICMP version (if possible).
227    */
228   int32_t af GNUNET_PACKED;
229
230   /**
231    * Identification for the desired service.
232    */
233   struct GNUNET_HashCode service_descriptor;
234
235   /**
236    * ICMP header to use.
237    */
238   struct GNUNET_TUN_IcmpHeader icmp_header;
239
240   /* followed by ICMP payload; however, for certain ICMP message
241      types where the payload is the original IP packet, the payload
242      is omitted as it is useless for the receiver (who will need
243      to create some fake payload manually)  */
244 };
245
246
247 /**
248  * Message send via mesh to an exit daemon to forward
249  * ICMP data to the Internet.
250  */
251 struct GNUNET_EXIT_IcmpInternetMessage
252 {
253   /**
254    * Type is GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_INTERNET
255    */
256   struct GNUNET_MessageHeader header;
257
258   /**
259    * Address family, AF_INET or AF_INET6, in network byte order.
260    * Determines both the ICMP version used in the 'icmp_header' and
261    * the IP address format that is used for the target IP.  If
262    * PT is necessary, the sender has already done it.
263    */
264   int32_t af GNUNET_PACKED;
265
266   /**
267    * ICMP header to use.  Must match the target 'af' given
268    * above.
269    */
270   struct GNUNET_TUN_IcmpHeader icmp_header;
271
272   /* followed by IP address of the destination; either
273      'struct in_addr' or 'struct in6_addr', depending on af */
274
275   /* followed by ICMP payload; however, for certain ICMP message
276      types where the payload is the original IP packet, the payload
277      is omitted as it is useless for the receiver (who will need
278      to create some fake payload manually)   */
279 };
280
281
282 /**
283  * Message send via mesh to the vpn service to send
284  * ICMP data to the VPN's TUN interface.
285  */
286 struct GNUNET_EXIT_IcmpToVPNMessage
287 {
288   /**
289    * Type is GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_VPN
290    */
291   struct GNUNET_MessageHeader header;
292
293   /**
294    * Address family, AF_INET or AF_INET6, in network byte order.
295    * Useful to determine if this is an ICMPv4 or ICMPv6 header.
296    */
297   int32_t af GNUNET_PACKED;
298
299   /**
300    * ICMP header to use.  ICMPv4 or ICMPv6, depending on 'af'.
301    */
302   struct GNUNET_TUN_IcmpHeader icmp_header;
303
304   /* followed by ICMP payload; however, for certain ICMP message
305      types where the payload is the original IP packet, the payload
306      is omitted as it is useless for the receiver (who will need
307      to create some fake payload manually) */
308 };
309
310
311 GNUNET_NETWORK_STRUCT_END
312
313 #endif