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