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