uncrustify as demanded.
[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      SPDX-License-Identifier: AGPL3.0-or-later
19  */
20
21 /**
22  * @file exit/exit.h
23  * @brief format for cadet 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 cadet to an exit daemon to initiate forwarding of
35  * TCP data to a local service.
36  */
37 struct GNUNET_EXIT_TcpServiceStartMessage {
38   /**
39    * Type is #GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START
40    */
41   struct GNUNET_MessageHeader header;
42
43   /**
44    * Always 0.
45    */
46   uint32_t reserved GNUNET_PACKED;
47
48   /**
49    * Skeleton of the TCP header to send.  Port numbers are to
50    * be replaced and the checksum may be updated as necessary.
51    */
52   struct GNUNET_TUN_TcpHeader tcp_header;
53
54   /* followed by TCP payload */
55 };
56
57
58 /**
59  * Message send via cadet to an exit daemon to initiate forwarding of
60  * TCP data to the Internet.
61  */
62 struct GNUNET_EXIT_TcpInternetStartMessage {
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    * Type is #GNUNET_MESSAGE_TYPE_VPN_TCP_DATA
95    */
96   struct GNUNET_MessageHeader header;
97
98   /**
99    * Always 0.
100    */
101   uint32_t reserved GNUNET_PACKED;
102
103   /**
104    * Skeleton of the TCP header to send.  Port numbers are to
105    * 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.)
106    */
107   struct GNUNET_TUN_TcpHeader tcp_header;
108
109   /* followed by TCP payload */
110 };
111
112
113 /**
114  * Message send via cadet to an exit daemon to send
115  * UDP data to a local service.
116  */
117 struct GNUNET_EXIT_UdpServiceMessage {
118   /**
119    * Type is #GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE
120    */
121   struct GNUNET_MessageHeader header;
122
123   /**
124    * Source port to use for the UDP request (0 to use a random port).  In NBO.
125    */
126   uint16_t source_port GNUNET_PACKED;
127
128   /**
129    * Destination port to use for the UDP request.  In NBO.
130    */
131   uint16_t destination_port GNUNET_PACKED;
132
133   /* followed by UDP payload */
134 };
135
136
137 /**
138  * Message send via cadet to an exit daemon to forward
139  * UDP data to the Internet.
140  */
141 struct GNUNET_EXIT_UdpInternetMessage {
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    * Type is #GNUNET_MESSAGE_TYPE_VPN_UDP_REPLY
176    */
177   struct GNUNET_MessageHeader header;
178
179   /**
180    * Source port to use for the UDP reply (0 to use the same
181    * port as for the original request).  In NBO.
182    */
183   uint16_t source_port GNUNET_PACKED;
184
185   /**
186    * Destination port to use for the UDP reply (0 to use the same
187    * port as for the original request).  In NBO.
188    */
189   uint16_t destination_port GNUNET_PACKED;
190
191   /* followed by UDP payload */
192 };
193
194
195 /**
196  * Message send via cadet to an exit daemon to send
197  * ICMP data to a local service.
198  */
199 struct GNUNET_EXIT_IcmpServiceMessage {
200   /**
201    * Type is #GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE
202    */
203   struct GNUNET_MessageHeader header;
204
205   /**
206    * Address family, AF_INET or AF_INET6, in network byte order.  This
207    * AF value determines if the 'icmp_header' is ICMPv4 or ICMPv6.
208    * The receiver (exit) may still have to translate (PT) to the services'
209    * ICMP version (if possible).
210    */
211   int32_t af GNUNET_PACKED;
212
213   /**
214    * ICMP header to use.
215    */
216   struct GNUNET_TUN_IcmpHeader icmp_header;
217
218   /* followed by ICMP payload; however, for certain ICMP message
219      types where the payload is the original IP packet, the payload
220      is omitted as it is useless for the receiver (who will need
221      to create some fake payload manually)  */
222 };
223
224
225 /**
226  * Message send via cadet to an exit daemon to forward
227  * ICMP data to the Internet.
228  */
229 struct GNUNET_EXIT_IcmpInternetMessage {
230   /**
231    * Type is #GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_INTERNET
232    */
233   struct GNUNET_MessageHeader header;
234
235   /**
236    * Address family, AF_INET or AF_INET6, in network byte order.
237    * Determines both the ICMP version used in the 'icmp_header' and
238    * the IP address format that is used for the target IP.  If
239    * PT is necessary, the sender has already done it.
240    */
241   int32_t af GNUNET_PACKED;
242
243   /**
244    * ICMP header to use.  Must match the target 'af' given
245    * above.
246    */
247   struct GNUNET_TUN_IcmpHeader icmp_header;
248
249   /* followed by IP address of the destination; either
250      'struct in_addr' or 'struct in6_addr', depending on af */
251
252   /* followed by ICMP payload; however, for certain ICMP message
253      types where the payload is the original IP packet, the payload
254      is omitted as it is useless for the receiver (who will need
255      to create some fake payload manually)   */
256 };
257
258
259 /**
260  * Message send via cadet to the vpn service to send
261  * ICMP data to the VPN's TUN interface.
262  */
263 struct GNUNET_EXIT_IcmpToVPNMessage {
264   /**
265    * Type is #GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_VPN
266    */
267   struct GNUNET_MessageHeader header;
268
269   /**
270    * Address family, AF_INET or AF_INET6, in network byte order.
271    * Useful to determine if this is an ICMPv4 or ICMPv6 header.
272    */
273   int32_t af GNUNET_PACKED;
274
275   /**
276    * ICMP header to use.  ICMPv4 or ICMPv6, depending on 'af'.
277    */
278   struct GNUNET_TUN_IcmpHeader icmp_header;
279
280   /* followed by ICMP payload; however, for certain ICMP message
281      types where the payload is the original IP packet, the payload
282      is omitted as it is useless for the receiver (who will need
283      to create some fake payload manually) */
284 };
285
286
287 GNUNET_NETWORK_STRUCT_END
288
289 #endif