GNUnet  0.10.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 {
139 
144 
150 
155 
160 
165 
169  struct GNUNET_BANDWIDTH_Tracker tracker;
170 
175 
180 
184  struct GNUNET_NAT_Handle *nat;
185 
190 
195 
200 
205 
210 
215 
220 
225 
230 
234  struct PrettyPrinterContext *ppc_dll_head;
235 
239  struct PrettyPrinterContext *ppc_dll_tail;
240 
245 
249  void *sic_cls;
250 
254  struct sockaddr_in6 ipv6_multicast_address;
255 
259  struct GNUNET_TIME_Relative broadcast_interval;
260 
265 
269  uint32_t myoptions;
270 
275 
280 
285 
290 
294  uint16_t broadcast_port;
295 
299  uint16_t port;
300 
304  uint16_t aport;
305 
306 };
307 
308 
320 const char *
321 udp_address_to_string (void *cls,
322  const void *addr,
323  size_t addrlen);
324 
325 
337 void
339  const char *buf,
340  ssize_t size,
341  const union UdpAddress *udp_addr,
342  size_t udp_addr_len,
343  enum GNUNET_NetworkType network_type);
344 
345 
346 void
347 setup_broadcast (struct Plugin *plugin,
348  struct sockaddr_in6 *server_addrv6,
349  struct sockaddr_in *server_addrv4);
350 
351 
352 void
353 stop_broadcast (struct Plugin *plugin);
354 
355 /*#ifndef PLUGIN_TRANSPORT_UDP_H*/
356 #endif
357 /* 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:72
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.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
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.
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:79
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:46
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.