diff options
Diffstat (limited to 'src/transport/plugin_transport_xu.h')
-rw-r--r-- | src/transport/plugin_transport_xu.h | 271 |
1 files changed, 271 insertions, 0 deletions
diff --git a/src/transport/plugin_transport_xu.h b/src/transport/plugin_transport_xu.h new file mode 100644 index 000000000..cbf9706b6 --- /dev/null +++ b/src/transport/plugin_transport_xu.h | |||
@@ -0,0 +1,271 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2010-2014 GNUnet e.V. | ||
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 transport/plugin_transport_xu.h | ||
21 | * @brief Implementation of the XU transport protocol | ||
22 | * @author Christian Grothoff | ||
23 | * @author Nathan Evans | ||
24 | * @author Matthias Wachs | ||
25 | */ | ||
26 | #ifndef PLUGIN_TRANSPORT_XU_H | ||
27 | #define PLUGIN_TRANSPORT_XU_H | ||
28 | |||
29 | #include "platform.h" | ||
30 | #include "gnunet_hello_lib.h" | ||
31 | #include "gnunet_util_lib.h" | ||
32 | #include "gnunet_fragmentation_lib.h" | ||
33 | #include "gnunet_protocols.h" | ||
34 | #include "gnunet_resolver_service.h" | ||
35 | #include "gnunet_signatures.h" | ||
36 | #include "gnunet_constants.h" | ||
37 | #include "gnunet_statistics_service.h" | ||
38 | #include "gnunet_transport_service.h" | ||
39 | #include "gnunet_transport_plugin.h" | ||
40 | #include "transport.h" | ||
41 | |||
42 | #define LOG(kind,...) GNUNET_log_from (kind, "transport-xu", __VA_ARGS__) | ||
43 | |||
44 | #define PLUGIN_NAME "xu" | ||
45 | |||
46 | #define DEBUG_XU GNUNET_NO | ||
47 | |||
48 | #define DEBUG_XU_BROADCASTING GNUNET_NO | ||
49 | |||
50 | /** | ||
51 | * MTU for fragmentation subsystem. Should be conservative since | ||
52 | * all communicating peers MUST work with this MTU. | ||
53 | */ | ||
54 | #define XU_MTU 1400 | ||
55 | |||
56 | |||
57 | GNUNET_NETWORK_STRUCT_BEGIN | ||
58 | /** | ||
59 | * Network format for IPv4 addresses. | ||
60 | */ | ||
61 | struct IPv4XuAddress | ||
62 | { | ||
63 | /** | ||
64 | * Optional options and flags for this address | ||
65 | */ | ||
66 | uint32_t options GNUNET_PACKED; | ||
67 | |||
68 | /** | ||
69 | * IPv4 address, in network byte order. | ||
70 | */ | ||
71 | uint32_t ipv4_addr GNUNET_PACKED; | ||
72 | |||
73 | /** | ||
74 | * Port number, in network byte order. | ||
75 | */ | ||
76 | uint16_t u4_port GNUNET_PACKED; | ||
77 | }; | ||
78 | |||
79 | |||
80 | /** | ||
81 | * Network format for IPv6 addresses. | ||
82 | */ | ||
83 | struct IPv6XuAddress | ||
84 | { | ||
85 | /** | ||
86 | * Optional options and flags for this address | ||
87 | */ | ||
88 | uint32_t options GNUNET_PACKED; | ||
89 | |||
90 | /** | ||
91 | * IPv6 address. | ||
92 | */ | ||
93 | struct in6_addr ipv6_addr GNUNET_PACKED; | ||
94 | |||
95 | /** | ||
96 | * Port number, in network byte order. | ||
97 | */ | ||
98 | uint16_t u6_port GNUNET_PACKED; | ||
99 | }; | ||
100 | GNUNET_NETWORK_STRUCT_END | ||
101 | |||
102 | /** | ||
103 | * Either an IPv4 or IPv6 XU address. Note that without a "length", | ||
104 | * one cannot tell which one of the two types this address represents. | ||
105 | */ | ||
106 | union XuAddress | ||
107 | { | ||
108 | /** | ||
109 | * IPv4 case. | ||
110 | */ | ||
111 | struct IPv4XuAddress v4; | ||
112 | |||
113 | /** | ||
114 | * IPv6 case. | ||
115 | */ | ||
116 | struct IPv6XuAddress v6; | ||
117 | }; | ||
118 | |||
119 | |||
120 | /** | ||
121 | * Information we track for each message in the queue. | ||
122 | */ | ||
123 | struct XU_MessageWrapper; | ||
124 | |||
125 | |||
126 | /** | ||
127 | * Closure for #append_port(). | ||
128 | */ | ||
129 | struct PrettyPrinterContext; | ||
130 | |||
131 | |||
132 | /** | ||
133 | * Encapsulation of all of the state of the plugin. | ||
134 | */ | ||
135 | struct Plugin | ||
136 | { | ||
137 | |||
138 | /** | ||
139 | * Our environment. | ||
140 | */ | ||
141 | struct GNUNET_TRANSPORT_PluginEnvironment *env; | ||
142 | |||
143 | /** | ||
144 | * Session of peers with whom we are currently connected, | ||
145 | * map of peer identity to `struct GNUNET_ATS_Session *`. | ||
146 | */ | ||
147 | struct GNUNET_CONTAINER_MultiPeerMap *sessions; | ||
148 | |||
149 | /** | ||
150 | * ID of select task for IPv4 | ||
151 | */ | ||
152 | struct GNUNET_SCHEDULER_Task *select_task_v4; | ||
153 | |||
154 | /** | ||
155 | * ID of select task for IPv6 | ||
156 | */ | ||
157 | struct GNUNET_SCHEDULER_Task *select_task_v6; | ||
158 | |||
159 | /** | ||
160 | * Address we were told to bind to exclusively (IPv4). | ||
161 | */ | ||
162 | char *bind4_address; | ||
163 | |||
164 | /** | ||
165 | * Address we were told to bind to exclusively (IPv6). | ||
166 | */ | ||
167 | char *bind6_address; | ||
168 | |||
169 | /** | ||
170 | * Handle to NAT traversal support. | ||
171 | */ | ||
172 | struct GNUNET_NAT_Handle *nat; | ||
173 | |||
174 | /** | ||
175 | * Handle to NAT traversal support. | ||
176 | */ | ||
177 | struct GNUNET_NAT_STUN_Handle *stun; | ||
178 | |||
179 | /** | ||
180 | * The read socket for IPv4 | ||
181 | */ | ||
182 | struct GNUNET_NETWORK_Handle *sockv4; | ||
183 | |||
184 | /** | ||
185 | * The read socket for IPv6 | ||
186 | */ | ||
187 | struct GNUNET_NETWORK_Handle *sockv6; | ||
188 | |||
189 | /** | ||
190 | * Running pretty printers: head | ||
191 | */ | ||
192 | struct PrettyPrinterContext *ppc_dll_head; | ||
193 | |||
194 | /** | ||
195 | * Running pretty printers: tail | ||
196 | */ | ||
197 | struct PrettyPrinterContext *ppc_dll_tail; | ||
198 | |||
199 | /** | ||
200 | * Function to call about session status changes. | ||
201 | */ | ||
202 | GNUNET_TRANSPORT_SessionInfoCallback sic; | ||
203 | |||
204 | /** | ||
205 | * Closure for @e sic. | ||
206 | */ | ||
207 | void *sic_cls; | ||
208 | |||
209 | /** | ||
210 | * IPv6 multicast address | ||
211 | */ | ||
212 | struct sockaddr_in6 ipv6_multicast_address; | ||
213 | |||
214 | /** | ||
215 | * Broadcast interval | ||
216 | */ | ||
217 | struct GNUNET_TIME_Relative broadcast_interval; | ||
218 | |||
219 | /** | ||
220 | * Bytes currently in buffer | ||
221 | */ | ||
222 | int64_t bytes_in_buffer; | ||
223 | |||
224 | /** | ||
225 | * Address options | ||
226 | */ | ||
227 | uint32_t myoptions; | ||
228 | |||
229 | /** | ||
230 | * Is IPv6 enabled: #GNUNET_YES or #GNUNET_NO | ||
231 | */ | ||
232 | int enable_ipv6; | ||
233 | |||
234 | /** | ||
235 | * Is IPv4 enabled: #GNUNET_YES or #GNUNET_NO | ||
236 | */ | ||
237 | int enable_ipv4; | ||
238 | |||
239 | /** | ||
240 | * Port we listen on. | ||
241 | */ | ||
242 | uint16_t port; | ||
243 | |||
244 | /** | ||
245 | * Port we advertise on. | ||
246 | */ | ||
247 | uint16_t aport; | ||
248 | |||
249 | }; | ||
250 | |||
251 | |||
252 | /** | ||
253 | * Function called for a quick conversion of the binary address to | ||
254 | * a numeric address. Note that the caller must not free the | ||
255 | * address and that the next call to this function is allowed | ||
256 | * to override the address again. | ||
257 | * | ||
258 | * @param cls closure | ||
259 | * @param addr binary address (a `union XuAddress`) | ||
260 | * @param addrlen length of the @a addr | ||
261 | * @return string representing the same address | ||
262 | */ | ||
263 | const char * | ||
264 | xu_address_to_string (void *cls, | ||
265 | const void *addr, | ||
266 | size_t addrlen); | ||
267 | |||
268 | |||
269 | /*#ifndef PLUGIN_TRANSPORT_XU_H*/ | ||
270 | #endif | ||
271 | /* end of plugin_transport_xu.h */ | ||