GNUnet 0.22.0
gnunet_nat_lib.h
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2024 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
21#include "gnunet_common.h"
22#if !defined (__GNUNET_UTIL_LIB_H_INSIDE__)
23#error "Only <gnunet_util_lib.h> can be included directly."
24#endif
25
37#ifndef GNUNET_NAT_LIB_H
38#define GNUNET_NAT_LIB_H
39
46{
51
56};
57
62{
67
71 unsigned int local_port;
72};
74
79{
83 void *context;
84
89
95
100
105
109 unsigned int sync_ready;
110};
111
113
114typedef void (*GNUNET_NotifyUdpSocket) (struct GNUNET_UdpSocketInfo *sock_info);
115
120{
125
130
131 // The peer the socket is for.
133
134 // The socket to send message with to the peer.
136
141
146
151
156
161
165 char *address;
166
170 const char *bind_address;
171
175 unsigned int port;
176
180 struct sockaddr *actual_address;
181
185 unsigned int std_port;
186
191};
192
193
202struct GNUNET_BurstSync *
205
206
218void
220 struct GNUNET_BurstSync *burst_sync,
222 struct GNUNET_StartBurstCls *task_cls);
223
224
232struct GNUNET_SCHEDULER_Task *
235
241void
242GNUNET_stop_burst (struct GNUNET_NETWORK_Handle *do_not_touch);
243
244#endif
245 /* end of group */
247 /* end of group addition to backbone */
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
#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;.
GNUNET_GenericReturnValue
Named constants for return values.
void GNUNET_is_burst_ready(struct GNUNET_TIME_Relative rtt_average, struct GNUNET_BurstSync *burst_sync, GNUNET_SCHEDULER_TaskCallback task, struct GNUNET_StartBurstCls *task_cls)
Checks if we are ready and starts burst when we and the other peer is ready.
Definition: nat.c:89
struct GNUNET_SCHEDULER_Task * GNUNET_get_udp_socket(struct GNUNET_UdpSocketInfo *sock_info, GNUNET_NotifyUdpSocket nus)
Method to get a UDP socket for a peer that is natted.
Definition: nat.c:509
struct GNUNET_BurstSync * GNUNET_get_burst_sync_msg(struct GNUNET_TIME_Relative rtt_average, enum GNUNET_GenericReturnValue sync_ready)
Create GNUNET_BurstSync message.
Definition: nat.c:66
void GNUNET_stop_burst(struct GNUNET_NETWORK_Handle *do_not_touch)
Method to stop all sockets we established to the other peer.
Definition: nat.c:564
void(* GNUNET_NotifyUdpSocket)(struct GNUNET_UdpSocketInfo *sock_info)
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
Message send during burst mode.
struct GNUNET_PeerIdentity peer
The peer who send the msg.
unsigned int local_port
The local port the message was send from.
Wrapper struct with the average RTT of message to some peer and if this peer und us is ready to sync.
enum GNUNET_GenericReturnValue sync_ready
Is this peer already ready to sync.
struct GNUNET_TIME_RelativeNBO rtt_average
The average RTT for the peer to communicate with.
handle to a socket
Definition: network.c:53
Context for a monitor.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Definition: scheduler.c:135
Struct wrapping information we use for starting the burst.
struct VirtualLink * vl
The VirtualLink of the peer to which we like to burst with.
struct GNUNET_TIME_Relative delay
The delay - calculate from the RTT and which peer was ready to sync first, after we will start the bu...
void * context
A Context which can be inserted into this struct, which is specific for the caller.
unsigned int sync_ready
We are ready to start the burst.
struct GNUNET_TIME_Relative rtt
The average RTT between the peers.
struct GNUNET_PEERSTORE_Monitor * mo
Peerstore request to start burst with natted addresses only.
Time for relative time used by GNUnet, in microseconds and in network byte order.
Time for relative time used by GNUnet, in microseconds.
Struct with the socket we like to use to send messages to another peer.
const char * bind_address
Our address without port.
enum GNUNET_GenericReturnValue has_port
Flag indicating, if the address is without port information.
struct GNUNET_TIME_Relative rtt
The actual RTT between the peers.
GNUNET_NotifyUdpSocket nus
The notify function to call if burst mode was successful.
const struct GNUNET_PeerIdentity * peer
char * address
The address of the other peer without port.
unsigned int port
The port we are bound to.
struct GNUNET_UdpSocketInfo * next
This is a linked list.
unsigned int std_port
Default local port we are bound to.
struct sockaddr * actual_address
The address of the other peer we received a burst message from.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task for this socket.
struct GNUNET_NETWORK_Handle * udp_sock
struct GNUNET_UdpSocketInfo * prev
This is a linked list.
struct GNUNET_PeerIdentity * pid
The peer we like to connect to.
struct GNUNET_SCHEDULER_Task * read_task
The read task for retrieving a burst message for this socket.