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