-renaming TUN structs to follow namnig conventions
[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 #endif