GNUnet  0.11.x
plugin_transport_udp.h
Go to the documentation of this file.
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  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
28 #ifndef PLUGIN_TRANSPORT_UDP_H
29 #define PLUGIN_TRANSPORT_UDP_H
30 
31 #include "platform.h"
32 #include "gnunet_hello_lib.h"
33 #include "gnunet_util_lib.h"
35 #include "gnunet_protocols.h"
37 #include "gnunet_signatures.h"
38 #include "gnunet_constants.h"
42 #include "transport.h"
43 
44 #define LOG(kind, ...) GNUNET_log_from (kind, "transport-udp", __VA_ARGS__)
45 
46 #define PLUGIN_NAME "udp"
47 
48 #define DEBUG_UDP GNUNET_NO
49 
50 #define DEBUG_UDP_BROADCASTING GNUNET_NO
51 
56 #define UDP_MTU 1400
57 
58 
64 {
69 
74 
79 };
80 
81 
86 {
91 
95  struct in6_addr ipv6_addr GNUNET_PACKED;
96 
100  uint16_t u6_port GNUNET_PACKED;
101 };
103 
109 {
113  struct IPv4UdpAddress v4;
114 
118  struct IPv6UdpAddress v6;
119 };
120 
121 
125 struct UDP_MessageWrapper;
126 
127 
131 struct PrettyPrinterContext;
132 
133 
137 struct Plugin
138 {
143 
149 
154 
159 
164 
168  struct GNUNET_BANDWIDTH_Tracker tracker;
169 
174 
179 
183  struct GNUNET_NAT_Handle *nat;
184 
189 
194 
199 
204 
209 
214 
219 
224 
229 
233  struct PrettyPrinterContext *ppc_dll_head;
234 
238  struct PrettyPrinterContext *ppc_dll_tail;
239 
244 
248  void *sic_cls;
249 
253  struct sockaddr_in6 ipv6_multicast_address;
254 
258  struct GNUNET_TIME_Relative broadcast_interval;
259 
264 
268  uint32_t myoptions;
269 
274 
279 
284 
289 
293  uint16_t broadcast_port;
294 
298  uint16_t port;
299 
303  uint16_t aport;
304 };
305 
306 
318 const char *
319 udp_address_to_string (void *cls,
320  const void *addr,
321  size_t addrlen);
322 
323 
335 void
337  const char *buf,
338  ssize_t size,
339  const union UdpAddress *udp_addr,
340  size_t udp_addr_len,
341  enum GNUNET_NetworkType network_type);
342 
343 
344 void
345 setup_broadcast (struct Plugin *plugin,
346  struct sockaddr_in6 *server_addrv6,
347  struct sockaddr_in *server_addrv4);
348 
349 
350 void
351 stop_broadcast (struct Plugin *plugin);
352 
353 /*#ifndef PLUGIN_TRANSPORT_UDP_H*/
354 #endif
355 /* end of plugin_transport_udp.h */
uint32_t options
Optional options and flags for this address.
Handle for active NAT registrations.
Definition: nat_api.c:71
int enable_broadcasting
Is broadcasting enabled: GNUNET_YES or GNUNET_NO.
struct UDP_MessageWrapper * ipv6_queue_head
Head of messages in IPv6 queue.
static struct GNUNET_NAT_Handle * nat
Connection to NAT service.
uint16_t aport
Port we advertise on.
common internal definitions for transport service
void stop_broadcast(struct Plugin *plugin)
Stop broadcasting subsystem.
char * bind6_address
Address we were told to bind to exclusively (IPv6).
int enable_ipv4
Is IPv4 enabled: GNUNET_YES or GNUNET_NO.
Handle to a request given to the resolver.
Definition: nat_api_stun.c:56
uint16_t u4_port
Port number, in network byte order.
Closure for append_port().
Struct to track available bandwidth.
uint16_t broadcast_port
Port we broadcasting on.
int64_t bytes_in_buffer
Bytes currently in buffer.
int enable_broadcasting_receiving
Is receiving broadcasts enabled: GNUNET_YES or GNUNET_NO.
struct GNUNET_NETWORK_Handle * sockv4
The read socket for IPv4.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Definition: gnunet_nt_lib.h:35
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won&#39;t work on W32.
struct GNUNET_CONTAINER_MultiPeerMap * sessions
Session of peers with whom we are currently connected, map of peer identity to struct GNUNET_ATS_Sess...
struct GNUNET_SCHEDULER_Task * select_task_v4
ID of select task for IPv4.
Network format for IPv4 addresses.
void setup_broadcast(struct Plugin *plugin, struct sockaddr_in6 *server_addrv6, struct sockaddr_in *server_addrv4)
Setup broadcasting subsystem.
uint32_t ipv4_addr
IPv4 address, in network byte order.
The transport service will pass a pointer to a struct of this type as the first and only argument to ...
static char buf[2048]
void(* GNUNET_TRANSPORT_SessionInfoCallback)(void *cls, struct GNUNET_ATS_Session *session, const struct GNUNET_TRANSPORT_SessionInfo *info)
Function called by the plugin with information about the current sessions managed by the plugin (for ...
Handle to a node in a heap.
Internal representation of the hash map.
struct BroadcastAddress * broadcast_head
Tail of DLL of broadcast addresses.
Information we track for each message in the queue.
void udp_broadcast_receive(struct Plugin *plugin, const char *buf, ssize_t size, const union UdpAddress *udp_addr, size_t udp_addr_len, enum GNUNET_NetworkType network_type)
We received a broadcast message.
static char * plugin
Solver plugin name as string.
struct GNUNET_SCHEDULER_Task * select_task_v6
ID of select task for IPv6.
Network format for IPv6 addresses.
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct UDP_MessageWrapper * ipv4_queue_tail
Tail of messages in IPv4 queue.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won&#39;t work on W32;.
const char * udp_address_to_string(void *cls, const void *addr, size_t addrlen)
Function called for a quick conversion of the binary address to a numeric address.
#define GNUNET_PACKED
gcc-ism to get packed structs.
static uint16_t port
Port number.
Definition: gnunet-bcd.c:81
struct UDP_MessageWrapper * ipv6_queue_tail
Tail of messages in IPv6 queue.
Handle for a plugin.
Definition: block.c:37
Either an IPv4 or IPv6 UDP address.
Entry in list of pending tasks.
Definition: scheduler.c:134
struct GNUNET_NETWORK_Handle * sockv6
The read socket for IPv6.
struct GNUNET_NAT_STUN_Handle * stun
Handle to NAT traversal support.
handle to a socket
Definition: network.c:52
char * bind4_address
Address we were told to bind to exclusively (IPv4).
struct GNUNET_CONTAINER_Heap * defrag_ctxs
Heap with all of our defragmentation activities.
struct UDP_MessageWrapper * ipv4_queue_head
Head of messages in IPv4 queue.
struct BroadcastAddress * broadcast_tail
Head of DLL of broadcast addresses.
int enable_ipv6
Is IPv6 enabled: GNUNET_YES or GNUNET_NO.
Time for relative time used by GNUnet, in microseconds.