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 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.
17 * @file transport/plugin_transport_xu.h
18 * @brief Implementation of the XU transport protocol
19 * @author Christian Grothoff
20 * @author Nathan Evans
21 * @author Matthias Wachs
23 #ifndef PLUGIN_TRANSPORT_XU_H
24 #define PLUGIN_TRANSPORT_XU_H
27 #include "gnunet_hello_lib.h"
28 #include "gnunet_util_lib.h"
29 #include "gnunet_fragmentation_lib.h"
30 #include "gnunet_protocols.h"
31 #include "gnunet_resolver_service.h"
32 #include "gnunet_signatures.h"
33 #include "gnunet_constants.h"
34 #include "gnunet_statistics_service.h"
35 #include "gnunet_transport_service.h"
36 #include "gnunet_transport_plugin.h"
37 #include "transport.h"
39 #define LOG(kind,...) GNUNET_log_from (kind, "transport-xu", __VA_ARGS__)
41 #define PLUGIN_NAME "xu"
43 #define DEBUG_XU GNUNET_NO
45 #define DEBUG_XU_BROADCASTING GNUNET_NO
48 * MTU for fragmentation subsystem. Should be conservative since
49 * all communicating peers MUST work with this MTU.
54 GNUNET_NETWORK_STRUCT_BEGIN
56 * Network format for IPv4 addresses.
61 * Optional options and flags for this address
63 uint32_t options GNUNET_PACKED;
66 * IPv4 address, in network byte order.
68 uint32_t ipv4_addr GNUNET_PACKED;
71 * Port number, in network byte order.
73 uint16_t u4_port GNUNET_PACKED;
78 * Network format for IPv6 addresses.
83 * Optional options and flags for this address
85 uint32_t options GNUNET_PACKED;
90 struct in6_addr ipv6_addr GNUNET_PACKED;
93 * Port number, in network byte order.
95 uint16_t u6_port GNUNET_PACKED;
97 GNUNET_NETWORK_STRUCT_END
100 * Either an IPv4 or IPv6 XU address. Note that without a "length",
101 * one cannot tell which one of the two types this address represents.
108 struct IPv4XuAddress v4;
113 struct IPv6XuAddress v6;
118 * Information we track for each message in the queue.
120 struct XU_MessageWrapper;
124 * Closure for #append_port().
126 struct PrettyPrinterContext;
130 * Encapsulation of all of the state of the plugin.
138 struct GNUNET_TRANSPORT_PluginEnvironment *env;
141 * Session of peers with whom we are currently connected,
142 * map of peer identity to `struct GNUNET_ATS_Session *`.
144 struct GNUNET_CONTAINER_MultiPeerMap *sessions;
147 * ID of select task for IPv4
149 struct GNUNET_SCHEDULER_Task *select_task_v4;
152 * ID of select task for IPv6
154 struct GNUNET_SCHEDULER_Task *select_task_v6;
157 * Address we were told to bind to exclusively (IPv4).
162 * Address we were told to bind to exclusively (IPv6).
167 * Handle to NAT traversal support.
169 struct GNUNET_NAT_Handle *nat;
172 * Handle to NAT traversal support.
174 struct GNUNET_NAT_STUN_Handle *stun;
177 * The read socket for IPv4
179 struct GNUNET_NETWORK_Handle *sockv4;
182 * The read socket for IPv6
184 struct GNUNET_NETWORK_Handle *sockv6;
187 * Running pretty printers: head
189 struct PrettyPrinterContext *ppc_dll_head;
192 * Running pretty printers: tail
194 struct PrettyPrinterContext *ppc_dll_tail;
197 * Function to call about session status changes.
199 GNUNET_TRANSPORT_SessionInfoCallback sic;
202 * Closure for @e sic.
207 * IPv6 multicast address
209 struct sockaddr_in6 ipv6_multicast_address;
214 struct GNUNET_TIME_Relative broadcast_interval;
217 * Bytes currently in buffer
219 int64_t bytes_in_buffer;
227 * Is IPv6 enabled: #GNUNET_YES or #GNUNET_NO
232 * Is IPv4 enabled: #GNUNET_YES or #GNUNET_NO
242 * Port we advertise on.
250 * Function called for a quick conversion of the binary address to
251 * a numeric address. Note that the caller must not free the
252 * address and that the next call to this function is allowed
253 * to override the address again.
256 * @param addr binary address (a `union XuAddress`)
257 * @param addrlen length of the @a addr
258 * @return string representing the same address
261 xu_address_to_string (void *cls,
266 /*#ifndef PLUGIN_TRANSPORT_XU_H*/
268 /* end of plugin_transport_xu.h */