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 
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 
169 
174 
179 
183  struct GNUNET_NAT_Handle *nat;
184 
189 
194 
199 
204 
209 
214 
219 
224 
229 
234 
239 
244 
248  void *sic_cls;
249 
253  struct sockaddr_in6 ipv6_multicast_address;
254 
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 */
struct Plugin * plugin
The process handle to the testbed service.
static char buf[2048]
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
#define GNUNET_PACKED
gcc-ism to get packed structs.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Definition: gnunet_nt_lib.h:36
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 ...
static unsigned int size
Size of the "table".
Definition: peer.c:67
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.
void stop_broadcast(struct Plugin *plugin)
Stop broadcasting subsystem.
void setup_broadcast(struct Plugin *plugin, struct sockaddr_in6 *server_addrv6, struct sockaddr_in *server_addrv4)
Setup broadcasting subsystem.
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.
Struct to track available bandwidth.
Handle to a node in a heap.
Internal representation of the hash map.
Handle for active NAT registrations.
Definition: nat_api.c:72
Handle to a request given to the resolver.
Definition: nat_api_stun.c:57
handle to a socket
Definition: network.c:53
Entry in list of pending tasks.
Definition: scheduler.c:135
Time for relative time used by GNUnet, in microseconds.
The transport service will pass a pointer to a struct of this type as the first and only argument to ...
Network format for IPv4 addresses.
uint16_t u4_port
Port number, in network byte order.
uint32_t ipv4_addr
IPv4 address, in network byte order.
uint32_t options
Optional options and flags for this address.
Network format for IPv6 addresses.
uint32_t options
Optional options and flags for this address.
uint16_t u6_port
Port number, in network byte order.
struct in6_addr ipv6_addr
IPv6 address.
Handle for a plugin.
Definition: block.c:38
struct GNUNET_TIME_Relative broadcast_interval
Broadcast interval.
struct GNUNET_NAT_STUN_Handle * stun
Handle to NAT traversal support.
uint16_t broadcast_port
Port we broadcasting on.
struct BroadcastAddress * broadcast_head
Tail of DLL of broadcast addresses.
struct UDP_MessageWrapper * ipv4_queue_tail
Tail of messages in IPv4 queue.
void * sic_cls
Closure for sic.
struct UDP_MessageWrapper * ipv4_queue_head
Head of messages in IPv4 queue.
int enable_ipv6
Is IPv6 enabled: GNUNET_YES or GNUNET_NO.
struct GNUNET_CONTAINER_Heap * defrag_ctxs
Heap with all of our defragmentation activities.
struct UDP_MessageWrapper * ipv6_queue_head
Head of messages in IPv6 queue.
struct GNUNET_BANDWIDTH_Tracker tracker
Bandwidth tracker to limit global UDP traffic.
int enable_ipv4
Is IPv4 enabled: GNUNET_YES or GNUNET_NO.
char * bind6_address
Address we were told to bind to exclusively (IPv6).
struct GNUNET_CONTAINER_MultiPeerMap * sessions
Session of peers with whom we are currently connected, map of peer identity to struct GNUNET_ATS_Sess...
int enable_broadcasting_receiving
Is receiving broadcasts enabled: GNUNET_YES or GNUNET_NO.
struct PrettyPrinterContext * ppc_dll_head
Running pretty printers: head.
struct UDP_MessageWrapper * ipv6_queue_tail
Tail of messages in IPv6 queue.
int64_t bytes_in_buffer
Bytes currently in buffer.
struct GNUNET_DATACACHE_PluginEnvironment * env
Our execution environment.
struct GNUNET_SCHEDULER_Task * select_task_v4
ID of select task for IPv4.
struct GNUNET_NETWORK_Handle * sockv4
The read socket for IPv4.
int enable_broadcasting
Is broadcasting enabled: GNUNET_YES or GNUNET_NO.
struct GNUNET_NAT_Handle * nat
NAT handle & address management.
uint32_t myoptions
Address options.
GNUNET_TRANSPORT_SessionInfoCallback sic
Function to call about session status changes.
uint16_t aport
Port we advertise on.
char * port
Port we bind to.
struct sockaddr_in6 ipv6_multicast_address
IPv6 multicast address.
struct GNUNET_NETWORK_Handle * sockv6
The read socket for IPv6.
char * bind4_address
Address we were told to bind to exclusively (IPv4).
struct BroadcastAddress * broadcast_tail
Head of DLL of broadcast addresses.
struct GNUNET_SCHEDULER_Task * select_task_v6
ID of select task for IPv6.
struct PrettyPrinterContext * ppc_dll_tail
Running pretty printers: tail.
Closure for append_port().
Information we track for each message in the queue.
common internal definitions for transport service
Either an IPv4 or IPv6 UDP address.
struct IPv4UdpAddress v4
IPv4 case.
struct IPv6UdpAddress v6
IPv6 case.