2 This file is part of GNUnet
3 Copyright (C) 2010-2014 GNUnet e.V.
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.
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.
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/>.
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
26 #ifndef PLUGIN_TRANSPORT_XU_H
27 #define PLUGIN_TRANSPORT_XU_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"
42 #define LOG(kind,...) GNUNET_log_from (kind, "transport-xu", __VA_ARGS__)
44 #define PLUGIN_NAME "xu"
46 #define DEBUG_XU GNUNET_NO
48 #define DEBUG_XU_BROADCASTING GNUNET_NO
51 * MTU for fragmentation subsystem. Should be conservative since
52 * all communicating peers MUST work with this MTU.
57 GNUNET_NETWORK_STRUCT_BEGIN
59 * Network format for IPv4 addresses.
64 * Optional options and flags for this address
66 uint32_t options GNUNET_PACKED;
69 * IPv4 address, in network byte order.
71 uint32_t ipv4_addr GNUNET_PACKED;
74 * Port number, in network byte order.
76 uint16_t u4_port GNUNET_PACKED;
81 * Network format for IPv6 addresses.
86 * Optional options and flags for this address
88 uint32_t options GNUNET_PACKED;
93 struct in6_addr ipv6_addr GNUNET_PACKED;
96 * Port number, in network byte order.
98 uint16_t u6_port GNUNET_PACKED;
100 GNUNET_NETWORK_STRUCT_END
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.
111 struct IPv4XuAddress v4;
116 struct IPv6XuAddress v6;
121 * Information we track for each message in the queue.
123 struct XU_MessageWrapper;
127 * Closure for #append_port().
129 struct PrettyPrinterContext;
133 * Encapsulation of all of the state of the plugin.
141 struct GNUNET_TRANSPORT_PluginEnvironment *env;
144 * Session of peers with whom we are currently connected,
145 * map of peer identity to `struct GNUNET_ATS_Session *`.
147 struct GNUNET_CONTAINER_MultiPeerMap *sessions;
150 * ID of select task for IPv4
152 struct GNUNET_SCHEDULER_Task *select_task_v4;
155 * ID of select task for IPv6
157 struct GNUNET_SCHEDULER_Task *select_task_v6;
160 * Address we were told to bind to exclusively (IPv4).
165 * Address we were told to bind to exclusively (IPv6).
170 * Handle to NAT traversal support.
172 struct GNUNET_NAT_Handle *nat;
175 * Handle to NAT traversal support.
177 struct GNUNET_NAT_STUN_Handle *stun;
180 * The read socket for IPv4
182 struct GNUNET_NETWORK_Handle *sockv4;
185 * The read socket for IPv6
187 struct GNUNET_NETWORK_Handle *sockv6;
190 * Running pretty printers: head
192 struct PrettyPrinterContext *ppc_dll_head;
195 * Running pretty printers: tail
197 struct PrettyPrinterContext *ppc_dll_tail;
200 * Function to call about session status changes.
202 GNUNET_TRANSPORT_SessionInfoCallback sic;
205 * Closure for @e sic.
210 * IPv6 multicast address
212 struct sockaddr_in6 ipv6_multicast_address;
217 struct GNUNET_TIME_Relative broadcast_interval;
220 * Bytes currently in buffer
222 int64_t bytes_in_buffer;
230 * Is IPv6 enabled: #GNUNET_YES or #GNUNET_NO
235 * Is IPv4 enabled: #GNUNET_YES or #GNUNET_NO
245 * Port we advertise on.
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.
259 * @param addr binary address (a `union XuAddress`)
260 * @param addrlen length of the @a addr
261 * @return string representing the same address
264 xu_address_to_string (void *cls,
269 /*#ifndef PLUGIN_TRANSPORT_XU_H*/
271 /* end of plugin_transport_xu.h */